diff --git a/modules/Migration/schema/730_to_740.php b/modules/Migration/schema/730_to_740.php index 4a0b367a12b62922088f3911c1674f10a3d68010..563270f25458b9dc5dc5404179556b6a343608e6 100644 --- a/modules/Migration/schema/730_to_740.php +++ b/modules/Migration/schema/730_to_740.php @@ -16,4 +16,36 @@ if (defined('VTIGER_UPGRADE')) { $className = 'Vtiger_RecordLabelUpdater_Handler'; $eventManager->unregisterHandler($className); echo "Unregistered record label update handler.<br>"; + + $moduleName = 'Users'; + $moduleModel = Vtiger_Module_Model::getInstance($moduleName); + $fieldName = 'userlabel'; + $blockModel = Vtiger_Block_Model::getInstance('LBL_MORE_INFORMATION', $moduleModel); + if ($blockModel) { + $fieldModel = Vtiger_Field_Model::getInstance($fieldName, $moduleModel); + if (!$fieldModel) { + $fieldModel = new Vtiger_Field(); + $fieldModel->name = $fieldName; + $fieldModel->label = 'User Label'; + $fieldModel->table = 'vtiger_users'; + $fieldModel->columntype = 'VARCHAR(255)'; + $fieldModel->typeofdata = 'V~O'; + $fieldModel->displaytype= 3; + $blockModel->addField($fieldModel); + echo "<br>Successfully added <b>$fieldName</b> field to <b>$moduleName</b><br>"; + } + } + $db->pquery("UPDATE vtiger_users SET $fieldName=TRIM(CONCAT(first_name, ' ' , last_name))", array()); + echo "<br>Successfully updated <b>$fieldName</b> value as concatenate of firstname and lastname for <b>$moduleName</b> module<br>"; + + vimport('~modules/Users/CreateUserPrivilegeFile.php'); + $result = $db->pquery('SELECT id FROM vtiger_users', array()); + $count = $db->num_rows($result); + while ($row = $db->fetch_array($result)) { + $userId = $row['id']; + createUserPrivilegesfile($userId); + echo "<br>Successfully recreated <b>User's privileges</b> file for id:<b>$userId</b><br>"; + } + echo "<br>Successfully completed concatenate of firstname and lastname as label in <b>$moduleName</b> module<br>"; + } \ No newline at end of file