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;
90 public $_groupIterator;
101 * The params used for search.
108 * The return properties used for search.
112 protected $_returnProperties;
115 * The sort by character.
119 protected $_sortByCharacter;
122 * The profile group id used for display.
126 protected $_ufGroupID;
129 * Csv - common search values
133 static $csv = array('contact_type', 'group', 'tag');
136 * @var string how to display the results. Should we display as
137 * contributons, members, cases etc
139 protected $_componentMode;
142 * @var string what operator should we use, AND or OR
144 protected $_operator;
146 protected $_modeValue;
149 * Declare entity reference fields as they will need to be converted to using 'IN'.
153 protected $entityReferenceFields = array('event_id', 'membership_type_id');
156 * Name of the selector to use.
158 static $_selectorName = 'CRM_Contact_Selector';
159 protected $_customSearchID = NULL;
160 protected $_customSearchClass = NULL;
162 protected $_openedPanes = array();
165 * Explicitly declare the entity api name.
167 public function getDefaultEntity() {
172 * Define the set of valid contexts that the search form operates on.
175 * the valid context set and the titles
177 public static function &validContext() {
178 if (!(self
::$_validContext)) {
179 self
::$_validContext = array(
180 'smog' => 'Show members of group',
181 'amtg' => 'Add members to group',
182 'basic' => 'Basic Search',
183 'search' => 'Search',
184 'builder' => 'Search Builder',
185 'advanced' => 'Advanced Search',
186 'custom' => 'Custom Search',
189 return self
::$_validContext;
197 public static function isSearchContext($context) {
198 $searchContext = CRM_Utils_Array
::value($context, self
::validContext());
199 return $searchContext ?
TRUE : FALSE;
202 public static function setModeValues() {
203 if (!self
::$_modeValues) {
204 self
::$_modeValues = array(
206 'selectorName' => self
::$_selectorName,
207 'selectorLabel' => ts('Contacts'),
208 'taskFile' => 'CRM/Contact/Form/Search/ResultTasks.tpl',
209 'taskContext' => NULL,
210 'resultFile' => 'CRM/Contact/Form/Selector.tpl',
211 'resultContext' => NULL,
212 'taskClassName' => 'CRM_Contact_Task',
215 'selectorName' => 'CRM_Contribute_Selector_Search',
216 'selectorLabel' => ts('Contributions'),
217 'taskFile' => 'CRM/common/searchResultTasks.tpl',
218 'taskContext' => 'Contribution',
219 'resultFile' => 'CRM/Contribute/Form/Selector.tpl',
220 'resultContext' => 'Search',
221 'taskClassName' => 'CRM_Contribute_Task',
224 'selectorName' => 'CRM_Event_Selector_Search',
225 'selectorLabel' => ts('Event Participants'),
226 'taskFile' => 'CRM/common/searchResultTasks.tpl',
227 'taskContext' => NULL,
228 'resultFile' => 'CRM/Event/Form/Selector.tpl',
229 'resultContext' => 'Search',
230 'taskClassName' => 'CRM_Event_Task',
233 'selectorName' => 'CRM_Activity_Selector_Search',
234 'selectorLabel' => ts('Activities'),
235 'taskFile' => 'CRM/common/searchResultTasks.tpl',
236 'taskContext' => NULL,
237 'resultFile' => 'CRM/Activity/Form/Selector.tpl',
238 'resultContext' => 'Search',
239 'taskClassName' => 'CRM_Activity_Task',
242 'selectorName' => 'CRM_Member_Selector_Search',
243 'selectorLabel' => ts('Memberships'),
244 'taskFile' => "CRM/common/searchResultTasks.tpl",
245 'taskContext' => NULL,
246 'resultFile' => 'CRM/Member/Form/Selector.tpl',
247 'resultContext' => 'Search',
248 'taskClassName' => 'CRM_Member_Task',
251 'selectorName' => 'CRM_Case_Selector_Search',
252 'selectorLabel' => ts('Cases'),
253 'taskFile' => "CRM/common/searchResultTasks.tpl",
254 'taskContext' => NULL,
255 'resultFile' => 'CRM/Case/Form/Selector.tpl',
256 'resultContext' => 'Search',
257 'taskClassName' => 'CRM_Case_Task',
260 'selectorName' => self
::$_selectorName,
261 'selectorLabel' => ts('Related Contacts'),
262 'taskFile' => 'CRM/Contact/Form/Search/ResultTasks.tpl',
263 'taskContext' => NULL,
264 'resultFile' => 'CRM/Contact/Form/Selector.tpl',
265 'resultContext' => NULL,
266 'taskClassName' => 'CRM_Contact_Task',
269 'selectorName' => 'CRM_Mailing_Selector_Search',
270 'selectorLabel' => ts('Mailings'),
271 'taskFile' => "CRM/common/searchResultTasks.tpl",
272 'taskContext' => NULL,
273 'resultFile' => 'CRM/Mailing/Form/Selector.tpl',
274 'resultContext' => 'Search',
275 'taskClassName' => 'CRM_Mailing_Task',
286 public static function getModeValue($mode = 1) {
287 self
::setModeValues();
289 if (!array_key_exists($mode, self
::$_modeValues)) {
293 return self
::$_modeValues[$mode];
299 public static function getModeSelect() {
300 self
::setModeValues();
303 foreach (self
::$_modeValues as $id => & $value) {
304 $select[$id] = $value['selectorLabel'];
307 // unset contributions or participants if user does not have
308 // permission on them
309 if (!CRM_Core_Permission
::access('CiviContribute')) {
313 if (!CRM_Core_Permission
::access('CiviEvent')) {
317 if (!CRM_Core_Permission
::check('view all activities')) {
324 * Builds the list of tasks or actions that a searcher can perform on a result set.
328 public function buildTaskList() {
329 if ($this->_context
!== 'amtg') {
330 $permission = CRM_Core_Permission
::getPermission();
332 if ($this->_componentMode
== 1 ||
$this->_componentMode
== 7) {
333 $this->_taskList +
= CRM_Contact_Task
::permissionedTaskTitles($permission,
334 CRM_Utils_Array
::value('deleted_contacts', $this->_formValues
)
338 $className = $this->_modeValue
['taskClassName'];
339 $this->_taskList +
= $className::permissionedTaskTitles($permission, FALSE);
342 // Only offer the "Update Smart Group" task if a smart group/saved search is already in play
343 if (isset($this->_ssID
) && $permission == CRM_Core_Permission
::EDIT
) {
344 $this->_taskList +
= CRM_Contact_Task
::optionalTaskTitle();
348 asort($this->_taskList
);
349 return $this->_taskList
;
353 * Build the common elements between the search/advanced form.
355 public function buildQuickForm() {
356 parent
::buildQuickForm();
357 CRM_Core_Resources
::singleton()
358 // jsTree is needed for tags popup
359 ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)
360 ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
361 $permission = CRM_Core_Permission
::getPermission();
362 // some tasks.. what do we want to do with the selected contacts ?
364 if ($this->_componentMode
== 1 ||
$this->_componentMode
== 7) {
365 $tasks +
= CRM_Contact_Task
::permissionedTaskTitles($permission,
366 CRM_Utils_Array
::value('deleted_contacts', $this->_formValues
)
370 $className = $this->_modeValue
['taskClassName'];
371 $tasks +
= $className::permissionedTaskTitles($permission, FALSE);
374 if (isset($this->_ssID
)) {
375 if ($permission == CRM_Core_Permission
::EDIT
) {
376 $tasks = $tasks + CRM_Contact_Task
::optionalTaskTitle();
380 = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID
, 'search_custom_id');
382 $savedSearchValues = array(
383 'id' => $this->_ssID
,
384 'name' => CRM_Contact_BAO_SavedSearch
::getName($this->_ssID
, 'title'),
385 'search_custom_id' => $search_custom_id,
387 $this->assign_by_ref('savedSearch', $savedSearchValues);
388 $this->assign('ssID', $this->_ssID
);
391 if ($this->_context
=== 'smog') {
392 // CRM-11788, we might want to do this for all of search where force=1
393 $formQFKey = CRM_Utils_Array
::value('qfKey', $this->_formValues
);
394 $getQFKey = CRM_Utils_Array
::value('qfKey', $_GET);
395 $postQFKey = CRM_Utils_Array
::value('qfKey', $_POST);
396 if ($formQFKey && empty($getQFKey) && empty($postQFKey)) {
397 $url = CRM_Utils_System
::makeURL('qfKey') . $formQFKey;
398 CRM_Utils_System
::redirect($url);
400 $permissionForGroup = FALSE;
402 if (!empty($this->_groupID
)) {
403 // check if user has permission to edit members of this group
404 $permission = CRM_Contact_BAO_Group
::checkPermission($this->_groupID
);
405 if ($permission && in_array(CRM_Core_Permission
::EDIT
, $permission)) {
406 $permissionForGroup = TRUE;
409 // check if _groupID exists, it might not if
410 // we are displaying a hidden group
411 if (!isset($this->_group
[$this->_groupID
])) {
412 $this->_group
[$this->_groupID
]
413 = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'title');
416 // set the group title
417 $groupValues = array('id' => $this->_groupID
, 'title' => $this->_group
[$this->_groupID
]);
418 $this->assign_by_ref('group', $groupValues);
420 // also set ssID if this is a saved search
421 $ssID = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'saved_search_id');
422 $this->assign('ssID', $ssID);
424 //get the saved search mapping id
426 $this->_ssID
= $ssID;
427 $ssMappingId = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $ssID, 'mapping_id');
428 $this->assign('ssMappingID', $ssMappingId);
431 // Set dynamic page title for 'Show Members of Group'
432 CRM_Utils_System
::setTitle(ts('Contacts in Group: %1', array(1 => $this->_group
[$this->_groupID
])));
435 $group_contact_status = array();
436 foreach (CRM_Core_SelectValues
::groupContactStatus() as $k => $v) {
438 $group_contact_status[] = $this->createElement('checkbox', $k, NULL, $v);
441 $this->addGroup($group_contact_status,
442 'group_contact_status', ts('Group Status')
445 $this->assign('permissionedForGroup', $permissionForGroup);
448 // add the go button for the action form, note it is of type 'next' rather than of type 'submit'
449 if ($this->_context
=== 'amtg') {
450 // check if _groupID exists, it might not if
451 // we are displaying a hidden group
452 if (!isset($this->_group
[$this->_amtgID
])) {
453 $this->assign('permissionedForGroup', FALSE);
454 $this->_group
[$this->_amtgID
]
455 = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_amtgID
, 'title');
458 // Set dynamic page title for 'Add Members Group'
459 CRM_Utils_System
::setTitle(ts('Add to Group: %1', array(1 => $this->_group
[$this->_amtgID
])));
460 // also set the group title and freeze the action task with Add Members to Group
461 $groupValues = array('id' => $this->_amtgID
, 'title' => $this->_group
[$this->_amtgID
]);
462 $this->assign_by_ref('group', $groupValues);
463 $this->add('submit', $this->_actionButtonName
, ts('Add Contacts to %1', array(1 => $this->_group
[$this->_amtgID
])),
465 'class' => 'crm-form-submit',
468 $this->add('hidden', 'task', CRM_Contact_Task
::GROUP_CONTACTS
);
469 $selectedRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked'));
470 $allRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all');
471 $this->assign('ts_sel_id', $selectedRowsRadio->_attributes
['id']);
472 $this->assign('ts_all_id', $allRowsRadio->_attributes
['id']);
475 $selectedContactIds = array();
476 $qfKeyParam = CRM_Utils_Array
::value('qfKey', $this->_formValues
);
477 // We use ajax to handle selections only if the search results component_mode is set to "contacts"
478 if ($qfKeyParam && ($this->get('component_mode') <= 1 ||
$this->get('component_mode') == 7)) {
479 $this->addClass('crm-ajax-selection-form');
480 $qfKeyParam = "civicrm search {$qfKeyParam}";
481 $selectedContactIdsArr = CRM_Core_BAO_PrevNextCache
::getSelection($qfKeyParam);
482 $selectedContactIds = array_keys($selectedContactIdsArr[$qfKeyParam]);
485 $this->assign_by_ref('selectedContactIds', $selectedContactIds);
487 $rows = $this->get('rows');
489 if (is_array($rows)) {
490 $this->addRowSelectors($rows);
496 * Processing needed for buildForm and later.
498 public function preProcess() {
499 // set the various class variables
501 $this->_group
= CRM_Core_PseudoConstant
::group();
503 $this->_groupIterator
= CRM_Core_PseudoConstant
::groupIterator();
504 $this->_tag
= CRM_Core_BAO_Tag
::getTags();
505 $this->_done
= FALSE;
508 * we allow the controller to set force/reset externally, useful when we are being
509 * driven by the wizard framework
512 $this->_reset
= CRM_Utils_Request
::retrieve('reset', 'Boolean',
513 CRM_Core_DAO
::$_nullObject
516 $this->_force
= CRM_Utils_Request
::retrieve('force', 'Boolean', CRM_Core_DAO
::$_nullObject);
517 $this->_groupID
= CRM_Utils_Request
::retrieve('gid', 'Positive', $this);
518 $this->_amtgID
= CRM_Utils_Request
::retrieve('amtgID', 'Positive', $this);
519 $this->_ssID
= CRM_Utils_Request
::retrieve('ssID', 'Positive', $this);
520 $this->_sortByCharacter
= CRM_Utils_Request
::retrieve('sortByCharacter', 'String', $this);
521 $this->_ufGroupID
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
522 $this->_componentMode
= CRM_Utils_Request
::retrieve('component_mode', 'Positive', $this, FALSE, 1, $_REQUEST);
523 $this->_operator
= CRM_Utils_Request
::retrieve('operator', 'String', $this, FALSE, 1, $_REQUEST, 'AND');
526 * set the button names
528 $this->_searchButtonName
= $this->getButtonName('refresh');
529 $this->_actionButtonName
= $this->getButtonName('next', 'action');
531 $this->assign('actionButtonName', $this->_actionButtonName
);
533 // reset from session, CRM-3526
534 $session = CRM_Core_Session
::singleton();
535 if ($this->_force
&& $session->get('selectedSearchContactIds')) {
536 $session->resetScope('selectedSearchContactIds');
539 // if we dont get this from the url, use default if one exsts
540 $config = CRM_Core_Config
::singleton();
541 if ($this->_ufGroupID
== NULL &&
542 $config->defaultSearchProfileID
!= NULL
544 $this->_ufGroupID
= $config->defaultSearchProfileID
;
547 // assign context to drive the template display, make sure context is valid
548 $this->_context
= CRM_Utils_Request
::retrieve('context', 'String', $this, FALSE, 'search');
549 if (!CRM_Utils_Array
::value($this->_context
, self
::validContext())) {
550 $this->_context
= 'search';
552 $this->set('context', $this->_context
);
553 $this->assign('context', $this->_context
);
555 $this->_modeValue
= self
::getModeValue($this->_componentMode
);
556 $this->assign($this->_modeValue
);
558 $this->set('selectorName', self
::$_selectorName);
560 // get user submitted values
561 // get it from controller only if form has been submitted, else preProcess has set this
562 // $this->controller->isModal( ) returns TRUE if page is
563 // valid, i.e all the validations are TRUE
565 if (!empty($_POST) && !$this->controller
->isModal()) {
566 $this->_formValues
= $this->controller
->exportValues($this->_name
);
568 $this->normalizeFormValues();
569 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
, 0, FALSE, NULL, $this->entityReferenceFields
);
570 $this->_returnProperties
= &$this->returnProperties();
572 // also get the uf group id directly from the post value
573 $this->_ufGroupID
= CRM_Utils_Array
::value('uf_group_id', $_POST, $this->_ufGroupID
);
574 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
575 $this->set('id', $this->_ufGroupID
);
577 // also get the object mode directly from the post value
578 $this->_componentMode
= CRM_Utils_Array
::value('component_mode', $_POST, $this->_componentMode
);
580 // also get the operator from the post value if set
581 $this->_operator
= CRM_Utils_Array
::value('operator', $_POST, $this->_operator
);
582 $this->_formValues
['operator'] = $this->_operator
;
583 $this->set('operator', $this->_operator
);
586 $this->_formValues
= $this->get('formValues');
587 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
, 0, FALSE, NULL, $this->entityReferenceFields
);
588 $this->_returnProperties
= &$this->returnProperties();
589 if (!empty($this->_ufGroupID
)) {
590 $this->set('id', $this->_ufGroupID
);
594 if (empty($this->_formValues
)) {
595 //check if group is a smart group (fix for CRM-1255)
596 if ($this->_groupID
) {
597 if ($ssId = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'saved_search_id')) {
598 $this->_ssID
= $ssId;
603 if (isset($this->_ssID
) && $this->_context
!= 'smog') {
604 // we only retrieve the saved search values if out current values are null
605 $this->_formValues
= CRM_Contact_BAO_SavedSearch
::getFormValues($this->_ssID
);
608 if (CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID
, 'mapping_id')) {
609 $this->_params
= CRM_Contact_BAO_SavedSearch
::getSearchParams($this->_ssID
);
612 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
614 $this->_returnProperties
= &$this->returnProperties();
617 if (isset($this->_ufGroupID
)) {
618 // also set the uf group id if not already present
619 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
621 if (isset($this->_componentMode
)) {
622 $this->_formValues
['component_mode'] = $this->_componentMode
;
624 if (isset($this->_operator
)) {
625 $this->_formValues
['operator'] = $this->_operator
;
628 // FIXME: we should generalise in a way that components could inject url-filters
629 // just like they build their own form elements
632 'mailing_delivery_status',
633 'mailing_open_status',
634 'mailing_click_status',
635 'mailing_reply_status',
638 'mailing_unsubscribe',
641 ) as $mailingFilter) {
643 if ($mailingFilter == 'mailing_id' &&
644 $filterVal = CRM_Utils_Request
::retrieve('mailing_id', 'Positive', $this)
646 $this->_formValues
[$mailingFilter] = array($filterVal);
648 elseif ($filterVal = CRM_Utils_Request
::retrieve($mailingFilter, $type, $this)) {
649 $this->_formValues
[$mailingFilter] = $filterVal;
652 $this->_openedPanes
['Mailings'] = 1;
653 $this->_formValues
['hidden_CiviMail'] = 1;
659 CRM_Utils_Array
::value('uf_group_id', $this->_formValues
)
661 $operator = CRM_Utils_Array
::value('operator', $this->_formValues
, 'AND');
662 $this->set('queryOperator', $operator);
663 if ($operator == 'OR') {
664 $this->assign('operator', ts('OR'));
667 $this->assign('operator', ts('AND'));
670 // show the context menu only when we’re not searching for deleted contacts; CRM-5673
671 if (empty($this->_formValues
['deleted_contacts'])) {
672 $menuItems = CRM_Contact_BAO_Contact
::contextMenu();
673 $primaryActions = CRM_Utils_Array
::value('primaryActions', $menuItems, array());
674 $this->_contextMenu
= CRM_Utils_Array
::value('moreActions', $menuItems, array());
675 $this->assign('contextMenu', $primaryActions +
$this->_contextMenu
);
678 if (!isset($this->_componentMode
)) {
679 $this->_componentMode
= CRM_Contact_BAO_Query
::MODE_CONTACTS
;
681 self
::setModeValues();
683 self
::$_selectorName = $this->_modeValue
['selectorName'];
686 if (strpos(self
::$_selectorName, 'CRM_Contact_Selector') !== FALSE) {
687 $selector = new self
::$_selectorName(
688 $this->_customSearchClass
,
691 $this->_returnProperties
,
700 $selector = new self
::$_selectorName(
708 $selector->setKey($this->controller
->_key
);
710 $controller = new CRM_Contact_Selector_Controller($selector,
711 $this->get(CRM_Utils_Pager
::PAGE_ID
),
712 $this->get(CRM_Utils_Sort
::SORT_ID
),
713 CRM_Core_Action
::VIEW
,
715 CRM_Core_Selector_Controller
::TRANSFER
717 $controller->setEmbedded(TRUE);
718 $controller->setDynamicAction($setDynamic);
722 $this->postProcess();
725 * Note that we repeat this, since the search creates and stores
726 * values that potentially change the controller behavior. i.e. things
727 * like totalCount etc
730 if ($this->get(CRM_Utils_Sort
::SORT_ID
)) {
731 $sortID = CRM_Utils_Sort
::sortIDValue($this->get(CRM_Utils_Sort
::SORT_ID
),
732 $this->get(CRM_Utils_Sort
::SORT_DIRECTION
)
735 $controller = new CRM_Contact_Selector_Controller($selector,
736 $this->get(CRM_Utils_Pager
::PAGE_ID
),
738 CRM_Core_Action
::VIEW
, $this, CRM_Core_Selector_Controller
::TRANSFER
740 $controller->setEmbedded(TRUE);
741 $controller->setDynamicAction($setDynamic);
744 $controller->moveFromSessionToTemplate();
750 public function &getFormValues() {
751 return $this->_formValues
;
755 * Common post processing.
757 public function postProcess() {
759 * sometime we do a postProcess early on, so we dont need to repeat it
760 * this will most likely introduce some more bugs :(
768 //for prev/next pagination
769 $crmPID = CRM_Utils_Request
::retrieve('crmPID', 'Integer', CRM_Core_DAO
::$_nullObject);
771 if (array_key_exists($this->_searchButtonName
, $_POST) ||
772 ($this->_force
&& !$crmPID)
774 //reset the cache table for new search
775 $cacheKey = "civicrm search {$this->controller->_key}";
776 CRM_Core_BAO_PrevNextCache
::deleteItem(NULL, $cacheKey);
779 //get the button name
780 $buttonName = $this->controller
->getButtonName();
782 if (isset($this->_ufGroupID
) && empty($this->_formValues
['uf_group_id'])) {
783 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
786 if (isset($this->_componentMode
) && empty($this->_formValues
['component_mode'])) {
787 $this->_formValues
['component_mode'] = $this->_componentMode
;
790 if (isset($this->_operator
) && empty($this->_formValues
['operator'])) {
791 $this->_formValues
['operator'] = $this->_operator
;
794 if (empty($this->_formValues
['qfKey'])) {
795 $this->_formValues
['qfKey'] = $this->controller
->_key
;
798 if (!CRM_Core_Permission
::check('access deleted contacts')) {
799 unset($this->_formValues
['deleted_contacts']);
802 $this->set('type', $this->_action
);
803 $this->set('formValues', $this->_formValues
);
804 $this->set('queryParams', $this->_params
);
805 $this->set('returnProperties', $this->_returnProperties
);
807 if ($buttonName == $this->_actionButtonName
) {
808 // check actionName and if next, then do not repeat a search, since we are going to the next page
809 // hack, make sure we reset the task values
810 $stateMachine = $this->controller
->getStateMachine();
811 $formName = $stateMachine->getTaskFormName();
812 $this->controller
->resetPage($formName);
816 $output = CRM_Core_Selector_Controller
::SESSION
;
818 // create the selector, controller and run - store results in session
819 $searchChildGroups = TRUE;
820 if ($this->get('isAdvanced')) {
821 $searchChildGroups = FALSE;
826 if (strpos(self
::$_selectorName, 'CRM_Contact_Selector') !== FALSE) {
827 $selector = new self
::$_selectorName(
828 $this->_customSearchClass
,
831 $this->_returnProperties
,
841 $selector = new self
::$_selectorName(
852 $selector->setKey($this->controller
->_key
);
854 // added the sorting character to the form array
855 $config = CRM_Core_Config
::singleton();
856 // do this only for contact search
857 if ($setDynamic && $config->includeAlphabeticalPager
) {
858 // Don't recompute if we are just paging/sorting
859 if ($this->_reset ||
(empty($_GET['crmPID']) && empty($_GET['crmSID']) && !$this->_sortByCharacter
)) {
860 $aToZBar = CRM_Utils_PagerAToZ
::getAToZBar($selector, $this->_sortByCharacter
);
861 $this->set('AToZBar', $aToZBar);
866 if ($this->get(CRM_Utils_Sort
::SORT_ID
)) {
867 $sortID = CRM_Utils_Sort
::sortIDValue($this->get(CRM_Utils_Sort
::SORT_ID
),
868 $this->get(CRM_Utils_Sort
::SORT_DIRECTION
)
871 $controller = new CRM_Contact_Selector_Controller($selector,
872 $this->get(CRM_Utils_Pager
::PAGE_ID
),
874 CRM_Core_Action
::VIEW
,
878 $controller->setEmbedded(TRUE);
879 $controller->setDynamicAction($setDynamic);
887 public function &returnProperties() {
888 return CRM_Core_DAO
::$_nullObject;
892 * Return a descriptive name for the page, used in wizard header
896 public function getTitle() {