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;
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 parent
::buildQuickForm();
375 CRM_Core_Resources
::singleton()
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('class' => 'select-rows', 'onclick' => $this->getName() . ".toggleSelect.checked = false; 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('class' => 'select-rows', 'onclick' => "toggleTaskAction( true ); 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 );", 'class' => 'select-row')
540 if (!in_array($row['contact_id'], $selectedContactIds)) {
541 $unselectedContactIds[] = $row['contact_id'];
544 $this->assign_by_ref('unselectedContactIds', $unselectedContactIds);
550 * processing needed for buildForm and later
555 function preProcess() {
556 // set the various class variables
558 $this->_group
= CRM_Core_PseudoConstant
::group();
560 $this->_groupIterator
= CRM_Core_PseudoConstant
::groupIterator();
561 $this->_tag
= CRM_Core_BAO_Tag
::getTags();
562 $this->_done
= FALSE;
565 * we allow the controller to set force/reset externally, useful when we are being
566 * driven by the wizard framework
569 $this->_reset
= CRM_Utils_Request
::retrieve('reset', 'Boolean',
570 CRM_Core_DAO
::$_nullObject
573 $this->_force
= CRM_Utils_Request
::retrieve('force', 'Boolean', CRM_Core_DAO
::$_nullObject);
574 $this->_groupID
= CRM_Utils_Request
::retrieve('gid', 'Positive', $this);
575 $this->_amtgID
= CRM_Utils_Request
::retrieve('amtgID', 'Positive', $this);
576 $this->_ssID
= CRM_Utils_Request
::retrieve('ssID', 'Positive', $this);
577 $this->_sortByCharacter
= CRM_Utils_Request
::retrieve('sortByCharacter', 'String', $this);
578 $this->_ufGroupID
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
579 $this->_componentMode
= CRM_Utils_Request
::retrieve('component_mode', 'Positive', $this, FALSE, 1, $_REQUEST);
580 $this->_operator
= CRM_Utils_Request
::retrieve('operator', 'String', $this, FALSE, 1, $_REQUEST, 'AND');
583 * set the button names
585 $this->_searchButtonName
= $this->getButtonName('refresh');
586 $this->_actionButtonName
= $this->getButtonName('next', 'action');
588 $this->assign('actionButtonName', $this->_actionButtonName
);
590 // reset from session, CRM-3526
591 $session = CRM_Core_Session
::singleton();
592 if ($this->_force
&& $session->get('selectedSearchContactIds')) {
593 $session->resetScope('selectedSearchContactIds');
596 // if we dont get this from the url, use default if one exsts
597 $config = CRM_Core_Config
::singleton();
598 if ($this->_ufGroupID
== NULL &&
599 $config->defaultSearchProfileID
!= NULL
601 $this->_ufGroupID
= $config->defaultSearchProfileID
;
604 // assign context to drive the template display, make sure context is valid
605 $this->_context
= CRM_Utils_Request
::retrieve('context', 'String', $this, FALSE, 'search');
606 if (!CRM_Utils_Array
::value($this->_context
, self
::validContext())) {
607 $this->_context
= 'search';
609 $this->set('context', $this->_context
);
610 $this->assign('context', $this->_context
);
612 $this->_modeValue
= self
::getModeValue($this->_componentMode
);
613 $this->assign($this->_modeValue
);
615 $this->set('selectorName', self
::$_selectorName);
617 // get user submitted values
618 // get it from controller only if form has been submitted, else preProcess has set this
619 // $this->controller->isModal( ) returns true if page is
620 // valid, i.e all the validations are true
622 if (!empty($_POST) && !$this->controller
->isModal()) {
623 $this->_formValues
= $this->controller
->exportValues($this->_name
);
625 $this->normalizeFormValues();
626 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
627 $this->_returnProperties
= &$this->returnProperties();
629 // also get the uf group id directly from the post value
630 $this->_ufGroupID
= CRM_Utils_Array
::value('uf_group_id', $_POST, $this->_ufGroupID
);
631 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
632 $this->set('id', $this->_ufGroupID
);
634 // also get the object mode directly from the post value
635 $this->_componentMode
= CRM_Utils_Array
::value('component_mode', $_POST, $this->_componentMode
);
637 // also get the operator from the post value if set
638 $this->_operator
= CRM_Utils_Array
::value('operator', $_POST, $this->_operator
);
639 $this->_formValues
['operator'] = $this->_operator
;
640 $this->set('operator', $this->_operator
);
643 $this->_formValues
= $this->get('formValues');
644 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
645 $this->_returnProperties
= &$this->returnProperties();
646 if (!empty($this->_ufGroupID
)) {
647 $this->set('id', $this->_ufGroupID
);
651 if (empty($this->_formValues
)) {
652 //check if group is a smart group (fix for CRM-1255)
653 if ($this->_groupID
) {
654 if ($ssId = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'saved_search_id')) {
655 $this->_ssID
= $ssId;
660 if (isset($this->_ssID
) && $this->_context
!= 'smog') {
661 // we only retrieve the saved search values if out current values are null
662 $this->_formValues
= CRM_Contact_BAO_SavedSearch
::getFormValues($this->_ssID
);
665 if (CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID
, 'mapping_id')) {
666 $this->_params
= CRM_Contact_BAO_SavedSearch
::getSearchParams($this->_ssID
);
669 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
671 $this->_returnProperties
= &$this->returnProperties();
674 if (isset($this->_ufGroupID
)) {
675 // also set the uf group id if not already present
676 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
678 if (isset($this->_componentMode
)) {
679 $this->_formValues
['component_mode'] = $this->_componentMode
;
681 if (isset($this->_operator
)) {
682 $this->_formValues
['operator'] = $this->_operator
;
685 // FIXME: we should generalise in a way that components could inject url-filters
686 // just like they build their own form elements
688 'mailing_id', 'mailing_delivery_status', 'mailing_open_status',
689 'mailing_click_status', 'mailing_reply_status', 'mailing_optout',
690 'mailing_forward', 'mailing_unsubscribe', 'mailing_date_low',
692 ) as $mailingFilter) {
694 if ($mailingFilter == 'mailing_id' &&
695 $filterVal = CRM_Utils_Request
::retrieve('mailing_id', 'Positive', $this)
697 $this->_formValues
[$mailingFilter] = array($filterVal);
699 elseif ($filterVal = CRM_Utils_Request
::retrieve($mailingFilter, $type, $this)) {
700 $this->_formValues
[$mailingFilter] = $filterVal;
703 $this->_openedPanes
['Mailings'] = 1;
704 $this->_formValues
['hidden_CiviMail'] = 1;
710 CRM_Utils_Array
::value('uf_group_id', $this->_formValues
)
712 $operator = CRM_Utils_Array
::value('operator', $this->_formValues
, 'AND');
713 $this->set('queryOperator', $operator);
714 if ($operator == 'OR') {
715 $this->assign('operator', ts('OR'));
718 $this->assign('operator', ts('AND'));
721 // show the context menu only when we’re not searching for deleted contacts; CRM-5673
722 if (empty($this->_formValues
['deleted_contacts'])) {
723 $menuItems = CRM_Contact_BAO_Contact
::contextMenu();
724 $primaryActions = CRM_Utils_Array
::value('primaryActions', $menuItems, array());
725 $this->_contextMenu
= CRM_Utils_Array
::value('moreActions', $menuItems, array());
726 $this->assign('contextMenu', $primaryActions +
$this->_contextMenu
);
729 if (!isset($this->_componentMode
)) {
730 $this->_componentMode
= CRM_Contact_BAO_Query
::MODE_CONTACTS
;
732 $modeValues = self
::getModeValue($this->_componentMode
);
734 self
::$_selectorName = $this->_modeValue
['selectorName'];
737 if (strpos(self
::$_selectorName, 'CRM_Contact_Selector') !== FALSE) {
738 $selector = new self
::$_selectorName(
739 $this->_customSearchClass
,
742 $this->_returnProperties
,
751 $selector = new self
::$_selectorName(
759 $selector->setKey($this->controller
->_key
);
761 $controller = new CRM_Contact_Selector_Controller($selector,
762 $this->get(CRM_Utils_Pager
::PAGE_ID
),
763 $this->get(CRM_Utils_Sort
::SORT_ID
),
764 CRM_Core_Action
::VIEW
,
766 CRM_Core_Selector_Controller
::TRANSFER
768 $controller->setEmbedded(TRUE);
769 $controller->setDynamicAction($setDynamic);
773 $this->postProcess();
776 * Note that we repeat this, since the search creates and stores
777 * values that potentially change the controller behavior. i.e. things
778 * like totalCount etc
781 if ($this->get(CRM_Utils_Sort
::SORT_ID
)) {
782 $sortID = CRM_Utils_Sort
::sortIDValue($this->get(CRM_Utils_Sort
::SORT_ID
),
783 $this->get(CRM_Utils_Sort
::SORT_DIRECTION
)
786 $controller = new CRM_Contact_Selector_Controller($selector,
787 $this->get(CRM_Utils_Pager
::PAGE_ID
),
789 CRM_Core_Action
::VIEW
, $this, CRM_Core_Selector_Controller
::TRANSFER
791 $controller->setEmbedded(TRUE);
792 $controller->setDynamicAction($setDynamic);
795 $controller->moveFromSessionToTemplate();
798 function &getFormValues() {
799 return $this->_formValues
;
803 * Common post processing
808 function postProcess() {
810 * sometime we do a postProcess early on, so we dont need to repeat it
811 * this will most likely introduce some more bugs :(
819 //for prev/next pagination
820 $crmPID = CRM_Utils_Request
::retrieve('crmPID', 'Integer', CRM_Core_DAO
::$_nullObject);
822 if (array_key_exists($this->_searchButtonName
, $_POST) ||
823 ($this->_force
&& !$crmPID)) {
824 //reset the cache table for new search
825 $cacheKey = "civicrm search {$this->controller->_key}";
826 CRM_Core_BAO_PrevNextCache
::deleteItem(NULL, $cacheKey);
829 //get the button name
830 $buttonName = $this->controller
->getButtonName();
832 if (isset($this->_ufGroupID
) && empty($this->_formValues
['uf_group_id'])) {
833 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
836 if (isset($this->_componentMode
) && empty($this->_formValues
['component_mode'])) {
837 $this->_formValues
['component_mode'] = $this->_componentMode
;
840 if (isset($this->_operator
) && empty($this->_formValues
['operator'])) {
841 $this->_formValues
['operator'] = $this->_operator
;
844 if (empty($this->_formValues
['qfKey'])) {
845 $this->_formValues
['qfKey'] = $this->controller
->_key
;
848 if (!CRM_Core_Permission
::check('access deleted contacts')) {
849 unset($this->_formValues
['deleted_contacts']);
852 $this->set('type', $this->_action
);
853 $this->set('formValues', $this->_formValues
);
854 $this->set('queryParams', $this->_params
);
855 $this->set('returnProperties', $this->_returnProperties
);
857 if ($buttonName == $this->_actionButtonName
) {
858 // check actionName and if next, then do not repeat a search, since we are going to the next page
859 // hack, make sure we reset the task values
860 $stateMachine = $this->controller
->getStateMachine();
861 $formName = $stateMachine->getTaskFormName();
862 $this->controller
->resetPage($formName);
866 $output = CRM_Core_Selector_Controller
::SESSION
;
868 // create the selector, controller and run - store results in session
869 $searchChildGroups = TRUE;
870 if ($this->get('isAdvanced')) {
871 $searchChildGroups = FALSE;
876 if (strpos(self
::$_selectorName, 'CRM_Contact_Selector') !== FALSE) {
877 $selector = new self
::$_selectorName (
878 $this->_customSearchClass
,
881 $this->_returnProperties
,
891 $selector = new self
::$_selectorName (
902 $selector->setKey($this->controller
->_key
);
904 // added the sorting character to the form array
905 $config = CRM_Core_Config
::singleton();
906 // do this only for contact search
907 if ($setDynamic && $config->includeAlphabeticalPager
) {
908 // Don't recompute if we are just paging/sorting
909 if ($this->_reset ||
(empty($_GET['crmPID']) && empty($_GET['crmSID']) && !$this->_sortByCharacter
)) {
910 $aToZBar = CRM_Utils_PagerAToZ
::getAToZBar($selector, $this->_sortByCharacter
);
911 $this->set('AToZBar', $aToZBar);
916 if ($this->get(CRM_Utils_Sort
::SORT_ID
)) {
917 $sortID = CRM_Utils_Sort
::sortIDValue($this->get(CRM_Utils_Sort
::SORT_ID
),
918 $this->get(CRM_Utils_Sort
::SORT_DIRECTION
)
921 $controller = new CRM_Contact_Selector_Controller($selector,
922 $this->get(CRM_Utils_Pager
::PAGE_ID
),
924 CRM_Core_Action
::VIEW
,
928 $controller->setEmbedded(TRUE);
929 $controller->setDynamicAction($setDynamic);
934 function &returnProperties() {
935 return CRM_Core_DAO
::$_nullObject;
939 * Return a descriptive name for the page, used in wizard header
944 function getTitle() {