3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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-2015
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.
51 static $_validContext = NULL;
54 * List of values used when we want to display other objects.
58 static $_modeValues = NULL;
65 protected $_contextMenu;
68 * The groupId retrieved from the GET vars.
75 * The Group ID belonging to Add Member to group ID.
76 * retrieved from the GET vars
83 * The saved search ID retrieved from the GET vars.
95 public $_groupElement;
96 public $_groupIterator;
107 * The params used for search.
114 * The return properties used for search.
118 protected $_returnProperties;
121 * The sort by character.
125 protected $_sortByCharacter;
128 * The profile group id used for display.
132 protected $_ufGroupID;
135 * Csv - common search values
139 static $csv = array('contact_type', 'group', 'tag');
142 * @var string how to display the results. Should we display as
143 * contributons, members, cases etc
145 protected $_componentMode;
148 * @var string what operator should we use, AND or OR
150 protected $_operator;
152 protected $_modeValue;
155 * Name of the selector to use.
157 static $_selectorName = 'CRM_Contact_Selector';
158 protected $_customSearchID = NULL;
159 protected $_customSearchClass = NULL;
161 protected $_openedPanes = array();
164 * Define the set of valid contexts that the search form operates on.
167 * the valid context set and the titles
169 public static function &validContext() {
170 if (!(self
::$_validContext)) {
171 self
::$_validContext = array(
172 'smog' => 'Show members of group',
173 'amtg' => 'Add members to group',
174 'basic' => 'Basic Search',
175 'search' => 'Search',
176 'builder' => 'Search Builder',
177 'advanced' => 'Advanced Search',
178 'custom' => 'Custom Search',
181 return self
::$_validContext;
189 public static function isSearchContext($context) {
190 $searchContext = CRM_Utils_Array
::value($context, self
::validContext());
191 return $searchContext ?
TRUE : FALSE;
194 public static function setModeValues() {
195 if (!self
::$_modeValues) {
196 self
::$_modeValues = array(
198 'selectorName' => self
::$_selectorName,
199 'selectorLabel' => ts('Contacts'),
200 'taskFile' => 'CRM/Contact/Form/Search/ResultTasks.tpl',
201 'taskContext' => NULL,
202 'resultFile' => 'CRM/Contact/Form/Selector.tpl',
203 'resultContext' => NULL,
204 'taskClassName' => 'CRM_Contact_Task',
207 'selectorName' => 'CRM_Contribute_Selector_Search',
208 'selectorLabel' => ts('Contributions'),
209 'taskFile' => 'CRM/common/searchResultTasks.tpl',
210 'taskContext' => 'Contribution',
211 'resultFile' => 'CRM/Contribute/Form/Selector.tpl',
212 'resultContext' => 'Search',
213 'taskClassName' => 'CRM_Contribute_Task',
216 'selectorName' => 'CRM_Event_Selector_Search',
217 'selectorLabel' => ts('Event Participants'),
218 'taskFile' => 'CRM/common/searchResultTasks.tpl',
219 'taskContext' => NULL,
220 'resultFile' => 'CRM/Event/Form/Selector.tpl',
221 'resultContext' => 'Search',
222 'taskClassName' => 'CRM_Event_Task',
225 'selectorName' => 'CRM_Activity_Selector_Search',
226 'selectorLabel' => ts('Activities'),
227 'taskFile' => 'CRM/common/searchResultTasks.tpl',
228 'taskContext' => NULL,
229 'resultFile' => 'CRM/Activity/Form/Selector.tpl',
230 'resultContext' => 'Search',
231 'taskClassName' => 'CRM_Activity_Task',
234 'selectorName' => 'CRM_Member_Selector_Search',
235 'selectorLabel' => ts('Memberships'),
236 'taskFile' => "CRM/common/searchResultTasks.tpl",
237 'taskContext' => NULL,
238 'resultFile' => 'CRM/Member/Form/Selector.tpl',
239 'resultContext' => 'Search',
240 'taskClassName' => 'CRM_Member_Task',
243 'selectorName' => 'CRM_Case_Selector_Search',
244 'selectorLabel' => ts('Cases'),
245 'taskFile' => "CRM/common/searchResultTasks.tpl",
246 'taskContext' => NULL,
247 'resultFile' => 'CRM/Case/Form/Selector.tpl',
248 'resultContext' => 'Search',
249 'taskClassName' => 'CRM_Case_Task',
252 'selectorName' => self
::$_selectorName,
253 'selectorLabel' => ts('Related Contacts'),
254 'taskFile' => 'CRM/Contact/Form/Search/ResultTasks.tpl',
255 'taskContext' => NULL,
256 'resultFile' => 'CRM/Contact/Form/Selector.tpl',
257 'resultContext' => NULL,
258 'taskClassName' => 'CRM_Contact_Task',
261 'selectorName' => 'CRM_Mailing_Selector_Search',
262 'selectorLabel' => ts('Mailings'),
263 'taskFile' => "CRM/common/searchResultTasks.tpl",
264 'taskContext' => NULL,
265 'resultFile' => 'CRM/Mailing/Form/Selector.tpl',
266 'resultContext' => 'Search',
267 'taskClassName' => 'CRM_Mailing_Task',
278 public static function getModeValue($mode = 1) {
279 self
::setModeValues();
281 if (!array_key_exists($mode, self
::$_modeValues)) {
285 return self
::$_modeValues[$mode];
291 public static function getModeSelect() {
292 self
::setModeValues();
295 foreach (self
::$_modeValues as $id => & $value) {
296 $select[$id] = $value['selectorLabel'];
299 // unset contributions or participants if user does not have
300 // permission on them
301 if (!CRM_Core_Permission
::access('CiviContribute')) {
305 if (!CRM_Core_Permission
::access('CiviEvent')) {
309 if (!CRM_Core_Permission
::check('view all activities')) {
316 * Builds the list of tasks or actions that a searcher can perform on a result set.
320 public function buildTaskList() {
321 if ($this->_context
!== 'amtg') {
322 $permission = CRM_Core_Permission
::getPermission();
324 if ($this->_componentMode
== 1 ||
$this->_componentMode
== 7) {
325 $this->_taskList +
= CRM_Contact_Task
::permissionedTaskTitles($permission,
326 CRM_Utils_Array
::value('deleted_contacts', $this->_formValues
)
329 $className = $this->_modeValue
['taskClassName'];
330 $this->_taskList +
= $className::permissionedTaskTitles($permission, false);
333 // Only offer the "Update Smart Group" task if a smart group/saved search is already in play
334 if (isset($this->_ssID
) && $permission == CRM_Core_Permission
::EDIT
) {
335 $this->_taskList +
= CRM_Contact_Task
::optionalTaskTitle();
339 return $this->_taskList
;
343 * Build the common elements between the search/advanced form.
347 public function buildQuickForm() {
348 parent
::buildQuickForm();
349 CRM_Core_Resources
::singleton()
350 // jsTree is needed for tags popup
351 ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)
352 ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
353 $permission = CRM_Core_Permission
::getPermission();
354 // some tasks.. what do we want to do with the selected contacts ?
356 if ($this->_componentMode
== 1 ||
$this->_componentMode
== 7) {
357 $tasks +
= CRM_Contact_Task
::permissionedTaskTitles($permission,
358 CRM_Utils_Array
::value('deleted_contacts', $this->_formValues
)
362 $className = $this->_modeValue
['taskClassName'];
363 $tasks +
= $className::permissionedTaskTitles($permission, FALSE);
366 if (isset($this->_ssID
)) {
367 if ($permission == CRM_Core_Permission
::EDIT
) {
368 $tasks = $tasks + CRM_Contact_Task
::optionalTaskTitle();
372 = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID
, 'search_custom_id');
374 $savedSearchValues = array(
375 'id' => $this->_ssID
,
376 'name' => CRM_Contact_BAO_SavedSearch
::getName($this->_ssID
, 'title'),
377 'search_custom_id' => $search_custom_id,
379 $this->assign_by_ref('savedSearch', $savedSearchValues);
380 $this->assign('ssID', $this->_ssID
);
383 if ($this->_context
=== 'smog') {
384 // CRM-11788, we might want to do this for all of search where force=1
385 $formQFKey = CRM_Utils_Array
::value('qfKey', $this->_formValues
);
386 $getQFKey = CRM_Utils_Array
::value('qfKey', $_GET);
387 $postQFKey = CRM_Utils_Array
::value('qfKey', $_POST);
388 if ($formQFKey && empty($getQFKey) && empty($postQFKey)) {
389 $url = CRM_Utils_System
::makeURL('qfKey') . $formQFKey;
390 CRM_Utils_System
::redirect($url);
392 $permissionForGroup = FALSE;
394 if (!empty($this->_groupID
)) {
395 // check if user has permission to edit members of this group
396 $permission = CRM_Contact_BAO_Group
::checkPermission($this->_groupID
);
397 if ($permission && in_array(CRM_Core_Permission
::EDIT
, $permission)) {
398 $permissionForGroup = TRUE;
401 // check if _groupID exists, it might not if
402 // we are displaying a hidden group
403 if (!isset($this->_group
[$this->_groupID
])) {
404 $this->_group
[$this->_groupID
]
405 = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'title');
408 // set the group title
409 $groupValues = array('id' => $this->_groupID
, 'title' => $this->_group
[$this->_groupID
]);
410 $this->assign_by_ref('group', $groupValues);
412 // also set ssID if this is a saved search
413 $ssID = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'saved_search_id');
414 $this->assign('ssID', $ssID);
416 //get the saved search mapping id
418 $this->_ssID
= $ssID;
419 $ssMappingId = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $ssID, 'mapping_id');
420 $this->assign('ssMappingID', $ssMappingId);
423 // Set dynamic page title for 'Show Members of Group'
424 CRM_Utils_System
::setTitle(ts('Contacts in Group: %1', array(1 => $this->_group
[$this->_groupID
])));
427 $group_contact_status = array();
428 foreach (CRM_Core_SelectValues
::groupContactStatus() as $k => $v) {
430 $group_contact_status[] = $this->createElement('checkbox', $k, NULL, $v);
433 $this->addGroup($group_contact_status,
434 'group_contact_status', ts('Group Status')
437 $this->assign('permissionedForGroup', $permissionForGroup);
440 // add the go button for the action form, note it is of type 'next' rather than of type 'submit'
441 if ($this->_context
=== 'amtg') {
442 // check if _groupID exists, it might not if
443 // we are displaying a hidden group
444 if (!isset($this->_group
[$this->_amtgID
])) {
445 $this->assign('permissionedForGroup', FALSE);
446 $this->_group
[$this->_amtgID
]
447 = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_amtgID
, 'title');
450 // Set dynamic page title for 'Add Members Group'
451 CRM_Utils_System
::setTitle(ts('Add to Group: %1', array(1 => $this->_group
[$this->_amtgID
])));
452 // also set the group title and freeze the action task with Add Members to Group
453 $groupValues = array('id' => $this->_amtgID
, 'title' => $this->_group
[$this->_amtgID
]);
454 $this->assign_by_ref('group', $groupValues);
455 $this->add('submit', $this->_actionButtonName
, ts('Add Contacts to %1', array(1 => $this->_group
[$this->_amtgID
])),
457 'class' => 'crm-form-submit',
460 $this->add('hidden', 'task', CRM_Contact_Task
::GROUP_CONTACTS
);
461 $selectedRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked'));
462 $allRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all');
463 $this->assign('ts_sel_id', $selectedRowsRadio->_attributes
['id']);
464 $this->assign('ts_all_id', $allRowsRadio->_attributes
['id']);
467 $selectedContactIds = array();
468 $qfKeyParam = CRM_Utils_Array
::value('qfKey', $this->_formValues
);
469 // We use ajax to handle selections only if the search results component_mode is set to "contacts"
470 if ($qfKeyParam && ($this->get('component_mode') <= 1 ||
$this->get('component_mode') == 7)) {
471 $this->addClass('crm-ajax-selection-form');
472 $qfKeyParam = "civicrm search {$qfKeyParam}";
473 $selectedContactIdsArr = CRM_Core_BAO_PrevNextCache
::getSelection($qfKeyParam);
474 $selectedContactIds = array_keys($selectedContactIdsArr[$qfKeyParam]);
477 $this->assign_by_ref('selectedContactIds', $selectedContactIds);
479 $rows = $this->get('rows');
481 if (is_array($rows)) {
482 $this->addRowSelectors($rows);
488 * Processing needed for buildForm and later.
492 public function preProcess() {
493 // set the various class variables
495 $this->_group
= CRM_Core_PseudoConstant
::group();
497 $this->_groupIterator
= CRM_Core_PseudoConstant
::groupIterator();
498 $this->_tag
= CRM_Core_BAO_Tag
::getTags();
499 $this->_done
= FALSE;
502 * we allow the controller to set force/reset externally, useful when we are being
503 * driven by the wizard framework
506 $this->_reset
= CRM_Utils_Request
::retrieve('reset', 'Boolean',
507 CRM_Core_DAO
::$_nullObject
510 $this->_force
= CRM_Utils_Request
::retrieve('force', 'Boolean', CRM_Core_DAO
::$_nullObject);
511 $this->_groupID
= CRM_Utils_Request
::retrieve('gid', 'Positive', $this);
512 $this->_amtgID
= CRM_Utils_Request
::retrieve('amtgID', 'Positive', $this);
513 $this->_ssID
= CRM_Utils_Request
::retrieve('ssID', 'Positive', $this);
514 $this->_sortByCharacter
= CRM_Utils_Request
::retrieve('sortByCharacter', 'String', $this);
515 $this->_ufGroupID
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
516 $this->_componentMode
= CRM_Utils_Request
::retrieve('component_mode', 'Positive', $this, FALSE, 1, $_REQUEST);
517 $this->_operator
= CRM_Utils_Request
::retrieve('operator', 'String', $this, FALSE, 1, $_REQUEST, 'AND');
520 * set the button names
522 $this->_searchButtonName
= $this->getButtonName('refresh');
523 $this->_actionButtonName
= $this->getButtonName('next', 'action');
525 $this->assign('actionButtonName', $this->_actionButtonName
);
527 // reset from session, CRM-3526
528 $session = CRM_Core_Session
::singleton();
529 if ($this->_force
&& $session->get('selectedSearchContactIds')) {
530 $session->resetScope('selectedSearchContactIds');
533 // if we dont get this from the url, use default if one exsts
534 $config = CRM_Core_Config
::singleton();
535 if ($this->_ufGroupID
== NULL &&
536 $config->defaultSearchProfileID
!= NULL
538 $this->_ufGroupID
= $config->defaultSearchProfileID
;
541 // assign context to drive the template display, make sure context is valid
542 $this->_context
= CRM_Utils_Request
::retrieve('context', 'String', $this, FALSE, 'search');
543 if (!CRM_Utils_Array
::value($this->_context
, self
::validContext())) {
544 $this->_context
= 'search';
546 $this->set('context', $this->_context
);
547 $this->assign('context', $this->_context
);
549 $this->_modeValue
= self
::getModeValue($this->_componentMode
);
550 $this->assign($this->_modeValue
);
552 $this->set('selectorName', self
::$_selectorName);
554 // get user submitted values
555 // get it from controller only if form has been submitted, else preProcess has set this
556 // $this->controller->isModal( ) returns TRUE if page is
557 // valid, i.e all the validations are TRUE
559 if (!empty($_POST) && !$this->controller
->isModal()) {
560 $this->_formValues
= $this->controller
->exportValues($this->_name
);
562 $this->normalizeFormValues();
563 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
564 $this->_returnProperties
= &$this->returnProperties();
566 // also get the uf group id directly from the post value
567 $this->_ufGroupID
= CRM_Utils_Array
::value('uf_group_id', $_POST, $this->_ufGroupID
);
568 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
569 $this->set('id', $this->_ufGroupID
);
571 // also get the object mode directly from the post value
572 $this->_componentMode
= CRM_Utils_Array
::value('component_mode', $_POST, $this->_componentMode
);
574 // also get the operator from the post value if set
575 $this->_operator
= CRM_Utils_Array
::value('operator', $_POST, $this->_operator
);
576 $this->_formValues
['operator'] = $this->_operator
;
577 $this->set('operator', $this->_operator
);
580 $this->_formValues
= $this->get('formValues');
581 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
582 $this->_returnProperties
= &$this->returnProperties();
583 if (!empty($this->_ufGroupID
)) {
584 $this->set('id', $this->_ufGroupID
);
588 if (empty($this->_formValues
)) {
589 //check if group is a smart group (fix for CRM-1255)
590 if ($this->_groupID
) {
591 if ($ssId = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'saved_search_id')) {
592 $this->_ssID
= $ssId;
597 if (isset($this->_ssID
) && $this->_context
!= 'smog') {
598 // we only retrieve the saved search values if out current values are null
599 $this->_formValues
= CRM_Contact_BAO_SavedSearch
::getFormValues($this->_ssID
);
602 if (CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID
, 'mapping_id')) {
603 $this->_params
= CRM_Contact_BAO_SavedSearch
::getSearchParams($this->_ssID
);
606 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
608 $this->_returnProperties
= &$this->returnProperties();
611 if (isset($this->_ufGroupID
)) {
612 // also set the uf group id if not already present
613 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
615 if (isset($this->_componentMode
)) {
616 $this->_formValues
['component_mode'] = $this->_componentMode
;
618 if (isset($this->_operator
)) {
619 $this->_formValues
['operator'] = $this->_operator
;
622 // FIXME: we should generalise in a way that components could inject url-filters
623 // just like they build their own form elements
626 'mailing_delivery_status',
627 'mailing_open_status',
628 'mailing_click_status',
629 'mailing_reply_status',
632 'mailing_unsubscribe',
635 ) as $mailingFilter) {
637 if ($mailingFilter == 'mailing_id' &&
638 $filterVal = CRM_Utils_Request
::retrieve('mailing_id', 'Positive', $this)
640 $this->_formValues
[$mailingFilter] = array($filterVal);
642 elseif ($filterVal = CRM_Utils_Request
::retrieve($mailingFilter, $type, $this)) {
643 $this->_formValues
[$mailingFilter] = $filterVal;
646 $this->_openedPanes
['Mailings'] = 1;
647 $this->_formValues
['hidden_CiviMail'] = 1;
653 CRM_Utils_Array
::value('uf_group_id', $this->_formValues
)
655 $operator = CRM_Utils_Array
::value('operator', $this->_formValues
, 'AND');
656 $this->set('queryOperator', $operator);
657 if ($operator == 'OR') {
658 $this->assign('operator', ts('OR'));
661 $this->assign('operator', ts('AND'));
664 // show the context menu only when we’re not searching for deleted contacts; CRM-5673
665 if (empty($this->_formValues
['deleted_contacts'])) {
666 $menuItems = CRM_Contact_BAO_Contact
::contextMenu();
667 $primaryActions = CRM_Utils_Array
::value('primaryActions', $menuItems, array());
668 $this->_contextMenu
= CRM_Utils_Array
::value('moreActions', $menuItems, array());
669 $this->assign('contextMenu', $primaryActions +
$this->_contextMenu
);
672 if (!isset($this->_componentMode
)) {
673 $this->_componentMode
= CRM_Contact_BAO_Query
::MODE_CONTACTS
;
675 $modeValues = self
::getModeValue($this->_componentMode
);
677 self
::$_selectorName = $this->_modeValue
['selectorName'];
680 if (strpos(self
::$_selectorName, 'CRM_Contact_Selector') !== FALSE) {
681 $selector = new self
::$_selectorName(
682 $this->_customSearchClass
,
685 $this->_returnProperties
,
694 $selector = new self
::$_selectorName(
702 $selector->setKey($this->controller
->_key
);
704 $controller = new CRM_Contact_Selector_Controller($selector,
705 $this->get(CRM_Utils_Pager
::PAGE_ID
),
706 $this->get(CRM_Utils_Sort
::SORT_ID
),
707 CRM_Core_Action
::VIEW
,
709 CRM_Core_Selector_Controller
::TRANSFER
711 $controller->setEmbedded(TRUE);
712 $controller->setDynamicAction($setDynamic);
716 $this->postProcess();
719 * Note that we repeat this, since the search creates and stores
720 * values that potentially change the controller behavior. i.e. things
721 * like totalCount etc
724 if ($this->get(CRM_Utils_Sort
::SORT_ID
)) {
725 $sortID = CRM_Utils_Sort
::sortIDValue($this->get(CRM_Utils_Sort
::SORT_ID
),
726 $this->get(CRM_Utils_Sort
::SORT_DIRECTION
)
729 $controller = new CRM_Contact_Selector_Controller($selector,
730 $this->get(CRM_Utils_Pager
::PAGE_ID
),
732 CRM_Core_Action
::VIEW
, $this, CRM_Core_Selector_Controller
::TRANSFER
734 $controller->setEmbedded(TRUE);
735 $controller->setDynamicAction($setDynamic);
738 $controller->moveFromSessionToTemplate();
744 public function &getFormValues() {
745 return $this->_formValues
;
749 * Common post processing.
753 public function postProcess() {
755 * sometime we do a postProcess early on, so we dont need to repeat it
756 * this will most likely introduce some more bugs :(
764 //for prev/next pagination
765 $crmPID = CRM_Utils_Request
::retrieve('crmPID', 'Integer', CRM_Core_DAO
::$_nullObject);
767 if (array_key_exists($this->_searchButtonName
, $_POST) ||
768 ($this->_force
&& !$crmPID)
770 //reset the cache table for new search
771 $cacheKey = "civicrm search {$this->controller->_key}";
772 CRM_Core_BAO_PrevNextCache
::deleteItem(NULL, $cacheKey);
775 //get the button name
776 $buttonName = $this->controller
->getButtonName();
778 if (isset($this->_ufGroupID
) && empty($this->_formValues
['uf_group_id'])) {
779 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
782 if (isset($this->_componentMode
) && empty($this->_formValues
['component_mode'])) {
783 $this->_formValues
['component_mode'] = $this->_componentMode
;
786 if (isset($this->_operator
) && empty($this->_formValues
['operator'])) {
787 $this->_formValues
['operator'] = $this->_operator
;
790 if (empty($this->_formValues
['qfKey'])) {
791 $this->_formValues
['qfKey'] = $this->controller
->_key
;
794 if (!CRM_Core_Permission
::check('access deleted contacts')) {
795 unset($this->_formValues
['deleted_contacts']);
798 $this->set('type', $this->_action
);
799 $this->set('formValues', $this->_formValues
);
800 $this->set('queryParams', $this->_params
);
801 $this->set('returnProperties', $this->_returnProperties
);
803 if ($buttonName == $this->_actionButtonName
) {
804 // check actionName and if next, then do not repeat a search, since we are going to the next page
805 // hack, make sure we reset the task values
806 $stateMachine = $this->controller
->getStateMachine();
807 $formName = $stateMachine->getTaskFormName();
808 $this->controller
->resetPage($formName);
812 $output = CRM_Core_Selector_Controller
::SESSION
;
814 // create the selector, controller and run - store results in session
815 $searchChildGroups = TRUE;
816 if ($this->get('isAdvanced')) {
817 $searchChildGroups = FALSE;
822 if (strpos(self
::$_selectorName, 'CRM_Contact_Selector') !== FALSE) {
823 $selector = new self
::$_selectorName(
824 $this->_customSearchClass
,
827 $this->_returnProperties
,
837 $selector = new self
::$_selectorName(
848 $selector->setKey($this->controller
->_key
);
850 // added the sorting character to the form array
851 $config = CRM_Core_Config
::singleton();
852 // do this only for contact search
853 if ($setDynamic && $config->includeAlphabeticalPager
) {
854 // Don't recompute if we are just paging/sorting
855 if ($this->_reset ||
(empty($_GET['crmPID']) && empty($_GET['crmSID']) && !$this->_sortByCharacter
)) {
856 $aToZBar = CRM_Utils_PagerAToZ
::getAToZBar($selector, $this->_sortByCharacter
);
857 $this->set('AToZBar', $aToZBar);
862 if ($this->get(CRM_Utils_Sort
::SORT_ID
)) {
863 $sortID = CRM_Utils_Sort
::sortIDValue($this->get(CRM_Utils_Sort
::SORT_ID
),
864 $this->get(CRM_Utils_Sort
::SORT_DIRECTION
)
867 $controller = new CRM_Contact_Selector_Controller($selector,
868 $this->get(CRM_Utils_Pager
::PAGE_ID
),
870 CRM_Core_Action
::VIEW
,
874 $controller->setEmbedded(TRUE);
875 $controller->setDynamicAction($setDynamic);
883 public function &returnProperties() {
884 return CRM_Core_DAO
::$_nullObject;
888 * Return a descriptive name for the page, used in wizard header
892 public function getTitle() {