3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
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;
67 protected $_contextMenu;
70 * The groupId retrieved from the GET vars
77 * The Group ID belonging to Add Member to group ID
78 * retrieved from the GET vars
85 * The saved search ID retrieved from the GET vars
97 public $_groupElement;
98 public $_groupIterator;
109 * The params used for search
116 * The return properties used for search
120 protected $_returnProperties;
123 * The sort by character
127 protected $_sortByCharacter;
130 * The profile group id used for display
134 protected $_ufGroupID;
137 * Csv - common search values
142 static $csv = array('contact_type', 'group', 'tag');
145 * @var string how to display the results. Should we display as
146 * contributons, members, cases etc
148 protected $_componentMode;
151 * @var string what operator should we use, AND or OR
153 protected $_operator;
155 protected $_modeValue;
158 * Name of the selector to use
160 static $_selectorName = 'CRM_Contact_Selector';
161 protected $_customSearchID = NULL;
162 protected $_customSearchClass = NULL;
164 protected $_openedPanes = array();
167 * Define the set of valid contexts that the search form operates on
169 * @return array the valid context set and the titles
172 public static function &validContext() {
173 if (!(self
::$_validContext)) {
174 self
::$_validContext = array(
175 'smog' => 'Show members of group',
176 'amtg' => 'Add members to group',
177 'basic' => 'Basic Search',
178 'search' => 'Search',
179 'builder' => 'Search Builder',
180 'advanced' => 'Advanced Search',
181 'custom' => 'Custom Search',
184 return self
::$_validContext;
192 public static function isSearchContext($context) {
193 $searchContext = CRM_Utils_Array
::value($context, self
::validContext());
194 return $searchContext ?
TRUE : FALSE;
197 public static function setModeValues() {
198 if (!self
::$_modeValues) {
199 self
::$_modeValues = array(
201 'selectorName' => self
::$_selectorName,
202 'selectorLabel' => ts('Contacts'),
203 'taskFile' => 'CRM/Contact/Form/Search/ResultTasks.tpl',
204 'taskContext' => NULL,
205 'resultFile' => 'CRM/Contact/Form/Selector.tpl',
206 'resultContext' => NULL,
207 'taskClassName' => 'CRM_Contact_Task',
210 'selectorName' => 'CRM_Contribute_Selector_Search',
211 'selectorLabel' => ts('Contributions'),
212 'taskFile' => 'CRM/common/searchResultTasks.tpl',
213 'taskContext' => 'Contribution',
214 'resultFile' => 'CRM/Contribute/Form/Selector.tpl',
215 'resultContext' => 'Search',
216 'taskClassName' => 'CRM_Contribute_Task',
219 'selectorName' => 'CRM_Event_Selector_Search',
220 'selectorLabel' => ts('Event Participants'),
221 'taskFile' => 'CRM/common/searchResultTasks.tpl',
222 'taskContext' => NULL,
223 'resultFile' => 'CRM/Event/Form/Selector.tpl',
224 'resultContext' => 'Search',
225 'taskClassName' => 'CRM_Event_Task',
228 'selectorName' => 'CRM_Activity_Selector_Search',
229 'selectorLabel' => ts('Activities'),
230 'taskFile' => 'CRM/common/searchResultTasks.tpl',
231 'taskContext' => NULL,
232 'resultFile' => 'CRM/Activity/Form/Selector.tpl',
233 'resultContext' => 'Search',
234 'taskClassName' => 'CRM_Activity_Task',
237 'selectorName' => 'CRM_Member_Selector_Search',
238 'selectorLabel' => ts('Memberships'),
239 'taskFile' => "CRM/common/searchResultTasks.tpl",
240 'taskContext' => NULL,
241 'resultFile' => 'CRM/Member/Form/Selector.tpl',
242 'resultContext' => 'Search',
243 'taskClassName' => 'CRM_Member_Task',
246 'selectorName' => 'CRM_Case_Selector_Search',
247 'selectorLabel' => ts('Cases'),
248 'taskFile' => "CRM/common/searchResultTasks.tpl",
249 'taskContext' => NULL,
250 'resultFile' => 'CRM/Case/Form/Selector.tpl',
251 'resultContext' => 'Search',
252 'taskClassName' => 'CRM_Case_Task',
255 'selectorName' => self
::$_selectorName,
256 'selectorLabel' => ts('Related Contacts'),
257 'taskFile' => 'CRM/Contact/Form/Search/ResultTasks.tpl',
258 'taskContext' => NULL,
259 'resultFile' => 'CRM/Contact/Form/Selector.tpl',
260 'resultContext' => NULL,
261 'taskClassName' => 'CRM_Contact_Task',
264 'selectorName' => 'CRM_Mailing_Selector_Search',
265 'selectorLabel' => ts('Mailings'),
266 'taskFile' => "CRM/common/searchResultTasks.tpl",
267 'taskContext' => NULL,
268 'resultFile' => 'CRM/Mailing/Form/Selector.tpl',
269 'resultContext' => 'Search',
270 'taskClassName' => 'CRM_Mailing_Task',
281 public static function getModeValue($mode = 1) {
282 self
::setModeValues();
284 if (!array_key_exists($mode, self
::$_modeValues)) {
288 return self
::$_modeValues[$mode];
294 public static function getModeSelect() {
295 self
::setModeValues();
298 foreach (self
::$_modeValues as $id => & $value) {
299 $select[$id] = $value['selectorLabel'];
302 // unset contributions or participants if user does not have
303 // permission on them
304 if (!CRM_Core_Permission
::access('CiviContribute')) {
308 if (!CRM_Core_Permission
::access('CiviEvent')) {
312 if (!CRM_Core_Permission
::check('view all activities')) {
319 * Build the common elements between the search/advanced form
324 public function buildQuickForm() {
325 parent
::buildQuickForm();
326 CRM_Core_Resources
::singleton()
327 // jsTree is needed for tags popup
328 ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)
329 ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
330 $permission = CRM_Core_Permission
::getPermission();
331 // some tasks.. what do we want to do with the selected contacts ?
333 if ($this->_componentMode
== 1 ||
$this->_componentMode
== 7) {
334 $tasks +
= CRM_Contact_Task
::permissionedTaskTitles($permission,
335 CRM_Utils_Array
::value('deleted_contacts', $this->_formValues
)
339 $className = $this->_modeValue
['taskClassName'];
340 $tasks +
= $className::permissionedTaskTitles($permission, FALSE);
343 if (isset($this->_ssID
)) {
344 if ($permission == CRM_Core_Permission
::EDIT
) {
345 $tasks = $tasks + CRM_Contact_Task
::optionalTaskTitle();
349 CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID
, 'search_custom_id');
351 $savedSearchValues = array(
352 'id' => $this->_ssID
,
353 'name' => CRM_Contact_BAO_SavedSearch
::getName($this->_ssID
, 'title'),
354 'search_custom_id' => $search_custom_id,
356 $this->assign_by_ref('savedSearch', $savedSearchValues);
357 $this->assign('ssID', $this->_ssID
);
360 if ($this->_context
=== 'smog') {
361 // CRM-11788, we might want to do this for all of search where force=1
362 $formQFKey = CRM_Utils_Array
::value('qfKey', $this->_formValues
);
363 $getQFKey = CRM_Utils_Array
::value('qfKey', $_GET);
364 $postQFKey = CRM_Utils_Array
::value('qfKey', $_POST);
365 if ($formQFKey && empty($getQFKey) && empty($postQFKey)) {
366 $url = CRM_Utils_System
::makeURL('qfKey') . $formQFKey;
367 CRM_Utils_System
::redirect($url);
369 $permissionForGroup = FALSE;
371 if (!empty($this->_groupID
)) {
372 // check if user has permission to edit members of this group
373 $permission = CRM_Contact_BAO_Group
::checkPermission($this->_groupID
);
374 if ($permission && in_array(CRM_Core_Permission
::EDIT
, $permission)) {
375 $permissionForGroup = TRUE;
378 // check if _groupID exists, it might not if
379 // we are displaying a hidden group
380 if (!isset($this->_group
[$this->_groupID
])) {
381 $this->_group
[$this->_groupID
] =
382 CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'title');
385 // set the group title
386 $groupValues = array('id' => $this->_groupID
, 'title' => $this->_group
[$this->_groupID
]);
387 $this->assign_by_ref('group', $groupValues);
389 // also set ssID if this is a saved search
390 $ssID = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'saved_search_id');
391 $this->assign('ssID', $ssID);
393 //get the saved search mapping id
395 $this->_ssID
= $ssID;
396 $ssMappingId = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $ssID, 'mapping_id');
397 $this->assign('ssMappingID', $ssMappingId);
400 // Set dynamic page title for 'Show Members of Group'
401 CRM_Utils_System
::setTitle(ts('Contacts in Group: %1', array(1 => $this->_group
[$this->_groupID
])));
404 $group_contact_status = array();
405 foreach (CRM_Core_SelectValues
::groupContactStatus() as $k => $v) {
407 $group_contact_status[] = $this->createElement('checkbox', $k, NULL, $v);
410 $this->addGroup($group_contact_status,
411 'group_contact_status', ts('Group Status')
414 $this->assign('permissionedForGroup', $permissionForGroup);
417 // add the go button for the action form, note it is of type 'next' rather than of type 'submit'
418 if ($this->_context
=== 'amtg') {
419 // check if _groupID exists, it might not if
420 // we are displaying a hidden group
421 if (!isset($this->_group
[$this->_amtgID
])) {
422 $this->assign('permissionedForGroup', FALSE);
423 $this->_group
[$this->_amtgID
] =
424 CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_amtgID
, 'title');
427 // Set dynamic page title for 'Add Members Group'
428 CRM_Utils_System
::setTitle(ts('Add to Group: %1', array(1 => $this->_group
[$this->_amtgID
])));
429 // also set the group title and freeze the action task with Add Members to Group
430 $groupValues = array('id' => $this->_amtgID
, 'title' => $this->_group
[$this->_amtgID
]);
431 $this->assign_by_ref('group', $groupValues);
432 $this->add('submit', $this->_actionButtonName
, ts('Add Contacts to %1', array(1 => $this->_group
[$this->_amtgID
])),
434 'class' => 'crm-form-submit',
437 $this->add('hidden', 'task', CRM_Contact_Task
::GROUP_CONTACTS
);
438 $selectedRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked'));
439 $allRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all');
440 $this->assign('ts_sel_id', $selectedRowsRadio->_attributes
['id']);
441 $this->assign('ts_all_id', $allRowsRadio->_attributes
['id']);
444 $this->addTaskMenu($tasks);
447 $selectedContactIds = array();
448 $qfKeyParam = CRM_Utils_Array
::value('qfKey', $this->_formValues
);
449 // We use ajax to handle selections only if the search results component_mode is set to "contacts"
450 if ($qfKeyParam && ($this->get('component_mode') <= 1 ||
$this->get('component_mode') == 7)) {
451 $this->addClass('crm-ajax-selection-form');
452 $qfKeyParam = "civicrm search {$qfKeyParam}";
453 $selectedContactIdsArr = CRM_Core_BAO_PrevNextCache
::getSelection($qfKeyParam);
454 $selectedContactIds = array_keys($selectedContactIdsArr[$qfKeyParam]);
457 $this->assign_by_ref('selectedContactIds', $selectedContactIds);
459 $rows = $this->get('rows');
461 if (is_array($rows)) {
462 $this->addRowSelectors($rows);
468 * Processing needed for buildForm and later
472 public function preProcess() {
473 // set the various class variables
475 $this->_group
= CRM_Core_PseudoConstant
::group();
477 $this->_groupIterator
= CRM_Core_PseudoConstant
::groupIterator();
478 $this->_tag
= CRM_Core_BAO_Tag
::getTags();
479 $this->_done
= FALSE;
482 * we allow the controller to set force/reset externally, useful when we are being
483 * driven by the wizard framework
486 $this->_reset
= CRM_Utils_Request
::retrieve('reset', 'Boolean',
487 CRM_Core_DAO
::$_nullObject
490 $this->_force
= CRM_Utils_Request
::retrieve('force', 'Boolean', CRM_Core_DAO
::$_nullObject);
491 $this->_groupID
= CRM_Utils_Request
::retrieve('gid', 'Positive', $this);
492 $this->_amtgID
= CRM_Utils_Request
::retrieve('amtgID', 'Positive', $this);
493 $this->_ssID
= CRM_Utils_Request
::retrieve('ssID', 'Positive', $this);
494 $this->_sortByCharacter
= CRM_Utils_Request
::retrieve('sortByCharacter', 'String', $this);
495 $this->_ufGroupID
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
496 $this->_componentMode
= CRM_Utils_Request
::retrieve('component_mode', 'Positive', $this, FALSE, 1, $_REQUEST);
497 $this->_operator
= CRM_Utils_Request
::retrieve('operator', 'String', $this, FALSE, 1, $_REQUEST, 'AND');
500 * set the button names
502 $this->_searchButtonName
= $this->getButtonName('refresh');
503 $this->_actionButtonName
= $this->getButtonName('next', 'action');
505 $this->assign('actionButtonName', $this->_actionButtonName
);
507 // reset from session, CRM-3526
508 $session = CRM_Core_Session
::singleton();
509 if ($this->_force
&& $session->get('selectedSearchContactIds')) {
510 $session->resetScope('selectedSearchContactIds');
513 // if we dont get this from the url, use default if one exsts
514 $config = CRM_Core_Config
::singleton();
515 if ($this->_ufGroupID
== NULL &&
516 $config->defaultSearchProfileID
!= NULL
518 $this->_ufGroupID
= $config->defaultSearchProfileID
;
521 // assign context to drive the template display, make sure context is valid
522 $this->_context
= CRM_Utils_Request
::retrieve('context', 'String', $this, FALSE, 'search');
523 if (!CRM_Utils_Array
::value($this->_context
, self
::validContext())) {
524 $this->_context
= 'search';
526 $this->set('context', $this->_context
);
527 $this->assign('context', $this->_context
);
529 $this->_modeValue
= self
::getModeValue($this->_componentMode
);
530 $this->assign($this->_modeValue
);
532 $this->set('selectorName', self
::$_selectorName);
534 // get user submitted values
535 // get it from controller only if form has been submitted, else preProcess has set this
536 // $this->controller->isModal( ) returns TRUE if page is
537 // valid, i.e all the validations are TRUE
539 if (!empty($_POST) && !$this->controller
->isModal()) {
540 $this->_formValues
= $this->controller
->exportValues($this->_name
);
542 $this->normalizeFormValues();
543 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
544 $this->_returnProperties
= &$this->returnProperties();
546 // also get the uf group id directly from the post value
547 $this->_ufGroupID
= CRM_Utils_Array
::value('uf_group_id', $_POST, $this->_ufGroupID
);
548 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
549 $this->set('id', $this->_ufGroupID
);
551 // also get the object mode directly from the post value
552 $this->_componentMode
= CRM_Utils_Array
::value('component_mode', $_POST, $this->_componentMode
);
554 // also get the operator from the post value if set
555 $this->_operator
= CRM_Utils_Array
::value('operator', $_POST, $this->_operator
);
556 $this->_formValues
['operator'] = $this->_operator
;
557 $this->set('operator', $this->_operator
);
560 $this->_formValues
= $this->get('formValues');
561 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
562 $this->_returnProperties
= &$this->returnProperties();
563 if (!empty($this->_ufGroupID
)) {
564 $this->set('id', $this->_ufGroupID
);
568 if (empty($this->_formValues
)) {
569 //check if group is a smart group (fix for CRM-1255)
570 if ($this->_groupID
) {
571 if ($ssId = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'saved_search_id')) {
572 $this->_ssID
= $ssId;
577 if (isset($this->_ssID
) && $this->_context
!= 'smog') {
578 // we only retrieve the saved search values if out current values are null
579 $this->_formValues
= CRM_Contact_BAO_SavedSearch
::getFormValues($this->_ssID
);
582 if (CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID
, 'mapping_id')) {
583 $this->_params
= CRM_Contact_BAO_SavedSearch
::getSearchParams($this->_ssID
);
586 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
588 $this->_returnProperties
= &$this->returnProperties();
591 if (isset($this->_ufGroupID
)) {
592 // also set the uf group id if not already present
593 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
595 if (isset($this->_componentMode
)) {
596 $this->_formValues
['component_mode'] = $this->_componentMode
;
598 if (isset($this->_operator
)) {
599 $this->_formValues
['operator'] = $this->_operator
;
602 // FIXME: we should generalise in a way that components could inject url-filters
603 // just like they build their own form elements
605 'mailing_id', 'mailing_delivery_status', 'mailing_open_status',
606 'mailing_click_status', 'mailing_reply_status', 'mailing_optout',
607 'mailing_forward', 'mailing_unsubscribe', 'mailing_date_low',
609 ) as $mailingFilter) {
611 if ($mailingFilter == 'mailing_id' &&
612 $filterVal = CRM_Utils_Request
::retrieve('mailing_id', 'Positive', $this)
614 $this->_formValues
[$mailingFilter] = array($filterVal);
616 elseif ($filterVal = CRM_Utils_Request
::retrieve($mailingFilter, $type, $this)) {
617 $this->_formValues
[$mailingFilter] = $filterVal;
620 $this->_openedPanes
['Mailings'] = 1;
621 $this->_formValues
['hidden_CiviMail'] = 1;
627 CRM_Utils_Array
::value('uf_group_id', $this->_formValues
)
629 $operator = CRM_Utils_Array
::value('operator', $this->_formValues
, 'AND');
630 $this->set('queryOperator', $operator);
631 if ($operator == 'OR') {
632 $this->assign('operator', ts('OR'));
635 $this->assign('operator', ts('AND'));
638 // show the context menu only when we’re not searching for deleted contacts; CRM-5673
639 if (empty($this->_formValues
['deleted_contacts'])) {
640 $menuItems = CRM_Contact_BAO_Contact
::contextMenu();
641 $primaryActions = CRM_Utils_Array
::value('primaryActions', $menuItems, array());
642 $this->_contextMenu
= CRM_Utils_Array
::value('moreActions', $menuItems, array());
643 $this->assign('contextMenu', $primaryActions +
$this->_contextMenu
);
646 if (!isset($this->_componentMode
)) {
647 $this->_componentMode
= CRM_Contact_BAO_Query
::MODE_CONTACTS
;
649 $modeValues = self
::getModeValue($this->_componentMode
);
651 self
::$_selectorName = $this->_modeValue
['selectorName'];
654 if (strpos(self
::$_selectorName, 'CRM_Contact_Selector') !== FALSE) {
655 $selector = new self
::$_selectorName(
656 $this->_customSearchClass
,
659 $this->_returnProperties
,
668 $selector = new self
::$_selectorName(
676 $selector->setKey($this->controller
->_key
);
678 $controller = new CRM_Contact_Selector_Controller($selector,
679 $this->get(CRM_Utils_Pager
::PAGE_ID
),
680 $this->get(CRM_Utils_Sort
::SORT_ID
),
681 CRM_Core_Action
::VIEW
,
683 CRM_Core_Selector_Controller
::TRANSFER
685 $controller->setEmbedded(TRUE);
686 $controller->setDynamicAction($setDynamic);
690 $this->postProcess();
693 * Note that we repeat this, since the search creates and stores
694 * values that potentially change the controller behavior. i.e. things
695 * like totalCount etc
698 if ($this->get(CRM_Utils_Sort
::SORT_ID
)) {
699 $sortID = CRM_Utils_Sort
::sortIDValue($this->get(CRM_Utils_Sort
::SORT_ID
),
700 $this->get(CRM_Utils_Sort
::SORT_DIRECTION
)
703 $controller = new CRM_Contact_Selector_Controller($selector,
704 $this->get(CRM_Utils_Pager
::PAGE_ID
),
706 CRM_Core_Action
::VIEW
, $this, CRM_Core_Selector_Controller
::TRANSFER
708 $controller->setEmbedded(TRUE);
709 $controller->setDynamicAction($setDynamic);
712 $controller->moveFromSessionToTemplate();
718 public function &getFormValues() {
719 return $this->_formValues
;
723 * Common post processing
727 public function postProcess() {
729 * sometime we do a postProcess early on, so we dont need to repeat it
730 * this will most likely introduce some more bugs :(
738 //for prev/next pagination
739 $crmPID = CRM_Utils_Request
::retrieve('crmPID', 'Integer', CRM_Core_DAO
::$_nullObject);
741 if (array_key_exists($this->_searchButtonName
, $_POST) ||
742 ($this->_force
&& !$crmPID)) {
743 //reset the cache table for new search
744 $cacheKey = "civicrm search {$this->controller->_key}";
745 CRM_Core_BAO_PrevNextCache
::deleteItem(NULL, $cacheKey);
748 //get the button name
749 $buttonName = $this->controller
->getButtonName();
751 if (isset($this->_ufGroupID
) && empty($this->_formValues
['uf_group_id'])) {
752 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
755 if (isset($this->_componentMode
) && empty($this->_formValues
['component_mode'])) {
756 $this->_formValues
['component_mode'] = $this->_componentMode
;
759 if (isset($this->_operator
) && empty($this->_formValues
['operator'])) {
760 $this->_formValues
['operator'] = $this->_operator
;
763 if (empty($this->_formValues
['qfKey'])) {
764 $this->_formValues
['qfKey'] = $this->controller
->_key
;
767 if (!CRM_Core_Permission
::check('access deleted contacts')) {
768 unset($this->_formValues
['deleted_contacts']);
771 $this->set('type', $this->_action
);
772 $this->set('formValues', $this->_formValues
);
773 $this->set('queryParams', $this->_params
);
774 $this->set('returnProperties', $this->_returnProperties
);
776 if ($buttonName == $this->_actionButtonName
) {
777 // check actionName and if next, then do not repeat a search, since we are going to the next page
778 // hack, make sure we reset the task values
779 $stateMachine = $this->controller
->getStateMachine();
780 $formName = $stateMachine->getTaskFormName();
781 $this->controller
->resetPage($formName);
785 $output = CRM_Core_Selector_Controller
::SESSION
;
787 // create the selector, controller and run - store results in session
788 $searchChildGroups = TRUE;
789 if ($this->get('isAdvanced')) {
790 $searchChildGroups = FALSE;
795 if (strpos(self
::$_selectorName, 'CRM_Contact_Selector') !== FALSE) {
796 $selector = new self
::$_selectorName (
797 $this->_customSearchClass
,
800 $this->_returnProperties
,
810 $selector = new self
::$_selectorName(
821 $selector->setKey($this->controller
->_key
);
823 // added the sorting character to the form array
824 $config = CRM_Core_Config
::singleton();
825 // do this only for contact search
826 if ($setDynamic && $config->includeAlphabeticalPager
) {
827 // Don't recompute if we are just paging/sorting
828 if ($this->_reset ||
(empty($_GET['crmPID']) && empty($_GET['crmSID']) && !$this->_sortByCharacter
)) {
829 $aToZBar = CRM_Utils_PagerAToZ
::getAToZBar($selector, $this->_sortByCharacter
);
830 $this->set('AToZBar', $aToZBar);
835 if ($this->get(CRM_Utils_Sort
::SORT_ID
)) {
836 $sortID = CRM_Utils_Sort
::sortIDValue($this->get(CRM_Utils_Sort
::SORT_ID
),
837 $this->get(CRM_Utils_Sort
::SORT_DIRECTION
)
840 $controller = new CRM_Contact_Selector_Controller($selector,
841 $this->get(CRM_Utils_Pager
::PAGE_ID
),
843 CRM_Core_Action
::VIEW
,
847 $controller->setEmbedded(TRUE);
848 $controller->setDynamicAction($setDynamic);
856 public function &returnProperties() {
857 return CRM_Core_DAO
::$_nullObject;
861 * Return a descriptive name for the page, used in wizard header
865 public function getTitle() {