Exemplo n.º 1
0
 /**
  * All CRM single or multi page pages should inherit from this class.
  *
  * @param string  title        descriptive title of the controller
  * @param boolean whether      controller is modal
  * @param string  scope        name of session if we want unique scope, used only by Controller_Simple
  * @param boolean addSequence  should we add a unique sequence number to the end of the key
  * @param boolean ignoreKey    should we not set a qfKey for this controller (for standalone forms)
  *
  * @access public
  *
  * @return void
  *
  */
 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)));
     }
     $this->HTML_QuickForm_Controller($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) {
             // this is used for popups and inlined ajax forms
             // also used for the various tabs via TabHeader
             $this->_print = CRM_Core_Smarty::PRINT_NOFORM;
         } elseif ($snippet == 6) {
             $this->_print = CRM_Core_Smarty::PRINT_NOFORM;
             $this->_QFResponseType = 'json';
         } else {
             $this->_print = CRM_Core_Smarty::PRINT_SNIPPET;
         }
     }
     // if the request has a reset value, initialize the controller session
     if (CRM_Utils_Array::value('reset', $_GET)) {
         $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);
 }
Exemplo n.º 2
0
 /**
  * All CRM single or multi page pages should inherit from this class. 
  *
  * @param string  title        descriptive title of the controller
  * @param boolean whether      controller is modal
  * @param string  scope        name of session if we want unique scope, used only by Controller_Simple
  * @param boolean addSequence  should we add a unique sequence number to the end of the key
  * @param boolean ignoreKey    should we not set a qfKey for this controller (for standalone forms)
  *
  * @access public
  *   
  * @return void
  *
  */
 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;
     // add a unique validable key to the name
     $name = CRM_Utils_System::getClassName($this);
     $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)) {
         require_once 'CRM/Core/BAO/Cache.php';
         CRM_Core_Session::registerAndRetrieveSessionObjects(array("_{$name}_container", array('CiviCRM', $this->_scope)));
     }
     $this->HTML_QuickForm_Controller($name, $modal);
     // 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();
     }
     $snippet = CRM_Utils_Array::value('snippet', $_REQUEST);
     //$snippet = CRM_Utils_Request::retrieve( 'snippet', 'Integer', $this, false, null, $_REQUEST );
     if ($snippet) {
         if ($snippet == 3) {
             $this->_print = CRM_Core_Smarty::PRINT_PDF;
         } else {
             if ($snippet == 4) {
                 $this->_print = CRM_Core_Smarty::PRINT_NOFORM;
                 self::$_template->assign('suppressForm', true);
             } else {
                 if ($snippet == 5) {
                     $this->_print = CRM_Core_Smarty::PRINT_NOFORM;
                 } else {
                     $this->_print = CRM_Core_Smarty::PRINT_SNIPPET;
                 }
             }
         }
     }
     // if the request has a reset value, initialize the controller session
     if (CRM_Utils_Array::value('reset', $_GET)) {
         $this->reset();
     }
     // 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);
     require_once 'CRM/Utils/Request.php';
     // also retrieve and store destination in session
     $this->_destination = CRM_Utils_Request::retrieve('destination', 'String', $this, false, null, $_REQUEST);
 }