X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FInvoke.php;h=7cc88fc74aac8b7bfd4fef0e48ebc53eb864e98d;hb=83c6658a8aa7e98e4d24435631f8d20e9b511de7;hp=ca79bbfe8f6e48d046e0515911c815ff0520ee3d;hpb=e3f27b9db97b237d61f7acf6fae653ef51f8921a;p=civicrm-core.git diff --git a/CRM/Core/Invoke.php b/CRM/Core/Invoke.php index ca79bbfe8f..7cc88fc74a 100644 --- a/CRM/Core/Invoke.php +++ b/CRM/Core/Invoke.php @@ -1,9 +1,9 @@ getErrorData(); - $message = $e->getMessage(); - if (isset($params['legacy_status_bounce'])) { - //@todo remove this- see comments on - //https://github.com/eileenmcnaughton/civicrm-core/commit/ae686b09e2c987091612bb25ba0a58e520a203e7 - CRM_Core_Error::statusBounce($params['message']); - } - else { - $session = CRM_Core_Session::singleton(); - $session->setStatus( - $message, - CRM_Utils_Array::value('message_title', $params), - CRM_Utils_Array::value('message_type', $params, 'error') - ); - - // @todo remove this code - legacy redirect path is an interim measure for moving redirects out of BAO - // to somewhere slightly more acceptable. they should not be part of the exception class & should - // be managed @ the form level - if you find a form that is triggering this piece of code - // you should log a ticket for it to be removed with details about the form you were on. - if(!empty($params['legacy_redirect_path'])) { - if(CRM_Utils_System::isDevelopment()) { - // here we could set a message telling devs to log it per above - } - CRM_Utils_System::redirect($params['legacy_redirect_path'], $params['legacy_redirect_query']); - } - } - } - catch (Exception $e) { - // Recall: CRM_Core_Config is initialized before calling CRM_Core_Invoke - $config = CRM_Core_Config::singleton(); - return CRM_Core_Error::handleUnhandledException($e); - /* - if ($config->backtrace) { - return CRM_Core_Error::formatHtmlException($e); - } else { - // TODO - }*/ - } - } else { + // Traditional Civi invocation path + self::hackMenuRebuild($args); // may exit + self::init($args); + self::hackStandalone($args); + $item = self::getItem($args); + return self::runItem($item); + } + else { // Symfony-based invocation path require_once CIVICRM_SYMFONY_PATH . '/app/bootstrap.php.cache'; require_once CIVICRM_SYMFONY_PATH . '/app/AppKernel.php'; - $kernel = new AppKernel('dev', true); + $kernel = new AppKernel('dev', TRUE); $kernel->loadClassCache(); $response = $kernel->handle(Symfony\Component\HttpFoundation\Request::createFromGlobals()); if (preg_match(':^text/html:', $response->headers->get('Content-Type'))) { // let the CMS handle the trappings return $response->getContent(); - } else { + } + else { $response->send(); exit(); } } } + /** * Hackish support /civicrm/menu/rebuild * - * @param array $args list of path parts + * @param array $args + * List of path parts. * @void */ static public function hackMenuRebuild($args) { - if (array('civicrm','menu','rebuild') == $args || array('civicrm', 'clearcache') == $args) { + if (array('civicrm', 'menu', 'rebuild') == $args || array('civicrm', 'clearcache') == $args) { // ensure that the user has a good privilege level if (CRM_Core_Permission::check('administer CiviCRM')) { self::rebuildMenuAndCaches(); @@ -154,9 +125,10 @@ class CRM_Core_Invoke { } /** - * Perform general setup + * Perform general setup. * - * @param array $args list of path parts + * @param array $args + * List of path parts. * @void */ static public function init($args) { @@ -175,7 +147,8 @@ class CRM_Core_Invoke { /** * Hackish support for /standalone/* * - * @param array $args list of path parts + * @param array $args + * List of path parts. * @void */ static public function hackStandalone($args) { @@ -194,14 +167,16 @@ class CRM_Core_Invoke { /** * Determine which menu $item corresponds to $args * - * @param array $args list of path parts + * @param array $args + * List of path parts. * @return array; see CRM_Core_Menu */ static public function getItem($args) { if (is_array($args)) { // get the menu items $path = implode('/', $args); - } else { + } + else { $path = $args; } $item = CRM_Core_Menu::get($path); @@ -219,7 +194,8 @@ class CRM_Core_Invoke { /** * Given a menu item, call the appropriate controller and return the response * - * @param array $item see CRM_Core_Menu + * @param array $item + * See CRM_Core_Menu. * @return string, HTML */ static public function runItem($item) { @@ -241,9 +217,9 @@ class CRM_Core_Invoke { 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'; + 'snippet', FALSE, FALSE, + CRM_Utils_Array::value('path', $item) + ) . '2'; $template->assign('printerFriendly', $printerFriendly); if (!array_key_exists('page_callback', $item)) { @@ -254,7 +230,7 @@ class CRM_Core_Invoke { // check that we are permissioned to access this page if (!CRM_Core_Permission::checkMenuItem($item)) { CRM_Utils_System::permissionDenied(); - return; + return NULL; } // check if ssl is set @@ -295,9 +271,11 @@ class CRM_Core_Invoke { } $result = NULL; - if (is_array($item['page_callback'])) { - require_once (str_replace('_', DIRECTORY_SEPARATOR, $item['page_callback'][0]) . '.php'); - $result = call_user_func($item['page_callback']); + // WISHLIST: Refactor this. Instead of pattern-matching on page_callback, lookup + // page_callback via Civi\Core\Resolver and check the implemented interfaces. This + // would require rethinking the default constructor. + if (is_array($item['page_callback']) || strpos($item['page_callback'], ':')) { + $result = call_user_func(Civi\Core\Resolver::singleton()->get($item['page_callback'])); } elseif (strstr($item['page_callback'], '_Form')) { $wrapper = new CRM_Utils_Wrapper(); @@ -309,25 +287,24 @@ class CRM_Core_Invoke { } 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')) { - $object = new $item['page_callback'] ($title, $mode ); + if (strstr($item['page_callback'], '_Page') || strstr($item['page_callback'], '\\Page\\')) { + $object = new $item['page_callback']($title, $mode); $object->urlPath = explode('/', $_GET[$config->userFrameworkURLVar]); } - elseif (strstr($item['page_callback'], '_Controller')) { + elseif (strstr($item['page_callback'], '_Controller') || strstr($item['page_callback'], '\\Controller\\')) { $addSequence = 'false'; if (isset($pageArgs['addSequence'])) { $addSequence = $pageArgs['addSequence']; $addSequence = $addSequence ? 'true' : 'false'; unset($pageArgs['addSequence']); } - $object = new $item['page_callback'] ($title, true, $mode, null, $addSequence ); + $object = new $item['page_callback']($title, TRUE, $mode, NULL, $addSequence); } else { CRM_Core_Error::fatal(); @@ -345,17 +322,15 @@ class CRM_Core_Invoke { } /** - * This function contains the default action + * This function contains the default action. * * @param $action * * @param $contact_type * @param $contact_sub_type * - * @static - * @access public */ - static function form($action, $contact_type, $contact_sub_type) { + public static function form($action, $contact_type, $contact_sub_type) { CRM_Utils_System::setUserContext(array('civicrm/contact/search/basic', 'civicrm/contact/view')); $wrapper = new CRM_Utils_Wrapper(); @@ -369,17 +344,23 @@ class CRM_Core_Invoke { } /** - * Show the message about CiviCRM versions + * Show the message about CiviCRM versions. * - * @param obj: $template (reference) + * @param CRM_Core_Smarty $template */ - static function versionCheck($template) { + public static function versionCheck($template) { if (CRM_Core_Config::isUpgradeMode()) { return; } - $versionCheck = CRM_Utils_VersionCheck::singleton(); - $newerVersion = $versionCheck->newerVersion(); + $newerVersion = $securityUpdate = NULL; + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'versionAlert', NULL, 1) & 1) { + $newerVersion = CRM_Utils_VersionCheck::singleton()->isNewerVersionAvailable(); + } + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'securityUpdateAlert', NULL, 3) & 1) { + $securityUpdate = CRM_Utils_VersionCheck::singleton()->isSecurityUpdateAvailable(); + } $template->assign('newer_civicrm_version', $newerVersion); + $template->assign('security_update', $securityUpdate); } /** @@ -388,7 +369,7 @@ class CRM_Core_Invoke { * * @throws Exception */ - static function rebuildMenuAndCaches($triggerRebuild = FALSE, $sessionReset = FALSE) { + public static function rebuildMenuAndCaches($triggerRebuild = FALSE, $sessionReset = FALSE) { $config = CRM_Core_Config::singleton(); $config->clearModuleList(); @@ -420,5 +401,9 @@ class CRM_Core_Invoke { } 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); } + }