3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
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-2018
35 * Base Search / View form for *all* listing of multiple
38 class CRM_Contact_Form_Search
extends CRM_Core_Form_Search
{
41 * list of valid contexts.
45 static $_validContext = NULL;
48 * List of values used when we want to display other objects.
52 static $_modeValues = NULL;
59 protected $_contextMenu;
62 * The groupId retrieved from the GET vars.
69 * The Group ID belonging to Add Member to group ID.
70 * retrieved from the GET vars
77 * The saved search ID retrieved from the GET vars.
89 public $_groupElement;
100 * The params used for search.
107 * The return properties used for search.
111 protected $_returnProperties;
114 * The sort by character.
118 protected $_sortByCharacter;
121 * The profile group id used for display.
125 protected $_ufGroupID;
128 * Csv - common search values
132 static $csv = array('contact_type', 'group', 'tag');
135 * @var string how to display the results. Should we display as
136 * contributons, members, cases etc
138 protected $_componentMode;
141 * @var string what operator should we use, AND or OR
143 protected $_operator;
145 protected $_modeValue;
148 * Declare entity reference fields as they will need to be converted to using 'IN'.
152 protected $entityReferenceFields = array('event_id', 'membership_type_id');
155 * Name of the selector to use.
157 static $_selectorName = 'CRM_Contact_Selector';
158 protected $_customSearchID = NULL;
159 protected $_customSearchClass = NULL;
161 protected $_openedPanes = array();
164 * Explicitly declare the entity api name.
166 public function getDefaultEntity() {
171 * Define the set of valid contexts that the search form operates on.
174 * the valid context set and the titles
176 public static function &validContext() {
177 if (!(self
::$_validContext)) {
178 self
::$_validContext = array(
179 'smog' => 'Show members of group',
180 'amtg' => 'Add members to group',
181 'basic' => 'Basic Search',
182 'search' => 'Search',
183 'builder' => 'Search Builder',
184 'advanced' => 'Advanced Search',
185 'custom' => 'Custom Search',
188 return self
::$_validContext;
196 public static function isSearchContext($context) {
197 $searchContext = CRM_Utils_Array
::value($context, self
::validContext());
198 return $searchContext ?
TRUE : FALSE;
201 public static function setModeValues() {
202 if (!self
::$_modeValues) {
203 self
::$_modeValues = array(
204 CRM_Contact_BAO_Query
::MODE_CONTACTS
=> array(
205 'selectorName' => self
::$_selectorName,
206 'selectorLabel' => ts('Contacts'),
207 'taskFile' => 'CRM/Contact/Form/Search/ResultTasks.tpl',
208 'taskContext' => NULL,
209 'resultFile' => 'CRM/Contact/Form/Selector.tpl',
210 'resultContext' => NULL,
211 'taskClassName' => 'CRM_Contact_Task',
213 CRM_Contact_BAO_Query
::MODE_CONTRIBUTE
=> array(
214 'selectorName' => 'CRM_Contribute_Selector_Search',
215 'selectorLabel' => ts('Contributions'),
216 'taskFile' => 'CRM/common/searchResultTasks.tpl',
217 'taskContext' => 'Contribution',
218 'resultFile' => 'CRM/Contribute/Form/Selector.tpl',
219 'resultContext' => 'Search',
220 'taskClassName' => 'CRM_Contribute_Task',
222 CRM_Contact_BAO_Query
::MODE_EVENT
=> array(
223 'selectorName' => 'CRM_Event_Selector_Search',
224 'selectorLabel' => ts('Event Participants'),
225 'taskFile' => 'CRM/common/searchResultTasks.tpl',
226 'taskContext' => NULL,
227 'resultFile' => 'CRM/Event/Form/Selector.tpl',
228 'resultContext' => 'Search',
229 'taskClassName' => 'CRM_Event_Task',
231 CRM_Contact_BAO_Query
::MODE_ACTIVITY
=> array(
232 'selectorName' => 'CRM_Activity_Selector_Search',
233 'selectorLabel' => ts('Activities'),
234 'taskFile' => 'CRM/common/searchResultTasks.tpl',
235 'taskContext' => NULL,
236 'resultFile' => 'CRM/Activity/Form/Selector.tpl',
237 'resultContext' => 'Search',
238 'taskClassName' => 'CRM_Activity_Task',
240 CRM_Contact_BAO_Query
::MODE_MEMBER
=> array(
241 'selectorName' => 'CRM_Member_Selector_Search',
242 'selectorLabel' => ts('Memberships'),
243 'taskFile' => "CRM/common/searchResultTasks.tpl",
244 'taskContext' => NULL,
245 'resultFile' => 'CRM/Member/Form/Selector.tpl',
246 'resultContext' => 'Search',
247 'taskClassName' => 'CRM_Member_Task',
249 CRM_Contact_BAO_Query
::MODE_CASE
=> array(
250 'selectorName' => 'CRM_Case_Selector_Search',
251 'selectorLabel' => ts('Cases'),
252 'taskFile' => "CRM/common/searchResultTasks.tpl",
253 'taskContext' => NULL,
254 'resultFile' => 'CRM/Case/Form/Selector.tpl',
255 'resultContext' => 'Search',
256 'taskClassName' => 'CRM_Case_Task',
258 CRM_Contact_BAO_Query
::MODE_CONTACTSRELATED
=> array(
259 'selectorName' => self
::$_selectorName,
260 'selectorLabel' => ts('Related Contacts'),
261 'taskFile' => 'CRM/Contact/Form/Search/ResultTasks.tpl',
262 'taskContext' => NULL,
263 'resultFile' => 'CRM/Contact/Form/Selector.tpl',
264 'resultContext' => NULL,
265 'taskClassName' => 'CRM_Contact_Task',
267 CRM_Contact_BAO_Query
::MODE_MAILING
=> array(
268 'selectorName' => 'CRM_Mailing_Selector_Search',
269 'selectorLabel' => ts('Mailings'),
270 'taskFile' => "CRM/common/searchResultTasks.tpl",
271 'taskContext' => NULL,
272 'resultFile' => 'CRM/Mailing/Form/Selector.tpl',
273 'resultContext' => 'Search',
274 'taskClassName' => 'CRM_Mailing_Task',
285 public static function getModeValue($mode = CRM_Contact_BAO_Query
::MODE_CONTACTS
) {
286 self
::setModeValues();
288 if (!array_key_exists($mode, self
::$_modeValues)) {
289 $mode = CRM_Contact_BAO_Query
::MODE_CONTACTS
;
292 return self
::$_modeValues[$mode];
298 public static function getModeSelect() {
299 self
::setModeValues();
301 $componentModes = array();
302 foreach (self
::$_modeValues as $id => & $value) {
303 $componentModes[$id] = $value['selectorLabel'];
306 $enabledComponents = CRM_Core_Component
::getEnabledComponents();
308 // unset disabled components
309 if (!array_key_exists('CiviMail', $enabledComponents)) {
310 unset($componentModes[CRM_Contact_BAO_Query
::MODE_MAILING
]);
313 // unset contributions or participants if user does not have permission on them
314 if (!CRM_Core_Permission
::access('CiviContribute')) {
315 unset($componentModes[CRM_Contact_BAO_Query
::MODE_CONTRIBUTE
]);
318 if (!CRM_Core_Permission
::access('CiviEvent')) {
319 unset($componentModes[CRM_Contact_BAO_Query
::MODE_EVENT
]);
322 if (!CRM_Core_Permission
::access('CiviMember')) {
323 unset($componentModes[CRM_Contact_BAO_Query
::MODE_MEMBER
]);
326 if (!CRM_Core_Permission
::check('view all activities')) {
327 unset($componentModes[CRM_Contact_BAO_Query
::MODE_ACTIVITY
]);
330 return $componentModes;
334 * Builds the list of tasks or actions that a searcher can perform on a result set.
338 public function buildTaskList() {
339 // amtg = 'Add members to group'
340 if ($this->_context
!== 'amtg') {
341 $taskParams['deletedContacts'] = FALSE;
342 if ($this->_componentMode
== CRM_Contact_BAO_Query
::MODE_CONTACTS ||
$this->_componentMode
== CRM_Contact_BAO_Query
::MODE_CONTACTSRELATED
) {
343 $taskParams['deletedContacts'] = CRM_Utils_Array
::value('deleted_contacts', $this->_formValues
);
345 $className = $this->_modeValue
['taskClassName'];
346 $taskParams['ssID'] = isset($this->_ssID
) ?
$this->_ssID
: NULL;
347 $this->_taskList +
= $className::permissionedTaskTitles(CRM_Core_Permission
::getPermission(), $taskParams);
350 return $this->_taskList
;
354 * Build the common elements between the search/advanced form.
356 public function buildQuickForm() {
357 parent
::buildQuickForm();
358 CRM_Core_Resources
::singleton()
359 // jsTree is needed for tags popup
360 ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)
361 ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
363 // some tasks.. what do we want to do with the selected contacts ?
364 $this->_taskList
= $this->buildTaskList();
366 if (isset($this->_ssID
)) {
368 = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID
, 'search_custom_id');
370 $savedSearchValues = array(
371 'id' => $this->_ssID
,
372 'name' => CRM_Contact_BAO_SavedSearch
::getName($this->_ssID
, 'title'),
373 'search_custom_id' => $search_custom_id,
375 $this->assign_by_ref('savedSearch', $savedSearchValues);
376 $this->assign('ssID', $this->_ssID
);
379 if ($this->_context
=== 'smog') {
380 // CRM-11788, we might want to do this for all of search where force=1
381 $formQFKey = CRM_Utils_Array
::value('qfKey', $this->_formValues
);
382 $getQFKey = CRM_Utils_Array
::value('qfKey', $_GET);
383 $postQFKey = CRM_Utils_Array
::value('qfKey', $_POST);
384 if ($formQFKey && empty($getQFKey) && empty($postQFKey)) {
385 $url = CRM_Utils_System
::makeURL('qfKey') . $formQFKey;
386 CRM_Utils_System
::redirect($url);
388 $permissionForGroup = FALSE;
390 if (!empty($this->_groupID
)) {
391 // check if user has permission to edit members of this group
392 $permission = CRM_Contact_BAO_Group
::checkPermission($this->_groupID
);
393 if ($permission && in_array(CRM_Core_Permission
::EDIT
, $permission)) {
394 $permissionForGroup = TRUE;
397 // check if _groupID exists, it might not if
398 // we are displaying a hidden group
399 if (!isset($this->_group
[$this->_groupID
])) {
400 $this->_group
[$this->_groupID
]
401 = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'title');
404 // set the group title
405 $groupValues = array('id' => $this->_groupID
, 'title' => $this->_group
[$this->_groupID
]);
406 $this->assign_by_ref('group', $groupValues);
408 // also set ssID if this is a saved search
409 $ssID = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'saved_search_id');
410 $this->assign('ssID', $ssID);
412 //get the saved search mapping id
414 $this->_ssID
= $ssID;
415 $ssMappingId = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $ssID, 'mapping_id');
416 $this->assign('ssMappingID', $ssMappingId);
419 // Set dynamic page title for 'Show Members of Group'
420 CRM_Utils_System
::setTitle(ts('Contacts in Group: %1', array(1 => $this->_group
[$this->_groupID
])));
423 $group_contact_status = array();
424 foreach (CRM_Core_SelectValues
::groupContactStatus() as $k => $v) {
426 $group_contact_status[] = $this->createElement('checkbox', $k, NULL, $v);
429 $this->addGroup($group_contact_status,
430 'group_contact_status', ts('Group Status')
433 $this->assign('permissionedForGroup', $permissionForGroup);
436 // add the go button for the action form, note it is of type 'next' rather than of type 'submit'
437 if ($this->_context
=== 'amtg') {
438 // check if _groupID exists, it might not if
439 // we are displaying a hidden group
440 if (!isset($this->_group
[$this->_amtgID
])) {
441 $this->assign('permissionedForGroup', FALSE);
442 $this->_group
[$this->_amtgID
]
443 = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_amtgID
, 'title');
446 // Set dynamic page title for 'Add Members Group'
447 CRM_Utils_System
::setTitle(ts('Add to Group: %1', array(1 => $this->_group
[$this->_amtgID
])));
448 // also set the group title and freeze the action task with Add Members to Group
449 $groupValues = array('id' => $this->_amtgID
, 'title' => $this->_group
[$this->_amtgID
]);
450 $this->assign_by_ref('group', $groupValues);
451 $this->add('submit', $this->_actionButtonName
, ts('Add Contacts to %1', array(1 => $this->_group
[$this->_amtgID
])),
453 'class' => 'crm-form-submit',
456 $this->add('hidden', 'task', CRM_Contact_Task
::GROUP_ADD
);
457 $selectedRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked'));
458 $allRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all');
459 $this->assign('ts_sel_id', $selectedRowsRadio->_attributes
['id']);
460 $this->assign('ts_all_id', $allRowsRadio->_attributes
['id']);
463 $selectedContactIds = array();
464 $qfKeyParam = CRM_Utils_Array
::value('qfKey', $this->_formValues
);
465 // We use ajax to handle selections only if the search results component_mode is set to "contacts"
466 if ($qfKeyParam && ($this->get('component_mode') <= CRM_Contact_BAO_Query
::MODE_CONTACTS ||
$this->get('component_mode') == CRM_Contact_BAO_Query
::MODE_CONTACTSRELATED
)) {
467 $this->addClass('crm-ajax-selection-form');
468 $qfKeyParam = "civicrm search {$qfKeyParam}";
469 $selectedContactIdsArr = CRM_Core_BAO_PrevNextCache
::getSelection($qfKeyParam);
470 $selectedContactIds = array_keys($selectedContactIdsArr[$qfKeyParam]);
473 $this->assign_by_ref('selectedContactIds', $selectedContactIds);
475 $rows = $this->get('rows');
477 if (is_array($rows)) {
478 $this->addRowSelectors($rows);
484 * Processing needed for buildForm and later.
486 public function preProcess() {
487 // set the various class variables
489 $this->_group
= CRM_Core_PseudoConstant
::group();
491 $this->_tag
= CRM_Core_BAO_Tag
::getTags();
492 $this->_done
= FALSE;
495 * we allow the controller to set force/reset externally, useful when we are being
496 * driven by the wizard framework
499 $this->_reset
= CRM_Utils_Request
::retrieve('reset', 'Boolean');
501 $this->_force
= CRM_Utils_Request
::retrieve('force', 'Boolean');
502 $this->_groupID
= CRM_Utils_Request
::retrieve('gid', 'Positive', $this);
503 $this->_amtgID
= CRM_Utils_Request
::retrieve('amtgID', 'Positive', $this);
504 $this->_ssID
= CRM_Utils_Request
::retrieve('ssID', 'Positive', $this);
505 $this->_sortByCharacter
= CRM_Utils_Request
::retrieve('sortByCharacter', 'String', $this);
506 $this->_ufGroupID
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
507 $this->_componentMode
= CRM_Utils_Request
::retrieve('component_mode', 'Positive', $this, FALSE, CRM_Contact_BAO_Query
::MODE_CONTACTS
, $_REQUEST);
508 $this->_operator
= CRM_Utils_Request
::retrieve('operator', 'String', $this, FALSE, CRM_Contact_BAO_Query
::SEARCH_OPERATOR_AND
, 'REQUEST');
511 * set the button names
513 $this->_searchButtonName
= $this->getButtonName('refresh');
514 $this->_actionButtonName
= $this->getButtonName('next', 'action');
516 $this->assign('actionButtonName', $this->_actionButtonName
);
518 // if we dont get this from the url, use default if one exsts
519 $config = CRM_Core_Config
::singleton();
520 if ($this->_ufGroupID
== NULL &&
521 $config->defaultSearchProfileID
!= NULL
523 $this->_ufGroupID
= $config->defaultSearchProfileID
;
526 // assign context to drive the template display, make sure context is valid
527 $this->_context
= CRM_Utils_Request
::retrieve('context', 'String', $this, FALSE, 'search');
528 if (!CRM_Utils_Array
::value($this->_context
, self
::validContext())) {
529 $this->_context
= 'search';
531 $this->set('context', $this->_context
);
532 $this->assign('context', $this->_context
);
534 $this->_modeValue
= self
::getModeValue($this->_componentMode
);
535 $this->assign($this->_modeValue
);
537 $this->set('selectorName', self
::$_selectorName);
539 // get user submitted values
540 // get it from controller only if form has been submitted, else preProcess has set this
541 // $this->controller->isModal( ) returns TRUE if page is
542 // valid, i.e all the validations are TRUE
544 if (!empty($_POST) && !$this->controller
->isModal()) {
545 $this->_formValues
= $this->controller
->exportValues($this->_name
);
547 $this->normalizeFormValues();
548 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
, 0, FALSE, NULL, $this->entityReferenceFields
);
549 $this->_returnProperties
= &$this->returnProperties();
551 // also get the uf group id directly from the post value
552 $this->_ufGroupID
= CRM_Utils_Array
::value('uf_group_id', $_POST, $this->_ufGroupID
);
553 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
554 $this->set('id', $this->_ufGroupID
);
556 // also get the object mode directly from the post value
557 $this->_componentMode
= CRM_Utils_Array
::value('component_mode', $_POST, $this->_componentMode
);
559 // also get the operator from the post value if set
560 $this->_operator
= CRM_Utils_Array
::value('operator', $_POST, $this->_operator
);
561 $this->_formValues
['operator'] = $this->_operator
;
562 $this->set('operator', $this->_operator
);
565 $this->_formValues
= $this->get('formValues');
566 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
, 0, FALSE, NULL, $this->entityReferenceFields
);
567 $this->_returnProperties
= &$this->returnProperties();
568 if (!empty($this->_ufGroupID
)) {
569 $this->set('id', $this->_ufGroupID
);
573 if (empty($this->_formValues
)) {
574 //check if group is a smart group (fix for CRM-1255)
575 if ($this->_groupID
) {
576 if ($ssId = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'saved_search_id')) {
577 $this->_ssID
= $ssId;
582 if (isset($this->_ssID
) && $this->_context
!= 'smog') {
583 // we only retrieve the saved search values if out current values are null
584 $this->_formValues
= CRM_Contact_BAO_SavedSearch
::getFormValues($this->_ssID
);
587 if (CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID
, 'mapping_id')) {
588 $this->_params
= CRM_Contact_BAO_SavedSearch
::getSearchParams($this->_ssID
);
591 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
593 $this->_returnProperties
= &$this->returnProperties();
596 if (isset($this->_ufGroupID
)) {
597 // also set the uf group id if not already present
598 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
600 if (isset($this->_componentMode
)) {
601 $this->_formValues
['component_mode'] = $this->_componentMode
;
603 if (isset($this->_operator
)) {
604 $this->_formValues
['operator'] = $this->_operator
;
607 // FIXME: we should generalise in a way that components could inject url-filters
608 // just like they build their own form elements
611 'mailing_delivery_status',
612 'mailing_open_status',
613 'mailing_click_status',
614 'mailing_reply_status',
617 'mailing_unsubscribe',
620 ) as $mailingFilter) {
622 if ($mailingFilter == 'mailing_id' &&
623 $filterVal = CRM_Utils_Request
::retrieve('mailing_id', 'Positive', $this)
625 $this->_formValues
[$mailingFilter] = array($filterVal);
627 elseif ($filterVal = CRM_Utils_Request
::retrieve($mailingFilter, $type, $this)) {
628 $this->_formValues
[$mailingFilter] = $filterVal;
631 $this->_openedPanes
['Mailings'] = 1;
632 $this->_formValues
['hidden_CiviMail'] = 1;
638 CRM_Utils_Array
::value('uf_group_id', $this->_formValues
)
640 $operator = CRM_Utils_Array
::value('operator', $this->_formValues
, CRM_Contact_BAO_Query
::SEARCH_OPERATOR_AND
);
641 $this->set('queryOperator', $operator);
642 if ($operator == CRM_Contact_BAO_Query
::SEARCH_OPERATOR_OR
) {
643 $this->assign('operator', ts('OR'));
646 $this->assign('operator', ts('AND'));
649 // show the context menu only when we’re not searching for deleted contacts; CRM-5673
650 if (empty($this->_formValues
['deleted_contacts'])) {
651 $menuItems = CRM_Contact_BAO_Contact
::contextMenu();
652 $primaryActions = CRM_Utils_Array
::value('primaryActions', $menuItems, array());
653 $this->_contextMenu
= CRM_Utils_Array
::value('moreActions', $menuItems, array());
654 $this->assign('contextMenu', $primaryActions +
$this->_contextMenu
);
657 if (!isset($this->_componentMode
)) {
658 $this->_componentMode
= CRM_Contact_BAO_Query
::MODE_CONTACTS
;
660 self
::setModeValues();
662 self
::$_selectorName = $this->_modeValue
['selectorName'];
665 if (strpos(self
::$_selectorName, 'CRM_Contact_Selector') !== FALSE) {
666 $selector = new self
::$_selectorName(
667 $this->_customSearchClass
,
670 $this->_returnProperties
,
679 $selector = new self
::$_selectorName(
687 $selector->setKey($this->controller
->_key
);
689 $controller = new CRM_Contact_Selector_Controller($selector,
690 $this->get(CRM_Utils_Pager
::PAGE_ID
),
691 $this->get(CRM_Utils_Sort
::SORT_ID
),
692 CRM_Core_Action
::VIEW
,
694 CRM_Core_Selector_Controller
::TRANSFER
696 $controller->setEmbedded(TRUE);
697 $controller->setDynamicAction($setDynamic);
701 $this->postProcess();
704 * Note that we repeat this, since the search creates and stores
705 * values that potentially change the controller behavior. i.e. things
706 * like totalCount etc
709 if ($this->get(CRM_Utils_Sort
::SORT_ID
)) {
710 $sortID = CRM_Utils_Sort
::sortIDValue($this->get(CRM_Utils_Sort
::SORT_ID
),
711 $this->get(CRM_Utils_Sort
::SORT_DIRECTION
)
714 $controller = new CRM_Contact_Selector_Controller($selector,
715 $this->get(CRM_Utils_Pager
::PAGE_ID
),
717 CRM_Core_Action
::VIEW
, $this, CRM_Core_Selector_Controller
::TRANSFER
719 $controller->setEmbedded(TRUE);
720 $controller->setDynamicAction($setDynamic);
723 $controller->moveFromSessionToTemplate();
729 public function &getFormValues() {
730 return $this->_formValues
;
734 * Common post processing.
736 public function postProcess() {
738 * sometime we do a postProcess early on, so we dont need to repeat it
739 * this will most likely introduce some more bugs :(
747 //for prev/next pagination
748 $crmPID = CRM_Utils_Request
::retrieve('crmPID', 'Integer');
750 if (array_key_exists($this->_searchButtonName
, $_POST) ||
751 ($this->_force
&& !$crmPID)
753 //reset the cache table for new search
754 $cacheKey = "civicrm search {$this->controller->_key}";
755 CRM_Core_BAO_PrevNextCache
::deleteItem(NULL, $cacheKey);
758 //get the button name
759 $buttonName = $this->controller
->getButtonName();
761 if (isset($this->_ufGroupID
) && empty($this->_formValues
['uf_group_id'])) {
762 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
765 if (isset($this->_componentMode
) && empty($this->_formValues
['component_mode'])) {
766 $this->_formValues
['component_mode'] = $this->_componentMode
;
769 if (isset($this->_operator
) && empty($this->_formValues
['operator'])) {
770 $this->_formValues
['operator'] = $this->_operator
;
773 if (empty($this->_formValues
['qfKey'])) {
774 $this->_formValues
['qfKey'] = $this->controller
->_key
;
777 if (!CRM_Core_Permission
::check('access deleted contacts')) {
778 unset($this->_formValues
['deleted_contacts']);
781 $this->set('type', $this->_action
);
782 $this->set('formValues', $this->_formValues
);
783 $this->set('queryParams', $this->_params
);
784 $this->set('returnProperties', $this->_returnProperties
);
786 if ($buttonName == $this->_actionButtonName
) {
787 // check actionName and if next, then do not repeat a search, since we are going to the next page
788 // hack, make sure we reset the task values
789 $stateMachine = $this->controller
->getStateMachine();
790 $formName = $stateMachine->getTaskFormName();
791 $this->controller
->resetPage($formName);
795 $output = CRM_Core_Selector_Controller
::SESSION
;
797 // create the selector, controller and run - store results in session
798 $searchChildGroups = TRUE;
799 if ($this->get('isAdvanced')) {
800 $searchChildGroups = FALSE;
805 if (strpos(self
::$_selectorName, 'CRM_Contact_Selector') !== FALSE) {
806 $selector = new self
::$_selectorName(
807 $this->_customSearchClass
,
810 $this->_returnProperties
,
820 $selector = new self
::$_selectorName(
831 $selector->setKey($this->controller
->_key
);
833 // added the sorting character to the form array
834 $config = CRM_Core_Config
::singleton();
835 // do this only for contact search
836 if ($setDynamic && $config->includeAlphabeticalPager
) {
837 // Don't recompute if we are just paging/sorting
838 if ($this->_reset ||
(empty($_GET['crmPID']) && empty($_GET['crmSID']) && !$this->_sortByCharacter
)) {
839 $aToZBar = CRM_Utils_PagerAToZ
::getAToZBar($selector, $this->_sortByCharacter
);
840 $this->set('AToZBar', $aToZBar);
845 if ($this->get(CRM_Utils_Sort
::SORT_ID
)) {
846 $sortID = CRM_Utils_Sort
::sortIDValue($this->get(CRM_Utils_Sort
::SORT_ID
),
847 $this->get(CRM_Utils_Sort
::SORT_DIRECTION
)
850 $controller = new CRM_Contact_Selector_Controller($selector,
851 $this->get(CRM_Utils_Pager
::PAGE_ID
),
853 CRM_Core_Action
::VIEW
,
857 $controller->setEmbedded(TRUE);
858 $controller->setDynamicAction($setDynamic);
866 public function &returnProperties() {
867 return CRM_Core_DAO
::$_nullObject;
871 * Return a descriptive name for the page, used in wizard header
875 public function getTitle() {