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;
68 protected $_contextMenu;
71 * The groupId retrieved from the GET vars
79 * The Group ID belonging to Add Member to group ID
80 * retrieved from the GET vars
88 * The saved search ID retrieved from the GET vars
102 public $_groupElement;
103 public $_groupIterator;
115 * The params used for search
123 * The return properties used for search
128 protected $_returnProperties;
131 * The sort by character
136 protected $_sortByCharacter;
139 * The profile group id used for display
144 protected $_ufGroupID;
147 * Csv - common search values
153 static $csv = array('contact_type', 'group', 'tag');
156 * @var string how to display the results. Should we display as
157 * contributons, members, cases etc
159 protected $_componentMode;
162 * @var string what operator should we use, AND or OR
164 protected $_operator;
166 protected $_modeValue;
169 * Name of the selector to use
171 static $_selectorName = 'CRM_Contact_Selector';
172 protected $_customSearchID = NULL;
173 protected $_customSearchClass = NULL;
175 protected $_openedPanes = array();
178 * Define the set of valid contexts that the search form operates on
180 * @return array the valid context set and the titles
184 static function &validContext() {
185 if (!(self
::$_validContext)) {
186 self
::$_validContext = array(
187 'smog' => 'Show members of group',
188 'amtg' => 'Add members to group',
189 'basic' => 'Basic Search',
190 'search' => 'Search',
191 'builder' => 'Search Builder',
192 'advanced' => 'Advanced Search',
193 'custom' => 'Custom Search',
196 return self
::$_validContext;
204 static function isSearchContext($context) {
205 $searchContext = CRM_Utils_Array
::value($context, self
::validContext());
206 return $searchContext ?
TRUE : FALSE;
209 static function setModeValues() {
210 if (!self
::$_modeValues) {
211 self
::$_modeValues = array(
213 'selectorName' => self
::$_selectorName,
214 'selectorLabel' => ts('Contacts'),
215 'taskFile' => 'CRM/Contact/Form/Search/ResultTasks.tpl',
216 'taskContext' => NULL,
217 'resultFile' => 'CRM/Contact/Form/Selector.tpl',
218 'resultContext' => NULL,
219 'taskClassName' => 'CRM_Contact_Task',
222 'selectorName' => 'CRM_Contribute_Selector_Search',
223 'selectorLabel' => ts('Contributions'),
224 'taskFile' => 'CRM/common/searchResultTasks.tpl',
225 'taskContext' => 'Contribution',
226 'resultFile' => 'CRM/Contribute/Form/Selector.tpl',
227 'resultContext' => 'Search',
228 'taskClassName' => 'CRM_Contribute_Task',
231 'selectorName' => 'CRM_Event_Selector_Search',
232 'selectorLabel' => ts('Event Participants'),
233 'taskFile' => 'CRM/common/searchResultTasks.tpl',
234 'taskContext' => NULL,
235 'resultFile' => 'CRM/Event/Form/Selector.tpl',
236 'resultContext' => 'Search',
237 'taskClassName' => 'CRM_Event_Task',
240 'selectorName' => 'CRM_Activity_Selector_Search',
241 'selectorLabel' => ts('Activities'),
242 'taskFile' => 'CRM/common/searchResultTasks.tpl',
243 'taskContext' => NULL,
244 'resultFile' => 'CRM/Activity/Form/Selector.tpl',
245 'resultContext' => 'Search',
246 'taskClassName' => 'CRM_Activity_Task',
249 'selectorName' => 'CRM_Member_Selector_Search',
250 'selectorLabel' => ts('Memberships'),
251 'taskFile' => "CRM/common/searchResultTasks.tpl",
252 'taskContext' => NULL,
253 'resultFile' => 'CRM/Member/Form/Selector.tpl',
254 'resultContext' => 'Search',
255 'taskClassName' => 'CRM_Member_Task',
258 'selectorName' => 'CRM_Case_Selector_Search',
259 'selectorLabel' => ts('Cases'),
260 'taskFile' => "CRM/common/searchResultTasks.tpl",
261 'taskContext' => NULL,
262 'resultFile' => 'CRM/Case/Form/Selector.tpl',
263 'resultContext' => 'Search',
264 'taskClassName' => 'CRM_Case_Task',
267 'selectorName' => self
::$_selectorName,
268 'selectorLabel' => ts('Related Contacts'),
269 'taskFile' => 'CRM/Contact/Form/Search/ResultTasks.tpl',
270 'taskContext' => NULL,
271 'resultFile' => 'CRM/Contact/Form/Selector.tpl',
272 'resultContext' => NULL,
273 'taskClassName' => 'CRM_Contact_Task',
276 'selectorName' => 'CRM_Mailing_Selector_Search',
277 'selectorLabel' => ts('Mailings'),
278 'taskFile' => "CRM/common/searchResultTasks.tpl",
279 'taskContext' => NULL,
280 'resultFile' => 'CRM/Mailing/Form/Selector.tpl',
281 'resultContext' => 'Search',
282 'taskClassName' => 'CRM_Mailing_Task',
293 static function getModeValue($mode = 1) {
294 self
::setModeValues();
296 if (!array_key_exists($mode, self
::$_modeValues)) {
300 return self
::$_modeValues[$mode];
306 static function getModeSelect() {
307 self
::setModeValues();
310 foreach (self
::$_modeValues as $id => & $value) {
311 $select[$id] = $value['selectorLabel'];
314 // unset contributions or participants if user does not have
315 // permission on them
316 if (!CRM_Core_Permission
::access('CiviContribute')) {
320 if (!CRM_Core_Permission
::access('CiviEvent')) {
324 if (!CRM_Core_Permission
::check('view all activities')) {
331 * Build the common elements between the search/advanced form
337 function buildQuickForm() {
338 parent
::buildQuickForm();
339 CRM_Core_Resources
::singleton()
340 // jsTree is needed for tags popup
341 ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)
342 ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
343 $permission = CRM_Core_Permission
::getPermission();
344 // some tasks.. what do we want to do with the selected contacts ?
346 if ($this->_componentMode
== 1 ||
$this->_componentMode
== 7) {
347 $tasks +
= CRM_Contact_Task
::permissionedTaskTitles($permission,
348 CRM_Utils_Array
::value('deleted_contacts', $this->_formValues
)
352 $className = $this->_modeValue
['taskClassName'];
353 $tasks +
= $className::permissionedTaskTitles($permission, false);
356 if (isset($this->_ssID
)) {
357 if ($permission == CRM_Core_Permission
::EDIT
) {
358 $tasks = $tasks + CRM_Contact_Task
::optionalTaskTitle();
362 CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID
, 'search_custom_id');
364 $savedSearchValues = array(
365 'id' => $this->_ssID
,
366 'name' => CRM_Contact_BAO_SavedSearch
::getName($this->_ssID
, 'title'),
367 'search_custom_id' => $search_custom_id,
369 $this->assign_by_ref('savedSearch', $savedSearchValues);
370 $this->assign('ssID', $this->_ssID
);
373 if ($this->_context
=== 'smog') {
374 // CRM-11788, we might want to do this for all of search where force=1
375 $formQFKey = CRM_Utils_Array
::value('qfKey', $this->_formValues
);
376 $getQFKey = CRM_Utils_Array
::value('qfKey', $_GET);
377 $postQFKey = CRM_Utils_Array
::value('qfKey', $_POST);
378 if ($formQFKey && empty($getQFKey) && empty($postQFKey)) {
379 $url = CRM_Utils_System
::makeURL('qfKey') . $formQFKey;
380 CRM_Utils_System
::redirect($url);
382 $permissionForGroup = FALSE;
384 if (!empty($this->_groupID
)) {
385 // check if user has permission to edit members of this group
386 $permission = CRM_Contact_BAO_Group
::checkPermission($this->_groupID
);
387 if ($permission && in_array(CRM_Core_Permission
::EDIT
, $permission)) {
388 $permissionForGroup = TRUE;
391 // check if _groupID exists, it might not if
392 // we are displaying a hidden group
393 if (!isset($this->_group
[$this->_groupID
])) {
394 $this->_group
[$this->_groupID
] =
395 CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'title');
398 // set the group title
399 $groupValues = array('id' => $this->_groupID
, 'title' => $this->_group
[$this->_groupID
]);
400 $this->assign_by_ref('group', $groupValues);
402 // also set ssID if this is a saved search
403 $ssID = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'saved_search_id');
404 $this->assign('ssID', $ssID);
406 //get the saved search mapping id
408 $this->_ssID
= $ssID;
409 $ssMappingId = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $ssID, 'mapping_id');
410 $this->assign('ssMappingID', $ssMappingId);
413 // Set dynamic page title for 'Show Members of Group'
414 CRM_Utils_System
::setTitle(ts('Contacts in Group: %1', array(1 => $this->_group
[$this->_groupID
])));
417 $group_contact_status = array();
418 foreach (CRM_Core_SelectValues
::groupContactStatus() as $k => $v) {
420 $group_contact_status[] = $this->createElement('checkbox', $k, NULL, $v);
423 $this->addGroup($group_contact_status,
424 'group_contact_status', ts('Group Status')
427 $this->assign('permissionedForGroup', $permissionForGroup);
430 // add the go button for the action form, note it is of type 'next' rather than of type 'submit'
431 if ($this->_context
=== 'amtg') {
432 // check if _groupID exists, it might not if
433 // we are displaying a hidden group
434 if (!isset($this->_group
[$this->_amtgID
])) {
435 $this->assign('permissionedForGroup', FALSE);
436 $this->_group
[$this->_amtgID
] =
437 CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_amtgID
, 'title');
440 // Set dynamic page title for 'Add Members Group'
441 CRM_Utils_System
::setTitle(ts('Add to Group: %1', array(1 => $this->_group
[$this->_amtgID
])));
442 // also set the group title and freeze the action task with Add Members to Group
443 $groupValues = array('id' => $this->_amtgID
, 'title' => $this->_group
[$this->_amtgID
]);
444 $this->assign_by_ref('group', $groupValues);
445 $this->add('submit', $this->_actionButtonName
, ts('Add Contacts to %1', array(1 => $this->_group
[$this->_amtgID
])),
447 'class' => 'crm-form-submit',
450 $this->add('hidden', 'task', CRM_Contact_Task
::GROUP_CONTACTS
);
451 $selectedRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked'));
452 $allRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all');
453 $this->assign('ts_sel_id', $selectedRowsRadio->_attributes
['id']);
454 $this->assign('ts_all_id', $allRowsRadio->_attributes
['id']);
457 $this->addTaskMenu($tasks);
460 $selectedContactIds = array();
461 $qfKeyParam = CRM_Utils_Array
::value('qfKey', $this->_formValues
);
462 // We use ajax to handle selections only if the search results component_mode is set to "contacts"
463 if ($qfKeyParam && ($this->get('component_mode') <= 1 ||
$this->get('component_mode') == 7)) {
464 $this->addClass('crm-ajax-selection-form');
465 $qfKeyParam = "civicrm search {$qfKeyParam}";
466 $selectedContactIdsArr = CRM_Core_BAO_PrevNextCache
::getSelection($qfKeyParam);
467 $selectedContactIds = array_keys($selectedContactIdsArr[$qfKeyParam]);
470 $this->assign_by_ref('selectedContactIds', $selectedContactIds);
472 $rows = $this->get('rows');
474 if (is_array($rows)) {
475 $this->addRowSelectors($rows);
481 * Processing needed for buildForm and later
486 function preProcess() {
487 // set the various class variables
489 $this->_group
= CRM_Core_PseudoConstant
::group();
491 $this->_groupIterator
= CRM_Core_PseudoConstant
::groupIterator();
492 $this->_tag
= CRM_Core_BAO_Tag
::getTags();
493 $this->_done
= FALSE;
496 * we allow the controller to set force/reset externally, useful when we are being
497 * driven by the wizard framework
500 $this->_reset
= CRM_Utils_Request
::retrieve('reset', 'Boolean',
501 CRM_Core_DAO
::$_nullObject
504 $this->_force
= CRM_Utils_Request
::retrieve('force', 'Boolean', CRM_Core_DAO
::$_nullObject);
505 $this->_groupID
= CRM_Utils_Request
::retrieve('gid', 'Positive', $this);
506 $this->_amtgID
= CRM_Utils_Request
::retrieve('amtgID', 'Positive', $this);
507 $this->_ssID
= CRM_Utils_Request
::retrieve('ssID', 'Positive', $this);
508 $this->_sortByCharacter
= CRM_Utils_Request
::retrieve('sortByCharacter', 'String', $this);
509 $this->_ufGroupID
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
510 $this->_componentMode
= CRM_Utils_Request
::retrieve('component_mode', 'Positive', $this, FALSE, 1, $_REQUEST);
511 $this->_operator
= CRM_Utils_Request
::retrieve('operator', 'String', $this, FALSE, 1, $_REQUEST, 'AND');
514 * set the button names
516 $this->_searchButtonName
= $this->getButtonName('refresh');
517 $this->_actionButtonName
= $this->getButtonName('next', 'action');
519 $this->assign('actionButtonName', $this->_actionButtonName
);
521 // reset from session, CRM-3526
522 $session = CRM_Core_Session
::singleton();
523 if ($this->_force
&& $session->get('selectedSearchContactIds')) {
524 $session->resetScope('selectedSearchContactIds');
527 // if we dont get this from the url, use default if one exsts
528 $config = CRM_Core_Config
::singleton();
529 if ($this->_ufGroupID
== NULL &&
530 $config->defaultSearchProfileID
!= NULL
532 $this->_ufGroupID
= $config->defaultSearchProfileID
;
535 // assign context to drive the template display, make sure context is valid
536 $this->_context
= CRM_Utils_Request
::retrieve('context', 'String', $this, FALSE, 'search');
537 if (!CRM_Utils_Array
::value($this->_context
, self
::validContext())) {
538 $this->_context
= 'search';
540 $this->set('context', $this->_context
);
541 $this->assign('context', $this->_context
);
543 $this->_modeValue
= self
::getModeValue($this->_componentMode
);
544 $this->assign($this->_modeValue
);
546 $this->set('selectorName', self
::$_selectorName);
548 // get user submitted values
549 // get it from controller only if form has been submitted, else preProcess has set this
550 // $this->controller->isModal( ) returns true if page is
551 // valid, i.e all the validations are true
553 if (!empty($_POST) && !$this->controller
->isModal()) {
554 $this->_formValues
= $this->controller
->exportValues($this->_name
);
556 $this->normalizeFormValues();
557 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
558 $this->_returnProperties
= &$this->returnProperties();
560 // also get the uf group id directly from the post value
561 $this->_ufGroupID
= CRM_Utils_Array
::value('uf_group_id', $_POST, $this->_ufGroupID
);
562 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
563 $this->set('id', $this->_ufGroupID
);
565 // also get the object mode directly from the post value
566 $this->_componentMode
= CRM_Utils_Array
::value('component_mode', $_POST, $this->_componentMode
);
568 // also get the operator from the post value if set
569 $this->_operator
= CRM_Utils_Array
::value('operator', $_POST, $this->_operator
);
570 $this->_formValues
['operator'] = $this->_operator
;
571 $this->set('operator', $this->_operator
);
574 $this->_formValues
= $this->get('formValues');
575 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
576 $this->_returnProperties
= &$this->returnProperties();
577 if (!empty($this->_ufGroupID
)) {
578 $this->set('id', $this->_ufGroupID
);
582 if (empty($this->_formValues
)) {
583 //check if group is a smart group (fix for CRM-1255)
584 if ($this->_groupID
) {
585 if ($ssId = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'saved_search_id')) {
586 $this->_ssID
= $ssId;
591 if (isset($this->_ssID
) && $this->_context
!= 'smog') {
592 // we only retrieve the saved search values if out current values are null
593 $this->_formValues
= CRM_Contact_BAO_SavedSearch
::getFormValues($this->_ssID
);
596 if (CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID
, 'mapping_id')) {
597 $this->_params
= CRM_Contact_BAO_SavedSearch
::getSearchParams($this->_ssID
);
600 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
602 $this->_returnProperties
= &$this->returnProperties();
605 if (isset($this->_ufGroupID
)) {
606 // also set the uf group id if not already present
607 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
609 if (isset($this->_componentMode
)) {
610 $this->_formValues
['component_mode'] = $this->_componentMode
;
612 if (isset($this->_operator
)) {
613 $this->_formValues
['operator'] = $this->_operator
;
616 // FIXME: we should generalise in a way that components could inject url-filters
617 // just like they build their own form elements
619 'mailing_id', 'mailing_delivery_status', 'mailing_open_status',
620 'mailing_click_status', 'mailing_reply_status', 'mailing_optout',
621 'mailing_forward', 'mailing_unsubscribe', 'mailing_date_low',
623 ) as $mailingFilter) {
625 if ($mailingFilter == 'mailing_id' &&
626 $filterVal = CRM_Utils_Request
::retrieve('mailing_id', 'Positive', $this)
628 $this->_formValues
[$mailingFilter] = array($filterVal);
630 elseif ($filterVal = CRM_Utils_Request
::retrieve($mailingFilter, $type, $this)) {
631 $this->_formValues
[$mailingFilter] = $filterVal;
634 $this->_openedPanes
['Mailings'] = 1;
635 $this->_formValues
['hidden_CiviMail'] = 1;
641 CRM_Utils_Array
::value('uf_group_id', $this->_formValues
)
643 $operator = CRM_Utils_Array
::value('operator', $this->_formValues
, 'AND');
644 $this->set('queryOperator', $operator);
645 if ($operator == 'OR') {
646 $this->assign('operator', ts('OR'));
649 $this->assign('operator', ts('AND'));
652 // show the context menu only when we’re not searching for deleted contacts; CRM-5673
653 if (empty($this->_formValues
['deleted_contacts'])) {
654 $menuItems = CRM_Contact_BAO_Contact
::contextMenu();
655 $primaryActions = CRM_Utils_Array
::value('primaryActions', $menuItems, array());
656 $this->_contextMenu
= CRM_Utils_Array
::value('moreActions', $menuItems, array());
657 $this->assign('contextMenu', $primaryActions +
$this->_contextMenu
);
660 if (!isset($this->_componentMode
)) {
661 $this->_componentMode
= CRM_Contact_BAO_Query
::MODE_CONTACTS
;
663 $modeValues = self
::getModeValue($this->_componentMode
);
665 self
::$_selectorName = $this->_modeValue
['selectorName'];
668 if (strpos(self
::$_selectorName, 'CRM_Contact_Selector') !== FALSE) {
669 $selector = new self
::$_selectorName(
670 $this->_customSearchClass
,
673 $this->_returnProperties
,
682 $selector = new self
::$_selectorName(
690 $selector->setKey($this->controller
->_key
);
692 $controller = new CRM_Contact_Selector_Controller($selector,
693 $this->get(CRM_Utils_Pager
::PAGE_ID
),
694 $this->get(CRM_Utils_Sort
::SORT_ID
),
695 CRM_Core_Action
::VIEW
,
697 CRM_Core_Selector_Controller
::TRANSFER
699 $controller->setEmbedded(TRUE);
700 $controller->setDynamicAction($setDynamic);
704 $this->postProcess();
707 * Note that we repeat this, since the search creates and stores
708 * values that potentially change the controller behavior. i.e. things
709 * like totalCount etc
712 if ($this->get(CRM_Utils_Sort
::SORT_ID
)) {
713 $sortID = CRM_Utils_Sort
::sortIDValue($this->get(CRM_Utils_Sort
::SORT_ID
),
714 $this->get(CRM_Utils_Sort
::SORT_DIRECTION
)
717 $controller = new CRM_Contact_Selector_Controller($selector,
718 $this->get(CRM_Utils_Pager
::PAGE_ID
),
720 CRM_Core_Action
::VIEW
, $this, CRM_Core_Selector_Controller
::TRANSFER
722 $controller->setEmbedded(TRUE);
723 $controller->setDynamicAction($setDynamic);
726 $controller->moveFromSessionToTemplate();
732 function &getFormValues() {
733 return $this->_formValues
;
737 * Common post processing
742 function postProcess() {
744 * sometime we do a postProcess early on, so we dont need to repeat it
745 * this will most likely introduce some more bugs :(
753 //for prev/next pagination
754 $crmPID = CRM_Utils_Request
::retrieve('crmPID', 'Integer', CRM_Core_DAO
::$_nullObject);
756 if (array_key_exists($this->_searchButtonName
, $_POST) ||
757 ($this->_force
&& !$crmPID)) {
758 //reset the cache table for new search
759 $cacheKey = "civicrm search {$this->controller->_key}";
760 CRM_Core_BAO_PrevNextCache
::deleteItem(NULL, $cacheKey);
763 //get the button name
764 $buttonName = $this->controller
->getButtonName();
766 if (isset($this->_ufGroupID
) && empty($this->_formValues
['uf_group_id'])) {
767 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
770 if (isset($this->_componentMode
) && empty($this->_formValues
['component_mode'])) {
771 $this->_formValues
['component_mode'] = $this->_componentMode
;
774 if (isset($this->_operator
) && empty($this->_formValues
['operator'])) {
775 $this->_formValues
['operator'] = $this->_operator
;
778 if (empty($this->_formValues
['qfKey'])) {
779 $this->_formValues
['qfKey'] = $this->controller
->_key
;
782 if (!CRM_Core_Permission
::check('access deleted contacts')) {
783 unset($this->_formValues
['deleted_contacts']);
786 $this->set('type', $this->_action
);
787 $this->set('formValues', $this->_formValues
);
788 $this->set('queryParams', $this->_params
);
789 $this->set('returnProperties', $this->_returnProperties
);
791 if ($buttonName == $this->_actionButtonName
) {
792 // check actionName and if next, then do not repeat a search, since we are going to the next page
793 // hack, make sure we reset the task values
794 $stateMachine = $this->controller
->getStateMachine();
795 $formName = $stateMachine->getTaskFormName();
796 $this->controller
->resetPage($formName);
800 $output = CRM_Core_Selector_Controller
::SESSION
;
802 // create the selector, controller and run - store results in session
803 $searchChildGroups = TRUE;
804 if ($this->get('isAdvanced')) {
805 $searchChildGroups = FALSE;
810 if (strpos(self
::$_selectorName, 'CRM_Contact_Selector') !== FALSE) {
811 $selector = new self
::$_selectorName (
812 $this->_customSearchClass
,
815 $this->_returnProperties
,
825 $selector = new self
::$_selectorName (
836 $selector->setKey($this->controller
->_key
);
838 // added the sorting character to the form array
839 $config = CRM_Core_Config
::singleton();
840 // do this only for contact search
841 if ($setDynamic && $config->includeAlphabeticalPager
) {
842 // Don't recompute if we are just paging/sorting
843 if ($this->_reset ||
(empty($_GET['crmPID']) && empty($_GET['crmSID']) && !$this->_sortByCharacter
)) {
844 $aToZBar = CRM_Utils_PagerAToZ
::getAToZBar($selector, $this->_sortByCharacter
);
845 $this->set('AToZBar', $aToZBar);
850 if ($this->get(CRM_Utils_Sort
::SORT_ID
)) {
851 $sortID = CRM_Utils_Sort
::sortIDValue($this->get(CRM_Utils_Sort
::SORT_ID
),
852 $this->get(CRM_Utils_Sort
::SORT_DIRECTION
)
855 $controller = new CRM_Contact_Selector_Controller($selector,
856 $this->get(CRM_Utils_Pager
::PAGE_ID
),
858 CRM_Core_Action
::VIEW
,
862 $controller->setEmbedded(TRUE);
863 $controller->setDynamicAction($setDynamic);
871 function &returnProperties() {
872 return CRM_Core_DAO
::$_nullObject;
876 * Return a descriptive name for the page, used in wizard header
881 function getTitle() {