Beispiel #1
0
 /**
  * All CRM single or multi page pages should inherit from this class.
  *
  * @param string $title
  *   Descriptive title of the controller.
  * @param bool $modal
  *   Whether controller is modal.
  * @param mixed $mode
  * @param string $scope
  *   Name of session if we want unique scope, used only by Controller_Simple.
  * @param bool $addSequence
  *   Should we add a unique sequence number to the end of the key.
  * @param bool $ignoreKey
  *   Should we not set a qfKey for this controller (for standalone forms).
  */
 public function __construct($title = NULL, $modal = TRUE, $mode = NULL, $scope = NULL, $addSequence = FALSE, $ignoreKey = FALSE)
 {
     // this has to true for multiple tab session fix
     $addSequence = TRUE;
     // let the constructor initialize this, should happen only once
     if (!isset(self::$_template)) {
         self::$_template = CRM_Core_Smarty::singleton();
         self::$_session = CRM_Core_Session::singleton();
     }
     // lets try to get it from the session and/or the request vars
     // we do this early on in case there is a fatal error in retrieving the
     // key and/or session
     $this->_entryURL = CRM_Utils_Request::retrieve('entryURL', 'String', $this);
     // add a unique validable key to the name
     $name = CRM_Utils_System::getClassName($this);
     if ($name == 'CRM_Core_Controller_Simple' && !empty($scope)) {
         // use form name if we have, since its a lot better and
         // definitely different for different forms
         $name = $scope;
     }
     $name = $name . '_' . $this->key($name, $addSequence, $ignoreKey);
     $this->_title = $title;
     if ($scope) {
         $this->_scope = $scope;
     } else {
         $this->_scope = CRM_Utils_System::getClassName($this);
     }
     $this->_scope = $this->_scope . '_' . $this->_key;
     // only use the civicrm cache if we have a valid key
     // else we clash with other users CRM-7059
     if (!empty($this->_key)) {
         CRM_Core_Session::registerAndRetrieveSessionObjects(array("_{$name}_container", array('CiviCRM', $this->_scope)));
     }
     parent::__construct($name, $modal);
     $snippet = CRM_Utils_Array::value('snippet', $_REQUEST);
     if ($snippet) {
         if ($snippet == 3) {
             $this->_print = CRM_Core_Smarty::PRINT_PDF;
         } elseif ($snippet == 4) {
             // this is used to embed fragments of a form
             $this->_print = CRM_Core_Smarty::PRINT_NOFORM;
             self::$_template->assign('suppressForm', TRUE);
             $this->_generateQFKey = FALSE;
         } elseif ($snippet == 5) {
             // mode deprecated in favor of json
             // still used by dashlets, probably nothing else
             $this->_print = CRM_Core_Smarty::PRINT_NOFORM;
         } elseif (in_array($snippet, array(CRM_Core_Smarty::PRINT_JSON, 6))) {
             $this->_print = CRM_Core_Smarty::PRINT_JSON;
             $this->_QFResponseType = 'json';
         } else {
             $this->_print = CRM_Core_Smarty::PRINT_SNIPPET;
         }
     }
     // if the request has a reset value, initialize the controller session
     if (!empty($_GET['reset'])) {
         $this->reset();
         // in this case we'll also cache the url as a hidden form variable, this allows us to
         // redirect in case the session has disappeared on us
         $this->_entryURL = CRM_Utils_System::makeURL(NULL, TRUE, FALSE, NULL, TRUE);
         $this->set('entryURL', $this->_entryURL);
     }
     // set the key in the session
     // do this at the end so we have initialized the object
     // and created the scope etc
     $this->set('qfKey', $this->_key);
     // also retrieve and store destination in session
     $this->_destination = CRM_Utils_Request::retrieve('civicrmDestination', 'String', $this, FALSE, NULL, $_REQUEST);
 }