Comments & e-notice fixes
[civicrm-core.git] / CRM / Core / Invoke.php
index 837dda2ef2d6b789aa1868e0772176af568f234d..c11ec176d5e8ecabc792e65dbac893f959cfdbee 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -31,7 +31,7 @@
  * Serves as a wrapper between the UserFrameWork and Core CRM
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
@@ -117,8 +117,13 @@ class CRM_Core_Invoke {
       $kernel = new AppKernel('dev', true);
       $kernel->loadClassCache();
       $response = $kernel->handle(Symfony\Component\HttpFoundation\Request::createFromGlobals());
-      // $response->send();
-      return $response->getContent();
+      if (preg_match(':^text/html:', $response->headers->get('Content-Type'))) {
+        // let the CMS handle the trappings
+        return $response->getContent();
+      } else {
+        $response->send();
+        exit();
+      }
     }
   }
   /**
@@ -284,9 +289,8 @@ class CRM_Core_Invoke {
 
       $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);
+        $result = call_user_func($item['page_callback']);
       }
       elseif (strstr($item['page_callback'], '_Form')) {
         $wrapper = new CRM_Utils_Wrapper();
@@ -307,7 +311,7 @@ class CRM_Core_Invoke {
         $title = CRM_Utils_Array::value('title', $item);
         if (strstr($item['page_callback'], '_Page')) {
           $object = new $item['page_callback'] ($title, $mode );
-          $object->urlPath = $_GET[$config->userFrameworkURLVar];
+          $object->urlPath = explode('/', $_GET[$config->userFrameworkURLVar]);
         }
         elseif (strstr($item['page_callback'], '_Controller')) {
           $addSequence = 'false';
@@ -354,114 +358,6 @@ class CRM_Core_Invoke {
     }
   }
 
-  /**
-   * This function contains the actions for profile arguments
-   *
-   * @param $args array this array contains the arguments of the url
-   *
-   * @static
-   * @access public
-   */
-  static function profile($args) {
-    if ($args[1] !== 'profile') {
-      return;
-    }
-
-    $secondArg = CRM_Utils_Array::value(2, $args, '');
-
-    if ($secondArg == 'map') {
-      $controller = new CRM_Core_Controller_Simple(
-        'CRM_Contact_Form_Task_Map',
-        ts('Map Contact'),
-        NULL, FALSE, FALSE, TRUE
-      );
-
-      $gids = explode(',', CRM_Utils_Request::retrieve('gid', 'String', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET'));
-
-      if (count($gids) > 1) {
-        foreach ($gids as $pfId) {
-          $profileIds[] = CRM_Utils_Type::escape($pfId, 'Positive');
-        }
-        $controller->set('gid', $profileIds[0]);
-        $profileGID = $profileIds[0];
-      }
-      else {
-        $profileGID = CRM_Utils_Request::retrieve('gid', 'Integer', $controller, TRUE);
-      }
-
-
-      // make sure that this profile enables mapping
-      // CRM-8609
-      $isMap =
-        CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileGID, 'is_map');
-      if (!$isMap) {
-        CRM_Core_Error::statusBounce(ts('This profile does not have the map feature turned on.'));
-      }
-
-      $profileView = CRM_Utils_Request::retrieve('pv', 'Integer', $controller, FALSE);
-
-      // set the userContext stack
-      $session = CRM_Core_Session::singleton();
-      if ($profileView) {
-        $session->pushUserContext(CRM_Utils_System::url('civicrm/profile/view'));
-      }
-      else {
-        $session->pushUserContext(CRM_Utils_System::url('civicrm/profile', 'force=1'));
-      }
-
-      $controller->set('profileGID', $profileGID);
-      $controller->process();
-      return $controller->run();
-    }
-
-    if ($secondArg == 'edit' || $secondArg == 'create') {
-      $buttonType = CRM_Utils_Array::value('_qf_Edit_cancel', $_POST);
-      // CRM-5849: we should actually check the button *type*, but we get the *value*, potentially translated;
-      // we should keep both English and translated checks just to make sure we also handle untranslated Cancels
-      if ($buttonType == 'Cancel' or $buttonType == ts('Cancel')) {
-        $cancelURL = CRM_Utils_Request::retrieve('cancelURL',
-          'String',
-          CRM_Core_DAO::$_nullObject,
-          FALSE,
-          NULL,
-          $_POST
-        );
-        if ($cancelURL) {
-          CRM_Utils_System::redirect($cancelURL);
-        }
-      }
-
-      if ($secondArg == 'edit') {
-        $controller = new CRM_Core_Controller_Simple('CRM_Profile_Form_Edit',
-          ts('Create Profile'),
-          CRM_Core_Action::UPDATE,
-          FALSE, FALSE, TRUE
-        );
-        $controller->set('edit', 1);
-        $controller->process();
-        return $controller->run();
-      }
-      else {
-        $wrapper = new CRM_Utils_Wrapper();
-        return $wrapper->run('CRM_Profile_Form_Edit',
-          ts('Create Profile'),
-          array(
-            'mode' => CRM_Core_Action::ADD,
-            'ignoreKey' => TRUE,
-          )
-        );
-      }
-    }
-
-    if ($secondArg == 'view' || empty($secondArg)) {
-      $page = new CRM_Profile_Page_Listings();
-      return $page->run();
-    }
-
-    CRM_Utils_System::permissionDenied();
-    return;
-  }
-
   /**
    * Show the message about CiviCRM versions
    *
@@ -480,14 +376,14 @@ class CRM_Core_Invoke {
     $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 all caches
-    $config->cleanupCaches($sessionReset || CRM_Utils_Request::retrieve('sessionReset', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET'));
-
     // also cleanup module permissions
     $config->cleanupPermissions();