} else { $confParams = array('LANG' => 'en', 'STATUS' => ''); $oConf->aConfig = $confParams; $oConf->saveConfig('APP_CACHE_VIEW_ENGINE', '', '', ''); $lang = 'en'; $status = ''; } //get user Root from hash $result->info = array(); $result->error = false; //setup the appcacheview object, and the path for the sql files $appCache = new AppCacheView(); $appCache->setPathToAppCacheFiles(PATH_METHODS . 'setup' . PATH_SEP . 'setupSchemas' . PATH_SEP); $res = $appCache->getMySQLVersion(); $result->info[] = array('name' => 'MySQL Version', 'value' => $res); $res = $appCache->checkGrantsForUser(false); $currentUser = $res['user']; $currentUserIsSuper = $res['super']; $result->info[] = array('name' => 'Current User', 'value' => $currentUser); $result->info[] = array('name' => 'Current User has SUPER privilege', 'value' => $currentUserIsSuper); try { PROPEL::Init(PATH_METHODS . 'dbConnections/rootDbConnections.php'); $con = Propel::getConnection("root"); } catch (Exception $e) { $result->info[] = array('name' => 'Checking MySql Root user', 'value' => 'failed'); $result->error = true; $result->errorMsg = $e->getMessage(); } //if user does not have the SUPER privilege we need to use the root user and grant the SUPER priv. to normal user. if (!$currentUserIsSuper && !$result->error) { $res = $appCache->checkGrantsForUser(true);
/** * Upgrade the AppCacheView table to the latest system version. * * This recreates the table and populates with data. * * @param bool $checkOnly only check if the upgrade is needed if true * @param string $lang not currently used */ public function upgradeCacheView($fill = true, $checkOnly = false, $lang = "en") { $this->initPropel(true); //require_once ('classes/model/AppCacheView.php'); //check the language, if no info in config about language, the default is 'en' G::LoadClass("configuration"); $oConf = new Configurations(); $oConf->loadConfig($x, 'APP_CACHE_VIEW_ENGINE', '', '', '', ''); $appCacheViewEngine = $oConf->aConfig; //setup the appcacheview object, and the path for the sql files $appCache = new AppCacheView(); $appCache->setPathToAppCacheFiles(PATH_METHODS . 'setup' . PATH_SEP . 'setupSchemas' . PATH_SEP); $userGrants = $appCache->checkGrantsForUser(false); $currentUser = $userGrants['user']; $currentUserIsSuper = $userGrants['super']; //if user does not have the SUPER privilege we need to use the root user and grant the SUPER priv. to normal user. if (!$currentUserIsSuper) { $appCache->checkGrantsForUser(true); $appCache->setSuperForUser($currentUser); $currentUserIsSuper = true; } CLI::logging("-> Creating tables \n"); //now check if table APPCACHEVIEW exists, and it have correct number of fields, etc. $res = $appCache->checkAppCacheView(); CLI::logging("-> Update DEL_LAST_INDEX field in APP_DELEGATION table \n"); //Update APP_DELEGATION.DEL_LAST_INDEX data $res = $appCache->updateAppDelegationDelLastIndex($lang, $checkOnly); CLI::logging("-> Verifying roles permissions in RBAC \n"); //Update table RBAC permissions Bootstrap::LoadSystem( 'rbac' ); $RBAC = & RBAC::getSingleton(); $RBAC->initRBAC(); $result = $RBAC->verifyPermissions(); if (count($result) > 1) { foreach ($result as $item) { CLI::logging(" $item... \n"); } } else { CLI::logging(" All roles permissions already updated \n"); } CLI::logging("-> Creating triggers\n"); //now check if we have the triggers installed $triggers = array(); $triggers[] = $appCache->triggerAppDelegationInsert($lang, $checkOnly); $triggers[] = $appCache->triggerAppDelegationUpdate($lang, $checkOnly); $triggers[] = $appCache->triggerApplicationUpdate($lang, $checkOnly); $triggers[] = $appCache->triggerApplicationDelete($lang, $checkOnly); $triggers[] = $appCache->triggerSubApplicationInsert($lang, $checkOnly); $triggers[] = $appCache->triggerContentUpdate($lang, $checkOnly); if ($fill) { CLI::logging("-> Rebuild Cache View with language $lang...\n"); //build using the method in AppCacheView Class $res = $appCache->fillAppCacheView($lang); } //set status in config table $confParams = Array('LANG' => $lang, 'STATUS' => 'active'); $oConf->aConfig = $confParams; $oConf->saveConfig('APP_CACHE_VIEW_ENGINE', '', '', ''); // removing casesList configuration records. TODO: removing these lines that resets all the configurations records $oCriteria = new Criteria(); $oCriteria->add(ConfigurationPeer::CFG_UID, "casesList"); $oCriteria->add(ConfigurationPeer::OBJ_UID, array("todo", "draft", "sent", "unassigned", "paused", "cancelled"), Criteria::NOT_IN); ConfigurationPeer::doDelete($oCriteria); // end of reset //close connection if (substr(PHP_OS, 0, 3) != 'WIN') { $connection = Propel::getConnection( 'workflow' ); $sql_sleep = "SELECT * FROM information_schema.processlist WHERE command = 'Sleep' and user = SUBSTRING_INDEX(USER(),'@',1) and db = DATABASE() ORDER BY id;"; $stmt_sleep = $connection->createStatement(); $rs_sleep = $stmt_sleep->executeQuery( $sql_sleep, ResultSet::FETCHMODE_ASSOC ); while ($rs_sleep->next()) { $row_sleep = $rs_sleep->getRow(); $oStatement_sleep = $connection->prepareStatement( "kill ". $row_sleep['ID'] ); $oStatement_sleep->executeQuery(); } $sql_query = "SELECT * FROM information_schema.processlist WHERE user = SUBSTRING_INDEX(USER(),'@',1) and db = DATABASE() and time > 0 ORDER BY id;"; $stmt_query = $connection->createStatement(); $rs_query = $stmt_query->executeQuery( $sql_query, ResultSet::FETCHMODE_ASSOC ); while ($rs_query->next()) { $row_query = $rs_query->getRow(); $oStatement_query = $connection->prepareStatement( "kill ". $row_query['ID'] ); $oStatement_query->executeQuery(); } } }
/** * Upgrade the AppCacheView table to the latest system version. * * This recreates the table and populates with data. * * @param bool $checkOnly only check if the upgrade is needed if true * @param string $lang not currently used */ public function upgradeCacheView($fill = true) { $this->initPropel(true); $lang = "en"; require_once 'classes/model/AppCacheView.php'; //check the language, if no info in config about language, the default is 'en' G::loadClass('configuration'); $oConf = new Configurations(); $oConf->loadConfig($x, 'APP_CACHE_VIEW_ENGINE', '', '', '', ''); $appCacheViewEngine = $oConf->aConfig; //setup the appcacheview object, and the path for the sql files $appCache = new AppCacheView(); $appCache->setPathToAppCacheFiles(PATH_METHODS . 'setup' . PATH_SEP . 'setupSchemas' . PATH_SEP); $userGrants = $appCache->checkGrantsForUser(false); $currentUser = $userGrants['user']; $currentUserIsSuper = $userGrants['super']; //if user does not have the SUPER privilege we need to use the root user and grant the SUPER priv. to normal user. if (!$currentUserIsSuper) { $appCache->checkGrantsForUser(true); $appCache->setSuperForUser($currentUser); $currentUserIsSuper = true; } CLI::logging("-> Creating table\n"); //now check if table APPCACHEVIEW exists, and it have correct number of fields, etc. $res = $appCache->checkAppCacheView(); CLI::logging("-> Creating triggers\n"); //now check if we have the triggers installed $triggers = array(); $triggers[] = $appCache->triggerAppDelegationInsert($lang, $checkOnly); $triggers[] = $appCache->triggerAppDelegationUpdate($lang, $checkOnly); $triggers[] = $appCache->triggerApplicationUpdate($lang, $checkOnly); $triggers[] = $appCache->triggerApplicationDelete($lang, $checkOnly); $triggers[] = $appCache->triggerContentUpdate($lang, $checkOnly); if ($fill) { CLI::logging("-> Rebuild Cache View\n"); //build using the method in AppCacheView Class $res = $appCache->fillAppCacheView($lang); //set status in config table $confParams = array('LANG' => $lang, 'STATUS' => 'active'); } $oConf->aConfig = $confParams; $oConf->saveConfig('APP_CACHE_VIEW_ENGINE', '', '', ''); // removing casesList configuration records. TODO: removing these lines that resets all the configurations records $oCriteria = new Criteria(); $oCriteria->add(ConfigurationPeer::CFG_UID, "casesList"); $oCriteria->add(ConfigurationPeer::OBJ_UID, array("todo", "draft", "sent", "unassigned", "paused", "cancelled"), Criteria::NOT_IN); ConfigurationPeer::doDelete($oCriteria); // end of reset }
/** * Upgrade the AppCacheView table to the latest system version. * * This recreates the table and populates with data. * * @param bool $checkOnly only check if the upgrade is needed if true * @param string $lang not currently used */ public function upgradeCacheView($fill = true, $checkOnly = false, $lang = "en") { $this->initPropel(true); //require_once ('classes/model/AppCacheView.php'); //check the language, if no info in config about language, the default is 'en' G::LoadClass("configuration"); $oConf = new Configurations(); $oConf->loadConfig($x, 'APP_CACHE_VIEW_ENGINE', '', '', '', ''); $appCacheViewEngine = $oConf->aConfig; //setup the appcacheview object, and the path for the sql files $appCache = new AppCacheView(); $appCache->setPathToAppCacheFiles(PATH_METHODS . 'setup' . PATH_SEP . 'setupSchemas' . PATH_SEP); $userGrants = $appCache->checkGrantsForUser(false); $currentUser = $userGrants['user']; $currentUserIsSuper = $userGrants['super']; //if user does not have the SUPER privilege we need to use the root user and grant the SUPER priv. to normal user. if (!$currentUserIsSuper) { $appCache->checkGrantsForUser(true); $appCache->setSuperForUser($currentUser); $currentUserIsSuper = true; } CLI::logging("-> Creating table\n"); //now check if table APPCACHEVIEW exists, and it have correct number of fields, etc. $res = $appCache->checkAppCacheView(); CLI::logging("-> Update DEL_LAST_INDEX field in APP_DELEGATION table\n"); //Update APP_DELEGATION.DEL_LAST_INDEX data $res = $appCache->updateAppDelegationDelLastIndex($lang, $checkOnly); CLI::logging("-> Verifying roles permissions in RBAC \n"); //Update table RBAC permissions Bootstrap::LoadSystem('rbac'); $RBAC =& RBAC::getSingleton(); $RBAC->initRBAC(); $result = $RBAC->verifyPermissions(); if (count($result) > 1) { foreach ($result as $item) { CLI::logging(" {$item}... \n"); } } else { CLI::logging(" All roles permissions already updated \n"); } CLI::logging("-> Creating triggers\n"); //now check if we have the triggers installed $triggers = array(); $triggers[] = $appCache->triggerAppDelegationInsert($lang, $checkOnly); $triggers[] = $appCache->triggerAppDelegationUpdate($lang, $checkOnly); $triggers[] = $appCache->triggerApplicationUpdate($lang, $checkOnly); $triggers[] = $appCache->triggerApplicationDelete($lang, $checkOnly); $triggers[] = $appCache->triggerSubApplicationInsert($lang, $checkOnly); $triggers[] = $appCache->triggerContentUpdate($lang, $checkOnly); if ($fill) { CLI::logging("-> Rebuild Cache View with language {$lang}...\n"); //build using the method in AppCacheView Class $res = $appCache->fillAppCacheView($lang); //set status in config table $confParams = array('LANG' => $lang, 'STATUS' => 'active'); } $oConf->aConfig = $confParams; $oConf->saveConfig('APP_CACHE_VIEW_ENGINE', '', '', ''); // removing casesList configuration records. TODO: removing these lines that resets all the configurations records $oCriteria = new Criteria(); $oCriteria->add(ConfigurationPeer::CFG_UID, "casesList"); $oCriteria->add(ConfigurationPeer::OBJ_UID, array("todo", "draft", "sent", "unassigned", "paused", "cancelled"), Criteria::NOT_IN); ConfigurationPeer::doDelete($oCriteria); // end of reset }