/** * Perform general setup * * @param array $args list of path parts * @void */ public static function init($args) { // first fire up IDS and check for bad stuff $config = CRM_Core_Config::singleton(); if (!CRM_Core_Permission::check('skip IDS check')) { $ids = new CRM_Core_IDS(); $ids->check($args); } // also initialize the i18n framework require_once 'CRM/Core/I18n.php'; $i18n = CRM_Core_I18n::singleton(); }
/** * @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); }
public static function doFinish() { $upgrade = new CRM_Upgrade_Form(); list($ignore, $latestVer) = $upgrade->getUpgradeVersions(); // Seems extraneous in context, but we'll preserve old behavior $upgrade->setVersion($latestVer); // lets rebuild the config array in case we've made a few changes in the // code base // this also helps us always store the latest version of civi in the DB $params = array(); CRM_Core_BAO_ConfigSetting::add($params); // CRM-12804 comment-51411 : add any missing settings // at the end of upgrade CRM_Core_BAO_Setting::updateSettingsFromMetaData(); // cleanup caches CRM-8739 $config = CRM_Core_Config::singleton(); $config->cleanupCaches(1); // Rebuild all triggers and re-enable logging if needed $logging = new CRM_Logging_Schema(); $logging->fixSchemaDifferences(); //CRM-16257 update Config.IDS.ini might be an old copy CRM_Core_IDS::createConfigFile(TRUE); }
/** * This is the main function that is called on every click action and based on the argument * respective functions are called * * @param $args array this array contains the arguments of the url * * @static * @access public */ static function invoke($args) { require_once 'CRM/Core/I18n.php'; require_once 'CRM/Utils/Wrapper.php'; require_once 'CRM/Core/Action.php'; require_once 'CRM/Utils/Request.php'; require_once 'CRM/Core/Menu.php'; require_once 'CRM/Core/Component.php'; require_once 'CRM/Core/Permission.php'; if ($args[0] !== 'civicrm') { return; } if (isset($args[1]) and $args[1] == 'menu' and isset($args[2]) and $args[2] == 'rebuild') { CRM_Core_Menu::store(); CRM_Core_Session::setStatus(ts('Menu has been rebuilt')); // also reset navigation require_once 'CRM/Core/BAO/Navigation.php'; CRM_Core_BAO_Navigation::resetNavigation(); return CRM_Utils_System::redirect(); } // first fire up IDS and check for bad stuff require_once 'CRM/Core/IDS.php'; $ids = new CRM_Core_IDS(); $ids->check($args); $config =& CRM_Core_Config::singleton(); // also initialize the i18n framework $i18n =& CRM_Core_I18n::singleton(); if ($config->userFramework == 'Standalone') { require_once 'CRM/Core/Session.php'; $session =& CRM_Core_Session::singleton(); if ($session->get('new_install') !== true) { require_once 'CRM/Core/Standalone.php'; CRM_Core_Standalone::sidebarLeft(); } else { if ($args[1] == 'standalone' && $args[2] == 'register') { CRM_Core_Menu::store(); } } } // get the menu items $path = implode('/', $args); $item =& CRM_Core_Menu::get($path); // we should try to compute menus, if item is empty and stay on the same page, // rather than compute and redirect to dashboard. if (!$item) { CRM_Core_Menu::store(false); $item =& CRM_Core_Menu::get($path); } if ($config->userFramework == 'Joomla' && $item) { $config->userFrameworkURLVar = 'task'; require_once 'CRM/Core/Joomla.php'; // joomla 1.5RC1 seems to push this in the POST variable, which messes // QF and checkboxes unset($_POST['option']); CRM_Core_Joomla::sidebarLeft(); } // set active Component $template =& CRM_Core_Smarty::singleton(); $template->assign('activeComponent', 'CiviCRM'); $template->assign('formTpl', 'default'); if ($item) { if (!array_key_exists('page_callback', $item)) { CRM_Core_Error::debug('Bad item', $item); CRM_Core_Error::fatal(ts('Bad menu record in database')); } // check that we are permissioned to access this page if (!CRM_Core_Permission::checkMenuItem($item)) { CRM_Utils_System::permissionDenied(); return; } // check if ssl is set if (CRM_Utils_Array::value('is_ssl', $item)) { CRM_Utils_System::redirectToSSL(); } if (isset($item['title'])) { CRM_Utils_System::setTitle($item['title']); } if (isset($item['breadcrumb']) && !isset($item['is_public'])) { CRM_Utils_System::appendBreadCrumb($item['breadcrumb']); } $pageArgs = null; if (CRM_Utils_Array::value('page_arguments', $item)) { $pageArgs = CRM_Core_Menu::getArrayForPathArgs($item['page_arguments']); } $template =& CRM_Core_Smarty::singleton(); if (isset($item['is_public']) && $item['is_public']) { $template->assign('urlIsPublic', true); } else { $template->assign('urlIsPublic', false); } if (isset($item['return_url'])) { $session =& CRM_Core_Session::singleton(); $args = CRM_Utils_Array::value('return_url_args', $item, 'reset=1'); $session->pushUserContext(CRM_Utils_System::url($item['return_url'], $args)); } if (is_array($item['page_callback'])) { $newArgs = explode('/', $_GET[$config->userFrameworkURLVar]); require_once str_replace('_', DIRECTORY_SEPARATOR, $item['page_callback'][0]) . '.php'; return call_user_func($item['page_callback'], $newArgs); } else { if (strstr($item['page_callback'], '_Form')) { $wrapper =& new CRM_Utils_Wrapper(); return $wrapper->run(CRM_Utils_Array::value('page_callback', $item), CRM_Utils_Array::value('title', $item), isset($pageArgs) ? $pageArgs : null); } else { $newArgs = explode('/', $_GET[$config->userFrameworkURLVar]); require_once str_replace('_', DIRECTORY_SEPARATOR, $item['page_callback']) . '.php'; $mode = 'null'; if (isset($pageArgs['mode'])) { $mode = $pageArgs['mode']; unset($pageArgs['mode']); } $title = CRM_Utils_Array::value('title', $item); if (strstr($item['page_callback'], '_Page')) { eval('$object =& ' . "new {$item['page_callback']}( \$title, \$mode );"); } else { if (strstr($item['page_callback'], '_Controller')) { $addSequence = 'false'; if (isset($pageArgs['addSequence'])) { $addSequence = $pageArgs['addSequence']; $addSequence = $addSequence ? 'true' : 'false'; unset($pageArgs['addSequence']); } eval('$object =& ' . "new {$item['page_callback']} ( \$title, true, \$mode, null, \$addSequence );"); } else { CRM_Core_Error::fatal(); } } return $object->run($newArgs, $pageArgs); } } } CRM_Core_Menu::store(); CRM_Core_Session::setStatus(ts('Menu has been rebuilt')); return CRM_Utils_System::redirect(); }
public static function doFinish() { $upgrade = new CRM_Upgrade_Form(); list($ignore, $latestVer) = $upgrade->getUpgradeVersions(); // Seems extraneous in context, but we'll preserve old behavior $upgrade->setVersion($latestVer); // Clear cached metadata. Civi::service('settings_manager')->flush(); // cleanup caches CRM-8739 $config = CRM_Core_Config::singleton(); $config->cleanupCaches(1); // Rebuild all triggers and re-enable logging if needed $logging = new CRM_Logging_Schema(); $logging->fixSchemaDifferences(); //CRM-16257 update Config.IDS.ini might be an old copy CRM_Core_IDS::createConfigFile(TRUE); }
protected static function _invoke($args) { if ($args[0] !== 'civicrm') { return; } require_once 'CRM/Core/I18n.php'; $config = CRM_Core_Config::singleton(); if (isset($args[1]) and $args[1] == 'menu' and isset($args[2]) and $args[2] == 'rebuild') { // ensure that the user has a good privilege level if (CRM_Core_Permission::check('administer CiviCRM')) { self::rebuildMenuAndCaches(); CRM_Core_Session::setStatus(ts('Menu has been rebuilt')); return CRM_Utils_System::redirect(); } else { CRM_Core_Error::fatal('You do not have permission to execute this url'); } } // first fire up IDS and check for bad stuff if ($config->useIDS) { $ids = new CRM_Core_IDS(); $ids->check($args); } // also initialize the i18n framework $i18n = CRM_Core_I18n::singleton(); if ($config->userFramework == 'Standalone') { $session = CRM_Core_Session::singleton(); if ($session->get('new_install') !== TRUE) { CRM_Core_Standalone::sidebarLeft(); } elseif ($args[1] == 'standalone' && $args[2] == 'register') { CRM_Core_Menu::store(); } } // get the menu items $path = implode('/', $args); $item = CRM_Core_Menu::get($path); // we should try to compute menus, if item is empty and stay on the same page, // rather than compute and redirect to dashboard. if (!$item) { CRM_Core_Menu::store(FALSE); $item = CRM_Core_Menu::get($path); } if ($config->userFramework == 'Joomla' && $item) { $config->userFrameworkURLVar = 'task'; // joomla 1.5RC1 seems to push this in the POST variable, which messes // QF and checkboxes unset($_POST['option']); CRM_Core_Joomla::sidebarLeft(); } // set active Component $template = CRM_Core_Smarty::singleton(); $template->assign('activeComponent', 'CiviCRM'); $template->assign('formTpl', 'default'); if ($item) { // CRM-7656 - make sure we send a clean sanitized path to create printer friendly url $printerFriendly = CRM_Utils_System::makeURL('snippet', FALSE, FALSE, CRM_Utils_Array::value('path', $item)) . '2'; $template->assign('printerFriendly', $printerFriendly); if (!array_key_exists('page_callback', $item)) { CRM_Core_Error::debug('Bad item', $item); CRM_Core_Error::fatal(ts('Bad menu record in database')); } // check that we are permissioned to access this page if (!CRM_Core_Permission::checkMenuItem($item)) { CRM_Utils_System::permissionDenied(); return; } // check if ssl is set if (CRM_Utils_Array::value('is_ssl', $item)) { CRM_Utils_System::redirectToSSL(); } if (isset($item['title'])) { CRM_Utils_System::setTitle($item['title']); } if (isset($item['breadcrumb']) && !isset($item['is_public'])) { CRM_Utils_System::appendBreadCrumb($item['breadcrumb']); } $pageArgs = NULL; if (CRM_Utils_Array::value('page_arguments', $item)) { $pageArgs = CRM_Core_Menu::getArrayForPathArgs($item['page_arguments']); } $template = CRM_Core_Smarty::singleton(); if (isset($item['is_public']) && $item['is_public']) { $template->assign('urlIsPublic', TRUE); } else { $template->assign('urlIsPublic', FALSE); } if (isset($item['return_url'])) { $session = CRM_Core_Session::singleton(); $args = CRM_Utils_Array::value('return_url_args', $item, 'reset=1'); $session->pushUserContext(CRM_Utils_System::url($item['return_url'], $args)); } // CRM_Core_Error::debug( $item ); exit( ); $result = NULL; if (is_array($item['page_callback'])) { $newArgs = explode('/', $_GET[$config->userFrameworkURLVar]); require_once str_replace('_', DIRECTORY_SEPARATOR, $item['page_callback'][0]) . '.php'; $result = call_user_func($item['page_callback'], $newArgs); } elseif (strstr($item['page_callback'], '_Form')) { $wrapper = new CRM_Utils_Wrapper(); $result = $wrapper->run(CRM_Utils_Array::value('page_callback', $item), CRM_Utils_Array::value('title', $item), isset($pageArgs) ? $pageArgs : NULL); } else { $newArgs = explode('/', $_GET[$config->userFrameworkURLVar]); require_once str_replace('_', DIRECTORY_SEPARATOR, $item['page_callback']) . '.php'; $mode = 'null'; if (isset($pageArgs['mode'])) { $mode = $pageArgs['mode']; unset($pageArgs['mode']); } $title = CRM_Utils_Array::value('title', $item); if (strstr($item['page_callback'], '_Page')) { eval("\$object = new {$item['page_callback']}( \$title, \$mode );"); } elseif (strstr($item['page_callback'], '_Controller')) { $addSequence = 'false'; if (isset($pageArgs['addSequence'])) { $addSequence = $pageArgs['addSequence']; $addSequence = $addSequence ? 'true' : 'false'; unset($pageArgs['addSequence']); } eval("\$object = new {$item['page_callback']}( \$title, true, \$mode, null, \$addSequence );"); } else { CRM_Core_Error::fatal(); } $result = $object->run($newArgs, $pageArgs); } CRM_Core_Session::storeSessionObjects(); return $result; } CRM_Core_Menu::store(); CRM_Core_Session::setStatus(ts('Menu has been rebuilt')); return CRM_Utils_System::redirect(); }