function applyChange() { global $adb; if ($this->hasError()) { $this->sendError(); } if ($this->isApplied()) { $this->sendMsg('Changeset ' . get_class($this) . ' already applied!'); } else { $moduleInstance = Vtiger_Module::getInstance('Users'); $block = Vtiger_Block::getInstance('LBL_USER_ADV_OPTIONS', $moduleInstance); $field = Vtiger_Field::getInstance('failed_login_attempts', $moduleInstance); if ($field) { $this->ExecuteQuery('update vtiger_field set presence=2 where fieldid=' . $field->id); } else { $user_field = new Vtiger_Field(); $user_field->name = 'failed_login_attempts'; $user_field->label = 'LBL_FAILED_LOGIN_ATTEMPTS'; $user_field->table = 'vtiger_users'; $user_field->column = 'failed_login_attempts'; $user_field->columntype = 'int(11)'; $user_field->typeofdata = 'I~O'; $user_field->uitype = '7'; $user_field->masseditable = '0'; $block->addField($user_field); $this->ExecuteQuery('update vtiger_users set failed_login_attempts=0'); RecalculateSharingRules(); } $this->sendMsg('Changeset ' . get_class($this) . ' applied!'); $this->markApplied(); } $this->finishExecution(); }
function applyChange() { global $adb; if ($this->hasError()) { $this->sendError(); } if ($this->isApplied()) { $this->sendMsg('Changeset ' . get_class($this) . ' already applied!'); } else { $moduleInstance = Vtiger_Module::getInstance('Users'); $block = Vtiger_Block::getInstance('LBL_MORE_INFORMATION', $moduleInstance); $field = Vtiger_Field::getInstance('send_email_to_sender', $moduleInstance); if ($field) { $this->ExecuteQuery('update vtiger_field set presence=2 where fieldid=' . $field->id); } else { $user_field = new Vtiger_Field(); $user_field->name = 'send_email_to_sender'; $user_field->label = 'LBL_SEND_EMAIL_TO_SENDER'; $user_field->table = 'vtiger_users'; $user_field->column = 'send_email_to_sender'; $user_field->columntype = 'varchar(3)'; $user_field->typeofdata = 'C~O'; $user_field->uitype = '56'; $user_field->masseditable = '0'; $block->addField($user_field); $this->ExecuteQuery("update vtiger_users set send_email_to_sender='1'"); RecalculateSharingRules(); } $this->sendMsg('Changeset ' . get_class($this) . ' applied!'); $this->markApplied(); } $this->finishExecution(); }
/** * Function starts applying schema changes */ public function initialize() { $this->initializeDatabase($this->sql_directory, array($this->corebos_sql)); $this->setDefaultUsersAccess(); $currencyName = $_SESSION['installation_info']['currency_name']; $currencyCode = $_SESSION['installation_info']['currency_code']; $currencySymbol = $_SESSION['installation_info']['currency_symbol']; $this->db->pquery('UPDATE vtiger_currency_info SET currency_name = ?, currency_code = ?, currency_symbol = ?', array($currencyName, $currencyCode, $currencySymbol)); // recalculate all sharing rules for users require_once 'include/utils/UserInfoUtil.php'; RecalculateSharingRules(); }
/** * Function starts applying schema changes */ public function initialize() { global $YetiForce_current_version; $this->initializeDatabase($this->sql_directory, array('scheme', 'data')); $this->setDefaultUsersAccess(); $currencyName = $_SESSION['config_file_info']['currency_name']; $currencyCode = $_SESSION['config_file_info']['currency_code']; $currencySymbol = $_SESSION['config_file_info']['currency_symbol']; $this->db->pquery("UPDATE vtiger_currency_info SET currency_name = ?, currency_code = ?, currency_symbol = ?", [$currencyName, $currencyCode, $currencySymbol]); $this->db->pquery("UPDATE vtiger_version SET `current_version` = ? ;", [$YetiForce_current_version]); // recalculate all sharing rules for users vimport('~include/utils/UserInfoUtil.php'); RecalculateSharingRules(); }
function applyChange() { global $adb; if ($this->hasError()) { $this->sendError(); } if ($this->isApplied()) { $this->sendMsg('Changeset ' . get_class($this) . ' already applied!'); } else { $module = Vtiger_Module::getInstance('Campaigns'); $module->enableTools(array('DuplicatesHandling')); $module->disableTools(array('Merge')); $module = Vtiger_Module::getInstance('PriceBooks'); $module->enableTools(array('Import', 'Export')); RecalculateSharingRules(); $this->sendMsg('Changeset ' . get_class($this) . ' applied!'); $this->markApplied(); } $this->finishExecution(); }
$cver = vtws_getVtigerVersion(); if ($cver == '6.1.0' or $force) { putMsg('<h2>** Starting Migration from 6.1 **</h2>'); include 'build/migrate6/migrate_from_vt61.php'; } $cver = vtws_getVtigerVersion(); if ($cver == '6.0.0' or $force) { putMsg('<h2>** Starting Migration from 6.0 **</h2>'); include 'build/migrate6/migrate_from_vt60.php'; } ExecuteQuery("DELETE FROM vtiger_def_org_share WHERE vtiger_def_org_share.tabid not in (select tabid from vtiger_tab)"); ExecuteQuery("update vtiger_users set theme='softed'"); ExecuteQuery("update vtiger_version set old_version='5.4.0', current_version='5.5.0' where id=1"); ExecuteQuery("DELETE FROM vtiger_field WHERE tablename = 'vtiger_inventoryproductrel'"); // Recalculate permissions RecalculateSharingRules RecalculateSharingRules(); ?> </table> <br /><br /> <b style="color:#FF0000">Failed Queries Log</b> <div id="failedLog" style="border:1px solid #666666;width:90%;position:relative;height:200px;overflow:auto;left:5%;top:10px;"> <?php foreach ($failure_query_array as $failed_query) { echo '<br><font color="red">' . $failed_query . '</font>'; } ?> </div> <br /><br /> <table width="35%" border="0" cellpadding="5" cellspacing="0" align="center" class="small"> <tr> <td width="75%" align="right" nowrap>
/** function used to run the migration process based on the option selected and values given * @param int $same_databases - 1 if both databases are same otherwise 0 * @param string $option - selected migration option (dbsource or dumpsource) * @param string $old_dump_file_name - dump file name of the old database which is optional when we use dbsource * @return void */ function migrate($same_databases, $option, $old_dump_file_name = '') { //1. Migration Procedure -- when we give the Source Database values //Step : 1 => Take a dump of old database //Step : 2 => Drop the New Database //Step : 3 => Create the New Database //Step : 4 => Put the old dump into the New Database //Step : 5 => Modify the new database with the new changes //2. Migration Procedure -- when we give the Database dump file //Step : 1 => Drop the New Database //Step : 2 => Create the New Database //Step : 3 => Put the dump into the New Database //Step : 4 => Modify the new database with the new changes global $migrationlog; global $conn; $migrationlog->debug("Database Migration from Old Database to the Current Database Starts."); $migrationlog->debug("Migration Option = {$option}"); //Set the old database parameters $old_host_name = $this->old_hostname; $old_mysql_port = $this->old_mysql_port; $old_mysql_username = $this->old_mysql_username; $old_mysql_password = $this->old_mysql_password; $old_dbname = $this->old_dbname; //Set the new database parameters $new_host_name = $this->new_hostname; $new_mysql_port = $this->new_mysql_port; $new_mysql_username = $this->new_mysql_username; $new_mysql_password = $this->new_mysql_password; $new_dbname = $this->new_dbname; //This will be done when we give the Source Database details if ($option == 'dbsource') { //Take the dump of the old Database $migrationlog->debug("Going to take the old Database Dump."); $dump_file = $this->takeDatabaseDump($old_host_name, $old_mysql_port, $old_mysql_username, $old_mysql_password, $old_dbname); //check the file size is greater than 10000 bytes (~app) and if yes then continue else goto step1 if (is_file($dump_file) && filesize($dump_file) > 10000) { $_SESSION['migration_log'] .= "Source database dump taken successfully."; } else { echo '<br><font color="red"><b>The Source database dump taken may not contain all values. So please use other option.</font></b>'; include "modules/Migration/MigrationStep1.php"; exit; } } elseif ($option == 'dumpsource') { $dump_file = $old_dump_file_name; } //if old db and new db are different then take new db dump if ($old_dbname != $new_dbname) { //This is to take dump of the new database for backup purpose $migrationlog->debug("Going to take the current Database Dump."); $new_dump_file = $this->takeDatabaseDump($new_host_name, $new_mysql_port, $new_mysql_username, $new_mysql_password, $new_dbname); //check the file size is greater than 10000 bytes (~app) and if yes then continue else goto step1 if (is_file($new_dump_file) && filesize($new_dump_file) > 10000) { $_SESSION['migration_log'] .= "Current database dump taken successfully."; } else { $_SESSION['migration_log'] .= '<br><font color="red"><b>The Current database dump taken may not contain all values. So may not be reload the current database if any problem occurs in migration. If the migration not completed please rename the install.php and install folder and run the install.php</font></b>'; //include("modules/Migration/MigrationStep1.php"); //exit; } } $continue_process = 1; if ($same_databases == 1) { $_SESSION['migration_log'] .= '<br> Same databases are used. so skip the process of drop and create the current database.'; } else { $_SESSION['migration_log'] .= '<br> Databases are different. So drop the Current Database and create. Also apply the dump of Old Database'; //Drop the current(latest) Database $migrationlog->debug("Going to Drop the current Database"); $this->dropDatabase($conn, $new_dbname); //Create the new current(latest) Database $migrationlog->debug("Going to Create the current Database"); $this->createDatabase($conn, $new_dbname); //Apply the dump of the old database to the current database $migrationlog->debug("Going to apply the old database dump to the new database."); $this->applyDumpData($new_host_name, $new_mysql_port, $new_mysql_username, $new_mysql_password, $new_dbname, $dump_file); //get the number of tables in new database $new_tables_count = $this->getTablesCountInNewDatabase(); //get the number of tables in old database $old_tables_count = $this->getTablesCountInOldDatabase(); //if tables are missing after apply the dump, then alert the user and quit if ($new_tables_count != $old_tables_count && $option == 'dbsource' || $new_tables_count < 180 && $option == 'dumpsource') { $migrationlog->debug("New Database tables not equal to Old Database tables count. Reload the current database again and quit."); $continue_process = 0; $msg = "The dump may not be applied correctly. Tables exist in 4.2.3 database : {$old_tables_count}. Tables exist in current database after apply the dump : {$new_tables_count}"; ?> <script language="javascript"> alert("<?php echo $msg; ?> "); </script> <?php } } if ($continue_process == 1) { //Modify the database which is now as old database setup $migrationlog->debug("Going to modify the current database which is now as old database setup"); $this->modifyDatabase($conn); $migrationlog->debug("Database Modifications Ends......"); $migrationlog->debug("Database Migration from Old Database to the Current Database has been Finished."); } else { //Drop the current(latest) Database $migrationlog->debug("Problem in migration. so going to Restore the current Database"); $migrationlog->debug("Going to Drop the current Database"); $this->dropDatabase($conn, $new_dbname); //Create the new current(latest) Database $migrationlog->debug("Going to Create the current Database"); $this->createDatabase($conn, $new_dbname); //Reload the new db dump and quit $migrationlog->debug("Going to apply the new backup db dump"); $this->applyDumpData($new_host_name, $new_mysql_port, $new_mysql_username, $new_mysql_password, $new_dbname, $new_dump_file); //Return to Step1 echo '<br><font color="red"><b>Dump could not be applied correctly. so your previous database restored.</b></font>'; include "modules/Migration/MigrationStep1.php"; } //Now we should recalculate the user and sharing privileges RecalculateSharingRules(); }
/** * Recalculate sharing access rules. * @internal This function could take up lot of resource while execution * @access private */ static function syncSharingAccess() { self::log("Recalculating sharing rules ... ", false); RecalculateSharingRules(); self::log("DONE"); }
public function verificationOfPowers() { global $log, $adb; $log->debug("Entering YetiForceUpdate::verificationOfPowers() method ..."); $resultP = $adb->query('SELECT profileid FROM vtiger_profile;'); $all = []; $profiles = []; while ($rowP = $adb->fetch_array($resultP)) { $profileid = $rowP['profileid']; $resultPU = $adb->pquery('select * from vtiger_profile2utility where profileid=? order by(tabid)', [$profileid]); while ($rowPT = $adb->fetch_array($resultPU)) { $all[$rowPT['tabid']][$rowPT['activityid']] = $rowPT['permission']; $profiles[$profileid][$rowPT['tabid']][$rowPT['activityid']] = $rowPT['permission']; } } foreach ($profiles as $profile => $dataP) { foreach ($all as $tabid => $dataT) { foreach ($dataT as $activityid => $permission) { if (!isset($dataP[$tabid][$activityid])) { echo "Profil: {$profile} | TabID: {$tabid} | ActionID: {$activityid}<br/>"; $adb->insert('vtiger_profile2utility', ['profileid' => $profile, 'tabid' => $tabid, 'activityid' => $activityid, 'permission' => $permission]); } } } } RecalculateSharingRules(); $log->debug("Exiting YetiForceUpdate::verificationOfPowers() method ..."); }