Exemplo n.º 1
0
 /**
  * Common post processing.
  */
 public function postProcess()
 {
     /*
      * sometime we do a postProcess early on, so we dont need to repeat it
      * this will most likely introduce some more bugs :(
      */
     if ($this->_done) {
         return;
     }
     $this->_done = TRUE;
     //for prev/next pagination
     $crmPID = CRM_Utils_Request::retrieve('crmPID', 'Integer', CRM_Core_DAO::$_nullObject);
     if (array_key_exists($this->_searchButtonName, $_POST) || $this->_force && !$crmPID) {
         //reset the cache table for new search
         $cacheKey = "civicrm search {$this->controller->_key}";
         CRM_Core_BAO_PrevNextCache::deleteItem(NULL, $cacheKey);
     }
     //get the button name
     $buttonName = $this->controller->getButtonName();
     if (isset($this->_ufGroupID) && empty($this->_formValues['uf_group_id'])) {
         $this->_formValues['uf_group_id'] = $this->_ufGroupID;
     }
     if (isset($this->_componentMode) && empty($this->_formValues['component_mode'])) {
         $this->_formValues['component_mode'] = $this->_componentMode;
     }
     if (isset($this->_operator) && empty($this->_formValues['operator'])) {
         $this->_formValues['operator'] = $this->_operator;
     }
     if (empty($this->_formValues['qfKey'])) {
         $this->_formValues['qfKey'] = $this->controller->_key;
     }
     if (!CRM_Core_Permission::check('access deleted contacts')) {
         unset($this->_formValues['deleted_contacts']);
     }
     $this->set('type', $this->_action);
     $this->set('formValues', $this->_formValues);
     $this->set('queryParams', $this->_params);
     $this->set('returnProperties', $this->_returnProperties);
     if ($buttonName == $this->_actionButtonName) {
         // check actionName and if next, then do not repeat a search, since we are going to the next page
         // hack, make sure we reset the task values
         $stateMachine = $this->controller->getStateMachine();
         $formName = $stateMachine->getTaskFormName();
         $this->controller->resetPage($formName);
         return;
     } else {
         $output = CRM_Core_Selector_Controller::SESSION;
         // create the selector, controller and run - store results in session
         $searchChildGroups = TRUE;
         if ($this->get('isAdvanced')) {
             $searchChildGroups = FALSE;
         }
         $setDynamic = FALSE;
         if (strpos(self::$_selectorName, 'CRM_Contact_Selector') !== FALSE) {
             $selector = new self::$_selectorName($this->_customSearchClass, $this->_formValues, $this->_params, $this->_returnProperties, $this->_action, FALSE, $searchChildGroups, $this->_context, $this->_contextMenu);
             $setDynamic = TRUE;
         } else {
             $selector = new self::$_selectorName($this->_params, $this->_action, NULL, FALSE, NULL, "search", "advanced");
         }
         $selector->setKey($this->controller->_key);
         // added the sorting  character to the form array
         $config = CRM_Core_Config::singleton();
         // do this only for contact search
         if ($setDynamic && $config->includeAlphabeticalPager) {
             // Don't recompute if we are just paging/sorting
             if ($this->_reset || empty($_GET['crmPID']) && empty($_GET['crmSID']) && !$this->_sortByCharacter) {
                 $aToZBar = CRM_Utils_PagerAToZ::getAToZBar($selector, $this->_sortByCharacter);
                 $this->set('AToZBar', $aToZBar);
             }
         }
         $sortID = NULL;
         if ($this->get(CRM_Utils_Sort::SORT_ID)) {
             $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION));
         }
         $controller = new CRM_Contact_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, $output);
         $controller->setEmbedded(TRUE);
         $controller->setDynamicAction($setDynamic);
         $controller->run();
     }
 }
Exemplo n.º 2
0
 /**
  * Common post processing
  *
  * @return void
  * @access public
  */
 function postProcess()
 {
     /*
      * sometime we do a postProcess early on, so we dont need to repeat it
      * this will most likely introduce some more bugs :(
      */
     if ($this->_done) {
         return;
     }
     $this->_done = true;
     //get the button name
     $buttonName = $this->controller->getButtonName();
     if (isset($this->_ufGroupID) && !CRM_Utils_Array::value('uf_group_id', $this->_formValues)) {
         $this->_formValues['uf_group_id'] = $this->_ufGroupID;
     }
     if (isset($this->_componentMode) && !CRM_Utils_Array::value('component_mode', $this->_formValues)) {
         $this->_formValues['component_mode'] = $this->_componentMode;
     }
     if (!CRM_Utils_Array::value('qfKey', $this->_formValues)) {
         $this->_formValues['qfKey'] = $this->controller->_key;
     }
     if (!CRM_Core_Permission::check('access deleted contacts')) {
         unset($this->_formValues['deleted_contacts']);
     }
     $this->set('type', $this->_action);
     $this->set('formValues', $this->_formValues);
     $this->set('queryParams', $this->_params);
     $this->set('returnProperties', $this->_returnProperties);
     if ($buttonName == $this->_actionButtonName || $buttonName == $this->_printButtonName) {
         // check actionName and if next, then do not repeat a search, since we are going to the next page
         // hack, make sure we reset the task values
         $stateMachine =& $this->controller->getStateMachine();
         $formName = $stateMachine->getTaskFormName();
         $this->controller->resetPage($formName);
         return;
     } else {
         $output = CRM_Core_Selector_Controller::SESSION;
         // create the selector, controller and run - store results in session
         $searchChildGroups = true;
         if ($this->get('isAdvanced')) {
             $searchChildGroups = false;
         }
         if (strpos($this->_selectorName, 'CRM_Contact_Selector') !== false) {
             eval('$selector = new ' . $this->_selectorName . '( $this->_customSearchClass,
                      $this->_formValues,
                      $this->_params,
                      $this->_returnProperties,
                      $this->_action,
                      false,
                      $searchChildGroups,
                      $this->_context,
                      $this->_contextMenu );');
         } else {
             eval('$selector = new ' . $this->_selectorName . '( $this->_params,
                      $this->_action,
                      null, false, null,
                      "search", "advanced" );');
         }
         $selector->setKey($this->controller->_key);
         // added the sorting  character to the form array
         // lets recompute the aToZ bar without the sortByCharacter
         // we need this in most cases except when just pager or sort values change, which
         // we'll ignore for now
         $config = CRM_Core_Config::singleton();
         if ($config->includeAlphabeticalPager) {
             if ($this->_reset || !$this->_sortByCharacter) {
                 $aToZBar = CRM_Utils_PagerAToZ::getAToZBar($selector, $this->_sortByCharacter);
                 $this->set('AToZBar', $aToZBar);
             }
         }
         $sortID = null;
         if ($this->get(CRM_Utils_Sort::SORT_ID)) {
             $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION));
         }
         $controller = new CRM_Contact_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, $output);
         $controller->setEmbedded(true);
         $controller->run();
     }
 }