/** * processing needed for buildForm and later * * @return void * @access public */ function preProcess() { /** * set the varios class variables */ $this->_group =& CRM_Core_PseudoConstant::group(); $this->_tag =& CRM_Core_PseudoConstant::tag(); $this->_done = false; /** * set the button names */ $this->_searchButtonName = $this->getButtonName('refresh'); $this->_exportButtonName = $this->getButtonName('refresh', 'export'); $this->_printButtonName = $this->getButtonName('next', 'print'); $this->_actionButtonName = $this->getButtonName('next', 'action'); /* * we allow the controller to set force/reset externally, useful when we are being * driven by the wizard framework */ $nullObject = null; $this->_reset = CRM_Utils_Request::retrieve('reset', $nullObject); $this->_force = CRM_Utils_Request::retrieve('force', $this, false); // we only force stuff once :) $this->set('force', false); $this->_groupID = CRM_Utils_Request::retrieve('gid', $this); $this->_amtgID = CRM_Utils_Request::retrieve('amtgID', $this); $this->_ssID = CRM_Utils_Request::retrieve('ssID', $this); $this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter', $this); // get user submitted values // get it from controller only if form has been submitted, else preProcess has set this if (!empty($_POST)) { $this->_formValues = $this->controller->exportValues($this->_name); $this->normalizeFormValues(); // CRM_Core_Error::debug( 'fv', $this->_formValues ); // also reset the sort by character $this->_sortByCharacter = null; $this->set('sortByCharacter', null); } else { $this->_formValues = $this->get('formValues'); } // we only retrieve the saved search values if out current values are null if (empty($this->_formValues) && isset($this->_ssID)) { $this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID); } /* * assign context to drive the template display, make sure context is valid */ $this->_context = CRM_Utils_Request::retrieve('context', $this, false, 'search'); if (!CRM_Utils_Array::value($this->_context, CRM_Contact_Form_Search::validContext())) { $this->_context = 'search'; $this->set('context', $this->_context); } $this->assign('context', $this->_context); $selector =& new CRM_Contact_Selector($this->_formValues, $this->_action); $controller =& new CRM_Contact_Selector_Controller($selector, $this->get(CRM_UTILS_PAGER_PAGE_ID), $this->get(CRM_UTILS_SORT_SORT_ID), CRM_CORE_ACTION_VIEW, $this, CRM_CORE_SELECTOR_CONTROLLER_TRANSFER); $controller->setEmbedded(true); if ($this->_force) { $this->postProcess(); /* * Note that we repeat this, since the search creates and stores * values that potentially change the controller behavior. i.e. things * like totalCount etc */ $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, CRM_CORE_SELECTOR_CONTROLLER_TRANSFER); $controller->setEmbedded(true); } $controller->moveFromSessionToTemplate(); }