3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2015
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 * Name of the selector to use.
151 static $_selectorName = 'CRM_Contact_Selector';
152 protected $_customSearchID = NULL;
153 protected $_customSearchClass = NULL;
155 protected $_openedPanes = array();
158 * Explicitly declare the entity api name.
160 public function getDefaultEntity() {
165 * Define the set of valid contexts that the search form operates on.
168 * the valid context set and the titles
170 public static function &validContext() {
171 if (!(self
::$_validContext)) {
172 self
::$_validContext = array(
173 'smog' => 'Show members of group',
174 'amtg' => 'Add members to group',
175 'basic' => 'Basic Search',
176 'search' => 'Search',
177 'builder' => 'Search Builder',
178 'advanced' => 'Advanced Search',
179 'custom' => 'Custom Search',
182 return self
::$_validContext;
190 public static function isSearchContext($context) {
191 $searchContext = CRM_Utils_Array
::value($context, self
::validContext());
192 return $searchContext ?
TRUE : FALSE;
195 public static function setModeValues() {
196 if (!self
::$_modeValues) {
197 self
::$_modeValues = array(
199 'selectorName' => self
::$_selectorName,
200 'selectorLabel' => ts('Contacts'),
201 'taskFile' => 'CRM/Contact/Form/Search/ResultTasks.tpl',
202 'taskContext' => NULL,
203 'resultFile' => 'CRM/Contact/Form/Selector.tpl',
204 'resultContext' => NULL,
205 'taskClassName' => 'CRM_Contact_Task',
208 'selectorName' => 'CRM_Contribute_Selector_Search',
209 'selectorLabel' => ts('Contributions'),
210 'taskFile' => 'CRM/common/searchResultTasks.tpl',
211 'taskContext' => 'Contribution',
212 'resultFile' => 'CRM/Contribute/Form/Selector.tpl',
213 'resultContext' => 'Search',
214 'taskClassName' => 'CRM_Contribute_Task',
217 'selectorName' => 'CRM_Event_Selector_Search',
218 'selectorLabel' => ts('Event Participants'),
219 'taskFile' => 'CRM/common/searchResultTasks.tpl',
220 'taskContext' => NULL,
221 'resultFile' => 'CRM/Event/Form/Selector.tpl',
222 'resultContext' => 'Search',
223 'taskClassName' => 'CRM_Event_Task',
226 'selectorName' => 'CRM_Activity_Selector_Search',
227 'selectorLabel' => ts('Activities'),
228 'taskFile' => 'CRM/common/searchResultTasks.tpl',
229 'taskContext' => NULL,
230 'resultFile' => 'CRM/Activity/Form/Selector.tpl',
231 'resultContext' => 'Search',
232 'taskClassName' => 'CRM_Activity_Task',
235 'selectorName' => 'CRM_Member_Selector_Search',
236 'selectorLabel' => ts('Memberships'),
237 'taskFile' => "CRM/common/searchResultTasks.tpl",
238 'taskContext' => NULL,
239 'resultFile' => 'CRM/Member/Form/Selector.tpl',
240 'resultContext' => 'Search',
241 'taskClassName' => 'CRM_Member_Task',
244 'selectorName' => 'CRM_Case_Selector_Search',
245 'selectorLabel' => ts('Cases'),
246 'taskFile' => "CRM/common/searchResultTasks.tpl",
247 'taskContext' => NULL,
248 'resultFile' => 'CRM/Case/Form/Selector.tpl',
249 'resultContext' => 'Search',
250 'taskClassName' => 'CRM_Case_Task',
253 'selectorName' => self
::$_selectorName,
254 'selectorLabel' => ts('Related Contacts'),
255 'taskFile' => 'CRM/Contact/Form/Search/ResultTasks.tpl',
256 'taskContext' => NULL,
257 'resultFile' => 'CRM/Contact/Form/Selector.tpl',
258 'resultContext' => NULL,
259 'taskClassName' => 'CRM_Contact_Task',
262 'selectorName' => 'CRM_Mailing_Selector_Search',
263 'selectorLabel' => ts('Mailings'),
264 'taskFile' => "CRM/common/searchResultTasks.tpl",
265 'taskContext' => NULL,
266 'resultFile' => 'CRM/Mailing/Form/Selector.tpl',
267 'resultContext' => 'Search',
268 'taskClassName' => 'CRM_Mailing_Task',
279 public static function getModeValue($mode = 1) {
280 self
::setModeValues();
282 if (!array_key_exists($mode, self
::$_modeValues)) {
286 return self
::$_modeValues[$mode];
292 public static function getModeSelect() {
293 self
::setModeValues();
296 foreach (self
::$_modeValues as $id => & $value) {
297 $select[$id] = $value['selectorLabel'];
300 // unset contributions or participants if user does not have
301 // permission on them
302 if (!CRM_Core_Permission
::access('CiviContribute')) {
306 if (!CRM_Core_Permission
::access('CiviEvent')) {
310 if (!CRM_Core_Permission
::check('view all activities')) {
317 * Builds the list of tasks or actions that a searcher can perform on a result set.
321 public function buildTaskList() {
322 if ($this->_context
!== 'amtg') {
323 $permission = CRM_Core_Permission
::getPermission();
325 if ($this->_componentMode
== 1 ||
$this->_componentMode
== 7) {
326 $this->_taskList +
= CRM_Contact_Task
::permissionedTaskTitles($permission,
327 CRM_Utils_Array
::value('deleted_contacts', $this->_formValues
)
331 $className = $this->_modeValue
['taskClassName'];
332 $this->_taskList +
= $className::permissionedTaskTitles($permission, FALSE);
335 // Only offer the "Update Smart Group" task if a smart group/saved search is already in play
336 if (isset($this->_ssID
) && $permission == CRM_Core_Permission
::EDIT
) {
337 $this->_taskList +
= CRM_Contact_Task
::optionalTaskTitle();
341 return $this->_taskList
;
345 * Build the common elements between the search/advanced form.
347 public function buildQuickForm() {
348 parent
::buildQuickForm();
349 CRM_Core_Resources
::singleton()
350 // jsTree is needed for tags popup
351 ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)
352 ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
353 $permission = CRM_Core_Permission
::getPermission();
354 // some tasks.. what do we want to do with the selected contacts ?
356 if ($this->_componentMode
== 1 ||
$this->_componentMode
== 7) {
357 $tasks +
= CRM_Contact_Task
::permissionedTaskTitles($permission,
358 CRM_Utils_Array
::value('deleted_contacts', $this->_formValues
)
362 $className = $this->_modeValue
['taskClassName'];
363 $tasks +
= $className::permissionedTaskTitles($permission, FALSE);
366 if (isset($this->_ssID
)) {
367 if ($permission == CRM_Core_Permission
::EDIT
) {
368 $tasks = $tasks + CRM_Contact_Task
::optionalTaskTitle();
372 = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID
, 'search_custom_id');
374 $savedSearchValues = array(
375 'id' => $this->_ssID
,
376 'name' => CRM_Contact_BAO_SavedSearch
::getName($this->_ssID
, 'title'),
377 'search_custom_id' => $search_custom_id,
379 $this->assign_by_ref('savedSearch', $savedSearchValues);
380 $this->assign('ssID', $this->_ssID
);
383 if ($this->_context
=== 'smog') {
384 // CRM-11788, we might want to do this for all of search where force=1
385 $formQFKey = CRM_Utils_Array
::value('qfKey', $this->_formValues
);
386 $getQFKey = CRM_Utils_Array
::value('qfKey', $_GET);
387 $postQFKey = CRM_Utils_Array
::value('qfKey', $_POST);
388 if ($formQFKey && empty($getQFKey) && empty($postQFKey)) {
389 $url = CRM_Utils_System
::makeURL('qfKey') . $formQFKey;
390 CRM_Utils_System
::redirect($url);
392 $permissionForGroup = FALSE;
394 if (!empty($this->_groupID
)) {
395 // check if user has permission to edit members of this group
396 $permission = CRM_Contact_BAO_Group
::checkPermission($this->_groupID
);
397 if ($permission && in_array(CRM_Core_Permission
::EDIT
, $permission)) {
398 $permissionForGroup = TRUE;
401 // check if _groupID exists, it might not if
402 // we are displaying a hidden group
403 if (!isset($this->_group
[$this->_groupID
])) {
404 $this->_group
[$this->_groupID
]
405 = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'title');
408 // set the group title
409 $groupValues = array('id' => $this->_groupID
, 'title' => $this->_group
[$this->_groupID
]);
410 $this->assign_by_ref('group', $groupValues);
412 // also set ssID if this is a saved search
413 $ssID = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'saved_search_id');
414 $this->assign('ssID', $ssID);
416 //get the saved search mapping id
418 $this->_ssID
= $ssID;
419 $ssMappingId = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $ssID, 'mapping_id');
420 $this->assign('ssMappingID', $ssMappingId);
423 // Set dynamic page title for 'Show Members of Group'
424 CRM_Utils_System
::setTitle(ts('Contacts in Group: %1', array(1 => $this->_group
[$this->_groupID
])));
427 $group_contact_status = array();
428 foreach (CRM_Core_SelectValues
::groupContactStatus() as $k => $v) {
430 $group_contact_status[] = $this->createElement('checkbox', $k, NULL, $v);
433 $this->addGroup($group_contact_status,
434 'group_contact_status', ts('Group Status')
437 $this->assign('permissionedForGroup', $permissionForGroup);
440 // add the go button for the action form, note it is of type 'next' rather than of type 'submit'
441 if ($this->_context
=== 'amtg') {
442 // check if _groupID exists, it might not if
443 // we are displaying a hidden group
444 if (!isset($this->_group
[$this->_amtgID
])) {
445 $this->assign('permissionedForGroup', FALSE);
446 $this->_group
[$this->_amtgID
]
447 = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_amtgID
, 'title');
450 // Set dynamic page title for 'Add Members Group'
451 CRM_Utils_System
::setTitle(ts('Add to Group: %1', array(1 => $this->_group
[$this->_amtgID
])));
452 // also set the group title and freeze the action task with Add Members to Group
453 $groupValues = array('id' => $this->_amtgID
, 'title' => $this->_group
[$this->_amtgID
]);
454 $this->assign_by_ref('group', $groupValues);
455 $this->add('submit', $this->_actionButtonName
, ts('Add Contacts to %1', array(1 => $this->_group
[$this->_amtgID
])),
457 'class' => 'crm-form-submit',
460 $this->add('hidden', 'task', CRM_Contact_Task
::GROUP_CONTACTS
);
461 $selectedRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked'));
462 $allRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all');
463 $this->assign('ts_sel_id', $selectedRowsRadio->_attributes
['id']);
464 $this->assign('ts_all_id', $allRowsRadio->_attributes
['id']);
467 $selectedContactIds = array();
468 $qfKeyParam = CRM_Utils_Array
::value('qfKey', $this->_formValues
);
469 // We use ajax to handle selections only if the search results component_mode is set to "contacts"
470 if ($qfKeyParam && ($this->get('component_mode') <= 1 ||
$this->get('component_mode') == 7)) {
471 $this->addClass('crm-ajax-selection-form');
472 $qfKeyParam = "civicrm search {$qfKeyParam}";
473 $selectedContactIdsArr = CRM_Core_BAO_PrevNextCache
::getSelection($qfKeyParam);
474 $selectedContactIds = array_keys($selectedContactIdsArr[$qfKeyParam]);
477 $this->assign_by_ref('selectedContactIds', $selectedContactIds);
479 $rows = $this->get('rows');
481 if (is_array($rows)) {
482 $this->addRowSelectors($rows);
488 * Processing needed for buildForm and later.
490 public function preProcess() {
491 // set the various class variables
493 $this->_group
= CRM_Core_PseudoConstant
::group();
495 $this->_groupIterator
= CRM_Core_PseudoConstant
::groupIterator();
496 $this->_tag
= CRM_Core_BAO_Tag
::getTags();
497 $this->_done
= FALSE;
500 * we allow the controller to set force/reset externally, useful when we are being
501 * driven by the wizard framework
504 $this->_reset
= CRM_Utils_Request
::retrieve('reset', 'Boolean',
505 CRM_Core_DAO
::$_nullObject
508 $this->_force
= CRM_Utils_Request
::retrieve('force', 'Boolean', CRM_Core_DAO
::$_nullObject);
509 $this->_groupID
= CRM_Utils_Request
::retrieve('gid', 'Positive', $this);
510 $this->_amtgID
= CRM_Utils_Request
::retrieve('amtgID', 'Positive', $this);
511 $this->_ssID
= CRM_Utils_Request
::retrieve('ssID', 'Positive', $this);
512 $this->_sortByCharacter
= CRM_Utils_Request
::retrieve('sortByCharacter', 'String', $this);
513 $this->_ufGroupID
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
514 $this->_componentMode
= CRM_Utils_Request
::retrieve('component_mode', 'Positive', $this, FALSE, 1, $_REQUEST);
515 $this->_operator
= CRM_Utils_Request
::retrieve('operator', 'String', $this, FALSE, 1, $_REQUEST, 'AND');
518 * set the button names
520 $this->_searchButtonName
= $this->getButtonName('refresh');
521 $this->_actionButtonName
= $this->getButtonName('next', 'action');
523 $this->assign('actionButtonName', $this->_actionButtonName
);
525 // reset from session, CRM-3526
526 $session = CRM_Core_Session
::singleton();
527 if ($this->_force
&& $session->get('selectedSearchContactIds')) {
528 $session->resetScope('selectedSearchContactIds');
531 // if we dont get this from the url, use default if one exsts
532 $config = CRM_Core_Config
::singleton();
533 if ($this->_ufGroupID
== NULL &&
534 $config->defaultSearchProfileID
!= NULL
536 $this->_ufGroupID
= $config->defaultSearchProfileID
;
539 // assign context to drive the template display, make sure context is valid
540 $this->_context
= CRM_Utils_Request
::retrieve('context', 'String', $this, FALSE, 'search');
541 if (!CRM_Utils_Array
::value($this->_context
, self
::validContext())) {
542 $this->_context
= 'search';
544 $this->set('context', $this->_context
);
545 $this->assign('context', $this->_context
);
547 $this->_modeValue
= self
::getModeValue($this->_componentMode
);
548 $this->assign($this->_modeValue
);
550 $this->set('selectorName', self
::$_selectorName);
552 // get user submitted values
553 // get it from controller only if form has been submitted, else preProcess has set this
554 // $this->controller->isModal( ) returns TRUE if page is
555 // valid, i.e all the validations are TRUE
557 if (!empty($_POST) && !$this->controller
->isModal()) {
558 $this->_formValues
= $this->controller
->exportValues($this->_name
);
560 $this->normalizeFormValues();
561 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
562 $this->_returnProperties
= &$this->returnProperties();
564 // also get the uf group id directly from the post value
565 $this->_ufGroupID
= CRM_Utils_Array
::value('uf_group_id', $_POST, $this->_ufGroupID
);
566 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
567 $this->set('id', $this->_ufGroupID
);
569 // also get the object mode directly from the post value
570 $this->_componentMode
= CRM_Utils_Array
::value('component_mode', $_POST, $this->_componentMode
);
572 // also get the operator from the post value if set
573 $this->_operator
= CRM_Utils_Array
::value('operator', $_POST, $this->_operator
);
574 $this->_formValues
['operator'] = $this->_operator
;
575 $this->set('operator', $this->_operator
);
578 $this->_formValues
= $this->get('formValues');
579 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
580 $this->_returnProperties
= &$this->returnProperties();
581 if (!empty($this->_ufGroupID
)) {
582 $this->set('id', $this->_ufGroupID
);
586 if (empty($this->_formValues
)) {
587 //check if group is a smart group (fix for CRM-1255)
588 if ($this->_groupID
) {
589 if ($ssId = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'saved_search_id')) {
590 $this->_ssID
= $ssId;
595 if (isset($this->_ssID
) && $this->_context
!= 'smog') {
596 // we only retrieve the saved search values if out current values are null
597 $this->_formValues
= CRM_Contact_BAO_SavedSearch
::getFormValues($this->_ssID
);
600 if (CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID
, 'mapping_id')) {
601 $this->_params
= CRM_Contact_BAO_SavedSearch
::getSearchParams($this->_ssID
);
604 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
606 $this->_returnProperties
= &$this->returnProperties();
609 if (isset($this->_ufGroupID
)) {
610 // also set the uf group id if not already present
611 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
613 if (isset($this->_componentMode
)) {
614 $this->_formValues
['component_mode'] = $this->_componentMode
;
616 if (isset($this->_operator
)) {
617 $this->_formValues
['operator'] = $this->_operator
;
620 // FIXME: we should generalise in a way that components could inject url-filters
621 // just like they build their own form elements
624 'mailing_delivery_status',
625 'mailing_open_status',
626 'mailing_click_status',
627 'mailing_reply_status',
630 'mailing_unsubscribe',
633 ) as $mailingFilter) {
635 if ($mailingFilter == 'mailing_id' &&
636 $filterVal = CRM_Utils_Request
::retrieve('mailing_id', 'Positive', $this)
638 $this->_formValues
[$mailingFilter] = array($filterVal);
640 elseif ($filterVal = CRM_Utils_Request
::retrieve($mailingFilter, $type, $this)) {
641 $this->_formValues
[$mailingFilter] = $filterVal;
644 $this->_openedPanes
['Mailings'] = 1;
645 $this->_formValues
['hidden_CiviMail'] = 1;
651 CRM_Utils_Array
::value('uf_group_id', $this->_formValues
)
653 $operator = CRM_Utils_Array
::value('operator', $this->_formValues
, 'AND');
654 $this->set('queryOperator', $operator);
655 if ($operator == 'OR') {
656 $this->assign('operator', ts('OR'));
659 $this->assign('operator', ts('AND'));
662 // show the context menu only when we’re not searching for deleted contacts; CRM-5673
663 if (empty($this->_formValues
['deleted_contacts'])) {
664 $menuItems = CRM_Contact_BAO_Contact
::contextMenu();
665 $primaryActions = CRM_Utils_Array
::value('primaryActions', $menuItems, array());
666 $this->_contextMenu
= CRM_Utils_Array
::value('moreActions', $menuItems, array());
667 $this->assign('contextMenu', $primaryActions +
$this->_contextMenu
);
670 if (!isset($this->_componentMode
)) {
671 $this->_componentMode
= CRM_Contact_BAO_Query
::MODE_CONTACTS
;
673 $modeValues = self
::getModeValue($this->_componentMode
);
675 self
::$_selectorName = $this->_modeValue
['selectorName'];
678 if (strpos(self
::$_selectorName, 'CRM_Contact_Selector') !== FALSE) {
679 $selector = new self
::$_selectorName(
680 $this->_customSearchClass
,
683 $this->_returnProperties
,
692 $selector = new self
::$_selectorName(
700 $selector->setKey($this->controller
->_key
);
702 $controller = new CRM_Contact_Selector_Controller($selector,
703 $this->get(CRM_Utils_Pager
::PAGE_ID
),
704 $this->get(CRM_Utils_Sort
::SORT_ID
),
705 CRM_Core_Action
::VIEW
,
707 CRM_Core_Selector_Controller
::TRANSFER
709 $controller->setEmbedded(TRUE);
710 $controller->setDynamicAction($setDynamic);
714 $this->postProcess();
717 * Note that we repeat this, since the search creates and stores
718 * values that potentially change the controller behavior. i.e. things
719 * like totalCount etc
722 if ($this->get(CRM_Utils_Sort
::SORT_ID
)) {
723 $sortID = CRM_Utils_Sort
::sortIDValue($this->get(CRM_Utils_Sort
::SORT_ID
),
724 $this->get(CRM_Utils_Sort
::SORT_DIRECTION
)
727 $controller = new CRM_Contact_Selector_Controller($selector,
728 $this->get(CRM_Utils_Pager
::PAGE_ID
),
730 CRM_Core_Action
::VIEW
, $this, CRM_Core_Selector_Controller
::TRANSFER
732 $controller->setEmbedded(TRUE);
733 $controller->setDynamicAction($setDynamic);
736 $controller->moveFromSessionToTemplate();
742 public function &getFormValues() {
743 return $this->_formValues
;
747 * Common post processing.
749 public function postProcess() {
751 * sometime we do a postProcess early on, so we dont need to repeat it
752 * this will most likely introduce some more bugs :(
760 //for prev/next pagination
761 $crmPID = CRM_Utils_Request
::retrieve('crmPID', 'Integer', CRM_Core_DAO
::$_nullObject);
763 if (array_key_exists($this->_searchButtonName
, $_POST) ||
764 ($this->_force
&& !$crmPID)
766 //reset the cache table for new search
767 $cacheKey = "civicrm search {$this->controller->_key}";
768 CRM_Core_BAO_PrevNextCache
::deleteItem(NULL, $cacheKey);
771 //get the button name
772 $buttonName = $this->controller
->getButtonName();
774 if (isset($this->_ufGroupID
) && empty($this->_formValues
['uf_group_id'])) {
775 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
778 if (isset($this->_componentMode
) && empty($this->_formValues
['component_mode'])) {
779 $this->_formValues
['component_mode'] = $this->_componentMode
;
782 if (isset($this->_operator
) && empty($this->_formValues
['operator'])) {
783 $this->_formValues
['operator'] = $this->_operator
;
786 if (empty($this->_formValues
['qfKey'])) {
787 $this->_formValues
['qfKey'] = $this->controller
->_key
;
790 if (!CRM_Core_Permission
::check('access deleted contacts')) {
791 unset($this->_formValues
['deleted_contacts']);
794 $this->set('type', $this->_action
);
795 $this->set('formValues', $this->_formValues
);
796 $this->set('queryParams', $this->_params
);
797 $this->set('returnProperties', $this->_returnProperties
);
799 if ($buttonName == $this->_actionButtonName
) {
800 // check actionName and if next, then do not repeat a search, since we are going to the next page
801 // hack, make sure we reset the task values
802 $stateMachine = $this->controller
->getStateMachine();
803 $formName = $stateMachine->getTaskFormName();
804 $this->controller
->resetPage($formName);
808 $output = CRM_Core_Selector_Controller
::SESSION
;
810 // create the selector, controller and run - store results in session
811 $searchChildGroups = TRUE;
812 if ($this->get('isAdvanced')) {
813 $searchChildGroups = FALSE;
818 if (strpos(self
::$_selectorName, 'CRM_Contact_Selector') !== FALSE) {
819 $selector = new self
::$_selectorName(
820 $this->_customSearchClass
,
823 $this->_returnProperties
,
833 $selector = new self
::$_selectorName(
844 $selector->setKey($this->controller
->_key
);
846 // added the sorting character to the form array
847 $config = CRM_Core_Config
::singleton();
848 // do this only for contact search
849 if ($setDynamic && $config->includeAlphabeticalPager
) {
850 // Don't recompute if we are just paging/sorting
851 if ($this->_reset ||
(empty($_GET['crmPID']) && empty($_GET['crmSID']) && !$this->_sortByCharacter
)) {
852 $aToZBar = CRM_Utils_PagerAToZ
::getAToZBar($selector, $this->_sortByCharacter
);
853 $this->set('AToZBar', $aToZBar);
858 if ($this->get(CRM_Utils_Sort
::SORT_ID
)) {
859 $sortID = CRM_Utils_Sort
::sortIDValue($this->get(CRM_Utils_Sort
::SORT_ID
),
860 $this->get(CRM_Utils_Sort
::SORT_DIRECTION
)
863 $controller = new CRM_Contact_Selector_Controller($selector,
864 $this->get(CRM_Utils_Pager
::PAGE_ID
),
866 CRM_Core_Action
::VIEW
,
870 $controller->setEmbedded(TRUE);
871 $controller->setDynamicAction($setDynamic);
879 public function &returnProperties() {
880 return CRM_Core_DAO
::$_nullObject;
884 * Return a descriptive name for the page, used in wizard header
888 public function getTitle() {