3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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-2014
41 * Base Search / View form for *all* listing of multiple
44 class CRM_Contact_Form_Search
extends CRM_Core_Form_Search
{
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;
253 static function isSearchContext($context) {
254 $searchContext = CRM_Utils_Array
::value($context, self
::validContext());
255 return $searchContext ?
TRUE : FALSE;
258 static function setModeValues() {
259 if (!self
::$_modeValues) {
260 self
::$_modeValues = array(
262 'selectorName' => self
::$_selectorName,
263 'selectorLabel' => ts('Contacts'),
264 'taskFile' => 'CRM/Contact/Form/Search/ResultTasks.tpl',
265 'taskContext' => NULL,
266 'resultFile' => 'CRM/Contact/Form/Selector.tpl',
267 'resultContext' => NULL,
268 'taskClassName' => 'CRM_Contact_Task',
271 'selectorName' => 'CRM_Contribute_Selector_Search',
272 'selectorLabel' => ts('Contributions'),
273 'taskFile' => 'CRM/common/searchResultTasks.tpl',
274 'taskContext' => 'Contribution',
275 'resultFile' => 'CRM/Contribute/Form/Selector.tpl',
276 'resultContext' => 'Search',
277 'taskClassName' => 'CRM_Contribute_Task',
280 'selectorName' => 'CRM_Event_Selector_Search',
281 'selectorLabel' => ts('Event Participants'),
282 'taskFile' => 'CRM/common/searchResultTasks.tpl',
283 'taskContext' => NULL,
284 'resultFile' => 'CRM/Event/Form/Selector.tpl',
285 'resultContext' => 'Search',
286 'taskClassName' => 'CRM_Event_Task',
289 'selectorName' => 'CRM_Activity_Selector_Search',
290 'selectorLabel' => ts('Activities'),
291 'taskFile' => 'CRM/common/searchResultTasks.tpl',
292 'taskContext' => NULL,
293 'resultFile' => 'CRM/Activity/Form/Selector.tpl',
294 'resultContext' => 'Search',
295 'taskClassName' => 'CRM_Activity_Task',
298 'selectorName' => 'CRM_Member_Selector_Search',
299 'selectorLabel' => ts('Memberships'),
300 'taskFile' => "CRM/common/searchResultTasks.tpl",
301 'taskContext' => NULL,
302 'resultFile' => 'CRM/Member/Form/Selector.tpl',
303 'resultContext' => 'Search',
304 'taskClassName' => 'CRM_Member_Task',
307 'selectorName' => 'CRM_Case_Selector_Search',
308 'selectorLabel' => ts('Cases'),
309 'taskFile' => "CRM/common/searchResultTasks.tpl",
310 'taskContext' => NULL,
311 'resultFile' => 'CRM/Case/Form/Selector.tpl',
312 'resultContext' => 'Search',
313 'taskClassName' => 'CRM_Case_Task',
316 'selectorName' => self
::$_selectorName,
317 'selectorLabel' => ts('Related Contacts'),
318 'taskFile' => 'CRM/Contact/Form/Search/ResultTasks.tpl',
319 'taskContext' => NULL,
320 'resultFile' => 'CRM/Contact/Form/Selector.tpl',
321 'resultContext' => NULL,
322 'taskClassName' => 'CRM_Contact_Task',
325 'selectorName' => 'CRM_Mailing_Selector_Search',
326 'selectorLabel' => ts('Mailings'),
327 'taskFile' => "CRM/common/searchResultTasks.tpl",
328 'taskContext' => NULL,
329 'resultFile' => 'CRM/Mailing/Form/Selector.tpl',
330 'resultContext' => 'Search',
331 'taskClassName' => 'CRM_Mailing_Task',
342 static function getModeValue($mode = 1) {
343 self
::setModeValues();
345 if (!array_key_exists($mode, self
::$_modeValues)) {
349 return self
::$_modeValues[$mode];
355 static function getModeSelect() {
356 self
::setModeValues();
359 foreach (self
::$_modeValues as $id => & $value) {
360 $select[$id] = $value['selectorLabel'];
363 // unset contributions or participants if user does not have
364 // permission on them
365 if (!CRM_Core_Permission
::access('CiviContribute')) {
369 if (!CRM_Core_Permission
::access('CiviEvent')) {
373 if (!CRM_Core_Permission
::check('view all activities')) {
380 * Build the common elements between the search/advanced form
386 function buildQuickForm() {
387 parent
::buildQuickForm();
388 CRM_Core_Resources
::singleton()
389 // jsTree is needed for tags popup
390 ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)
391 ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
392 $permission = CRM_Core_Permission
::getPermission();
393 // some tasks.. what do we want to do with the selected contacts ?
394 $tasks = array('' => ts('- actions -'));
395 if ($this->_componentMode
== 1 ||
$this->_componentMode
== 7) {
396 $tasks +
= CRM_Contact_Task
::permissionedTaskTitles($permission,
397 CRM_Utils_Array
::value('deleted_contacts', $this->_formValues
)
401 $className = $this->_modeValue
['taskClassName'];
402 $tasks +
= $className::permissionedTaskTitles($permission, false);
405 if (isset($this->_ssID
)) {
406 if ($permission == CRM_Core_Permission
::EDIT
) {
407 $tasks = $tasks + CRM_Contact_Task
::optionalTaskTitle();
411 CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID
, 'search_custom_id');
413 $savedSearchValues = array(
414 'id' => $this->_ssID
,
415 'name' => CRM_Contact_BAO_SavedSearch
::getName($this->_ssID
, 'title'),
416 'search_custom_id' => $search_custom_id,
418 $this->assign_by_ref('savedSearch', $savedSearchValues);
419 $this->assign('ssID', $this->_ssID
);
422 if ($this->_context
=== 'smog') {
423 // CRM-11788, we might want to do this for all of search where force=1
424 $formQFKey = CRM_Utils_Array
::value('qfKey', $this->_formValues
);
425 $getQFKey = CRM_Utils_Array
::value('qfKey', $_GET);
426 $postQFKey = CRM_Utils_Array
::value('qfKey', $_POST);
427 if ($formQFKey && empty($getQFKey) && empty($postQFKey)) {
428 $url = CRM_Utils_System
::makeURL('qfKey') . $formQFKey;
429 CRM_Utils_System
::redirect($url);
432 if (!empty($this->_groupID
)) {
433 $permissionForGroup = FALSE;
435 // check if user has permission to edit members of this group
436 $permission = CRM_Contact_BAO_Group
::checkPermission($this->_groupID
);
437 if ($permission && in_array(CRM_Core_Permission
::EDIT
, $permission)) {
438 $permissionForGroup = TRUE;
441 // check if _groupID exists, it might not if
442 // we are displaying a hidden group
443 if (!isset($this->_group
[$this->_groupID
])) {
444 $permissionForGroup = FALSE;
445 $this->_group
[$this->_groupID
] =
446 CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'title');
449 $this->assign('permissionedForGroup', $permissionForGroup);
451 // set the group title
452 $groupValues = array('id' => $this->_groupID
, 'title' => $this->_group
[$this->_groupID
]);
453 $this->assign_by_ref('group', $groupValues);
455 // also set ssID if this is a saved search
456 $ssID = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'saved_search_id');
457 $this->assign('ssID', $ssID);
459 //get the saved search mapping id
461 $this->_ssID
= $ssID;
462 $ssMappingId = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $ssID, 'mapping_id');
463 $this->assign('ssMappingID', $ssMappingId);
466 // Set dynamic page title for 'Show Members of Group'
467 CRM_Utils_System
::setTitle(ts('Contacts in Group: %1', array(1 => $this->_group
[$this->_groupID
])));
470 $group_contact_status = array();
471 foreach (CRM_Core_SelectValues
::groupContactStatus() as $k => $v) {
473 $group_contact_status[] = $this->createElement('checkbox', $k, NULL, $v);
476 $this->addGroup($group_contact_status,
477 'group_contact_status', ts('Group Status')
480 $this->assign('permissionedForGroup', FALSE);
483 // add the go button for the action form, note it is of type 'next' rather than of type 'submit'
484 if ($this->_context
=== 'amtg') {
485 // check if _groupID exists, it might not if
486 // we are displaying a hidden group
487 if (!isset($this->_group
[$this->_amtgID
])) {
488 $this->assign('permissionedForGroup', FALSE);
489 $this->_group
[$this->_amtgID
] =
490 CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_amtgID
, 'title');
493 // Set dynamic page title for 'Add Members Group'
494 CRM_Utils_System
::setTitle(ts('Add to Group: %1', array(1 => $this->_group
[$this->_amtgID
])));
495 // also set the group title and freeze the action task with Add Members to Group
496 $groupValues = array('id' => $this->_amtgID
, 'title' => $this->_group
[$this->_amtgID
]);
497 $this->assign_by_ref('group', $groupValues);
498 $this->add('submit', $this->_actionButtonName
, ts('Add Contacts to %1', array(1 => $this->_group
[$this->_amtgID
])),
500 'class' => 'form-submit',
501 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 1);",
504 $this->add('hidden', 'task', CRM_Contact_Task
::GROUP_CONTACTS
);
507 $this->add('select', 'task', ts('Actions:') . ' ', $tasks);
508 $this->add('submit', $this->_actionButtonName
, ts('Go'),
510 'class' => 'form-submit',
512 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 0, 1);",
517 // need to perform tasks on all or selected items ? using radio_ts(task selection) for it
518 $selectedRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array(
519 'checked' => 'checked',
520 'onclick' => 'toggleTaskAction( true );',
522 $this->assign('ts_sel_id', $selectedRowsRadio->_attributes
['id']);
525 if ($qfKeyParam = CRM_Utils_Array
::value('qfKey', $this->_formValues
)) {
526 $qfKeyParam = "civicrm search {$qfKeyParam}";
527 $selectedContactIdsArr = CRM_Core_BAO_PrevNextCache
::getSelection($qfKeyParam);
528 $selectedContactIds = array_keys($selectedContactIdsArr[$qfKeyParam]);
531 $this->assign_by_ref('selectedContactIds', $selectedContactIds);
533 $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' );"));
534 $this->assign('ts_all_id', $allRowsRadio->_attributes
['id']);
537 * add form checkboxes for each row. This is needed out here to conform to QF protocol
538 * of all elements being declared in builQuickForm
541 $rows = $this->get('rows');
543 if (is_array($rows)) {
544 $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('class' => 'select-rows', 'onclick' => "toggleTaskAction( true ); toggleContactSelection( 'toggleSelect', '" . $qfKeyParam . "' , 'multiple' );"));
546 $unselectedContactIds = array();
547 foreach ($rows as $row) {
548 $this->addElement('checkbox', $row['checkbox'],
550 array('onclick' => "toggleContactSelection( '" . $row['checkbox'] . "', '" . $qfKeyParam . "' , 'single' );toggleTaskAction( true );", 'class' => 'select-row')
553 if (!in_array($row['contact_id'], $selectedContactIds)) {
554 $unselectedContactIds[] = $row['contact_id'];
557 $this->assign_by_ref('unselectedContactIds', $unselectedContactIds);
563 * processing needed for buildForm and later
568 function preProcess() {
569 // set the various class variables
571 $this->_group
= CRM_Core_PseudoConstant
::group();
573 $this->_groupIterator
= CRM_Core_PseudoConstant
::groupIterator();
574 $this->_tag
= CRM_Core_BAO_Tag
::getTags();
575 $this->_done
= FALSE;
578 * we allow the controller to set force/reset externally, useful when we are being
579 * driven by the wizard framework
582 $this->_reset
= CRM_Utils_Request
::retrieve('reset', 'Boolean',
583 CRM_Core_DAO
::$_nullObject
586 $this->_force
= CRM_Utils_Request
::retrieve('force', 'Boolean', CRM_Core_DAO
::$_nullObject);
587 $this->_groupID
= CRM_Utils_Request
::retrieve('gid', 'Positive', $this);
588 $this->_amtgID
= CRM_Utils_Request
::retrieve('amtgID', 'Positive', $this);
589 $this->_ssID
= CRM_Utils_Request
::retrieve('ssID', 'Positive', $this);
590 $this->_sortByCharacter
= CRM_Utils_Request
::retrieve('sortByCharacter', 'String', $this);
591 $this->_ufGroupID
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
592 $this->_componentMode
= CRM_Utils_Request
::retrieve('component_mode', 'Positive', $this, FALSE, 1, $_REQUEST);
593 $this->_operator
= CRM_Utils_Request
::retrieve('operator', 'String', $this, FALSE, 1, $_REQUEST, 'AND');
596 * set the button names
598 $this->_searchButtonName
= $this->getButtonName('refresh');
599 $this->_actionButtonName
= $this->getButtonName('next', 'action');
601 $this->assign('actionButtonName', $this->_actionButtonName
);
603 // reset from session, CRM-3526
604 $session = CRM_Core_Session
::singleton();
605 if ($this->_force
&& $session->get('selectedSearchContactIds')) {
606 $session->resetScope('selectedSearchContactIds');
609 // if we dont get this from the url, use default if one exsts
610 $config = CRM_Core_Config
::singleton();
611 if ($this->_ufGroupID
== NULL &&
612 $config->defaultSearchProfileID
!= NULL
614 $this->_ufGroupID
= $config->defaultSearchProfileID
;
617 // assign context to drive the template display, make sure context is valid
618 $this->_context
= CRM_Utils_Request
::retrieve('context', 'String', $this, FALSE, 'search');
619 if (!CRM_Utils_Array
::value($this->_context
, self
::validContext())) {
620 $this->_context
= 'search';
622 $this->set('context', $this->_context
);
623 $this->assign('context', $this->_context
);
625 $this->_modeValue
= self
::getModeValue($this->_componentMode
);
626 $this->assign($this->_modeValue
);
628 $this->set('selectorName', self
::$_selectorName);
630 // get user submitted values
631 // get it from controller only if form has been submitted, else preProcess has set this
632 // $this->controller->isModal( ) returns true if page is
633 // valid, i.e all the validations are true
635 if (!empty($_POST) && !$this->controller
->isModal()) {
636 $this->_formValues
= $this->controller
->exportValues($this->_name
);
638 $this->normalizeFormValues();
639 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
640 $this->_returnProperties
= &$this->returnProperties();
642 // also get the uf group id directly from the post value
643 $this->_ufGroupID
= CRM_Utils_Array
::value('uf_group_id', $_POST, $this->_ufGroupID
);
644 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
645 $this->set('id', $this->_ufGroupID
);
647 // also get the object mode directly from the post value
648 $this->_componentMode
= CRM_Utils_Array
::value('component_mode', $_POST, $this->_componentMode
);
650 // also get the operator from the post value if set
651 $this->_operator
= CRM_Utils_Array
::value('operator', $_POST, $this->_operator
);
652 $this->_formValues
['operator'] = $this->_operator
;
653 $this->set('operator', $this->_operator
);
656 $this->_formValues
= $this->get('formValues');
657 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
658 $this->_returnProperties
= &$this->returnProperties();
659 if (!empty($this->_ufGroupID
)) {
660 $this->set('id', $this->_ufGroupID
);
664 if (empty($this->_formValues
)) {
665 //check if group is a smart group (fix for CRM-1255)
666 if ($this->_groupID
) {
667 if ($ssId = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'saved_search_id')) {
668 $this->_ssID
= $ssId;
673 if (isset($this->_ssID
) && $this->_context
!= 'smog') {
674 // we only retrieve the saved search values if out current values are null
675 $this->_formValues
= CRM_Contact_BAO_SavedSearch
::getFormValues($this->_ssID
);
678 if (CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID
, 'mapping_id')) {
679 $this->_params
= CRM_Contact_BAO_SavedSearch
::getSearchParams($this->_ssID
);
682 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
684 $this->_returnProperties
= &$this->returnProperties();
687 if (isset($this->_ufGroupID
)) {
688 // also set the uf group id if not already present
689 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
691 if (isset($this->_componentMode
)) {
692 $this->_formValues
['component_mode'] = $this->_componentMode
;
694 if (isset($this->_operator
)) {
695 $this->_formValues
['operator'] = $this->_operator
;
698 // FIXME: we should generalise in a way that components could inject url-filters
699 // just like they build their own form elements
701 'mailing_id', 'mailing_delivery_status', 'mailing_open_status',
702 'mailing_click_status', 'mailing_reply_status', 'mailing_optout',
703 'mailing_forward', 'mailing_unsubscribe', 'mailing_date_low',
705 ) as $mailingFilter) {
707 if ($mailingFilter == 'mailing_id' &&
708 $filterVal = CRM_Utils_Request
::retrieve('mailing_id', 'Positive', $this)
710 $this->_formValues
[$mailingFilter] = array($filterVal);
712 elseif ($filterVal = CRM_Utils_Request
::retrieve($mailingFilter, $type, $this)) {
713 $this->_formValues
[$mailingFilter] = $filterVal;
716 $this->_openedPanes
['Mailings'] = 1;
717 $this->_formValues
['hidden_CiviMail'] = 1;
723 CRM_Utils_Array
::value('uf_group_id', $this->_formValues
)
725 $operator = CRM_Utils_Array
::value('operator', $this->_formValues
, 'AND');
726 $this->set('queryOperator', $operator);
727 if ($operator == 'OR') {
728 $this->assign('operator', ts('OR'));
731 $this->assign('operator', ts('AND'));
734 // show the context menu only when we’re not searching for deleted contacts; CRM-5673
735 if (empty($this->_formValues
['deleted_contacts'])) {
736 $menuItems = CRM_Contact_BAO_Contact
::contextMenu();
737 $primaryActions = CRM_Utils_Array
::value('primaryActions', $menuItems, array());
738 $this->_contextMenu
= CRM_Utils_Array
::value('moreActions', $menuItems, array());
739 $this->assign('contextMenu', $primaryActions +
$this->_contextMenu
);
742 if (!isset($this->_componentMode
)) {
743 $this->_componentMode
= CRM_Contact_BAO_Query
::MODE_CONTACTS
;
745 $modeValues = self
::getModeValue($this->_componentMode
);
747 self
::$_selectorName = $this->_modeValue
['selectorName'];
750 if (strpos(self
::$_selectorName, 'CRM_Contact_Selector') !== FALSE) {
751 $selector = new self
::$_selectorName(
752 $this->_customSearchClass
,
755 $this->_returnProperties
,
764 $selector = new self
::$_selectorName(
772 $selector->setKey($this->controller
->_key
);
774 $controller = new CRM_Contact_Selector_Controller($selector,
775 $this->get(CRM_Utils_Pager
::PAGE_ID
),
776 $this->get(CRM_Utils_Sort
::SORT_ID
),
777 CRM_Core_Action
::VIEW
,
779 CRM_Core_Selector_Controller
::TRANSFER
781 $controller->setEmbedded(TRUE);
782 $controller->setDynamicAction($setDynamic);
786 $this->postProcess();
789 * Note that we repeat this, since the search creates and stores
790 * values that potentially change the controller behavior. i.e. things
791 * like totalCount etc
794 if ($this->get(CRM_Utils_Sort
::SORT_ID
)) {
795 $sortID = CRM_Utils_Sort
::sortIDValue($this->get(CRM_Utils_Sort
::SORT_ID
),
796 $this->get(CRM_Utils_Sort
::SORT_DIRECTION
)
799 $controller = new CRM_Contact_Selector_Controller($selector,
800 $this->get(CRM_Utils_Pager
::PAGE_ID
),
802 CRM_Core_Action
::VIEW
, $this, CRM_Core_Selector_Controller
::TRANSFER
804 $controller->setEmbedded(TRUE);
805 $controller->setDynamicAction($setDynamic);
808 $controller->moveFromSessionToTemplate();
814 function &getFormValues() {
815 return $this->_formValues
;
819 * Common post processing
824 function postProcess() {
826 * sometime we do a postProcess early on, so we dont need to repeat it
827 * this will most likely introduce some more bugs :(
835 //for prev/next pagination
836 $crmPID = CRM_Utils_Request
::retrieve('crmPID', 'Integer', CRM_Core_DAO
::$_nullObject);
838 if (array_key_exists($this->_searchButtonName
, $_POST) ||
839 ($this->_force
&& !$crmPID)) {
840 //reset the cache table for new search
841 $cacheKey = "civicrm search {$this->controller->_key}";
842 CRM_Core_BAO_PrevNextCache
::deleteItem(NULL, $cacheKey);
845 //get the button name
846 $buttonName = $this->controller
->getButtonName();
848 if (isset($this->_ufGroupID
) && empty($this->_formValues
['uf_group_id'])) {
849 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
852 if (isset($this->_componentMode
) && empty($this->_formValues
['component_mode'])) {
853 $this->_formValues
['component_mode'] = $this->_componentMode
;
856 if (isset($this->_operator
) && empty($this->_formValues
['operator'])) {
857 $this->_formValues
['operator'] = $this->_operator
;
860 if (empty($this->_formValues
['qfKey'])) {
861 $this->_formValues
['qfKey'] = $this->controller
->_key
;
864 if (!CRM_Core_Permission
::check('access deleted contacts')) {
865 unset($this->_formValues
['deleted_contacts']);
868 $this->set('type', $this->_action
);
869 $this->set('formValues', $this->_formValues
);
870 $this->set('queryParams', $this->_params
);
871 $this->set('returnProperties', $this->_returnProperties
);
873 if ($buttonName == $this->_actionButtonName
) {
874 // check actionName and if next, then do not repeat a search, since we are going to the next page
875 // hack, make sure we reset the task values
876 $stateMachine = $this->controller
->getStateMachine();
877 $formName = $stateMachine->getTaskFormName();
878 $this->controller
->resetPage($formName);
882 $output = CRM_Core_Selector_Controller
::SESSION
;
884 // create the selector, controller and run - store results in session
885 $searchChildGroups = TRUE;
886 if ($this->get('isAdvanced')) {
887 $searchChildGroups = FALSE;
892 if (strpos(self
::$_selectorName, 'CRM_Contact_Selector') !== FALSE) {
893 $selector = new self
::$_selectorName (
894 $this->_customSearchClass
,
897 $this->_returnProperties
,
907 $selector = new self
::$_selectorName (
918 $selector->setKey($this->controller
->_key
);
920 // added the sorting character to the form array
921 $config = CRM_Core_Config
::singleton();
922 // do this only for contact search
923 if ($setDynamic && $config->includeAlphabeticalPager
) {
924 // Don't recompute if we are just paging/sorting
925 if ($this->_reset ||
(empty($_GET['crmPID']) && empty($_GET['crmSID']) && !$this->_sortByCharacter
)) {
926 $aToZBar = CRM_Utils_PagerAToZ
::getAToZBar($selector, $this->_sortByCharacter
);
927 $this->set('AToZBar', $aToZBar);
932 if ($this->get(CRM_Utils_Sort
::SORT_ID
)) {
933 $sortID = CRM_Utils_Sort
::sortIDValue($this->get(CRM_Utils_Sort
::SORT_ID
),
934 $this->get(CRM_Utils_Sort
::SORT_DIRECTION
)
937 $controller = new CRM_Contact_Selector_Controller($selector,
938 $this->get(CRM_Utils_Pager
::PAGE_ID
),
940 CRM_Core_Action
::VIEW
,
944 $controller->setEmbedded(TRUE);
945 $controller->setDynamicAction($setDynamic);
953 function &returnProperties() {
954 return CRM_Core_DAO
::$_nullObject;
958 * Return a descriptive name for the page, used in wizard header
963 function getTitle() {