public function postProcess() { if (!empty($_POST['_qf_UpdateConfigBackend_next_cleanup'])) { $config = CRM_Core_Config::singleton(); // cleanup templates_c directory $config->cleanup(1, FALSE); // clear all caches CRM_Core_Config::clearDBCache(); CRM_Utils_System::flushCache(); parent::rebuildMenu(); CRM_Core_BAO_WordReplacement::rebuild(); CRM_Core_Session::setStatus(ts('Cache has been cleared and menu has been rebuilt successfully.'), ts("Success"), "success"); } if (!empty($_POST['_qf_UpdateConfigBackend_next_resetpaths'])) { $msg = CRM_Core_BAO_ConfigSetting::doSiteMove(); CRM_Core_Session::setStatus($msg, ts("Success"), "success"); } return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/setting/updateConfigBackend', 'reset=1')); }
static function rebuildMenuAndCaches($triggerRebuild = FALSE, $sessionReset = FALSE) { $config = CRM_Core_Config::singleton(); $config->clearModuleList(); // also cleanup all caches $config->cleanupCaches($sessionReset || CRM_Utils_Request::retrieve('sessionReset', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET')); CRM_Core_Menu::store(); // also reset navigation CRM_Core_BAO_Navigation::resetNavigation(); // also cleanup module permissions $config->cleanupPermissions(); // also rebuild word replacement cache CRM_Core_BAO_WordReplacement::rebuild(); CRM_Core_BAO_Setting::updateSettingsFromMetaData(); CRM_Core_Resources::singleton()->resetCacheCode(); // also rebuild triggers if requested explicitly if ($triggerRebuild || CRM_Utils_Request::retrieve('triggerRebuild', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET')) { CRM_Core_DAO::triggerRebuild(); } CRM_Core_DAO_AllCoreTables::reinitializeCache(TRUE); CRM_Core_ManagedEntities::singleton(TRUE)->reconcile(); }
/** * Rebuild word replacements. * * Get all the word-replacements stored in config-arrays * and write them out as records in civicrm_word_replacement. * * Note: This function is duplicated in CRM_Core_BAO_WordReplacement and * CRM_Upgrade_Incremental_php_FourFour to ensure that the incremental upgrade * step behaves consistently even as the BAO evolves in future versions. * However, if there's a bug in here prior to 4.4.0, we should apply the * bug-fix in both places. */ public static function rebuildWordReplacementTable() { civicrm_api3('word_replacement', 'replace', array('options' => array('match' => array('domain_id', 'find_word')), 'values' => self::getConfigArraysAsAPIParams(FALSE))); CRM_Core_BAO_WordReplacement::rebuild(); }
/** * Process the form submission. */ public function postProcess() { $params = $this->controller->exportValues($this->_name); $this->_numStrings = count($params['old']); $enabled['exactMatch'] = $enabled['wildcardMatch'] = $disabled['exactMatch'] = $disabled['wildcardMatch'] = array(); for ($i = 1; $i <= $this->_numStrings; $i++) { if (!empty($params['new'][$i]) && !empty($params['old'][$i])) { if (isset($params['enabled']) && !empty($params['enabled'][$i])) { if (!empty($params['cb']) && !empty($params['cb'][$i])) { $enabled['exactMatch'] += array($params['old'][$i] => $params['new'][$i]); } else { $enabled['wildcardMatch'] += array($params['old'][$i] => $params['new'][$i]); } } else { if (isset($params['cb']) && is_array($params['cb']) && array_key_exists($i, $params['cb'])) { $disabled['exactMatch'] += array($params['old'][$i] => $params['new'][$i]); } else { $disabled['wildcardMatch'] += array($params['old'][$i] => $params['new'][$i]); } } } } $overrides = array('enabled' => $enabled, 'disabled' => $disabled); $config = CRM_Core_Config::singleton(); CRM_Core_BAO_WordReplacement::setLocaleCustomStrings($config->lcMessages, $overrides); // This controller was originally written to CRUD $config->locale_custom_strings, // but that's no longer the canonical store. Sync changes to canonical store. // This is inefficient - at some point, we should rewrite this UI. CRM_Core_BAO_WordReplacement::rebuildWordReplacementTable(); CRM_Core_Session::setStatus("", ts("Settings Saved"), "success"); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/options/wordreplacements', "reset=1")); }
/** * Function to process the form * * @access public * * @return void */ public function postProcess() { $params = $this->controller->exportValues($this->_name); $this->_numStrings = sizeof($params['old']); $enabled['exactMatch'] = $enabled['wildcardMatch'] = $disabled['exactMatch'] = $disabled['wildcardMatch'] = array(); for ($i = 1; $i <= $this->_numStrings; $i++) { if (!empty($params['new'][$i]) && !empty($params['old'][$i])) { if (isset($params['enabled']) && !empty($params['enabled'][$i])) { if (!empty($params['cb']) && !empty($params['cb'][$i])) { $enabled['exactMatch'] += array($params['old'][$i] => $params['new'][$i]); } else { $enabled['wildcardMatch'] += array($params['old'][$i] => $params['new'][$i]); } } else { if (isset($params['cb']) && is_array($params['cb']) && array_key_exists($i, $params['cb'])) { $disabled['exactMatch'] += array($params['old'][$i] => $params['new'][$i]); } else { $disabled['wildcardMatch'] += array($params['old'][$i] => $params['new'][$i]); } } } } $overrides = array('enabled' => $enabled, 'disabled' => $disabled); $config = CRM_Core_Config::singleton(); $domain = new CRM_Core_DAO_Domain(); $domain->find(TRUE); if ($domain->locales && $config->localeCustomStrings) { // for multilingual $addReplacements = $config->localeCustomStrings; $addReplacements[$config->lcMessages] = $overrides; $stringOverride = serialize($addReplacements); } else { // for single language $stringOverride = serialize(array($config->lcMessages => $overrides)); } $params = array('locale_custom_strings' => $stringOverride); $id = CRM_Core_Config::domainID(); $wordReplacementSettings = CRM_Core_BAO_Domain::edit($params, $id); if ($wordReplacementSettings) { // This controller was originally written to CRUD $config->locale_custom_strings, // but that's no longer the canonical store. Sync changes to canonical store. // This is inefficient - at some point, we should rewrite this UI. CRM_Core_BAO_WordReplacement::rebuildWordReplacementTable(); CRM_Core_Session::setStatus("", ts("Settings Saved"), "success"); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/options/wordreplacements', "reset=1")); } }
/** * @param bool $triggerRebuild * @param bool $sessionReset * * @throws Exception */ public static function rebuildMenuAndCaches($triggerRebuild = FALSE, $sessionReset = FALSE) { $config = CRM_Core_Config::singleton(); $config->clearModuleList(); // also cleanup all caches $config->cleanupCaches($sessionReset || CRM_Utils_Request::retrieve('sessionReset', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET')); CRM_Core_Menu::store(); // also reset navigation CRM_Core_BAO_Navigation::resetNavigation(); // also cleanup module permissions $config->cleanupPermissions(); // rebuild word replacement cache - pass false to prevent operations redundant with this fn CRM_Core_BAO_WordReplacement::rebuild(FALSE); Civi::service('settings_manager')->flush(); // Clear js caches CRM_Core_Resources::singleton()->flushStrings()->resetCacheCode(); CRM_Case_XMLRepository::singleton(TRUE); // also rebuild triggers if requested explicitly if ($triggerRebuild || CRM_Utils_Request::retrieve('triggerRebuild', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET')) { CRM_Core_DAO::triggerRebuild(); } CRM_Core_DAO_AllCoreTables::reinitializeCache(TRUE); CRM_Core_ManagedEntities::singleton(TRUE)->reconcile(); //CRM-16257 update Config.IDS.ini might be an old copy CRM_Core_IDS::createConfigFile(TRUE); }
/** * Lookup the raw translation of a string (without any extra escaping or interpolation). * * @param string $text * @param string|NULL $domain * @param int|NULL $count * @param string $plural * @param string $context * * @return string */ protected function crm_translate_raw($text, $domain, $count, $plural, $context) { // gettext domain for extensions $domain_changed = FALSE; if (!empty($domain) && $this->_phpgettext) { if ($this->setGettextDomain($domain)) { $domain_changed = TRUE; } } // do all wildcard translations first if (!isset(Civi::$statics[__CLASS__]) || !array_key_exists($this->locale, Civi::$statics[__CLASS__])) { if (defined('CIVICRM_DSN') && !CRM_Core_Config::isUpgradeMode()) { Civi::$statics[__CLASS__][$this->locale] = CRM_Core_BAO_WordReplacement::getLocaleCustomStrings($this->locale); } else { Civi::$statics[__CLASS__][$this->locale] = array(); } } $stringTable = Civi::$statics[__CLASS__][$this->locale]; $exactMatch = FALSE; if (isset($stringTable['enabled']['exactMatch'])) { foreach ($stringTable['enabled']['exactMatch'] as $search => $replace) { if ($search === $text) { $exactMatch = TRUE; $text = $replace; break; } } } if (!$exactMatch && isset($stringTable['enabled']['wildcardMatch'])) { $search = array_keys($stringTable['enabled']['wildcardMatch']); $replace = array_values($stringTable['enabled']['wildcardMatch']); $text = str_replace($search, $replace, $text); } // dont translate if we've done exactMatch already if (!$exactMatch) { // use plural if required parameters are set if (isset($count) && isset($plural)) { if ($this->_phpgettext) { $text = $this->_phpgettext->ngettext($text, $plural, $count); } else { // if the locale's not set, we do ngettext work by hand // if $count == 1 then $text = $text, else $text = $plural if ($count != 1) { $text = $plural; } } // expand %count in translated string to $count $text = strtr($text, array('%count' => $count)); // if not plural, but the locale's set, translate } elseif ($this->_phpgettext) { if ($context) { $text = $this->_phpgettext->pgettext($context, $text); } else { $text = $this->_phpgettext->translate($text); } } } if ($domain_changed) { $this->setGettextDomain('civicrm'); } return $text; }
/** * This api cleans up all the old session entries and temp tables. * * We recommend that sites run this on an hourly basis. * * @param array $params * Sends in various config parameters to decide what needs to be cleaned. */ function civicrm_api3_job_cleanup($params) { $session = CRM_Utils_Array::value('session', $params, TRUE); $tempTable = CRM_Utils_Array::value('tempTables', $params, TRUE); $jobLog = CRM_Utils_Array::value('jobLog', $params, TRUE); $prevNext = CRM_Utils_Array::value('prevNext', $params, TRUE); $dbCache = CRM_Utils_Array::value('dbCache', $params, FALSE); $memCache = CRM_Utils_Array::value('memCache', $params, FALSE); $tplCache = CRM_Utils_Array::value('tplCache', $params, FALSE); $wordRplc = CRM_Utils_Array::value('wordRplc', $params, FALSE); if ($session || $tempTable || $prevNext) { CRM_Core_BAO_Cache::cleanup($session, $tempTable, $prevNext); } if ($jobLog) { CRM_Core_BAO_Job::cleanup(); } if ($tplCache) { $config = CRM_Core_Config::singleton(); $config->cleanup(1, FALSE); } if ($dbCache) { CRM_Core_Config::clearDBCache(); } if ($memCache) { CRM_Utils_System::flushCache(); } if ($wordRplc) { CRM_Core_BAO_WordReplacement::rebuild(); } }
function postProcess() { if (!empty($_POST['_qf_UpdateConfigBackend_next_cleanup'])) { $config = CRM_Core_Config::singleton(); // cleanup templates_c directory $config->cleanup(1, FALSE); // clear db caching CRM_Core_Config::clearDBCache(); parent::rebuildMenu(); CRM_Core_BAO_WordReplacement::rebuild(); CRM_Core_Session::setStatus(ts('Cache has been cleared and menu has been rebuilt successfully.'), ts("Success"), "success"); return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/setting/updateConfigBackend', 'reset=1')); } // redirect to admin page after saving $session = CRM_Core_Session::singleton(); $session->pushUserContext(CRM_Utils_System::url('civicrm/admin')); $params = $this->controller->exportValues($this->_name); //CRM-5679 foreach ($params as $name => &$val) { if ($val && in_array($name, array('newBaseURL', 'newBaseDir', 'newSiteName'))) { $val = CRM_Utils_File::addTrailingSlash($val); } } $from = array($this->_oldBaseURL, $this->_oldBaseDir); $to = array(trim($params['newBaseURL']), trim($params['newBaseDir'])); if ($this->_oldSiteName && $params['newSiteName']) { $from[] = $this->_oldSiteName; $to[] = $params['newSiteName']; } $newValues = str_replace($from, $to, $this->_defaults); parent::commonProcess($newValues); parent::rebuildMenu(); }