3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2013
41 * Base Search / View form for *all* listing of multiple
44 class CRM_Contact_Form_Search
extends CRM_Core_Form
{
47 * list of valid contexts
52 static $_validContext = NULL;
55 * list of values used when we want to display other objects
60 static $_modeValues = NULL;
63 * The context that we are working on
76 protected $_contextMenu;
79 * the groupId retrieved from the GET vars
87 * the Group ID belonging to Add Member to group ID
88 * retrieved from the GET vars
96 * the saved search ID retrieved from the GET vars
104 * Are we forced to run a search
112 * name of search button
117 protected $_searchButtonName;
120 * name of action button
125 protected $_actionButtonName;
134 public $_groupElement;
135 public $_groupIterator;
147 * form values that we will be using
155 * The params used for search
163 * The return properties used for search
168 protected $_returnProperties;
171 * The sort by character
176 protected $_sortByCharacter;
179 * The profile group id used for display
184 protected $_ufGroupID;
187 * csv - common search values
194 static $csv = array('contact_type', 'group', 'tag');
197 * @var string how to display the results. Should we display as
198 * contributons, members, cases etc
200 protected $_componentMode;
203 * @var string what operator should we use, AND or OR
205 protected $_operator;
207 protected $_modeValue;
210 * have we already done this search
218 * name of the selector to use
220 static $_selectorName = 'CRM_Contact_Selector';
221 protected $_customSearchID = NULL;
222 protected $_customSearchClass = NULL;
224 protected $_openedPanes = array();
227 * define the set of valid contexts that the search form operates on
229 * @return array the valid context set and the titles
233 static function &validContext() {
234 if (!(self
::$_validContext)) {
235 self
::$_validContext = array(
236 'smog' => 'Show members of group',
237 'amtg' => 'Add members to group',
238 'basic' => 'Basic Search',
239 'search' => 'Search',
240 'builder' => 'Search Builder',
241 'advanced' => 'Advanced Search',
242 'custom' => 'Custom Search',
245 return self
::$_validContext;
248 static function isSearchContext($context) {
249 $searchContext = CRM_Utils_Array
::value($context, self
::validContext());
250 return $searchContext ?
TRUE : FALSE;
253 static function setModeValues() {
254 if (!self
::$_modeValues) {
255 self
::$_modeValues = array(
257 'selectorName' => self
::$_selectorName,
258 'selectorLabel' => ts('Contacts'),
259 'taskFile' => 'CRM/Contact/Form/Search/ResultTasks.tpl',
260 'taskContext' => NULL,
261 'resultFile' => 'CRM/Contact/Form/Selector.tpl',
262 'resultContext' => NULL,
263 'taskClassName' => 'CRM_Contact_Task',
266 'selectorName' => 'CRM_Contribute_Selector_Search',
267 'selectorLabel' => ts('Contributions'),
268 'taskFile' => 'CRM/common/searchResultTasks.tpl',
269 'taskContext' => 'Contribution',
270 'resultFile' => 'CRM/Contribute/Form/Selector.tpl',
271 'resultContext' => 'Search',
272 'taskClassName' => 'CRM_Contribute_Task',
275 'selectorName' => 'CRM_Event_Selector_Search',
276 'selectorLabel' => ts('Event Participants'),
277 'taskFile' => 'CRM/common/searchResultTasks.tpl',
278 'taskContext' => NULL,
279 'resultFile' => 'CRM/Event/Form/Selector.tpl',
280 'resultContext' => 'Search',
281 'taskClassName' => 'CRM_Event_Task',
284 'selectorName' => 'CRM_Activity_Selector_Search',
285 'selectorLabel' => ts('Activities'),
286 'taskFile' => 'CRM/common/searchResultTasks.tpl',
287 'taskContext' => NULL,
288 'resultFile' => 'CRM/Activity/Form/Selector.tpl',
289 'resultContext' => 'Search',
290 'taskClassName' => 'CRM_Activity_Task',
293 'selectorName' => 'CRM_Member_Selector_Search',
294 'selectorLabel' => ts('Memberships'),
295 'taskFile' => "CRM/common/searchResultTasks.tpl",
296 'taskContext' => NULL,
297 'resultFile' => 'CRM/Member/Form/Selector.tpl',
298 'resultContext' => 'Search',
299 'taskClassName' => 'CRM_Member_Task',
302 'selectorName' => 'CRM_Case_Selector_Search',
303 'selectorLabel' => ts('Cases'),
304 'taskFile' => "CRM/common/searchResultTasks.tpl",
305 'taskContext' => NULL,
306 'resultFile' => 'CRM/Case/Form/Selector.tpl',
307 'resultContext' => 'Search',
308 'taskClassName' => 'CRM_Case_Task',
311 'selectorName' => self
::$_selectorName,
312 'selectorLabel' => ts('Related Contacts'),
313 'taskFile' => 'CRM/Contact/Form/Search/ResultTasks.tpl',
314 'taskContext' => NULL,
315 'resultFile' => 'CRM/Contact/Form/Selector.tpl',
316 'resultContext' => NULL,
317 'taskClassName' => 'CRM_Contact_Task',
320 'selectorName' => 'CRM_Mailing_Selector_Search',
321 'selectorLabel' => ts('Mailings'),
322 'taskFile' => "CRM/common/searchResultTasks.tpl",
323 'taskContext' => NULL,
324 'resultFile' => 'CRM/Mailing/Form/Selector.tpl',
325 'resultContext' => 'Search',
326 'taskClassName' => 'CRM_Mailing_Task',
332 static function getModeValue($mode = 1) {
333 self
::setModeValues();
335 if (!array_key_exists($mode, self
::$_modeValues)) {
339 return self
::$_modeValues[$mode];
342 static function getModeSelect() {
343 self
::setModeValues();
346 foreach (self
::$_modeValues as $id => & $value) {
347 $select[$id] = $value['selectorLabel'];
350 // unset contributions or participants if user does not have
351 // permission on them
352 if (!CRM_Core_Permission
::access('CiviContribute')) {
356 if (!CRM_Core_Permission
::access('CiviEvent')) {
360 if (!CRM_Core_Permission
::check('view all activities')) {
367 * Build the common elements between the search/advanced form
373 function buildQuickForm() {
374 CRM_Core_Resources
::singleton()
375 ->addScriptFile('civicrm', 'js/crm.livePage.js')
376 // jsTree is needed for tags popup
377 ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)
378 ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
379 $permission = CRM_Core_Permission
::getPermission();
380 // some tasks.. what do we want to do with the selected contacts ?
381 $tasks = array('' => ts('- actions -'));
382 if ($this->_componentMode
== 1 ||
$this->_componentMode
== 7) {
383 $tasks +
= CRM_Contact_Task
::permissionedTaskTitles($permission,
384 CRM_Utils_Array
::value('deleted_contacts', $this->_formValues
)
388 $className = $this->_modeValue
['taskClassName'];
389 $tasks +
= $className::permissionedTaskTitles($permission, false);
392 if (isset($this->_ssID
)) {
393 if ($permission == CRM_Core_Permission
::EDIT
) {
394 $tasks = $tasks + CRM_Contact_Task
::optionalTaskTitle();
398 CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID
, 'search_custom_id');
400 $savedSearchValues = array(
401 'id' => $this->_ssID
,
402 'name' => CRM_Contact_BAO_SavedSearch
::getName($this->_ssID
, 'title'),
403 'search_custom_id' => $search_custom_id,
405 $this->assign_by_ref('savedSearch', $savedSearchValues);
406 $this->assign('ssID', $this->_ssID
);
409 if ($this->_context
=== 'smog') {
410 // CRM-11788, we might want to do this for all of search where force=1
411 $formQFKey = CRM_Utils_Array
::value('qfKey', $this->_formValues
);
412 $getQFKey = CRM_Utils_Array
::value('qfKey', $_GET);
413 $postQFKey = CRM_Utils_Array
::value('qfKey', $_POST);
414 if ($formQFKey && empty($getQFKey) && empty($postQFKey)) {
415 $url = CRM_Utils_System
::makeURL('qfKey') . $formQFKey;
416 CRM_Utils_System
::redirect($url);
419 if (!empty($this->_groupID
)) {
420 $permissionForGroup = FALSE;
422 // check if user has permission to edit members of this group
423 $permission = CRM_Contact_BAO_Group
::checkPermission($this->_groupID
);
424 if ($permission && in_array(CRM_Core_Permission
::EDIT
, $permission)) {
425 $permissionForGroup = TRUE;
428 // check if _groupID exists, it might not if
429 // we are displaying a hidden group
430 if (!isset($this->_group
[$this->_groupID
])) {
431 $permissionForGroup = FALSE;
432 $this->_group
[$this->_groupID
] =
433 CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'title');
436 $this->assign('permissionedForGroup', $permissionForGroup);
438 // set the group title
439 $groupValues = array('id' => $this->_groupID
, 'title' => $this->_group
[$this->_groupID
]);
440 $this->assign_by_ref('group', $groupValues);
442 // also set ssID if this is a saved search
443 $ssID = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'saved_search_id');
444 $this->assign('ssID', $ssID);
446 //get the saved search mapping id
448 $this->_ssID
= $ssID;
449 $ssMappingId = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $ssID, 'mapping_id');
450 $this->assign('ssMappingID', $ssMappingId);
453 // Set dynamic page title for 'Show Members of Group'
454 CRM_Utils_System
::setTitle(ts('Contacts in Group: %1', array(1 => $this->_group
[$this->_groupID
])));
457 $group_contact_status = array();
458 foreach (CRM_Core_SelectValues
::groupContactStatus() as $k => $v) {
460 $group_contact_status[] = $this->createElement('checkbox', $k, NULL, $v);
463 $this->addGroup($group_contact_status,
464 'group_contact_status', ts('Group Status')
467 $this->assign('permissionedForGroup', FALSE);
470 // add the go button for the action form, note it is of type 'next' rather than of type 'submit'
471 if ($this->_context
=== 'amtg') {
472 // check if _groupID exists, it might not if
473 // we are displaying a hidden group
474 if (!isset($this->_group
[$this->_amtgID
])) {
475 $this->assign('permissionedForGroup', FALSE);
476 $this->_group
[$this->_amtgID
] =
477 CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_amtgID
, 'title');
480 // Set dynamic page title for 'Add Members Group'
481 CRM_Utils_System
::setTitle(ts('Add to Group: %1', array(1 => $this->_group
[$this->_amtgID
])));
482 // also set the group title and freeze the action task with Add Members to Group
483 $groupValues = array('id' => $this->_amtgID
, 'title' => $this->_group
[$this->_amtgID
]);
484 $this->assign_by_ref('group', $groupValues);
485 $this->add('submit', $this->_actionButtonName
, ts('Add Contacts to %1', array(1 => $this->_group
[$this->_amtgID
])),
487 'class' => 'form-submit',
488 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 1);",
491 $this->add('hidden', 'task', CRM_Contact_Task
::GROUP_CONTACTS
);
494 $this->add('select', 'task', ts('Actions:') . ' ', $tasks);
495 $this->add('submit', $this->_actionButtonName
, ts('Go'),
497 'class' => 'form-submit',
499 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 0, 1);",
504 // need to perform tasks on all or selected items ? using radio_ts(task selection) for it
505 $selectedRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array(
506 'checked' => 'checked',
507 'onclick' => 'toggleTaskAction( true );',
509 $this->assign('ts_sel_id', $selectedRowsRadio->_attributes
['id']);
512 if ($qfKeyParam = CRM_Utils_Array
::value('qfKey', $this->_formValues
)) {
513 $qfKeyParam = "civicrm search {$qfKeyParam}";
514 $selectedContactIdsArr = CRM_Core_BAO_PrevNextCache
::getSelection($qfKeyParam);
515 $selectedContactIds = array_keys($selectedContactIdsArr[$qfKeyParam]);
518 $this->assign_by_ref('selectedContactIds', $selectedContactIds);
520 $allRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all', array('onclick' => $this->getName() . ".toggleSelect.checked = false; toggleCheckboxVals('mark_x_', this);toggleTaskAction( true );toggleContactSelection( 'resetSel', '{$qfKeyParam}', 'reset' );"));
521 $this->assign('ts_all_id', $allRowsRadio->_attributes
['id']);
524 * add form checkboxes for each row. This is needed out here to conform to QF protocol
525 * of all elements being declared in builQuickForm
528 $rows = $this->get('rows');
530 if (is_array($rows)) {
531 $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('onclick' => "toggleTaskAction( true ); toggleCheckboxVals('mark_x_',this);return toggleContactSelection( 'toggleSelect', '" . $qfKeyParam . "' , 'multiple' );"));
533 $unselectedContactIds = array();
534 foreach ($rows as $row) {
535 $this->addElement('checkbox', $row['checkbox'],
537 array('onclick' => "toggleContactSelection( '" . $row['checkbox'] . "', '" . $qfKeyParam . "' , 'single' );toggleTaskAction( true ); return checkSelectedBox('" . $row['checkbox'] . "');")
540 if (!in_array($row['contact_id'], $selectedContactIds)) {
541 $unselectedContactIds[] = $row['contact_id'];
544 $this->assign_by_ref('unselectedContactIds', $unselectedContactIds);
548 $this->addButtons(array(
551 'name' => ts('Search'),
557 $this->setDefaultAction('refresh');
561 * processing needed for buildForm and later
566 function preProcess() {
567 // set the various class variables
569 $this->_group
= CRM_Core_PseudoConstant
::group();
571 $this->_groupIterator
= CRM_Core_PseudoConstant
::groupIterator();
572 $this->_tag
= CRM_Core_BAO_Tag
::getTags();
573 $this->_done
= FALSE;
576 * we allow the controller to set force/reset externally, useful when we are being
577 * driven by the wizard framework
580 $this->_reset
= CRM_Utils_Request
::retrieve('reset', 'Boolean',
581 CRM_Core_DAO
::$_nullObject
584 $this->_force
= CRM_Utils_Request
::retrieve('force', 'Boolean', CRM_Core_DAO
::$_nullObject);
585 $this->_groupID
= CRM_Utils_Request
::retrieve('gid', 'Positive', $this);
586 $this->_amtgID
= CRM_Utils_Request
::retrieve('amtgID', 'Positive', $this);
587 $this->_ssID
= CRM_Utils_Request
::retrieve('ssID', 'Positive', $this);
588 $this->_sortByCharacter
= CRM_Utils_Request
::retrieve('sortByCharacter', 'String', $this);
589 $this->_ufGroupID
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
590 $this->_componentMode
= CRM_Utils_Request
::retrieve('component_mode', 'Positive', $this, FALSE, 1, $_REQUEST);
591 $this->_operator
= CRM_Utils_Request
::retrieve('operator', 'String', $this, FALSE, 1, $_REQUEST, 'AND');
594 * set the button names
596 $this->_searchButtonName
= $this->getButtonName('refresh');
597 $this->_actionButtonName
= $this->getButtonName('next', 'action');
599 $this->assign('actionButtonName', $this->_actionButtonName
);
601 // reset from session, CRM-3526
602 $session = CRM_Core_Session
::singleton();
603 if ($this->_force
&& $session->get('selectedSearchContactIds')) {
604 $session->resetScope('selectedSearchContactIds');
607 // if we dont get this from the url, use default if one exsts
608 $config = CRM_Core_Config
::singleton();
609 if ($this->_ufGroupID
== NULL &&
610 $config->defaultSearchProfileID
!= NULL
612 $this->_ufGroupID
= $config->defaultSearchProfileID
;
615 // assign context to drive the template display, make sure context is valid
616 $this->_context
= CRM_Utils_Request
::retrieve('context', 'String', $this, FALSE, 'search');
617 if (!CRM_Utils_Array
::value($this->_context
, self
::validContext())) {
618 $this->_context
= 'search';
620 $this->set('context', $this->_context
);
621 $this->assign('context', $this->_context
);
623 $this->_modeValue
= self
::getModeValue($this->_componentMode
);
624 $this->assign($this->_modeValue
);
626 $this->set('selectorName', self
::$_selectorName);
628 // get user submitted values
629 // get it from controller only if form has been submitted, else preProcess has set this
630 // $this->controller->isModal( ) returns true if page is
631 // valid, i.e all the validations are true
633 if (!empty($_POST) && !$this->controller
->isModal()) {
634 $this->_formValues
= $this->controller
->exportValues($this->_name
);
636 $this->normalizeFormValues();
637 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
638 $this->_returnProperties
= &$this->returnProperties();
640 // also get the uf group id directly from the post value
641 $this->_ufGroupID
= CRM_Utils_Array
::value('uf_group_id', $_POST, $this->_ufGroupID
);
642 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
643 $this->set('id', $this->_ufGroupID
);
645 // also get the object mode directly from the post value
646 $this->_componentMode
= CRM_Utils_Array
::value('component_mode', $_POST, $this->_componentMode
);
648 // also get the operator from the post value if set
649 $this->_operator
= CRM_Utils_Array
::value('operator', $_POST, $this->_operator
);
650 $this->_formValues
['operator'] = $this->_operator
;
651 $this->set('operator', $this->_operator
);
654 $this->_formValues
= $this->get('formValues');
655 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
656 $this->_returnProperties
= &$this->returnProperties();
657 if (!empty($this->_ufGroupID
)) {
658 $this->set('id', $this->_ufGroupID
);
662 if (empty($this->_formValues
)) {
663 //check if group is a smart group (fix for CRM-1255)
664 if ($this->_groupID
) {
665 if ($ssId = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'saved_search_id')) {
666 $this->_ssID
= $ssId;
671 if (isset($this->_ssID
) && $this->_context
!= 'smog') {
672 // we only retrieve the saved search values if out current values are null
673 $this->_formValues
= CRM_Contact_BAO_SavedSearch
::getFormValues($this->_ssID
);
676 if (CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID
, 'mapping_id')) {
677 $this->_params
= CRM_Contact_BAO_SavedSearch
::getSearchParams($this->_ssID
);
680 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
682 $this->_returnProperties
= &$this->returnProperties();
685 if (isset($this->_ufGroupID
)) {
686 // also set the uf group id if not already present
687 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
689 if (isset($this->_componentMode
)) {
690 $this->_formValues
['component_mode'] = $this->_componentMode
;
692 if (isset($this->_operator
)) {
693 $this->_formValues
['operator'] = $this->_operator
;
696 // FIXME: we should generalise in a way that components could inject url-filters
697 // just like they build their own form elements
699 'mailing_id', 'mailing_delivery_status', 'mailing_open_status',
700 'mailing_click_status', 'mailing_reply_status', 'mailing_optout',
701 'mailing_forward', 'mailing_unsubscribe', 'mailing_date_low',
703 ) as $mailingFilter) {
705 if ($mailingFilter == 'mailing_id' &&
706 $filterVal = CRM_Utils_Request
::retrieve('mailing_id', 'Positive', $this)
708 $this->_formValues
[$mailingFilter] = array($filterVal);
710 elseif ($filterVal = CRM_Utils_Request
::retrieve($mailingFilter, $type, $this)) {
711 $this->_formValues
[$mailingFilter] = $filterVal;
714 $this->_openedPanes
['Mailings'] = 1;
715 $this->_formValues
['hidden_CiviMail'] = 1;
721 CRM_Utils_Array
::value('uf_group_id', $this->_formValues
)
723 $operator = CRM_Utils_Array
::value('operator', $this->_formValues
, 'AND');
724 $this->set('queryOperator', $operator);
725 if ($operator == 'OR') {
726 $this->assign('operator', ts('OR'));
729 $this->assign('operator', ts('AND'));
732 // show the context menu only when we’re not searching for deleted contacts; CRM-5673
733 if (empty($this->_formValues
['deleted_contacts'])) {
734 $menuItems = CRM_Contact_BAO_Contact
::contextMenu();
735 $primaryActions = CRM_Utils_Array
::value('primaryActions', $menuItems, array());
736 $this->_contextMenu
= CRM_Utils_Array
::value('moreActions', $menuItems, array());
737 $this->assign('contextMenu', $primaryActions +
$this->_contextMenu
);
740 if (!isset($this->_componentMode
)) {
741 $this->_componentMode
= CRM_Contact_BAO_Query
::MODE_CONTACTS
;
743 $modeValues = self
::getModeValue($this->_componentMode
);
745 self
::$_selectorName = $this->_modeValue
['selectorName'];
748 if (strpos(self
::$_selectorName, 'CRM_Contact_Selector') !== FALSE) {
749 $selector = new self
::$_selectorName(
750 $this->_customSearchClass
,
753 $this->_returnProperties
,
762 $selector = new self
::$_selectorName(
770 $selector->setKey($this->controller
->_key
);
772 $controller = new CRM_Contact_Selector_Controller($selector,
773 $this->get(CRM_Utils_Pager
::PAGE_ID
),
774 $this->get(CRM_Utils_Sort
::SORT_ID
),
775 CRM_Core_Action
::VIEW
,
777 CRM_Core_Selector_Controller
::TRANSFER
779 $controller->setEmbedded(TRUE);
780 $controller->setDynamicAction($setDynamic);
784 $this->postProcess();
787 * Note that we repeat this, since the search creates and stores
788 * values that potentially change the controller behavior. i.e. things
789 * like totalCount etc
792 if ($this->get(CRM_Utils_Sort
::SORT_ID
)) {
793 $sortID = CRM_Utils_Sort
::sortIDValue($this->get(CRM_Utils_Sort
::SORT_ID
),
794 $this->get(CRM_Utils_Sort
::SORT_DIRECTION
)
797 $controller = new CRM_Contact_Selector_Controller($selector,
798 $this->get(CRM_Utils_Pager
::PAGE_ID
),
800 CRM_Core_Action
::VIEW
, $this, CRM_Core_Selector_Controller
::TRANSFER
802 $controller->setEmbedded(TRUE);
803 $controller->setDynamicAction($setDynamic);
806 $controller->moveFromSessionToTemplate();
809 function &getFormValues() {
810 return $this->_formValues
;
814 * Common post processing
819 function postProcess() {
821 * sometime we do a postProcess early on, so we dont need to repeat it
822 * this will most likely introduce some more bugs :(
830 //for prev/next pagination
831 $crmPID = CRM_Utils_Request
::retrieve('crmPID', 'Integer', CRM_Core_DAO
::$_nullObject);
833 if (array_key_exists($this->_searchButtonName
, $_POST) ||
834 ($this->_force
&& !$crmPID)) {
835 //reset the cache table for new search
836 $cacheKey = "civicrm search {$this->controller->_key}";
837 CRM_Core_BAO_PrevNextCache
::deleteItem(NULL, $cacheKey);
840 //get the button name
841 $buttonName = $this->controller
->getButtonName();
843 if (isset($this->_ufGroupID
) && empty($this->_formValues
['uf_group_id'])) {
844 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
847 if (isset($this->_componentMode
) && empty($this->_formValues
['component_mode'])) {
848 $this->_formValues
['component_mode'] = $this->_componentMode
;
851 if (isset($this->_operator
) && empty($this->_formValues
['operator'])) {
852 $this->_formValues
['operator'] = $this->_operator
;
855 if (empty($this->_formValues
['qfKey'])) {
856 $this->_formValues
['qfKey'] = $this->controller
->_key
;
859 if (!CRM_Core_Permission
::check('access deleted contacts')) {
860 unset($this->_formValues
['deleted_contacts']);
863 $this->set('type', $this->_action
);
864 $this->set('formValues', $this->_formValues
);
865 $this->set('queryParams', $this->_params
);
866 $this->set('returnProperties', $this->_returnProperties
);
868 if ($buttonName == $this->_actionButtonName
) {
869 // check actionName and if next, then do not repeat a search, since we are going to the next page
870 // hack, make sure we reset the task values
871 $stateMachine = $this->controller
->getStateMachine();
872 $formName = $stateMachine->getTaskFormName();
873 $this->controller
->resetPage($formName);
877 $output = CRM_Core_Selector_Controller
::SESSION
;
879 // create the selector, controller and run - store results in session
880 $searchChildGroups = TRUE;
881 if ($this->get('isAdvanced')) {
882 $searchChildGroups = FALSE;
887 if (strpos(self
::$_selectorName, 'CRM_Contact_Selector') !== FALSE) {
888 $selector = new self
::$_selectorName (
889 $this->_customSearchClass
,
892 $this->_returnProperties
,
902 $selector = new self
::$_selectorName (
913 $selector->setKey($this->controller
->_key
);
915 // added the sorting character to the form array
916 $config = CRM_Core_Config
::singleton();
917 // do this only for contact search
918 if ($setDynamic && $config->includeAlphabeticalPager
) {
919 // Don't recompute if we are just paging/sorting
920 if ($this->_reset ||
(empty($_GET['crmPID']) && empty($_GET['crmSID']) && !$this->_sortByCharacter
)) {
921 $aToZBar = CRM_Utils_PagerAToZ
::getAToZBar($selector, $this->_sortByCharacter
);
922 $this->set('AToZBar', $aToZBar);
927 if ($this->get(CRM_Utils_Sort
::SORT_ID
)) {
928 $sortID = CRM_Utils_Sort
::sortIDValue($this->get(CRM_Utils_Sort
::SORT_ID
),
929 $this->get(CRM_Utils_Sort
::SORT_DIRECTION
)
932 $controller = new CRM_Contact_Selector_Controller($selector,
933 $this->get(CRM_Utils_Pager
::PAGE_ID
),
935 CRM_Core_Action
::VIEW
,
939 $controller->setEmbedded(TRUE);
940 $controller->setDynamicAction($setDynamic);
945 function &returnProperties() {
946 return CRM_Core_DAO
::$_nullObject;
950 * Return a descriptive name for the page, used in wizard header
955 function getTitle() {