3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2016 |
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-2016
35 * Base Search / View form for *all* listing of multiple
38 class CRM_Contact_Form_Search
extends CRM_Core_Form_Search
{
41 * list of valid contexts.
45 static $_validContext = NULL;
48 * List of values used when we want to display other objects.
52 static $_modeValues = NULL;
59 protected $_contextMenu;
62 * The groupId retrieved from the GET vars.
69 * The Group ID belonging to Add Member to group ID.
70 * retrieved from the GET vars
77 * The saved search ID retrieved from the GET vars.
89 public $_groupElement;
100 * The params used for search.
107 * The return properties used for search.
111 protected $_returnProperties;
114 * The sort by character.
118 protected $_sortByCharacter;
121 * The profile group id used for display.
125 protected $_ufGroupID;
128 * Csv - common search values
132 static $csv = array('contact_type', 'group', 'tag');
135 * @var string how to display the results. Should we display as
136 * contributons, members, cases etc
138 protected $_componentMode;
141 * @var string what operator should we use, AND or OR
143 protected $_operator;
145 protected $_modeValue;
148 * Declare entity reference fields as they will need to be converted to using 'IN'.
152 protected $entityReferenceFields = array('event_id', 'membership_type_id');
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 * Explicitly declare the entity api name.
166 public function getDefaultEntity() {
171 * Define the set of valid contexts that the search form operates on.
174 * the valid context set and the titles
176 public static function &validContext() {
177 if (!(self
::$_validContext)) {
178 self
::$_validContext = array(
179 'smog' => 'Show members of group',
180 'amtg' => 'Add members to group',
181 'basic' => 'Basic Search',
182 'search' => 'Search',
183 'builder' => 'Search Builder',
184 'advanced' => 'Advanced Search',
185 'custom' => 'Custom Search',
188 return self
::$_validContext;
196 public static function isSearchContext($context) {
197 $searchContext = CRM_Utils_Array
::value($context, self
::validContext());
198 return $searchContext ?
TRUE : FALSE;
201 public static function setModeValues() {
202 if (!self
::$_modeValues) {
203 self
::$_modeValues = array(
205 'selectorName' => self
::$_selectorName,
206 'selectorLabel' => ts('Contacts'),
207 'taskFile' => 'CRM/Contact/Form/Search/ResultTasks.tpl',
208 'taskContext' => NULL,
209 'resultFile' => 'CRM/Contact/Form/Selector.tpl',
210 'resultContext' => NULL,
211 'taskClassName' => 'CRM_Contact_Task',
214 'selectorName' => 'CRM_Contribute_Selector_Search',
215 'selectorLabel' => ts('Contributions'),
216 'taskFile' => 'CRM/common/searchResultTasks.tpl',
217 'taskContext' => 'Contribution',
218 'resultFile' => 'CRM/Contribute/Form/Selector.tpl',
219 'resultContext' => 'Search',
220 'taskClassName' => 'CRM_Contribute_Task',
223 'selectorName' => 'CRM_Event_Selector_Search',
224 'selectorLabel' => ts('Event Participants'),
225 'taskFile' => 'CRM/common/searchResultTasks.tpl',
226 'taskContext' => NULL,
227 'resultFile' => 'CRM/Event/Form/Selector.tpl',
228 'resultContext' => 'Search',
229 'taskClassName' => 'CRM_Event_Task',
232 'selectorName' => 'CRM_Activity_Selector_Search',
233 'selectorLabel' => ts('Activities'),
234 'taskFile' => 'CRM/common/searchResultTasks.tpl',
235 'taskContext' => NULL,
236 'resultFile' => 'CRM/Activity/Form/Selector.tpl',
237 'resultContext' => 'Search',
238 'taskClassName' => 'CRM_Activity_Task',
241 'selectorName' => 'CRM_Member_Selector_Search',
242 'selectorLabel' => ts('Memberships'),
243 'taskFile' => "CRM/common/searchResultTasks.tpl",
244 'taskContext' => NULL,
245 'resultFile' => 'CRM/Member/Form/Selector.tpl',
246 'resultContext' => 'Search',
247 'taskClassName' => 'CRM_Member_Task',
250 'selectorName' => 'CRM_Case_Selector_Search',
251 'selectorLabel' => ts('Cases'),
252 'taskFile' => "CRM/common/searchResultTasks.tpl",
253 'taskContext' => NULL,
254 'resultFile' => 'CRM/Case/Form/Selector.tpl',
255 'resultContext' => 'Search',
256 'taskClassName' => 'CRM_Case_Task',
259 'selectorName' => self
::$_selectorName,
260 'selectorLabel' => ts('Related Contacts'),
261 'taskFile' => 'CRM/Contact/Form/Search/ResultTasks.tpl',
262 'taskContext' => NULL,
263 'resultFile' => 'CRM/Contact/Form/Selector.tpl',
264 'resultContext' => NULL,
265 'taskClassName' => 'CRM_Contact_Task',
268 'selectorName' => 'CRM_Mailing_Selector_Search',
269 'selectorLabel' => ts('Mailings'),
270 'taskFile' => "CRM/common/searchResultTasks.tpl",
271 'taskContext' => NULL,
272 'resultFile' => 'CRM/Mailing/Form/Selector.tpl',
273 'resultContext' => 'Search',
274 'taskClassName' => 'CRM_Mailing_Task',
285 public static function getModeValue($mode = 1) {
286 self
::setModeValues();
288 if (!array_key_exists($mode, self
::$_modeValues)) {
292 return self
::$_modeValues[$mode];
298 public static function getModeSelect() {
299 self
::setModeValues();
302 foreach (self
::$_modeValues as $id => & $value) {
303 $select[$id] = $value['selectorLabel'];
306 // unset contributions or participants if user does not have
307 // permission on them
308 if (!CRM_Core_Permission
::access('CiviContribute')) {
312 if (!CRM_Core_Permission
::access('CiviEvent')) {
316 if (!CRM_Core_Permission
::check('view all activities')) {
323 * Builds the list of tasks or actions that a searcher can perform on a result set.
327 public function buildTaskList() {
328 if ($this->_context
!== 'amtg') {
329 $permission = CRM_Core_Permission
::getPermission();
331 if ($this->_componentMode
== 1 ||
$this->_componentMode
== 7) {
332 $this->_taskList +
= CRM_Contact_Task
::permissionedTaskTitles($permission,
333 CRM_Utils_Array
::value('deleted_contacts', $this->_formValues
)
337 $className = $this->_modeValue
['taskClassName'];
338 $this->_taskList +
= $className::permissionedTaskTitles($permission, FALSE);
341 // Only offer the "Update Smart Group" task if a smart group/saved search is already in play
342 if (isset($this->_ssID
) && $permission == CRM_Core_Permission
::EDIT
) {
343 $this->_taskList +
= CRM_Contact_Task
::optionalTaskTitle();
347 asort($this->_taskList
);
348 return $this->_taskList
;
352 * Build the common elements between the search/advanced form.
354 public function buildQuickForm() {
355 parent
::buildQuickForm();
356 CRM_Core_Resources
::singleton()
357 // jsTree is needed for tags popup
358 ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)
359 ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
360 $permission = CRM_Core_Permission
::getPermission();
361 // some tasks.. what do we want to do with the selected contacts ?
363 if ($this->_componentMode
== 1 ||
$this->_componentMode
== 7) {
364 $tasks +
= CRM_Contact_Task
::permissionedTaskTitles($permission,
365 CRM_Utils_Array
::value('deleted_contacts', $this->_formValues
)
369 $className = $this->_modeValue
['taskClassName'];
370 $tasks +
= $className::permissionedTaskTitles($permission, FALSE);
373 if (isset($this->_ssID
)) {
374 if ($permission == CRM_Core_Permission
::EDIT
) {
375 $tasks = $tasks + CRM_Contact_Task
::optionalTaskTitle();
379 = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID
, 'search_custom_id');
381 $savedSearchValues = array(
382 'id' => $this->_ssID
,
383 'name' => CRM_Contact_BAO_SavedSearch
::getName($this->_ssID
, 'title'),
384 'search_custom_id' => $search_custom_id,
386 $this->assign_by_ref('savedSearch', $savedSearchValues);
387 $this->assign('ssID', $this->_ssID
);
390 if ($this->_context
=== 'smog') {
391 // CRM-11788, we might want to do this for all of search where force=1
392 $formQFKey = CRM_Utils_Array
::value('qfKey', $this->_formValues
);
393 $getQFKey = CRM_Utils_Array
::value('qfKey', $_GET);
394 $postQFKey = CRM_Utils_Array
::value('qfKey', $_POST);
395 if ($formQFKey && empty($getQFKey) && empty($postQFKey)) {
396 $url = CRM_Utils_System
::makeURL('qfKey') . $formQFKey;
397 CRM_Utils_System
::redirect($url);
399 $permissionForGroup = FALSE;
401 if (!empty($this->_groupID
)) {
402 // check if user has permission to edit members of this group
403 $permission = CRM_Contact_BAO_Group
::checkPermission($this->_groupID
);
404 if ($permission && in_array(CRM_Core_Permission
::EDIT
, $permission)) {
405 $permissionForGroup = TRUE;
408 // check if _groupID exists, it might not if
409 // we are displaying a hidden group
410 if (!isset($this->_group
[$this->_groupID
])) {
411 $this->_group
[$this->_groupID
]
412 = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'title');
415 // set the group title
416 $groupValues = array('id' => $this->_groupID
, 'title' => $this->_group
[$this->_groupID
]);
417 $this->assign_by_ref('group', $groupValues);
419 // also set ssID if this is a saved search
420 $ssID = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'saved_search_id');
421 $this->assign('ssID', $ssID);
423 //get the saved search mapping id
425 $this->_ssID
= $ssID;
426 $ssMappingId = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $ssID, 'mapping_id');
427 $this->assign('ssMappingID', $ssMappingId);
430 // Set dynamic page title for 'Show Members of Group'
431 CRM_Utils_System
::setTitle(ts('Contacts in Group: %1', array(1 => $this->_group
[$this->_groupID
])));
434 $group_contact_status = array();
435 foreach (CRM_Core_SelectValues
::groupContactStatus() as $k => $v) {
437 $group_contact_status[] = $this->createElement('checkbox', $k, NULL, $v);
440 $this->addGroup($group_contact_status,
441 'group_contact_status', ts('Group Status')
444 $this->assign('permissionedForGroup', $permissionForGroup);
447 // add the go button for the action form, note it is of type 'next' rather than of type 'submit'
448 if ($this->_context
=== 'amtg') {
449 // check if _groupID exists, it might not if
450 // we are displaying a hidden group
451 if (!isset($this->_group
[$this->_amtgID
])) {
452 $this->assign('permissionedForGroup', FALSE);
453 $this->_group
[$this->_amtgID
]
454 = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_amtgID
, 'title');
457 // Set dynamic page title for 'Add Members Group'
458 CRM_Utils_System
::setTitle(ts('Add to Group: %1', array(1 => $this->_group
[$this->_amtgID
])));
459 // also set the group title and freeze the action task with Add Members to Group
460 $groupValues = array('id' => $this->_amtgID
, 'title' => $this->_group
[$this->_amtgID
]);
461 $this->assign_by_ref('group', $groupValues);
462 $this->add('submit', $this->_actionButtonName
, ts('Add Contacts to %1', array(1 => $this->_group
[$this->_amtgID
])),
464 'class' => 'crm-form-submit',
467 $this->add('hidden', 'task', CRM_Contact_Task
::GROUP_CONTACTS
);
468 $selectedRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked'));
469 $allRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all');
470 $this->assign('ts_sel_id', $selectedRowsRadio->_attributes
['id']);
471 $this->assign('ts_all_id', $allRowsRadio->_attributes
['id']);
474 $selectedContactIds = array();
475 $qfKeyParam = CRM_Utils_Array
::value('qfKey', $this->_formValues
);
476 // We use ajax to handle selections only if the search results component_mode is set to "contacts"
477 if ($qfKeyParam && ($this->get('component_mode') <= 1 ||
$this->get('component_mode') == 7)) {
478 $this->addClass('crm-ajax-selection-form');
479 $qfKeyParam = "civicrm search {$qfKeyParam}";
480 $selectedContactIdsArr = CRM_Core_BAO_PrevNextCache
::getSelection($qfKeyParam);
481 $selectedContactIds = array_keys($selectedContactIdsArr[$qfKeyParam]);
484 $this->assign_by_ref('selectedContactIds', $selectedContactIds);
486 $rows = $this->get('rows');
488 if (is_array($rows)) {
489 $this->addRowSelectors($rows);
495 * Processing needed for buildForm and later.
497 public function preProcess() {
498 // set the various class variables
500 $this->_group
= CRM_Core_PseudoConstant
::group();
502 $this->_tag
= CRM_Core_BAO_Tag
::getTags();
503 $this->_done
= FALSE;
506 * we allow the controller to set force/reset externally, useful when we are being
507 * driven by the wizard framework
510 $this->_reset
= CRM_Utils_Request
::retrieve('reset', 'Boolean',
511 CRM_Core_DAO
::$_nullObject
514 $this->_force
= CRM_Utils_Request
::retrieve('force', 'Boolean', CRM_Core_DAO
::$_nullObject);
515 $this->_groupID
= CRM_Utils_Request
::retrieve('gid', 'Positive', $this);
516 $this->_amtgID
= CRM_Utils_Request
::retrieve('amtgID', 'Positive', $this);
517 $this->_ssID
= CRM_Utils_Request
::retrieve('ssID', 'Positive', $this);
518 $this->_sortByCharacter
= CRM_Utils_Request
::retrieve('sortByCharacter', 'String', $this);
519 $this->_ufGroupID
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
520 $this->_componentMode
= CRM_Utils_Request
::retrieve('component_mode', 'Positive', $this, FALSE, 1, $_REQUEST);
521 $this->_operator
= CRM_Utils_Request
::retrieve('operator', 'String', $this, FALSE, 1, $_REQUEST, 'AND');
524 * set the button names
526 $this->_searchButtonName
= $this->getButtonName('refresh');
527 $this->_actionButtonName
= $this->getButtonName('next', 'action');
529 $this->assign('actionButtonName', $this->_actionButtonName
);
531 // reset from session, CRM-3526
532 $session = CRM_Core_Session
::singleton();
533 if ($this->_force
&& $session->get('selectedSearchContactIds')) {
534 $session->resetScope('selectedSearchContactIds');
537 // if we dont get this from the url, use default if one exsts
538 $config = CRM_Core_Config
::singleton();
539 if ($this->_ufGroupID
== NULL &&
540 $config->defaultSearchProfileID
!= NULL
542 $this->_ufGroupID
= $config->defaultSearchProfileID
;
545 // assign context to drive the template display, make sure context is valid
546 $this->_context
= CRM_Utils_Request
::retrieve('context', 'String', $this, FALSE, 'search');
547 if (!CRM_Utils_Array
::value($this->_context
, self
::validContext())) {
548 $this->_context
= 'search';
550 $this->set('context', $this->_context
);
551 $this->assign('context', $this->_context
);
553 $this->_modeValue
= self
::getModeValue($this->_componentMode
);
554 $this->assign($this->_modeValue
);
556 $this->set('selectorName', self
::$_selectorName);
558 // get user submitted values
559 // get it from controller only if form has been submitted, else preProcess has set this
560 // $this->controller->isModal( ) returns TRUE if page is
561 // valid, i.e all the validations are TRUE
563 if (!empty($_POST) && !$this->controller
->isModal()) {
564 $this->_formValues
= $this->controller
->exportValues($this->_name
);
566 $this->normalizeFormValues();
567 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
, 0, FALSE, NULL, $this->entityReferenceFields
);
568 $this->_returnProperties
= &$this->returnProperties();
570 // also get the uf group id directly from the post value
571 $this->_ufGroupID
= CRM_Utils_Array
::value('uf_group_id', $_POST, $this->_ufGroupID
);
572 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
573 $this->set('id', $this->_ufGroupID
);
575 // also get the object mode directly from the post value
576 $this->_componentMode
= CRM_Utils_Array
::value('component_mode', $_POST, $this->_componentMode
);
578 // also get the operator from the post value if set
579 $this->_operator
= CRM_Utils_Array
::value('operator', $_POST, $this->_operator
);
580 $this->_formValues
['operator'] = $this->_operator
;
581 $this->set('operator', $this->_operator
);
584 $this->_formValues
= $this->get('formValues');
585 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
, 0, FALSE, NULL, $this->entityReferenceFields
);
586 $this->_returnProperties
= &$this->returnProperties();
587 if (!empty($this->_ufGroupID
)) {
588 $this->set('id', $this->_ufGroupID
);
592 if (empty($this->_formValues
)) {
593 //check if group is a smart group (fix for CRM-1255)
594 if ($this->_groupID
) {
595 if ($ssId = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'saved_search_id')) {
596 $this->_ssID
= $ssId;
601 if (isset($this->_ssID
) && $this->_context
!= 'smog') {
602 // we only retrieve the saved search values if out current values are null
603 $this->_formValues
= CRM_Contact_BAO_SavedSearch
::getFormValues($this->_ssID
);
606 if (CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID
, 'mapping_id')) {
607 $this->_params
= CRM_Contact_BAO_SavedSearch
::getSearchParams($this->_ssID
);
610 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
612 $this->_returnProperties
= &$this->returnProperties();
615 if (isset($this->_ufGroupID
)) {
616 // also set the uf group id if not already present
617 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
619 if (isset($this->_componentMode
)) {
620 $this->_formValues
['component_mode'] = $this->_componentMode
;
622 if (isset($this->_operator
)) {
623 $this->_formValues
['operator'] = $this->_operator
;
626 // FIXME: we should generalise in a way that components could inject url-filters
627 // just like they build their own form elements
630 'mailing_delivery_status',
631 'mailing_open_status',
632 'mailing_click_status',
633 'mailing_reply_status',
636 'mailing_unsubscribe',
639 ) as $mailingFilter) {
641 if ($mailingFilter == 'mailing_id' &&
642 $filterVal = CRM_Utils_Request
::retrieve('mailing_id', 'Positive', $this)
644 $this->_formValues
[$mailingFilter] = array($filterVal);
646 elseif ($filterVal = CRM_Utils_Request
::retrieve($mailingFilter, $type, $this)) {
647 $this->_formValues
[$mailingFilter] = $filterVal;
650 $this->_openedPanes
['Mailings'] = 1;
651 $this->_formValues
['hidden_CiviMail'] = 1;
657 CRM_Utils_Array
::value('uf_group_id', $this->_formValues
)
659 $operator = CRM_Utils_Array
::value('operator', $this->_formValues
, 'AND');
660 $this->set('queryOperator', $operator);
661 if ($operator == 'OR') {
662 $this->assign('operator', ts('OR'));
665 $this->assign('operator', ts('AND'));
668 // show the context menu only when we’re not searching for deleted contacts; CRM-5673
669 if (empty($this->_formValues
['deleted_contacts'])) {
670 $menuItems = CRM_Contact_BAO_Contact
::contextMenu();
671 $primaryActions = CRM_Utils_Array
::value('primaryActions', $menuItems, array());
672 $this->_contextMenu
= CRM_Utils_Array
::value('moreActions', $menuItems, array());
673 $this->assign('contextMenu', $primaryActions +
$this->_contextMenu
);
676 if (!isset($this->_componentMode
)) {
677 $this->_componentMode
= CRM_Contact_BAO_Query
::MODE_CONTACTS
;
679 self
::setModeValues();
681 self
::$_selectorName = $this->_modeValue
['selectorName'];
684 if (strpos(self
::$_selectorName, 'CRM_Contact_Selector') !== FALSE) {
685 $selector = new self
::$_selectorName(
686 $this->_customSearchClass
,
689 $this->_returnProperties
,
698 $selector = new self
::$_selectorName(
706 $selector->setKey($this->controller
->_key
);
708 $controller = new CRM_Contact_Selector_Controller($selector,
709 $this->get(CRM_Utils_Pager
::PAGE_ID
),
710 $this->get(CRM_Utils_Sort
::SORT_ID
),
711 CRM_Core_Action
::VIEW
,
713 CRM_Core_Selector_Controller
::TRANSFER
715 $controller->setEmbedded(TRUE);
716 $controller->setDynamicAction($setDynamic);
720 $this->postProcess();
723 * Note that we repeat this, since the search creates and stores
724 * values that potentially change the controller behavior. i.e. things
725 * like totalCount etc
728 if ($this->get(CRM_Utils_Sort
::SORT_ID
)) {
729 $sortID = CRM_Utils_Sort
::sortIDValue($this->get(CRM_Utils_Sort
::SORT_ID
),
730 $this->get(CRM_Utils_Sort
::SORT_DIRECTION
)
733 $controller = new CRM_Contact_Selector_Controller($selector,
734 $this->get(CRM_Utils_Pager
::PAGE_ID
),
736 CRM_Core_Action
::VIEW
, $this, CRM_Core_Selector_Controller
::TRANSFER
738 $controller->setEmbedded(TRUE);
739 $controller->setDynamicAction($setDynamic);
742 $controller->moveFromSessionToTemplate();
748 public function &getFormValues() {
749 return $this->_formValues
;
753 * Common post processing.
755 public function postProcess() {
757 * sometime we do a postProcess early on, so we dont need to repeat it
758 * this will most likely introduce some more bugs :(
766 //for prev/next pagination
767 $crmPID = CRM_Utils_Request
::retrieve('crmPID', 'Integer', CRM_Core_DAO
::$_nullObject);
769 if (array_key_exists($this->_searchButtonName
, $_POST) ||
770 ($this->_force
&& !$crmPID)
772 //reset the cache table for new search
773 $cacheKey = "civicrm search {$this->controller->_key}";
774 CRM_Core_BAO_PrevNextCache
::deleteItem(NULL, $cacheKey);
777 //get the button name
778 $buttonName = $this->controller
->getButtonName();
780 if (isset($this->_ufGroupID
) && empty($this->_formValues
['uf_group_id'])) {
781 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
784 if (isset($this->_componentMode
) && empty($this->_formValues
['component_mode'])) {
785 $this->_formValues
['component_mode'] = $this->_componentMode
;
788 if (isset($this->_operator
) && empty($this->_formValues
['operator'])) {
789 $this->_formValues
['operator'] = $this->_operator
;
792 if (empty($this->_formValues
['qfKey'])) {
793 $this->_formValues
['qfKey'] = $this->controller
->_key
;
796 if (!CRM_Core_Permission
::check('access deleted contacts')) {
797 unset($this->_formValues
['deleted_contacts']);
800 $this->set('type', $this->_action
);
801 $this->set('formValues', $this->_formValues
);
802 $this->set('queryParams', $this->_params
);
803 $this->set('returnProperties', $this->_returnProperties
);
805 if ($buttonName == $this->_actionButtonName
) {
806 // check actionName and if next, then do not repeat a search, since we are going to the next page
807 // hack, make sure we reset the task values
808 $stateMachine = $this->controller
->getStateMachine();
809 $formName = $stateMachine->getTaskFormName();
810 $this->controller
->resetPage($formName);
814 $output = CRM_Core_Selector_Controller
::SESSION
;
816 // create the selector, controller and run - store results in session
817 $searchChildGroups = TRUE;
818 if ($this->get('isAdvanced')) {
819 $searchChildGroups = FALSE;
824 if (strpos(self
::$_selectorName, 'CRM_Contact_Selector') !== FALSE) {
825 $selector = new self
::$_selectorName(
826 $this->_customSearchClass
,
829 $this->_returnProperties
,
839 $selector = new self
::$_selectorName(
850 $selector->setKey($this->controller
->_key
);
852 // added the sorting character to the form array
853 $config = CRM_Core_Config
::singleton();
854 // do this only for contact search
855 if ($setDynamic && $config->includeAlphabeticalPager
) {
856 // Don't recompute if we are just paging/sorting
857 if ($this->_reset ||
(empty($_GET['crmPID']) && empty($_GET['crmSID']) && !$this->_sortByCharacter
)) {
858 $aToZBar = CRM_Utils_PagerAToZ
::getAToZBar($selector, $this->_sortByCharacter
);
859 $this->set('AToZBar', $aToZBar);
864 if ($this->get(CRM_Utils_Sort
::SORT_ID
)) {
865 $sortID = CRM_Utils_Sort
::sortIDValue($this->get(CRM_Utils_Sort
::SORT_ID
),
866 $this->get(CRM_Utils_Sort
::SORT_DIRECTION
)
869 $controller = new CRM_Contact_Selector_Controller($selector,
870 $this->get(CRM_Utils_Pager
::PAGE_ID
),
872 CRM_Core_Action
::VIEW
,
876 $controller->setEmbedded(TRUE);
877 $controller->setDynamicAction($setDynamic);
885 public function &returnProperties() {
886 return CRM_Core_DAO
::$_nullObject;
890 * Return a descriptive name for the page, used in wizard header
894 public function getTitle() {