3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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-2013
41 * Base Search / View form for *all* listing of multiple
44 class CRM_Contact_Form_Search
extends CRM_Core_Form
{
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;
63 * The context that we are working on
76 protected $_contextMenu;
79 * the groupId retrieved from the GET vars
87 * the Group ID belonging to Add Member to group ID
88 * retrieved from the GET vars
96 * the saved search ID retrieved from the GET vars
104 * Are we forced to run a search
112 * name of search button
117 protected $_searchButtonName;
120 * name of print button
125 protected $_printButtonName;
128 * name of action button
133 protected $_actionButtonName;
142 public $_groupElement;
143 public $_groupIterator;
155 * form values that we will be using
163 * The params used for search
171 * The return properties used for search
176 protected $_returnProperties;
179 * The sort by character
184 protected $_sortByCharacter;
187 * The profile group id used for display
192 protected $_ufGroupID;
195 * csv - common search values
202 static $csv = array('contact_type', 'group', 'tag');
205 * @var string how to display the results. Should we display as
206 * contributons, members, cases etc
208 protected $_componentMode;
211 * @var string what operator should we use, AND or OR
213 protected $_operator;
215 protected $_modeValue;
218 * have we already done this search
226 * name of the selector to use
228 static $_selectorName = 'CRM_Contact_Selector';
229 protected $_customSearchID = NULL;
230 protected $_customSearchClass = NULL;
232 protected $_openedPanes = array();
235 * define the set of valid contexts that the search form operates on
237 * @return array the valid context set and the titles
241 static function &validContext() {
242 if (!(self
::$_validContext)) {
243 self
::$_validContext = array(
244 'smog' => 'Show members of group',
245 'amtg' => 'Add members to group',
246 'basic' => 'Basic Search',
247 'search' => 'Search',
248 'builder' => 'Search Builder',
249 'advanced' => 'Advanced Search',
250 'custom' => 'Custom Search',
253 return self
::$_validContext;
256 static function isSearchContext($context) {
257 $searchContext = CRM_Utils_Array
::value($context, self
::validContext());
258 return $searchContext ?
TRUE : FALSE;
261 static function setModeValues() {
262 if (!self
::$_modeValues) {
263 self
::$_modeValues = array(
265 'selectorName' => self
::$_selectorName,
266 'selectorLabel' => ts('Contacts'),
267 'taskFile' => 'CRM/Contact/Form/Search/ResultTasks.tpl',
268 'taskContext' => NULL,
269 'resultFile' => 'CRM/Contact/Form/Selector.tpl',
270 'resultContext' => NULL,
271 'taskClassName' => 'CRM_Contact_Task',
274 'selectorName' => 'CRM_Contribute_Selector_Search',
275 'selectorLabel' => ts('Contributions'),
276 'taskFile' => 'CRM/common/searchResultTasks.tpl',
277 'taskContext' => 'Contribution',
278 'resultFile' => 'CRM/Contribute/Form/Selector.tpl',
279 'resultContext' => 'Search',
280 'taskClassName' => 'CRM_Contribute_Task',
283 'selectorName' => 'CRM_Event_Selector_Search',
284 'selectorLabel' => ts('Event Participants'),
285 'taskFile' => 'CRM/common/searchResultTasks.tpl',
286 'taskContext' => NULL,
287 'resultFile' => 'CRM/Event/Form/Selector.tpl',
288 'resultContext' => 'Search',
289 'taskClassName' => 'CRM_Event_Task',
292 'selectorName' => 'CRM_Activity_Selector_Search',
293 'selectorLabel' => ts('Activities'),
294 'taskFile' => 'CRM/common/searchResultTasks.tpl',
295 'taskContext' => NULL,
296 'resultFile' => 'CRM/Activity/Form/Selector.tpl',
297 'resultContext' => 'Search',
298 'taskClassName' => 'CRM_Activity_Task',
301 'selectorName' => 'CRM_Member_Selector_Search',
302 'selectorLabel' => ts('Memberships'),
303 'taskFile' => "CRM/common/searchResultTasks.tpl",
304 'taskContext' => NULL,
305 'resultFile' => 'CRM/Member/Form/Selector.tpl',
306 'resultContext' => 'Search',
307 'taskClassName' => 'CRM_Member_Task',
310 'selectorName' => 'CRM_Case_Selector_Search',
311 'selectorLabel' => ts('Cases'),
312 'taskFile' => "CRM/common/searchResultTasks.tpl",
313 'taskContext' => NULL,
314 'resultFile' => 'CRM/Case/Form/Selector.tpl',
315 'resultContext' => 'Search',
316 'taskClassName' => 'CRM_Case_Task',
319 'selectorName' => self
::$_selectorName,
320 'selectorLabel' => ts('Related Contacts'),
321 'taskFile' => 'CRM/Contact/Form/Search/ResultTasks.tpl',
322 'taskContext' => NULL,
323 'resultFile' => 'CRM/Contact/Form/Selector.tpl',
324 'resultContext' => NULL,
325 'taskClassName' => 'CRM_Contact_Task',
328 'selectorName' => 'CRM_Mailing_Selector_Search',
329 'selectorLabel' => ts('Mailings'),
330 'taskFile' => "CRM/common/searchResultTasks.tpl",
331 'taskContext' => NULL,
332 'resultFile' => 'CRM/Mailing/Form/Selector.tpl',
333 'resultContext' => 'Search',
334 'taskClassName' => 'CRM_Mailing_Task',
340 static function getModeValue($mode = 1) {
341 self
::setModeValues();
343 if (!array_key_exists($mode, self
::$_modeValues)) {
347 return self
::$_modeValues[$mode];
350 static function getModeSelect() {
351 self
::setModeValues();
354 foreach (self
::$_modeValues as $id => & $value) {
355 $select[$id] = $value['selectorLabel'];
358 // unset contributions or participants if user does not have
359 // permission on them
360 if (!CRM_Core_Permission
::access('CiviContribute')) {
364 if (!CRM_Core_Permission
::access('CiviEvent')) {
368 if (!CRM_Core_Permission
::check('view all activities')) {
375 * Build the common elements between the search/advanced form
381 function buildQuickForm() {
382 CRM_Core_Resources
::singleton()
383 ->addScriptFile('civicrm', 'js/crm.livePage.js')
384 // jsTree is needed for tags popup
385 ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)
386 ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
387 $permission = CRM_Core_Permission
::getPermission();
388 // some tasks.. what do we want to do with the selected contacts ?
389 $tasks = array('' => ts('- actions -'));
390 if ($this->_componentMode
== 1 ||
$this->_componentMode
== 7) {
391 $tasks +
= CRM_Contact_Task
::permissionedTaskTitles($permission,
392 CRM_Utils_Array
::value('deleted_contacts', $this->_formValues
)
396 $className = $this->_modeValue
['taskClassName'];
397 $tasks +
= $className::permissionedTaskTitles($permission, false);
400 if (isset($this->_ssID
)) {
401 if ($permission == CRM_Core_Permission
::EDIT
) {
402 $tasks = $tasks + CRM_Contact_Task
::optionalTaskTitle();
406 CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID
, 'search_custom_id');
408 $savedSearchValues = array(
409 'id' => $this->_ssID
,
410 'name' => CRM_Contact_BAO_SavedSearch
::getName($this->_ssID
, 'title'),
411 'search_custom_id' => $search_custom_id,
413 $this->assign_by_ref('savedSearch', $savedSearchValues);
414 $this->assign('ssID', $this->_ssID
);
417 if ($this->_context
=== 'smog') {
418 // CRM-11788, we might want to do this for all of search where force=1
419 $formQFKey = CRM_Utils_Array
::value('qfKey', $this->_formValues
);
420 $getQFKey = CRM_Utils_Array
::value('qfKey', $_GET);
421 $postQFKey = CRM_Utils_Array
::value('qfKey', $_POST);
422 if ($formQFKey && empty($getQFKey) && empty($postQFKey)) {
423 $url = CRM_Utils_System
::makeURL('qfKey') . $formQFKey;
424 CRM_Utils_System
::redirect($url);
427 if (!empty($this->_groupID
)) {
428 $permissionForGroup = FALSE;
430 // check if user has permission to edit members of this group
431 $permission = CRM_Contact_BAO_Group
::checkPermission($this->_groupID
);
432 if ($permission && in_array(CRM_Core_Permission
::EDIT
, $permission)) {
433 $permissionForGroup = TRUE;
436 // check if _groupID exists, it might not if
437 // we are displaying a hidden group
438 if (!isset($this->_group
[$this->_groupID
])) {
439 $permissionForGroup = FALSE;
440 $this->_group
[$this->_groupID
] =
441 CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'title');
444 $this->assign('permissionedForGroup', $permissionForGroup);
446 // set the group title
447 $groupValues = array('id' => $this->_groupID
, 'title' => $this->_group
[$this->_groupID
]);
448 $this->assign_by_ref('group', $groupValues);
450 // also set ssID if this is a saved search
451 $ssID = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'saved_search_id');
452 $this->assign('ssID', $ssID);
454 //get the saved search mapping id
456 $this->_ssID
= $ssID;
457 $ssMappingId = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $ssID, 'mapping_id');
458 $this->assign('ssMappingID', $ssMappingId);
461 // Set dynamic page title for 'Show Members of Group'
462 CRM_Utils_System
::setTitle(ts('Contacts in Group: %1', array(1 => $this->_group
[$this->_groupID
])));
465 $group_contact_status = array();
466 foreach (CRM_Core_SelectValues
::groupContactStatus() as $k => $v) {
468 $group_contact_status[] = $this->createElement('checkbox', $k, NULL, $v);
471 $this->addGroup($group_contact_status,
472 'group_contact_status', ts('Group Status')
475 $this->assign('permissionedForGroup', FALSE);
478 // add the go button for the action form, note it is of type 'next' rather than of type 'submit'
479 if ($this->_context
=== 'amtg') {
480 // check if _groupID exists, it might not if
481 // we are displaying a hidden group
482 if (!isset($this->_group
[$this->_amtgID
])) {
483 $this->assign('permissionedForGroup', FALSE);
484 $this->_group
[$this->_amtgID
] =
485 CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_amtgID
, 'title');
488 // Set dynamic page title for 'Add Members Group'
489 CRM_Utils_System
::setTitle(ts('Add to Group: %1', array(1 => $this->_group
[$this->_amtgID
])));
490 // also set the group title and freeze the action task with Add Members to Group
491 $groupValues = array('id' => $this->_amtgID
, 'title' => $this->_group
[$this->_amtgID
]);
492 $this->assign_by_ref('group', $groupValues);
493 $this->add('submit', $this->_actionButtonName
, ts('Add Contacts to %1', array(1 => $this->_group
[$this->_amtgID
])),
495 'class' => 'form-submit',
496 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 1);",
499 $this->add('hidden', 'task', CRM_Contact_Task
::GROUP_CONTACTS
);
502 $this->add('select', 'task', ts('Actions:') . ' ', $tasks);
503 $this->add('submit', $this->_actionButtonName
, ts('Go'),
505 'class' => 'form-submit',
507 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 0, 1);",
512 // need to perform tasks on all or selected items ? using radio_ts(task selection) for it
513 $selectedRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array(
514 'checked' => 'checked',
515 'onclick' => 'toggleTaskAction( true );',
517 $this->assign('ts_sel_id', $selectedRowsRadio->_attributes
['id']);
520 if ($qfKeyParam = CRM_Utils_Array
::value('qfKey', $this->_formValues
)) {
521 $qfKeyParam = "civicrm search {$qfKeyParam}";
522 $selectedContactIdsArr = CRM_Core_BAO_PrevNextCache
::getSelection($qfKeyParam);
523 $selectedContactIds = array_keys($selectedContactIdsArr[$qfKeyParam]);
526 $this->assign_by_ref('selectedContactIds', $selectedContactIds);
528 $allRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all', array('onclick' => $this->getName() . ".toggleSelect.checked = false; toggleCheckboxVals('mark_x_', this);toggleTaskAction( true );toggleContactSelection( 'resetSel', '{$qfKeyParam}', 'reset' );"));
529 $this->assign('ts_all_id', $allRowsRadio->_attributes
['id']);
532 * add form checkboxes for each row. This is needed out here to conform to QF protocol
533 * of all elements being declared in builQuickForm
536 $rows = $this->get('rows');
538 if (is_array($rows)) {
539 $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('onclick' => "toggleTaskAction( true ); toggleCheckboxVals('mark_x_',this);return toggleContactSelection( 'toggleSelect', '" . $qfKeyParam . "' , 'multiple' );"));
541 $unselectedContactIds = array();
542 foreach ($rows as $row) {
543 $this->addElement('checkbox', $row['checkbox'],
545 array('onclick' => "toggleContactSelection( '" . $row['checkbox'] . "', '" . $qfKeyParam . "' , 'single' );toggleTaskAction( true ); return checkSelectedBox('" . $row['checkbox'] . "');")
548 if (!in_array($row['contact_id'], $selectedContactIds)) {
549 $unselectedContactIds[] = $row['contact_id'];
552 $this->assign_by_ref('unselectedContactIds', $unselectedContactIds);
556 $this->addButtons(array(
559 'name' => ts('Search'),
565 $this->setDefaultAction('refresh');
569 * processing needed for buildForm and later
574 function preProcess() {
575 // set the various class variables
577 $this->_group
= CRM_Core_PseudoConstant
::group();
579 $this->_groupIterator
= CRM_Core_PseudoConstant
::groupIterator();
580 $this->_tag
= CRM_Core_BAO_Tag
::getTags();
581 $this->_done
= FALSE;
584 * we allow the controller to set force/reset externally, useful when we are being
585 * driven by the wizard framework
588 $this->_reset
= CRM_Utils_Request
::retrieve('reset', 'Boolean',
589 CRM_Core_DAO
::$_nullObject
592 $this->_force
= CRM_Utils_Request
::retrieve('force', 'Boolean', CRM_Core_DAO
::$_nullObject);
593 $this->_groupID
= CRM_Utils_Request
::retrieve('gid', 'Positive', $this);
594 $this->_amtgID
= CRM_Utils_Request
::retrieve('amtgID', 'Positive', $this);
595 $this->_ssID
= CRM_Utils_Request
::retrieve('ssID', 'Positive', $this);
596 $this->_sortByCharacter
= CRM_Utils_Request
::retrieve('sortByCharacter', 'String', $this);
597 $this->_ufGroupID
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
598 $this->_componentMode
= CRM_Utils_Request
::retrieve('component_mode', 'Positive', $this, FALSE, 1, $_REQUEST);
599 $this->_operator
= CRM_Utils_Request
::retrieve('operator', 'String', $this, FALSE, 1, $_REQUEST, 'AND');
602 * set the button names
604 $this->_searchButtonName
= $this->getButtonName('refresh');
605 $this->_printButtonName
= $this->getButtonName('next', 'print');
606 $this->_actionButtonName
= $this->getButtonName('next', 'action');
608 $this->assign('printButtonName', $this->_printButtonName
);
610 $this->assign('actionButtonName', $this->_actionButtonName
);
612 // reset from session, CRM-3526
613 $session = CRM_Core_Session
::singleton();
614 if ($this->_force
&& $session->get('selectedSearchContactIds')) {
615 $session->resetScope('selectedSearchContactIds');
618 // if we dont get this from the url, use default if one exsts
619 $config = CRM_Core_Config
::singleton();
620 if ($this->_ufGroupID
== NULL &&
621 $config->defaultSearchProfileID
!= NULL
623 $this->_ufGroupID
= $config->defaultSearchProfileID
;
626 // assign context to drive the template display, make sure context is valid
627 $this->_context
= CRM_Utils_Request
::retrieve('context', 'String', $this, FALSE, 'search');
628 if (!CRM_Utils_Array
::value($this->_context
, self
::validContext())) {
629 $this->_context
= 'search';
631 $this->set('context', $this->_context
);
632 $this->assign('context', $this->_context
);
634 $this->_modeValue
= self
::getModeValue($this->_componentMode
);
635 $this->assign($this->_modeValue
);
637 $this->set('selectorName', self
::$_selectorName);
639 // get user submitted values
640 // get it from controller only if form has been submitted, else preProcess has set this
641 // $this->controller->isModal( ) returns true if page is
642 // valid, i.e all the validations are true
644 if (!empty($_POST) && !$this->controller
->isModal()) {
645 $this->_formValues
= $this->controller
->exportValues($this->_name
);
647 $this->normalizeFormValues();
648 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
649 $this->_returnProperties
= &$this->returnProperties();
651 // also get the uf group id directly from the post value
652 $this->_ufGroupID
= CRM_Utils_Array
::value('uf_group_id', $_POST, $this->_ufGroupID
);
653 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
654 $this->set('id', $this->_ufGroupID
);
656 // also get the object mode directly from the post value
657 $this->_componentMode
= CRM_Utils_Array
::value('component_mode', $_POST, $this->_componentMode
);
659 // also get the operator from the post value if set
660 $this->_operator
= CRM_Utils_Array
::value('operator', $_POST, $this->_operator
);
661 $this->_formValues
['operator'] = $this->_operator
;
662 $this->set('operator', $this->_operator
);
665 $this->_formValues
= $this->get('formValues');
666 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
667 $this->_returnProperties
= &$this->returnProperties();
668 if (!empty($this->_ufGroupID
)) {
669 $this->set('id', $this->_ufGroupID
);
673 if (empty($this->_formValues
)) {
674 //check if group is a smart group (fix for CRM-1255)
675 if ($this->_groupID
) {
676 if ($ssId = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID
, 'saved_search_id')) {
677 $this->_ssID
= $ssId;
682 if (isset($this->_ssID
) && $this->_context
!= 'smog') {
683 // we only retrieve the saved search values if out current values are null
684 $this->_formValues
= CRM_Contact_BAO_SavedSearch
::getFormValues($this->_ssID
);
687 if (CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID
, 'mapping_id')) {
688 $this->_params
= CRM_Contact_BAO_SavedSearch
::getSearchParams($this->_ssID
);
691 $this->_params
= CRM_Contact_BAO_Query
::convertFormValues($this->_formValues
);
693 $this->_returnProperties
= &$this->returnProperties();
696 if (isset($this->_ufGroupID
)) {
697 // also set the uf group id if not already present
698 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
700 if (isset($this->_componentMode
)) {
701 $this->_formValues
['component_mode'] = $this->_componentMode
;
703 if (isset($this->_operator
)) {
704 $this->_formValues
['operator'] = $this->_operator
;
707 // FIXME: we should generalise in a way that components could inject url-filters
708 // just like they build their own form elements
710 'mailing_id', 'mailing_delivery_status', 'mailing_open_status',
711 'mailing_click_status', 'mailing_reply_status', 'mailing_optout',
712 'mailing_forward', 'mailing_unsubscribe', 'mailing_date_low',
714 ) as $mailingFilter) {
716 if ($mailingFilter == 'mailing_id' &&
717 $filterVal = CRM_Utils_Request
::retrieve('mailing_id', 'Positive', $this)
719 $this->_formValues
[$mailingFilter] = array($filterVal);
721 elseif ($filterVal = CRM_Utils_Request
::retrieve($mailingFilter, $type, $this)) {
722 $this->_formValues
[$mailingFilter] = $filterVal;
725 $this->_openedPanes
['Mailings'] = 1;
726 $this->_formValues
['hidden_CiviMail'] = 1;
732 CRM_Utils_Array
::value('uf_group_id', $this->_formValues
)
734 $operator = CRM_Utils_Array
::value('operator', $this->_formValues
, 'AND');
735 $this->set('queryOperator', $operator);
736 if ($operator == 'OR') {
737 $this->assign('operator', ts('OR'));
740 $this->assign('operator', ts('AND'));
743 // show the context menu only when we’re not searching for deleted contacts; CRM-5673
744 if (!CRM_Utils_Array
::value('deleted_contacts', $this->_formValues
)) {
745 $menuItems = CRM_Contact_BAO_Contact
::contextMenu();
746 $primaryActions = CRM_Utils_Array
::value('primaryActions', $menuItems, array());
747 $this->_contextMenu
= CRM_Utils_Array
::value('moreActions', $menuItems, array());
748 $this->assign('contextMenu', $primaryActions +
$this->_contextMenu
);
751 if (!isset($this->_componentMode
)) {
752 $this->_componentMode
= CRM_Contact_BAO_Query
::MODE_CONTACTS
;
754 $modeValues = self
::getModeValue($this->_componentMode
);
756 self
::$_selectorName = $this->_modeValue
['selectorName'];
759 if (strpos(self
::$_selectorName, 'CRM_Contact_Selector') !== FALSE) {
760 $selector = new self
::$_selectorName(
761 $this->_customSearchClass
,
764 $this->_returnProperties
,
773 $selector = new self
::$_selectorName(
781 $selector->setKey($this->controller
->_key
);
783 $controller = new CRM_Contact_Selector_Controller($selector,
784 $this->get(CRM_Utils_Pager
::PAGE_ID
),
785 $this->get(CRM_Utils_Sort
::SORT_ID
),
786 CRM_Core_Action
::VIEW
,
788 CRM_Core_Selector_Controller
::TRANSFER
790 $controller->setEmbedded(TRUE);
791 $controller->setDynamicAction($setDynamic);
795 $this->postProcess();
798 * Note that we repeat this, since the search creates and stores
799 * values that potentially change the controller behavior. i.e. things
800 * like totalCount etc
803 if ($this->get(CRM_Utils_Sort
::SORT_ID
)) {
804 $sortID = CRM_Utils_Sort
::sortIDValue($this->get(CRM_Utils_Sort
::SORT_ID
),
805 $this->get(CRM_Utils_Sort
::SORT_DIRECTION
)
808 $controller = new CRM_Contact_Selector_Controller($selector,
809 $this->get(CRM_Utils_Pager
::PAGE_ID
),
811 CRM_Core_Action
::VIEW
, $this, CRM_Core_Selector_Controller
::TRANSFER
813 $controller->setEmbedded(TRUE);
814 $controller->setDynamicAction($setDynamic);
817 $controller->moveFromSessionToTemplate();
820 function &getFormValues() {
821 return $this->_formValues
;
825 * Common post processing
830 function postProcess() {
832 * sometime we do a postProcess early on, so we dont need to repeat it
833 * this will most likely introduce some more bugs :(
841 //for prev/next pagination
842 $crmPID = CRM_Utils_Request
::retrieve('crmPID', 'Integer', CRM_Core_DAO
::$_nullObject);
844 if (array_key_exists($this->_searchButtonName
, $_POST) ||
845 ($this->_force
&& !$crmPID)) {
846 //reset the cache table for new search
847 $cacheKey = "civicrm search {$this->controller->_key}";
848 CRM_Core_BAO_PrevNextCache
::deleteItem(NULL, $cacheKey);
851 //get the button name
852 $buttonName = $this->controller
->getButtonName();
854 if (isset($this->_ufGroupID
) &&
855 !CRM_Utils_Array
::value('uf_group_id', $this->_formValues
)
857 $this->_formValues
['uf_group_id'] = $this->_ufGroupID
;
860 if (isset($this->_componentMode
) &&
861 !CRM_Utils_Array
::value('component_mode', $this->_formValues
)
863 $this->_formValues
['component_mode'] = $this->_componentMode
;
866 if (isset($this->_operator
) &&
867 !CRM_Utils_Array
::value('operator', $this->_formValues
)
869 $this->_formValues
['operator'] = $this->_operator
;
872 if (!CRM_Utils_Array
::value('qfKey', $this->_formValues
)) {
873 $this->_formValues
['qfKey'] = $this->controller
->_key
;
876 if (!CRM_Core_Permission
::check('access deleted contacts')) {
877 unset($this->_formValues
['deleted_contacts']);
880 $this->set('type', $this->_action
);
881 $this->set('formValues', $this->_formValues
);
882 $this->set('queryParams', $this->_params
);
883 $this->set('returnProperties', $this->_returnProperties
);
885 if ($buttonName == $this->_actionButtonName ||
$buttonName == $this->_printButtonName
) {
886 // check actionName and if next, then do not repeat a search, since we are going to the next page
887 // hack, make sure we reset the task values
888 $stateMachine = $this->controller
->getStateMachine();
889 $formName = $stateMachine->getTaskFormName();
890 $this->controller
->resetPage($formName);
894 $output = CRM_Core_Selector_Controller
::SESSION
;
896 // create the selector, controller and run - store results in session
897 $searchChildGroups = TRUE;
898 if ($this->get('isAdvanced')) {
899 $searchChildGroups = FALSE;
904 if (strpos(self
::$_selectorName, 'CRM_Contact_Selector') !== FALSE) {
905 $selector = new self
::$_selectorName (
906 $this->_customSearchClass
,
909 $this->_returnProperties
,
919 $selector = new self
::$_selectorName (
930 $selector->setKey($this->controller
->_key
);
932 // added the sorting character to the form array
933 $config = CRM_Core_Config
::singleton();
934 // do this only for contact search
935 if ($setDynamic && $config->includeAlphabeticalPager
) {
936 // Don't recompute if we are just paging/sorting
937 if ($this->_reset ||
(empty($_GET['crmPID']) && empty($_GET['crmSID']) && !$this->_sortByCharacter
)) {
938 $aToZBar = CRM_Utils_PagerAToZ
::getAToZBar($selector, $this->_sortByCharacter
);
939 $this->set('AToZBar', $aToZBar);
944 if ($this->get(CRM_Utils_Sort
::SORT_ID
)) {
945 $sortID = CRM_Utils_Sort
::sortIDValue($this->get(CRM_Utils_Sort
::SORT_ID
),
946 $this->get(CRM_Utils_Sort
::SORT_DIRECTION
)
949 $controller = new CRM_Contact_Selector_Controller($selector,
950 $this->get(CRM_Utils_Pager
::PAGE_ID
),
952 CRM_Core_Action
::VIEW
,
956 $controller->setEmbedded(TRUE);
957 $controller->setDynamicAction($setDynamic);
962 function &returnProperties() {
963 return CRM_Core_DAO
::$_nullObject;
967 * Return a descriptive name for the page, used in wizard header
972 function getTitle() {