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 ->addScriptFile('civicrm', 'js/crm.searchForm.js')
377 // jsTree is needed for tags popup
378 ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)
379 ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
380 $permission = CRM_Core_Permission
::getPermission();
381 // some tasks.. what do we want to do with the selected contacts ?
382 $tasks = array('' => ts('- actions -'));
383 if ($this->_componentMode
== 1 ||
$this->_componentMode
== 7) {
384 $tasks +
= CRM_Contact_Task
::permissionedTaskTitles($permission,
385 CRM_Utils_Array
::value('deleted_contacts', $this->_formValues
)
389 $className = $this->_modeValue
['taskClassName'];
390 $tasks +
= $className::permissionedTaskTitles($permission, false);
393 if (isset($this->_ssID
)) {
394 if ($permission == CRM_Core_Permission
::EDIT
) {
395 $tasks = $tasks + CRM_Contact_Task
::optionalTaskTitle();
399 CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID
, 'search_custom_id');
401 $savedSearchValues = array(
402 'id' => $this->_ssID
,
403 'name' => CRM_Contact_BAO_SavedSearch
::getName($this->_ssID
, 'title'),
404 'search_custom_id' => $search_custom_id,
406 $this->assign_by_ref('savedSearch', $savedSearchValues);
407 $this->assign('ssID', $this->_ssID
);
410 if ($this->_context
=== 'smog') {
411 // CRM-11788, we might want to do this for all of search where force=1
412 $formQFKey = CRM_Utils_Array
::value('qfKey', $this->_formValues
);
413 $getQFKey = CRM_Utils_Array
::value('qfKey', $_GET);
414 $postQFKey = CRM_Utils_Array
::value('qfKey', $_POST);
415 if ($formQFKey && empty($getQFKey) && empty($postQFKey)) {
416 $url = CRM_Utils_System
::makeURL('qfKey') . $formQFKey;
417 CRM_Utils_System
::redirect($url);
420 if (!empty($this->_groupID
)) {
421 $permissionForGroup = FALSE;
423 // check if user has permission to edit members of this group
424 $permission = CRM_Contact_BAO_Group
::checkPermission($this->_groupID
);
425 if ($permission && in_array(CRM_Core_Permission
::EDIT
, $permission)) {
426 $permissionForGroup = TRUE;
429 // check if _groupID exists, it might not if
430 // we are displaying a hidden group
431 if (!isset($this->_group
[$this->_groupID
])) {
432 $permissionForGroup = FALSE;
433 $this->_group
[$this->_groupID
] =
434 CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'title');
437 $this->assign('permissionedForGroup', $permissionForGroup);
439 // set the group title
440 $groupValues = array('id' => $this->_groupID
, 'title' => $this->_group
[$this->_groupID
]);
441 $this->assign_by_ref('group', $groupValues);
443 // also set ssID if this is a saved search
444 $ssID = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'saved_search_id');
445 $this->assign('ssID', $ssID);
447 //get the saved search mapping id
449 $this->_ssID
= $ssID;
450 $ssMappingId = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $ssID, 'mapping_id');
451 $this->assign('ssMappingID', $ssMappingId);
454 // Set dynamic page title for 'Show Members of Group'
455 CRM_Utils_System
::setTitle(ts('Contacts in Group: %1', array(1 => $this->_group
[$this->_groupID
])));
458 $group_contact_status = array();
459 foreach (CRM_Core_SelectValues
::groupContactStatus() as $k => $v) {
461 $group_contact_status[] = $this->createElement('checkbox', $k, NULL, $v);
464 $this->addGroup($group_contact_status,
465 'group_contact_status', ts('Group Status')
468 $this->assign('permissionedForGroup', FALSE);
471 // add the go button for the action form, note it is of type 'next' rather than of type 'submit'
472 if ($this->_context
=== 'amtg') {
473 // check if _groupID exists, it might not if
474 // we are displaying a hidden group
475 if (!isset($this->_group
[$this->_amtgID
])) {
476 $this->assign('permissionedForGroup', FALSE);
477 $this->_group
[$this->_amtgID
] =
478 CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_amtgID
, 'title');
481 // Set dynamic page title for 'Add Members Group'
482 CRM_Utils_System
::setTitle(ts('Add to Group: %1', array(1 => $this->_group
[$this->_amtgID
])));
483 // also set the group title and freeze the action task with Add Members to Group
484 $groupValues = array('id' => $this->_amtgID
, 'title' => $this->_group
[$this->_amtgID
]);
485 $this->assign_by_ref('group', $groupValues);
486 $this->add('submit', $this->_actionButtonName
, ts('Add Contacts to %1', array(1 => $this->_group
[$this->_amtgID
])),
488 'class' => 'form-submit',
489 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 1);",
492 $this->add('hidden', 'task', CRM_Contact_Task
::GROUP_CONTACTS
);
495 $this->add('select', 'task', ts('Actions:') . ' ', $tasks);
496 $this->add('submit', $this->_actionButtonName
, ts('Go'),
498 'class' => 'form-submit',
500 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 0, 1);",
505 // need to perform tasks on all or selected items ? using radio_ts(task selection) for it
506 $selectedRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array(
507 'checked' => 'checked',
508 'onclick' => 'toggleTaskAction( true );',
510 $this->assign('ts_sel_id', $selectedRowsRadio->_attributes
['id']);
513 if ($qfKeyParam = CRM_Utils_Array
::value('qfKey', $this->_formValues
)) {
514 $qfKeyParam = "civicrm search {$qfKeyParam}";
515 $selectedContactIdsArr = CRM_Core_BAO_PrevNextCache
::getSelection($qfKeyParam);
516 $selectedContactIds = array_keys($selectedContactIdsArr[$qfKeyParam]);
519 $this->assign_by_ref('selectedContactIds', $selectedContactIds);
521 $allRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all', array('class' => 'select-rows', 'onclick' => $this->getName() . ".toggleSelect.checked = false; toggleTaskAction( true );toggleContactSelection( 'resetSel', '{$qfKeyParam}', 'reset' );"));
522 $this->assign('ts_all_id', $allRowsRadio->_attributes
['id']);
525 * add form checkboxes for each row. This is needed out here to conform to QF protocol
526 * of all elements being declared in builQuickForm
529 $rows = $this->get('rows');
531 if (is_array($rows)) {
532 $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('class' => 'select-rows', 'onclick' => "toggleTaskAction( true ); toggleContactSelection( 'toggleSelect', '" . $qfKeyParam . "' , 'multiple' );"));
534 $unselectedContactIds = array();
535 foreach ($rows as $row) {
536 $this->addElement('checkbox', $row['checkbox'],
538 array('onclick' => "toggleContactSelection( '" . $row['checkbox'] . "', '" . $qfKeyParam . "' , 'single' );toggleTaskAction( true );", 'class' => 'select-row')
541 if (!in_array($row['contact_id'], $selectedContactIds)) {
542 $unselectedContactIds[] = $row['contact_id'];
545 $this->assign_by_ref('unselectedContactIds', $unselectedContactIds);
549 $this->addButtons(array(
552 'name' => ts('Search'),
558 $this->setDefaultAction('refresh');
562 * processing needed for buildForm and later
567 function preProcess() {
568 // set the various class variables
570 $this->_group
= CRM_Core_PseudoConstant
::group();
572 $this->_groupIterator
= CRM_Core_PseudoConstant
::groupIterator();
573 $this->_tag
= CRM_Core_BAO_Tag
::getTags();
574 $this->_done
= FALSE;
577 * we allow the controller to set force/reset externally, useful when we are being
578 * driven by the wizard framework
581 $this->_reset
= CRM_Utils_Request
::retrieve('reset', 'Boolean',
582 CRM_Core_DAO
::$_nullObject
585 $this->_force
= CRM_Utils_Request
::retrieve('force', 'Boolean', CRM_Core_DAO
::$_nullObject);
586 $this->_groupID
= CRM_Utils_Request
::retrieve('gid', 'Positive', $this);
587 $this->_amtgID
= CRM_Utils_Request
::retrieve('amtgID', 'Positive', $this);
588 $this->_ssID
= CRM_Utils_Request
::retrieve('ssID', 'Positive', $this);
589 $this->_sortByCharacter
= CRM_Utils_Request
::retrieve('sortByCharacter', 'String', $this);
590 $this->_ufGroupID
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
591 $this->_componentMode
= CRM_Utils_Request
::retrieve('component_mode', 'Positive', $this, FALSE, 1, $_REQUEST);
592 $this->_operator
= CRM_Utils_Request
::retrieve('operator', 'String', $this, FALSE, 1, $_REQUEST, 'AND');
595 * set the button names
597 $this->_searchButtonName
= $this->getButtonName('refresh');
598 $this->_actionButtonName
= $this->getButtonName('next', 'action');
600 $this->assign('actionButtonName', $this->_actionButtonName
);
602 // reset from session, CRM-3526
603 $session = CRM_Core_Session
::singleton();
604 if ($this->_force
&& $session->get('selectedSearchContactIds')) {
605 $session->resetScope('selectedSearchContactIds');
608 // if we dont get this from the url, use default if one exsts
609 $config = CRM_Core_Config
::singleton();
610 if ($this->_ufGroupID
== NULL &&
611 $config->defaultSearchProfileID
!= NULL
613 $this->_ufGroupID
= $config->defaultSearchProfileID
;
616 // assign context to drive the template display, make sure context is valid
617 $this->_context
= CRM_Utils_Request
::retrieve('context', 'String', $this, FALSE, 'search');
618 if (!CRM_Utils_Array
::value($this->_context
, self
::validContext())) {
619 $this->_context
= 'search';
621 $this->set('context', $this->_context
);
622 $this->assign('context', $this->_context
);
624 $this->_modeValue
= self
::getModeValue($this->_componentMode
);
625 $this->assign($this->_modeValue
);
627 $this->set('selectorName', self
::$_selectorName);
629 // get user submitted values
630 // get it from controller only if form has been submitted, else preProcess has set this
631 // $this->controller->isModal( ) returns true if page is
632 // valid, i.e all the validations are true
634 if (!empty($_POST) && !$this->controller
->isModal()) {
635 $this->_formValues
= $this->controller
->exportValues($this->_name
);
637 $this->normalizeFormValues();
638 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
639 $this->_returnProperties
= &$this->returnProperties();
641 // also get the uf group id directly from the post value
642 $this->_ufGroupID
= CRM_Utils_Array
::value('uf_group_id', $_POST, $this->_ufGroupID
);
643 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
644 $this->set('id', $this->_ufGroupID
);
646 // also get the object mode directly from the post value
647 $this->_componentMode
= CRM_Utils_Array
::value('component_mode', $_POST, $this->_componentMode
);
649 // also get the operator from the post value if set
650 $this->_operator
= CRM_Utils_Array
::value('operator', $_POST, $this->_operator
);
651 $this->_formValues
['operator'] = $this->_operator
;
652 $this->set('operator', $this->_operator
);
655 $this->_formValues
= $this->get('formValues');
656 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
657 $this->_returnProperties
= &$this->returnProperties();
658 if (!empty($this->_ufGroupID
)) {
659 $this->set('id', $this->_ufGroupID
);
663 if (empty($this->_formValues
)) {
664 //check if group is a smart group (fix for CRM-1255)
665 if ($this->_groupID
) {
666 if ($ssId = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'saved_search_id')) {
667 $this->_ssID
= $ssId;
672 if (isset($this->_ssID
) && $this->_context
!= 'smog') {
673 // we only retrieve the saved search values if out current values are null
674 $this->_formValues
= CRM_Contact_BAO_SavedSearch
::getFormValues($this->_ssID
);
677 if (CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID
, 'mapping_id')) {
678 $this->_params
= CRM_Contact_BAO_SavedSearch
::getSearchParams($this->_ssID
);
681 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
683 $this->_returnProperties
= &$this->returnProperties();
686 if (isset($this->_ufGroupID
)) {
687 // also set the uf group id if not already present
688 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
690 if (isset($this->_componentMode
)) {
691 $this->_formValues
['component_mode'] = $this->_componentMode
;
693 if (isset($this->_operator
)) {
694 $this->_formValues
['operator'] = $this->_operator
;
697 // FIXME: we should generalise in a way that components could inject url-filters
698 // just like they build their own form elements
700 'mailing_id', 'mailing_delivery_status', 'mailing_open_status',
701 'mailing_click_status', 'mailing_reply_status', 'mailing_optout',
702 'mailing_forward', 'mailing_unsubscribe', 'mailing_date_low',
704 ) as $mailingFilter) {
706 if ($mailingFilter == 'mailing_id' &&
707 $filterVal = CRM_Utils_Request
::retrieve('mailing_id', 'Positive', $this)
709 $this->_formValues
[$mailingFilter] = array($filterVal);
711 elseif ($filterVal = CRM_Utils_Request
::retrieve($mailingFilter, $type, $this)) {
712 $this->_formValues
[$mailingFilter] = $filterVal;
715 $this->_openedPanes
['Mailings'] = 1;
716 $this->_formValues
['hidden_CiviMail'] = 1;
722 CRM_Utils_Array
::value('uf_group_id', $this->_formValues
)
724 $operator = CRM_Utils_Array
::value('operator', $this->_formValues
, 'AND');
725 $this->set('queryOperator', $operator);
726 if ($operator == 'OR') {
727 $this->assign('operator', ts('OR'));
730 $this->assign('operator', ts('AND'));
733 // show the context menu only when we’re not searching for deleted contacts; CRM-5673
734 if (empty($this->_formValues
['deleted_contacts'])) {
735 $menuItems = CRM_Contact_BAO_Contact
::contextMenu();
736 $primaryActions = CRM_Utils_Array
::value('primaryActions', $menuItems, array());
737 $this->_contextMenu
= CRM_Utils_Array
::value('moreActions', $menuItems, array());
738 $this->assign('contextMenu', $primaryActions +
$this->_contextMenu
);
741 if (!isset($this->_componentMode
)) {
742 $this->_componentMode
= CRM_Contact_BAO_Query
::MODE_CONTACTS
;
744 $modeValues = self
::getModeValue($this->_componentMode
);
746 self
::$_selectorName = $this->_modeValue
['selectorName'];
749 if (strpos(self
::$_selectorName, 'CRM_Contact_Selector') !== FALSE) {
750 $selector = new self
::$_selectorName(
751 $this->_customSearchClass
,
754 $this->_returnProperties
,
763 $selector = new self
::$_selectorName(
771 $selector->setKey($this->controller
->_key
);
773 $controller = new CRM_Contact_Selector_Controller($selector,
774 $this->get(CRM_Utils_Pager
::PAGE_ID
),
775 $this->get(CRM_Utils_Sort
::SORT_ID
),
776 CRM_Core_Action
::VIEW
,
778 CRM_Core_Selector_Controller
::TRANSFER
780 $controller->setEmbedded(TRUE);
781 $controller->setDynamicAction($setDynamic);
785 $this->postProcess();
788 * Note that we repeat this, since the search creates and stores
789 * values that potentially change the controller behavior. i.e. things
790 * like totalCount etc
793 if ($this->get(CRM_Utils_Sort
::SORT_ID
)) {
794 $sortID = CRM_Utils_Sort
::sortIDValue($this->get(CRM_Utils_Sort
::SORT_ID
),
795 $this->get(CRM_Utils_Sort
::SORT_DIRECTION
)
798 $controller = new CRM_Contact_Selector_Controller($selector,
799 $this->get(CRM_Utils_Pager
::PAGE_ID
),
801 CRM_Core_Action
::VIEW
, $this, CRM_Core_Selector_Controller
::TRANSFER
803 $controller->setEmbedded(TRUE);
804 $controller->setDynamicAction($setDynamic);
807 $controller->moveFromSessionToTemplate();
810 function &getFormValues() {
811 return $this->_formValues
;
815 * Common post processing
820 function postProcess() {
822 * sometime we do a postProcess early on, so we dont need to repeat it
823 * this will most likely introduce some more bugs :(
831 //for prev/next pagination
832 $crmPID = CRM_Utils_Request
::retrieve('crmPID', 'Integer', CRM_Core_DAO
::$_nullObject);
834 if (array_key_exists($this->_searchButtonName
, $_POST) ||
835 ($this->_force
&& !$crmPID)) {
836 //reset the cache table for new search
837 $cacheKey = "civicrm search {$this->controller->_key}";
838 CRM_Core_BAO_PrevNextCache
::deleteItem(NULL, $cacheKey);
841 //get the button name
842 $buttonName = $this->controller
->getButtonName();
844 if (isset($this->_ufGroupID
) && empty($this->_formValues
['uf_group_id'])) {
845 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
848 if (isset($this->_componentMode
) && empty($this->_formValues
['component_mode'])) {
849 $this->_formValues
['component_mode'] = $this->_componentMode
;
852 if (isset($this->_operator
) && empty($this->_formValues
['operator'])) {
853 $this->_formValues
['operator'] = $this->_operator
;
856 if (empty($this->_formValues
['qfKey'])) {
857 $this->_formValues
['qfKey'] = $this->controller
->_key
;
860 if (!CRM_Core_Permission
::check('access deleted contacts')) {
861 unset($this->_formValues
['deleted_contacts']);
864 $this->set('type', $this->_action
);
865 $this->set('formValues', $this->_formValues
);
866 $this->set('queryParams', $this->_params
);
867 $this->set('returnProperties', $this->_returnProperties
);
869 if ($buttonName == $this->_actionButtonName
) {
870 // check actionName and if next, then do not repeat a search, since we are going to the next page
871 // hack, make sure we reset the task values
872 $stateMachine = $this->controller
->getStateMachine();
873 $formName = $stateMachine->getTaskFormName();
874 $this->controller
->resetPage($formName);
878 $output = CRM_Core_Selector_Controller
::SESSION
;
880 // create the selector, controller and run - store results in session
881 $searchChildGroups = TRUE;
882 if ($this->get('isAdvanced')) {
883 $searchChildGroups = FALSE;
888 if (strpos(self
::$_selectorName, 'CRM_Contact_Selector') !== FALSE) {
889 $selector = new self
::$_selectorName (
890 $this->_customSearchClass
,
893 $this->_returnProperties
,
903 $selector = new self
::$_selectorName (
914 $selector->setKey($this->controller
->_key
);
916 // added the sorting character to the form array
917 $config = CRM_Core_Config
::singleton();
918 // do this only for contact search
919 if ($setDynamic && $config->includeAlphabeticalPager
) {
920 // Don't recompute if we are just paging/sorting
921 if ($this->_reset ||
(empty($_GET['crmPID']) && empty($_GET['crmSID']) && !$this->_sortByCharacter
)) {
922 $aToZBar = CRM_Utils_PagerAToZ
::getAToZBar($selector, $this->_sortByCharacter
);
923 $this->set('AToZBar', $aToZBar);
928 if ($this->get(CRM_Utils_Sort
::SORT_ID
)) {
929 $sortID = CRM_Utils_Sort
::sortIDValue($this->get(CRM_Utils_Sort
::SORT_ID
),
930 $this->get(CRM_Utils_Sort
::SORT_DIRECTION
)
933 $controller = new CRM_Contact_Selector_Controller($selector,
934 $this->get(CRM_Utils_Pager
::PAGE_ID
),
936 CRM_Core_Action
::VIEW
,
940 $controller->setEmbedded(TRUE);
941 $controller->setDynamicAction($setDynamic);
946 function &returnProperties() {
947 return CRM_Core_DAO
::$_nullObject;
951 * Return a descriptive name for the page, used in wizard header
956 function getTitle() {