Example #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();
     }
 }
Example #2
0
 /**
  * @param $whereClause
  * @param array $whereParams
  */
 public function pagerAtoZ($whereClause, $whereParams)
 {
     $query = "\nSELECT DISTINCT UPPER(LEFT(title, 1)) as sort_name\nFROM civicrm_contribution_page\nWHERE {$whereClause}\nORDER BY LEFT(title, 1)\n";
     $dao = CRM_Core_DAO::executeQuery($query, $whereParams);
     $aToZBar = CRM_Utils_PagerAToZ::getAToZBar($dao, $this->_sortByCharacter, TRUE);
     $this->assign('aToZ', $aToZBar);
 }
Example #3
0
 function pagerAtoZ($whereClause, $whereParams)
 {
     require_once 'CRM/Utils/PagerAToZ.php';
     $query = "\n SELECT UPPER(LEFT(cp.title, 1)) as sort_name\n     FROM civicrm_pcp cp, civicrm_contribution_page cpp\n   WHERE cp.contribution_page_id = cpp.id {$whereClause}\n ORDER BY LEFT(cp.title, 1);\n        ";
     $dao = CRM_Core_DAO::executeQuery($query, $whereParams);
     $aToZBar = CRM_Utils_PagerAToZ::getAToZBar($dao, $this->_sortByCharacter, true);
     $this->assign('aToZ', $aToZBar);
 }
Example #4
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;
     }
     $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;
         $session =& CRM_Core_Session::singleton();
         if ($session->get('isAdvanced')) {
             $searchChildGroups = false;
         }
         eval('$selector =& new ' . $this->_selectorName . '( $this->_customSearchClass,
                  $this->_formValues,
                  $this->_params,
                  $this->_returnProperties,
                  $this->_action,
                  false,
                  $searchChildGroups,
                  $this->_context,
                  $this->_contextMenu );');
         // 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();
     }
 }
Example #5
0
 function pagerAtoZ($whereClause, $whereParams)
 {
     require_once 'CRM/Utils/PagerAToZ.php';
     $query = "\n   SELECT DISTINCT UPPER(LEFT(title, 1)) as sort_name\n     FROM civicrm_event\n    WHERE {$whereClause}\n ORDER BY LEFT(title, 1)\n";
     $dao = CRM_Core_DAO::executeQuery($query, $whereParams);
     $aToZBar = CRM_Utils_PagerAToZ::getAToZBar($dao, $this->_sortByCharacter, true);
     $this->assign('aToZ', $aToZBar);
 }
Example #6
0
 /**
  * @param $whereClause
  * @param array $whereParams
  *
  * @return string
  */
 public function pagerAtoZ($whereClause, $whereParams)
 {
     $query = "\n        SELECT DISTINCT UPPER(LEFT(groups.title, 1)) as sort_name\n        FROM  civicrm_group groups\n        WHERE {$whereClause}\n        ORDER BY LEFT(groups.title, 1)\n            ";
     $dao = CRM_Core_DAO::executeQuery($query, $whereParams);
     return CRM_Utils_PagerAToZ::getAToZBar($dao, $this->_sortByCharacter, TRUE);
 }
Example #7
0
 function pagerAtoZ()
 {
     require_once 'CRM/Utils/PagerAToZ.php';
     $params = array();
     $whereClause = $this->whereClause($params, false);
     $query = "\n   SELECT DISTINCT UPPER(LEFT(name, 1)) as sort_name\n     FROM civicrm_mailing\nLEFT JOIN civicrm_mailing_job ON (civicrm_mailing_job.mailing_id = civicrm_mailing.id)\nLEFT JOIN civicrm_contact createdContact ON ( civicrm_mailing.created_id = createdContact.id )\nLEFT JOIN civicrm_contact scheduledContact ON ( civicrm_mailing.scheduled_id = scheduledContact.id ) \n      AND {$whereClause}\n ORDER BY LEFT(name, 1)\n";
     $dao = CRM_Core_DAO::executeQuery($query, $params);
     $aToZBar = CRM_Utils_PagerAToZ::getAToZBar($dao, $this->_parent->_sortByCharacter, true);
     $this->_parent->assign('aToZ', $aToZBar);
 }
