/** * Function starts applying schema changes */ public static function initialize() { global $adb; $adb = PearDatabase::getInstance(); $adb->createTables("schema/DatabaseSchema.xml"); $defaultDataPopulator = new DefaultDataPopulator(); $defaultDataPopulator->create_tables(); self::createDefaultUsersAccess(); // create and populate combo tables $combo = new PopulateComboValues(); $combo->create_tables(); $combo->create_nonpicklist_tables(); create_tab_data_file(); create_parenttab_data_file(); // default report population vimport('~~modules/Reports/PopulateReports.php'); // default customview population vimport('~~modules/CustomView/PopulateCustomView.php'); // ensure required sequences are created (adodb creates them as needed, but if // creation occurs within a transaction we get problems $adb->getUniqueID("vtiger_crmentity"); $adb->getUniqueID("vtiger_seactivityrel"); $adb->getUniqueID("vtiger_freetags"); $currencyName = $_SESSION['config_file_info']['currency_name']; $currencyCode = $_SESSION['config_file_info']['currency_code']; $currencySymbol = $_SESSION['config_file_info']['currency_symbol']; $adb->pquery("INSERT INTO vtiger_currency_info VALUES (?,?,?,?,?,?,?,?)", array($adb->getUniqueID("vtiger_currency_info"), $currencyName, $currencyCode, $currencySymbol, 1, 'Active', '-11', '0')); Install_InitSchema_Model::installDefaultEventsAndWorkflows(); }
public function process(Vtiger_Request $request) { $moduleName = $request->getModule(); $packages = $request->get(packages); $userModuleModel = Users_Module_Model::getInstance($moduleName); $userModuleModel::savePackagesInfo($packages); //SalesPlatform.ru begin create_tab_data_file(); create_parenttab_data_file(); //SalesPlatform.ru end header('Location: index.php?module=Users&parent=Settings&view=UserSetup'); exit; }
/** * Toggle the module (enable/disable) */ function vtlib_toggleModuleAccess($module, $enable_disable) { global $adb, $__cache_module_activeinfo; include_once 'vtlib/Vtiger/Module.php'; $event_type = false; if ($enable_disable === true) { $enable_disable = 0; $event_type = Vtiger_Module::EVENT_MODULE_ENABLED; } else { if ($enable_disable === false) { $enable_disable = 1; $event_type = Vtiger_Module::EVENT_MODULE_DISABLED; } } $adb->pquery("UPDATE vtiger_tab set presence = ? WHERE name = ?", array($enable_disable, $module)); $__cache_module_activeinfo[$module] = $enable_disable; create_tab_data_file(); create_parenttab_data_file(); // UserPrivilege file needs to be regenerated if module state is changed from // vtiger 5.1.0 onwards global $vtiger_current_version; if (version_compare($vtiger_current_version, '5.0.4', '>')) { vtlib_RecreateUserPrivilegeFiles(); } Vtiger_Module::fireEvent($module, $event_type); }
function migrate($migrationInfo) { global $installationStrings; $completed = false; set_time_limit(0); //ADDED TO AVOID UNEXPECTED TIME OUT WHILE MIGRATING global $dbconfig; require $migrationInfo['root_directory'] . '/config.inc.php'; $dbtype = $dbconfig['db_type']; $host = $dbconfig['db_server'] . $dbconfig['db_port']; $dbname = $dbconfig['db_name']; $username = $dbconfig['db_username']; $passwd = $dbconfig['db_password']; global $adb, $migrationlog; $adb = new PearDatabase($dbtype, $host, $dbname, $username, $passwd); $query = " ALTER DATABASE " . $adb->escapeDbName($dbname) . " DEFAULT CHARACTER SET utf8"; $adb->query($query); $source_directory = $migrationInfo['source_directory']; if (file_exists($source_directory . 'user_privileges/CustomInvoiceNo.php')) { require_once $source_directory . 'user_privileges/CustomInvoiceNo.php'; } $migrationlog =& LoggerManager::getLogger('MIGRATION'); if (isset($migrationInfo['old_version'])) { $source_version = $migrationInfo['old_version']; } if (!isset($source_version) || empty($source_version)) { //If source version is not set then we cannot proceed echo "<br> " . $installationStrings['LBL_SOURCE_VERSION_NOT_SET']; exit; } $reach = 0; include $migrationInfo['root_directory'] . "/modules/Migration/versions.php"; foreach ($versions as $version => $label) { if ($version == $source_version || $reach == 1) { $reach = 1; $temp[] = $version; } } $temp[] = $current_version; global $adb, $dbname; $_SESSION['adodb_current_object'] = $adb; @ini_set('zlib.output_compression', 0); @ini_set('output_buffering', 'off'); ob_implicit_flush(true); echo '<table width="98%" border="1px" cellpadding="3" cellspacing="0" height="100%">'; if (is_array($_SESSION['migration_info']['user_messages'])) { foreach ($_SESSION['migration_info']['user_messages'] as $infoMap) { echo "<tr><td>" . $infoMap['status'] . "</td><td>" . $infoMap['msg'] . "</td></tr>"; } } echo "<tr><td colspan='2'><b>{$installationStrings['LBL_GOING_TO_APPLY_DB_CHANGES']}...</b></td></tr>"; for ($patch_count = 0; $patch_count < count($temp); $patch_count++) { //Here we have to include all the files (all db differences for each release will be included) $filename = "modules/Migration/DBChanges/" . $temp[$patch_count] . "_to_" . $temp[$patch_count + 1] . ".php"; $empty_tag = "<tr><td colspan='2'> </td></tr>"; $start_tag = "<tr><td colspan='2'><b><font color='red'> "; $end_tag = "</font></b></td></tr>"; if (is_file($filename)) { echo $empty_tag . $start_tag . $temp[$patch_count] . " ==> " . $temp[$patch_count + 1] . " " . $installationStrings['LBL_DATABASE_CHANGES'] . " -- " . $installationStrings['LBL_STARTS'] . "." . $end_tag; include $filename; //include the file which contains the corresponding db changes echo $start_tag . $temp[$patch_count] . " ==> " . $temp[$patch_count + 1] . " " . $installationStrings['LBL_DATABASE_CHANGES'] . " -- " . $installationStrings['LBL_ENDS'] . "." . $end_tag; } } /* Install Vtlib Compliant Modules */ Common_Install_Wizard_Utils::installMandatoryModules(); Migration_Utils::installOptionalModules($migrationInfo['selected_optional_modules'], $migrationInfo['source_directory'], $migrationInfo['root_directory']); Migration_utils::copyLanguageFiles($migrationInfo['source_directory'], $migrationInfo['root_directory']); //Here we have to update the version in table. so that when we do migration next time we will get the version $res = $adb->query('SELECT * FROM vtiger_version'); global $vtiger_current_version; require $migrationInfo['root_directory'] . '/vtigerversion.php'; if ($adb->num_rows($res)) { $res = ExecuteQuery("UPDATE vtiger_version SET old_version='{$versions[$source_version]}',current_version='{$vtiger_current_version}'"); $completed = true; } else { ExecuteQuery("INSERT INTO vtiger_version (id, old_version, current_version) values (" . $adb->getUniqueID('vtiger_version') . ", '{$versions[$source_version]}', '{$vtiger_current_version}');"); $completed = true; } echo '</table><br><br>'; create_tab_data_file(); create_parenttab_data_file(); return $completed; }
} elseif ($success == 1) { die("Error: Tables partially created. Table creation failed.\n"); } foreach ($modules as $module) { $focus = new $module(); $focus->create_tables(); } create_default_users_access(); // create and populate combo tables require_once 'include/PopulateComboValues.php'; $combo = new PopulateComboValues(); $combo->create_tables(); $combo->create_nonpicklist_tables(); //Writing tab data in flat file create_tab_data_file(); create_parenttab_data_file(); // default report population require_once 'modules/Reports/PopulateReports.php'; // default customview population require_once 'modules/CustomView/PopulateCustomView.php'; // ensure required sequences are created (adodb creates them as needed, but if // creation occurs within a transaction we get problems $adb->getUniqueID("vtiger_crmentity"); $adb->getUniqueID("vtiger_seactivityrel"); $adb->getUniqueID("vtiger_freetags"); //Master currency population //Insert into vtiger_currency vtiger_table $adb->pquery("insert into vtiger_currency_info values(?,?,?,?,?,?,?,?)", array($adb->getUniqueID("vtiger_currency_info"), $currency_name, $currency_code, $currency_symbol, 1, 'Active', '-11', '0')); // Register All the Events registerEvents($adb); // Register All the Entity Methods
/** * Synchronize the menu information to flat file * @access private */ static function syncfile() { self::log("Updating parent_tabdata file ... STARTED"); create_parenttab_data_file(); self::log("Updating parent_tabdata file ... DONE"); }
/** Function to carry out all the necessary actions after migration */ function perform_post_migration_activities() { //After applying all the DB Changes,Here we clear the Smarty cache files clear_smarty_cache(); //Writing tab data in flat file create_tab_data_file(); create_parenttab_data_file(); }
function process() { set_time_limit(0); //ADDED TO AVOID UNEXPECTED TIME OUT WHILE MIGRATING $returnValue = vtiger_DatabaseMigration::initMigration(); if ($returnValue !== true) { echo $returnValue; return false; } global $dbconfig; require dirname(__FILE__) . '/config.inc.php'; $dbtype = $dbconfig['db_type']; $host = $dbconfig['db_server'] . $dbconfig['db_port']; $dbname = $dbconfig['db_name']; $username = $dbconfig['db_username']; $passwd = $dbconfig['db_password']; global $adb, $migrationlog; $adb = new PearDatabase($dbtype, $host, $dbname, $username, $passwd); // Why do we do this here? We shouldn't alter here if its not in UTF8. $query = " ALTER DATABASE " . $dbname . " DEFAULT CHARACTER SET utf8"; $adb->query($query); $source_directory = $_SESSION['migration_info']['source_directory']; if (file_exists($source_directory . 'user_privileges/CustomInvoiceNo.php')) { require_once $source_directory . 'user_privileges/CustomInvoiceNo.php'; } $versions_non_utf8 = array("50", "501", "502", "503rc2", "503", "504rc"); $php_max_execution_time = 0; $migrationlog =& LoggerManager::getLogger('MIGRATION'); if (isset($_SESSION['migration_info']['old_version'])) { $source_version = $_SESSION['migration_info']['old_version']; } if (!isset($source_version) || empty($source_version)) { //If source version is not set then we cannot proceed echo "<br> Source Version is not set. Please check vtigerversion.php and contiune the Patch Process"; exit; } $reach = 0; include dirname(__FILE__) . "/modules/Migration/versions.php"; foreach ($versions as $version => $label) { if ($version == $source_version || $reach == 1) { $reach = 1; $temp[] = $version; } } $temp[] = $current_version; global $adb, $dbname; $_SESSION['adodb_current_object'] = $adb; @ini_set('zlib.output_compression', 0); @ini_set('output_buffering', 'off'); ob_implicit_flush(true); echo '<table width="98%" border="1px" cellpadding="3" cellspacing="0" height="100%">'; echo "<tr><td colspan='2'><b>Going to apply the Database Changes...</b></td><tr>"; for ($patch_count = 0; $patch_count < count($temp); $patch_count++) { //Here we have to include all the files (all db differences for each release will be included) $filename = "modules/Migration/DBChanges/" . $temp[$patch_count] . "_to_" . $temp[$patch_count + 1] . ".php"; $empty_tag = "<tr><td colspan='2'> </td></tr>"; $start_tag = "<tr><td colspan='2'><b><font color='red'> "; $end_tag = "</font></b></td></tr>"; if (is_file($filename)) { echo $empty_tag . $start_tag . $temp[$patch_count] . " ==> " . $temp[$patch_count + 1] . " Database changes -- Starts." . $end_tag; include $filename; //include the file which contains the corresponding db changes echo $start_tag . $temp[$patch_count] . " ==> " . $temp[$patch_count + 1] . " Database changes -- Ends." . $end_tag; } } //Here we have to update the version in table. so that when we do migration next time we will get the version $res = $adb->query('SELECT * FROM vtiger_version'); global $vtiger_current_version; require dirname(__FILE__) . '/vtigerversion.php'; if ($adb->num_rows($res)) { $res = ExecuteQuery("UPDATE vtiger_version SET old_version='{$versions[$source_version]}',current_version='{$vtiger_current_version}'"); $completed = true; } else { ExecuteQuery("INSERT INTO vtiger_version (id, old_version, current_version) values (" . $adb->getUniqueID('vtiger_version') . ", '{$versions[$source_version]}', '{$vtiger_current_version}');"); $completed = true; } echo '</table><br><br>'; if ($completed == true) { echo "<script type='text/javascript'>window.parent.Migration_Complete();</script>"; } create_tab_data_file(); create_parenttab_data_file(); if ($completed == true) { return true; } }