Example #8
0
 /**
  * @param $whereClause
  * @param $whereParams
  */
 function pagerAtoZ($whereClause, $whereParams)
 {
     $where = '';
     if ($whereClause) {
         if (strpos($whereClause, ' AND') == 0) {
             $whereClause = substr($whereClause, 4);
         }
         $where = 'WHERE ' . $whereClause;
     }
     $query = "\n SELECT UPPER(LEFT(cp.title, 1)) as sort_name\n FROM civicrm_pcp cp\n   " . $where . "\n ORDER BY LEFT(cp.title, 1);\n        ";
     $dao = CRM_Core_DAO::executeQuery($query, $whereParams);
     $aToZBar = CRM_Utils_PagerAToZ::getAToZBar($dao, $this->_sortByCharacter, TRUE);
     $this->assign('aToZ', $aToZBar);
 }
Example #9
0
 /**
  * Common post processing
  *
  * @return void
  * @access public
  */
 function postProcessCommon()
 {
     /*
      * 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();
     // we dont want to store the sortByCharacter in the formValue, it is more like
     // a filter on the result set
     // this filter is reset if we click on the search button
     if ($this->_sortByCharacter && $buttonName != $this->_searchButtonName) {
         if ($this->_sortByCharacter == 1) {
             $this->_formValues['sortByCharacter'] = null;
         } else {
             $this->_formValues['sortByCharacter'] = $this->_sortByCharacter;
         }
     }
     $this->set('type', $this->_action);
     $this->set('formValues', $this->_formValues);
     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 {
         // do export stuff
         if ($buttonName == $this->_exportButtonName) {
             //$output = CRM_Core_Selector_Controller::EXPORT;
             return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/export/contact'));
         } else {
             $output = CRM_CORE_SELECTOR_CONTROLLER_SESSION;
         }
         // create the selector, controller and run - store results in session
         $selector =& new CRM_Contact_Selector($this->_formValues, $this->_action);
         // 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
         $query =& $selector->getQuery();
         $aToZBar = CRM_Utils_PagerAToZ::getAToZBar($query, $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();
     }
 }
Example #10
0
 /**
  * create the links 
  *
  * @param array  $query          The form values for search
  * @param string $sortByCharacter The character that we are potentially sorting on
  *
  * @return array with links
  * @access private
  * @static
  */
 function createLinks(&$query, $sortByCharacter)
 {
     $AToZBar = CRM_Utils_PagerAToZ::getStaticCharacters();
     $dynamicAlphabets = CRM_Utils_PagerAToZ::getDynamicCharacters($query);
     $AToZBar = array_merge($AToZBar, $dynamicAlphabets);
     $AToZBar = array_unique($AToZBar);
     //get the current path
     $path = CRM_Utils_System::currentPath();
     $aToZBar = array();
     foreach ($AToZBar as $key => $link) {
         if (!$link) {
             continue;
         }
         $element = array();
         if (in_array($link, $dynamicAlphabets)) {
             $klass = '';
             if ($link == $sortByCharacter) {
                 $element['class'] = "active";
                 $klass = 'class="active"';
             }
             $element['item'] = sprintf('<a href="%s" %s>%s</a>', CRM_Utils_System::url($path, "q={$path}&force=1&sortByCharacter={$link}", true, null, false), $klass, $link);
         } else {
             $element['item'] = $link;
         }
         $aToZBar[] = $element;
     }
     $url = sprintf('<a href="%s">%s</a>', CRM_Utils_System::url($path, "q={$path}&force=1&sortByCharacter=1"), 'All');
     $aToZBar[] = array('item' => $url);
     return $aToZBar;
 }