/** * run this page (figure out the action needed and perform it). * * @return void */ function run() { $selector =& new CRM_Mailing_Selector_Event(CRM_Utils_Request::retrieve('event', 'String', $this), CRM_Utils_Request::retrieve('distinct', 'Boolean', $this), CRM_Utils_Request::retrieve('mid', 'Positive', $this), CRM_Utils_Request::retrieve('jid', 'Positive', $this), CRM_Utils_Request::retrieve('uid', 'Positive', $this)); $mailing_id = CRM_Utils_Request::retrieve('mid', 'Positive', $this); //assign backurl $context = CRM_Utils_Request::retrieve('context', 'String', $this); if ($context == 'activitySelector') { $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this); $backUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=activity"); $backUrlTitle = ts('Back to Activities'); } elseif ($context == 'mailing') { $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this); $backUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=mailing"); $backUrlTitle = ts('Back to Mailing'); } else { $backUrl = CRM_Utils_System::url('civicrm/mailing/report', "reset=1&mid={$mailing_id}"); $backUrlTitle = ts('Back to Report'); } $this->assign('backUrl', $backUrl); $this->assign('backUrlTitle', $backUrlTitle); CRM_Utils_System::setTitle($selector->getTitle()); $this->assign('title', $selector->getTitle()); $this->assign('mailing_id', $mailing_id); $sortID = NULL; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } $controller = new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::TEMPLATE); $controller->setEmbedded(TRUE); $controller->run(); return parent::run(); }
/** * build all the data structures needed to build the form * * @return void * @access public */ function preProcess() { parent::preprocess(); // set print view, so that print templates are called $this->controller->setPrint(1); $this->assign('id', $this->get('id')); $this->assign('pageTitle', ts('CiviCRM Contact Listing')); // create the selector, controller and run - store results in session $fv = $this->get('formValues'); $params = $this->get('queryParams'); $returnProperties = $this->get('returnProperties'); $sortID = null; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } $includeContactIds = false; if ($fv['radio_ts'] == 'ts_sel') { $includeContactIds = true; } $selectorName = $this->controller->selectorName(); require_once str_replace('_', DIRECTORY_SEPARATOR, $selectorName) . '.php'; $returnP = isset($returnPropeties) ? $returnPropeties : ""; $customSearchClass = $this->get('customSearchClass'); eval('$selector = new ' . $selectorName . '( $customSearchClass, $fv, $params, $returnP, $this->_action, $includeContactIds );'); $controller = new CRM_Core_Selector_Controller($selector, null, $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SCREEN); $controller->setEmbedded(true); $controller->run(); }
/** * Build all the data structures needed to build the form. * * @return void */ public function preProcess() { parent::preprocess(); // set print view, so that print templates are called $this->controller->setPrint(1); $this->assign('id', $this->get('id')); $this->assign('pageTitle', ts('CiviCRM Contact Listing')); $params = $this->get('queryParams'); if (!empty($this->_contactIds)) { //using _contactIds field for creating params for query so that multiple selections on multiple pages //can be printed. foreach ($this->_contactIds as $contactId) { $params[] = array(CRM_Core_Form::CB_PREFIX . $contactId, '=', 1, 0, 0); } } // create the selector, controller and run - store results in session $fv = $this->get('formValues'); $returnProperties = $this->get('returnProperties'); $sortID = NULL; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } $includeContactIds = FALSE; if ($fv['radio_ts'] == 'ts_sel') { $includeContactIds = TRUE; } $selectorName = $this->controller->selectorName(); require_once str_replace('_', DIRECTORY_SEPARATOR, $selectorName) . '.php'; $returnP = isset($returnPropeties) ? $returnPropeties : ""; $customSearchClass = $this->get('customSearchClass'); $selector = new $selectorName($customSearchClass, $fv, $params, $returnP, $this->_action, $includeContactIds); $controller = new CRM_Core_Selector_Controller($selector, NULL, $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SCREEN); $controller->setEmbedded(TRUE); $controller->run(); }
/** * List activities as dashlet * * @return none * * @access public */ function run() { $session = CRM_Core_Session::singleton(); $contactID = $session->get('userID'); // a user can always view their own activity // if they have access CiviCRM permission $permission = CRM_Core_Permission::VIEW; // make the permission edit if the user has edit permission on the contact require_once 'CRM/Contact/BAO/Contact/Permission.php'; if (CRM_Contact_BAO_Contact_Permission::allow($contactID, CRM_Core_Permission::EDIT)) { $permission = CRM_Core_Permission::EDIT; } $admin = CRM_Core_Permission::check('view all activities') || CRM_Core_Permission::check('administer CiviCRM'); require_once 'CRM/Core/Selector/Controller.php'; $output = CRM_Core_Selector_Controller::SESSION; require_once 'CRM/Activity/Selector/Activity.php'; $selector = new CRM_Activity_Selector_Activity($contactID, $permission, $admin, 'home'); $sortID = null; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } $controller = new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, $output); $controller->setEmbedded(true); $controller->run(); $controller->moveFromSessionToTemplate(); return parent::run(); }
/** * Browse all activities for a particular contact * * @param boolean $history - true if we want to browse activity history, false otherwise. * @return none * * @access public */ function browse($history) { $this->assign('totalCountOpenActivity', CRM_Contact_BAO_Contact::getNumOpenActivity($this->_contactId)); $this->assign('totalCountActivity', CRM_Core_BAO_History::getNumHistory($this->_contactId, 'Activity')); require_once 'CRM/Core/Selector/Controller.php'; if ($history) { $this->assign('history', true); // create the selector, controller and run - store results in session $output = CRM_CORE_SELECTOR_CONTROLLER_SESSION; require_once 'CRM/History/Selector/Activity.php'; $selector =& new CRM_History_Selector_Activity($this->_contactId, $this->_permission); $sortID = null; if ($this->get(CRM_UTILS_SORT_SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_UTILS_SORT_SORT_ID), $this->get(CRM_UTILS_SORT_SORT_DIRECTION)); } $controller =& new CRM_Core_Selector_Controller($selector, $this->get(CRM_UTILS_PAGER_PAGE_ID), $sortID, CRM_CORE_ACTION_VIEW, $this, $output); $controller->setEmbedded(true); $controller->run(); $controller->moveFromSessionToTemplate(); } else { $this->assign('history', false); // create the selector, controller and run - store results in session $output = CRM_CORE_SELECTOR_CONTROLLER_SESSION; require_once 'CRM/Contact/Selector/Activity.php'; $selector =& new CRM_Contact_Selector_Activity($this->_contactId, $this->_permission); $sortID = null; if ($this->get(CRM_UTILS_SORT_SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_UTILS_SORT_SORT_ID), $this->get(CRM_UTILS_SORT_SORT_DIRECTION)); } $controller =& new CRM_Core_Selector_Controller($selector, $this->get(CRM_UTILS_PAGER_PAGE_ID), $sortID, CRM_CORE_ACTION_VIEW, $this, $output); $controller->setEmbedded(true); $controller->run(); $controller->moveFromSessionToTemplate(); } }
function preProcess() { CRM_Utils_Request::retrieve('id', 'Int', $this, false); $readonly = CRM_Utils_Request::retrieve('readonly', 'Boolean', $this, false); $this->assign('readonly', $readonly); $id = $this->get('id'); $params = $this->controller->exportValues(); $selector = new CRM_Finance_Selector_Import($id, $params); $this->assign('importId', $id); $dataExchange = new CRM_Finance_Utils_DataExchange(); $processData = $dataExchange->getProcessById($id); if (isset($processData['data']['status'])) { $this->assign('validationSummary', $processData['data']['status']); } require_once 'CRM/Finance/BAO/Import/Source.php'; $sourceOptions = CRM_Finance_BAO_Import_Source::getAllAsOptions(); $processData['sourceName'] = $sourceOptions[$processData['source']]; $this->assign('importSummary', $processData); $output = CRM_Core_Selector_Controller::TEMPLATE; $sortID = null; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } $controller = new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, $output); $controller->setEmbedded(true); $controller->run(); }
/** * run this page (figure out the action needed and perform it). * * @return void */ function run() { $selector =& new CRM_Mailing_Selector_Event(CRM_Utils_Request::retrieve('event', 'String', $this), CRM_Utils_Request::retrieve('distinct', 'Boolean', $this), CRM_Utils_Request::retrieve('mid', 'Positive', $this), CRM_Utils_Request::retrieve('jid', 'Positive', $this), CRM_Utils_Request::retrieve('uid', 'Positive', $this)); $mailing_id = CRM_Utils_Request::retrieve('mid', 'Positive', $this); CRM_Utils_System::setTitle($selector->getTitle()); $this->assign('title', $selector->getTitle()); $this->assign('mailing_id', $mailing_id); $sortID = NULL; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } $controller = new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::TEMPLATE); $controller->setEmbedded(TRUE); $controller->run(); return parent::run(); }
/** * build all the data structures needed to build the form * * @return void * @access public */ function preProcess() { parent::preprocess(); // set print view, so that print templates are called $this->controller->setPrint(1); // get the formatted params $queryParams = $this->get('queryParams'); $sortID = null; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } $selector =& new CRM_Pledge_Selector_Search($queryParams, $this->_action, $this->_componentClause); $controller =& new CRM_Core_Selector_Controller($selector, null, $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SCREEN); $controller->setEmbedded(true); $controller->run(); }
/** * Browse all activities for a particular contact * * @return none * * @access public */ function browse() { require_once 'CRM/Core/Selector/Controller.php'; $output = CRM_Core_Selector_Controller::SESSION; require_once 'CRM/Activity/Selector/Activity.php'; $selector =& new CRM_Activity_Selector_Activity($this->_contactId, $this->_permission); $sortID = null; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } $controller =& new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, $output); $controller->setEmbedded(true); $controller->run(); $controller->moveFromSessionToTemplate(); // check if case is enabled require_once 'CRM/Core/BAO/Preferences.php'; $viewOptions = CRM_Core_BAO_Preferences::valueOptions('contact_view_options', true, null, true); $enableCase = false; if (CRM_Utils_Array::value('CiviCase', $viewOptions)) { $enableCase = true; } $this->assign('enableCase', $enableCase); $this->assign('context', 'activity'); }
/** * Common post processing * * @return void * @access public */ function postProcessCommon() { /* * sometime we do a postProcess early on, so we dont need to repeat it * this will most likely introduce some more bugs :( */ if ($this->_done) { return; } $this->_done = true; //get the button name $buttonName = $this->controller->getButtonName(); // we dont want to store the sortByCharacter in the formValue, it is more like // a filter on the result set // this filter is reset if we click on the search button if ($this->_sortByCharacter && $buttonName != $this->_searchButtonName) { if ($this->_sortByCharacter == 1) { $this->_formValues['sortByCharacter'] = null; } else { $this->_formValues['sortByCharacter'] = $this->_sortByCharacter; } } $this->set('type', $this->_action); $this->set('formValues', $this->_formValues); if ($buttonName == $this->_actionButtonName || $buttonName == $this->_printButtonName) { // check actionName and if next, then do not repeat a search, since we are going to the next page // hack, make sure we reset the task values $stateMachine =& $this->controller->getStateMachine(); $formName = $stateMachine->getTaskFormName(); $this->controller->resetPage($formName); return; } else { // do export stuff if ($buttonName == $this->_exportButtonName) { //$output = CRM_Core_Selector_Controller::EXPORT; return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/export/contact')); } else { $output = CRM_CORE_SELECTOR_CONTROLLER_SESSION; } // create the selector, controller and run - store results in session $selector =& new CRM_Contact_Selector($this->_formValues, $this->_action); // added the sorting character to the form array // lets recompute the aToZ bar without the sortByCharacter // we need this in most cases except when just pager or sort values change, which // we'll ignore for now $query =& $selector->getQuery(); $aToZBar = CRM_Utils_PagerAToZ::getAToZBar($query, $this->_sortByCharacter); $this->set('AToZBar', $aToZBar); $sortID = null; if ($this->get(CRM_UTILS_SORT_SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_UTILS_SORT_SORT_ID), $this->get(CRM_UTILS_SORT_SORT_DIRECTION)); } $controller =& new CRM_Contact_Selector_Controller($selector, $this->get(CRM_UTILS_PAGER_PAGE_ID), $sortID, CRM_CORE_ACTION_VIEW, $this, $output); $controller->setEmbedded(true); $controller->run(); } }
/** * Common post processing * * @return void * @access public */ function postProcess() { /* * sometime we do a postProcess early on, so we dont need to repeat it * this will most likely introduce some more bugs :( */ if ($this->_done) { return; } $this->_done = true; //get the button name $buttonName = $this->controller->getButtonName(); if (isset($this->_ufGroupID) && !CRM_Utils_Array::value('uf_group_id', $this->_formValues)) { $this->_formValues['uf_group_id'] = $this->_ufGroupID; } $this->set('type', $this->_action); $this->set('formValues', $this->_formValues); $this->set('queryParams', $this->_params); $this->set('returnProperties', $this->_returnProperties); if ($buttonName == $this->_actionButtonName || $buttonName == $this->_printButtonName) { // check actionName and if next, then do not repeat a search, since we are going to the next page // hack, make sure we reset the task values $stateMachine =& $this->controller->getStateMachine(); $formName = $stateMachine->getTaskFormName(); $this->controller->resetPage($formName); return; } else { $output = CRM_Core_Selector_Controller::SESSION; // create the selector, controller and run - store results in session $searchChildGroups = true; $session =& CRM_Core_Session::singleton(); if ($session->get('isAdvanced')) { $searchChildGroups = false; } eval('$selector =& new ' . $this->_selectorName . '( $this->_customSearchClass, $this->_formValues, $this->_params, $this->_returnProperties, $this->_action, false, $searchChildGroups, $this->_context, $this->_contextMenu );'); // added the sorting character to the form array // lets recompute the aToZ bar without the sortByCharacter // we need this in most cases except when just pager or sort values change, which // we'll ignore for now $config =& CRM_Core_Config::singleton(); if ($config->includeAlphabeticalPager) { if ($this->_reset || !$this->_sortByCharacter) { $aToZBar = CRM_Utils_PagerAToZ::getAToZBar($selector, $this->_sortByCharacter); $this->set('AToZBar', $aToZBar); } } $sortID = null; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } $controller =& new CRM_Contact_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, $output); $controller->setEmbedded(true); $controller->run(); } }
/** * The post processing of the form gets done here. * * Key things done during post processing are * - check for reset or next request. if present, skip post procesing. * - now check if user requested running a saved search, if so, then * the form values associated with the saved search are used for searching. * - if user has done a submit with new values the regular post submissing is * done. * * The processing consists of using a Selector / Controller framework for getting the * search results. */ public function postProcess() { if ($this->_done) { return; } $this->_done = TRUE; if (!empty($_POST)) { $this->_formValues = $this->controller->exportValues($this->_name); foreach (array('activity_type_id', 'status_id', 'activity_subject') as $element) { $value = CRM_Utils_Array::value($element, $this->_formValues); if ($value) { if (is_array($value)) { if ($element == 'status_id') { unset($this->_formValues[$element]); $this->_formValues['activity_' . $element] = $value; } } else { $this->_formValues[$element] = array('LIKE' => "%{$value}%"); } } } } $this->fixFormValues(); if (isset($this->_ssID) && empty($_POST)) { // if we are editing / running a saved search and the form has not been posted $this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID); } // We don't show test records in summaries or dashboards if (empty($this->_formValues['activity_test']) && $this->_force) { $this->_formValues["activity_test"] = 0; } CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues); $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues); $this->set('formValues', $this->_formValues); $this->set('queryParams', $this->_queryParams); $buttonName = $this->controller->getButtonName(); if ($buttonName == $this->_actionButtonName) { // check actionName and if next, then do not repeat a search, since we are going to the next page // hack, make sure we reset the task values $stateMachine = $this->controller->getStateMachine(); $formName = $stateMachine->getTaskFormName(); $this->controller->resetPage($formName); return; } $sortID = NULL; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues); $selector = new CRM_Activity_Selector_Search($this->_queryParams, $this->_action, NULL, $this->_single, $this->_limit, $this->_context); $selector->setKey($this->controller->_key); $prefix = NULL; if ($this->_context == 'basic' || $this->_context == 'user') { $prefix = $this->_prefix; } $controller = new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SESSION, $prefix); $controller->setEmbedded(TRUE); $query =& $selector->getQuery(); if ($this->_context == 'user') { $query->setSkipPermission(TRUE); } $controller->run(); }
/** * The post processing of the form gets done here. * * Key things done during post processing are * - check for reset or next request. if present, skip post processing. * - now check if user requested running a saved search, if so, then * the form values associated with the saved search are used for searching. * - if user has done a submit with new values the regular post submission is * done. * The processing consists of using a Selector / Controller framework for getting the * search results. */ public function postProcess() { if ($this->_done) { return; } $this->_done = TRUE; if (!empty($_POST)) { $this->_formValues = $this->controller->exportValues($this->_name); } $this->fixFormValues(); // We don't show test records in summaries or dashboards if (empty($this->_formValues['contribution_test']) && $this->_force && !empty($this->_context) && $this->_context == 'dashboard') { $this->_formValues["contribution_test"] = 0; } foreach (array('contribution_amount_low', 'contribution_amount_high') as $f) { if (isset($this->_formValues[$f])) { $this->_formValues[$f] = CRM_Utils_Rule::cleanMoney($this->_formValues[$f]); } } $config = CRM_Core_Config::singleton(); if (!empty($_POST)) { $specialParams = array('financial_type_id', 'contribution_soft_credit_type_id', 'contribution_status_id', 'contribution_source', 'contribution_trxn_id', 'contribution_page_id', 'contribution_product_id'); foreach ($specialParams as $element) { $value = CRM_Utils_Array::value($element, $this->_formValues); if ($value) { if (is_array($value)) { $this->_formValues[$element] = array('IN' => $value); } else { $this->_formValues[$element] = array('LIKE' => "%{$value}%"); } } } $tags = CRM_Utils_Array::value('contact_tags', $this->_formValues); if ($tags && !is_array($tags)) { unset($this->_formValues['contact_tags']); $this->_formValues['contact_tags'][$tags] = 1; } if ($tags && is_array($tags)) { unset($this->_formValues['contact_tags']); foreach ($tags as $notImportant => $tagID) { $this->_formValues['contact_tags'][$tagID] = 1; } } if (!$config->groupTree) { $group = CRM_Utils_Array::value('group', $this->_formValues); if ($group && !is_array($group)) { unset($this->_formValues['group']); $this->_formValues['group'][$group] = 1; } if ($group && is_array($group)) { unset($this->_formValues['group']); foreach ($group as $notImportant => $groupID) { $this->_formValues['group'][$groupID] = 1; } } } } CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($this->_formValues); $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues); $this->set('formValues', $this->_formValues); $this->set('queryParams', $this->_queryParams); $buttonName = $this->controller->getButtonName(); if ($buttonName == $this->_actionButtonName) { // check actionName and if next, then do not repeat a search, since we are going to the next page // hack, make sure we reset the task values $stateMachine = $this->controller->getStateMachine(); $formName = $stateMachine->getTaskFormName(); $this->controller->resetPage($formName); return; } $sortID = NULL; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues); $selector = new CRM_Contribute_Selector_Search($this->_queryParams, $this->_action, NULL, $this->_single, $this->_limit, $this->_context); $selector->setKey($this->controller->_key); $prefix = NULL; if ($this->_context == 'basic' || $this->_context == 'user') { $prefix = $this->_prefix; } $controller = new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SESSION, $prefix); $controller->setEmbedded(TRUE); $query =& $selector->getQuery(); if ($this->_context == 'user') { $query->setSkipPermission(TRUE); } $summary =& $query->summaryContribution($this->_context); $this->set('summary', $summary); $this->assign('contributionSummary', $summary); $controller->run(); }
/** * The post processing of the form gets done here. * * Key things done during post processing are * - check for reset or next request. if present, skip post procesing. * - now check if user requested running a saved search, if so, then * the form values associated with the saved search are used for searching. * - if user has done a submit with new values the regular post submissing is * done. * The processing consists of using a Selector / Controller framework for getting the * search results. * * @param * * @return void * @access public */ function postProcess() { if ($this->_done) { return; } $this->_done = true; $this->_formValues = $this->controller->exportValues($this->_name); $this->fixFormValues(); if (isset($this->_ssID) && empty($_POST)) { // if we are editing / running a saved search and the form has not been posted $this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID); } require_once 'CRM/Contact/BAO/Query.php'; $this->_queryParams =& CRM_Contact_BAO_Query::convertFormValues($this->_formValues); $this->set('formValues', $this->_formValues); $this->set('queryParams', $this->_queryParams); $buttonName = $this->controller->getButtonName(); if ($buttonName == $this->_actionButtonName || $buttonName == $this->_printButtonName) { // check actionName and if next, then do not repeat a search, since we are going to the next page // hack, make sure we reset the task values $stateMachine =& $this->controller->getStateMachine(); $formName = $stateMachine->getTaskFormName(); $this->controller->resetPage($formName); return; } $sortID = null; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } require_once 'CRM/Contact/BAO/Query.php'; $selector =& new CRM_Grant_Selector_Search($this->_queryParams, $this->_action, null, $this->_single, $this->_limit, $this->_context); $prefix = null; if ($this->_context == 'basic' || $this->_context == 'user') { $prefix = $this->_prefix; } $controller =& new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SESSION, $prefix); $controller->setEmbedded(true); $query =& $selector->getQuery(); if ($this->_context == 'user') { $query->setSkipPermission(true); } $controller->run(); }
/** * Common post processing. */ public function postProcess() { /* * sometime we do a postProcess early on, so we dont need to repeat it * this will most likely introduce some more bugs :( */ if ($this->_done) { return; } $this->_done = TRUE; //for prev/next pagination $crmPID = CRM_Utils_Request::retrieve('crmPID', 'Integer', CRM_Core_DAO::$_nullObject); if (array_key_exists($this->_searchButtonName, $_POST) || $this->_force && !$crmPID) { //reset the cache table for new search $cacheKey = "civicrm search {$this->controller->_key}"; CRM_Core_BAO_PrevNextCache::deleteItem(NULL, $cacheKey); } //get the button name $buttonName = $this->controller->getButtonName(); if (isset($this->_ufGroupID) && empty($this->_formValues['uf_group_id'])) { $this->_formValues['uf_group_id'] = $this->_ufGroupID; } if (isset($this->_componentMode) && empty($this->_formValues['component_mode'])) { $this->_formValues['component_mode'] = $this->_componentMode; } if (isset($this->_operator) && empty($this->_formValues['operator'])) { $this->_formValues['operator'] = $this->_operator; } if (empty($this->_formValues['qfKey'])) { $this->_formValues['qfKey'] = $this->controller->_key; } if (!CRM_Core_Permission::check('access deleted contacts')) { unset($this->_formValues['deleted_contacts']); } $this->set('type', $this->_action); $this->set('formValues', $this->_formValues); $this->set('queryParams', $this->_params); $this->set('returnProperties', $this->_returnProperties); if ($buttonName == $this->_actionButtonName) { // check actionName and if next, then do not repeat a search, since we are going to the next page // hack, make sure we reset the task values $stateMachine = $this->controller->getStateMachine(); $formName = $stateMachine->getTaskFormName(); $this->controller->resetPage($formName); return; } else { $output = CRM_Core_Selector_Controller::SESSION; // create the selector, controller and run - store results in session $searchChildGroups = TRUE; if ($this->get('isAdvanced')) { $searchChildGroups = FALSE; } $setDynamic = FALSE; if (strpos(self::$_selectorName, 'CRM_Contact_Selector') !== FALSE) { $selector = new self::$_selectorName($this->_customSearchClass, $this->_formValues, $this->_params, $this->_returnProperties, $this->_action, FALSE, $searchChildGroups, $this->_context, $this->_contextMenu); $setDynamic = TRUE; } else { $selector = new self::$_selectorName($this->_params, $this->_action, NULL, FALSE, NULL, "search", "advanced"); } $selector->setKey($this->controller->_key); // added the sorting character to the form array $config = CRM_Core_Config::singleton(); // do this only for contact search if ($setDynamic && $config->includeAlphabeticalPager) { // Don't recompute if we are just paging/sorting if ($this->_reset || empty($_GET['crmPID']) && empty($_GET['crmSID']) && !$this->_sortByCharacter) { $aToZBar = CRM_Utils_PagerAToZ::getAToZBar($selector, $this->_sortByCharacter); $this->set('AToZBar', $aToZBar); } } $sortID = NULL; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } $controller = new CRM_Contact_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, $output); $controller->setEmbedded(TRUE); $controller->setDynamicAction($setDynamic); $controller->run(); } }
/** * build all the data structures needed to build the form * * @param * @return void * @access public */ function preProcess() { $this->_contactIds = array(); $this->_contactTypes = array(); // get the submitted values of the search form // we'll need to get fv from either search or adv search in the future $fragment = 'search'; if ($this->_action == CRM_Core_Action::ADVANCED) { $values = $this->controller->exportValues('Advanced'); $fragment .= '/advanced'; } else { if ($this->_action == CRM_Core_Action::PROFILE) { $values = $this->controller->exportValues('Builder'); $fragment .= '/builder'; } else { if ($this->_action == CRM_Core_Action::COPY) { $values = $this->controller->exportValues('Custom'); $fragment .= '/custom'; } else { $values = $this->controller->exportValues('Basic'); } } } //set the user context for redirection of task actions $url = CRM_Utils_System::url('civicrm/contact/' . $fragment, 'force=1'); $session =& CRM_Core_Session::singleton(); $session->replaceUserContext($url); require_once 'CRM/Contact/Task.php'; $this->_task = $values['task']; $crmContactTaskTasks = CRM_Contact_Task::taskTitles(); $this->assign('taskName', $crmContactTaskTasks[$this->_task]); // all contacts or action = save a search if (CRM_Utils_Array::value('radio_ts', $values) == 'ts_all' || $this->_task == CRM_Contact_Task::SAVE_SEARCH) { // need to perform action on all contacts // fire the query again and get the contact id's + display name $sortID = null; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } $selectorName = $this->controller->selectorName(); require_once str_replace('_', DIRECTORY_SEPARATOR, $selectorName) . '.php'; $fv = $this->get('formValues'); $customClass = $this->get('customSearchClass'); require_once "CRM/Core/BAO/Mapping.php"; $returnProperties = CRM_Core_BAO_Mapping::returnProperties($values); eval('$selector =& new ' . $selectorName . '( $customClass, $fv, null, $returnProperties ); '); $params = $this->get('queryParams'); // fix for CRM-5165 $sortByCharacter = $this->get('sortByCharacter'); if ($sortByCharacter && $sortByCharacter != 1) { $params[] = array('sortByCharacter', '=', $sortByCharacter, 0, 0); } $dao =& $selector->contactIDQuery($params, $this->_action, $sortID); while ($dao->fetch()) { $this->_contactIds[] = $dao->contact_id; } } else { if (CRM_Utils_Array::value('radio_ts', $values) == 'ts_sel') { // selected contacts only // need to perform action on only selected contacts foreach ($values as $name => $value) { if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) { $this->_contactIds[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN); } } } } //contact type for pick up profiles as per selected contact types with subtypes //CRM-5521 if ($selectedTypes = CRM_Utils_Array::value('contact_type', $values)) { $selectedTypes = explode(" ", $selectedTypes); foreach ($selectedTypes as $ct => $dontcare) { if (strpos($ct, CRM_Core_DAO::VALUE_SEPARATOR) === false) { $this->_contactTypes[] = $ct; } else { $separator = strpos($ct, CRM_Core_DAO::VALUE_SEPARATOR); $this->_contactTypes[] = substr($ct, $separator + 1); } } } if (!empty($this->_contactIds)) { $this->_componentClause = ' contact_a.id IN ( ' . implode(',', $this->_contactIds) . ' ) '; $this->assign('totalSelectedContacts', count($this->_contactIds)); $this->_componentIds = $this->_contactIds; } }
/** * The post processing of the form gets done here. * * Key things done during post processing are * - check for reset or next request. if present, skip post procesing. * - now check if user requested running a saved search, if so, then * the form values associated with the saved search are used for searching. * - if user has done a submit with new values the regular post submissing is * done. * The processing consists of using a Selector / Controller framework for getting the * search results. * * @param * * @return void * @access public */ function postProcess() { if ($this->_done) { return; } $this->_done = true; $this->_formValues = $this->controller->exportValues($this->_name); $this->fixFormValues(); $this->set('formValues', $this->_formValues); $buttonName = $this->controller->getButtonName(); if ($buttonName == $this->_actionButtonName || $buttonName == $this->_printButtonName) { // check actionName and if next, then do not repeat a search, since we are going to the next page // hack, make sure we reset the task values $stateMachine =& $this->controller->getStateMachine(); $formName = $stateMachine->getTaskFormName(); $this->controller->resetPage($formName); return; } $sortID = null; if ($this->get(CRM_UTILS_SORT_SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_UTILS_SORT_SORT_ID), $this->get(CRM_UTILS_SORT_SORT_DIRECTION)); } $selector =& new CRM_Contribute_Selector_Search($this->_formValues, $this->_action, null, $this->_single, $this->_limit, $this->_context); $controller =& new CRM_Core_Selector_Controller($selector, $this->get(CRM_UTILS_PAGER_PAGE_ID), $sortID, CRM_CORE_ACTION_VIEW, $this, CRM_CORE_SELECTOR_CONTROLLER_SESSION); $controller->setEmbedded(true); $controller->run(); }
/** * The post processing of the form gets done here. * * Key things done during post processing are * - check for reset or next request. if present, skip post procesing. * - now check if user requested running a saved search, if so, then * the form values associated with the saved search are used for searching. * - if user has done a submit with new values the regular post submissing is * done. * The processing consists of using a Selector / Controller framework for getting the * search results. * * @param * * @return void * @access public */ function postProcess() { if ($this->_done) { return; } $this->_done = true; if (!empty($_POST)) { $this->_formValues = $this->controller->exportValues($this->_name); } $this->fixFormValues(); // we don't show test contributions in Contact Summary / User Dashboard // in Search mode by default we hide test contributions if (!CRM_Utils_Array::value('contribution_test', $this->_formValues)) { $this->_formValues["contribution_test"] = 0; } foreach (array('contribution_amount_low', 'contribution_amount_high') as $f) { if (isset($this->_formValues[$f])) { $this->_formValues[$f] = CRM_Utils_Rule::cleanMoney($this->_formValues[$f]); } } require_once 'CRM/Core/BAO/CustomValue.php'; CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($this->_formValues); require_once 'CRM/Contact/BAO/Query.php'; $this->_queryParams =& CRM_Contact_BAO_Query::convertFormValues($this->_formValues); $this->set('formValues', $this->_formValues); $this->set('queryParams', $this->_queryParams); $buttonName = $this->controller->getButtonName(); if ($buttonName == $this->_actionButtonName || $buttonName == $this->_printButtonName) { // check actionName and if next, then do not repeat a search, since we are going to the next page // hack, make sure we reset the task values $stateMachine =& $this->controller->getStateMachine(); $formName = $stateMachine->getTaskFormName(); $this->controller->resetPage($formName); return; } $sortID = null; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } require_once 'CRM/Contact/BAO/Query.php'; $this->_queryParams =& CRM_Contact_BAO_Query::convertFormValues($this->_formValues); $selector =& new CRM_Contribute_Selector_Search($this->_queryParams, $this->_action, null, $this->_single, $this->_limit, $this->_context); $prefix = null; if ($this->_context == 'basic' || $this->_context == 'user') { $prefix = $this->_prefix; } $controller =& new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SESSION, $prefix); $controller->setEmbedded(true); $query =& $selector->getQuery(); if ($this->_context == 'user') { $query->setSkipPermission(true); } $summary =& $query->summaryContribution(); $this->set('summary', $summary); $this->assign('contributionSummary', $summary); $controller->run(); }
/** * The post processing of the form gets done here. * * Key things done during post processing are * - check for reset or next request. if present, skip post procesing. * - now check if user requested running a saved search, if so, then * the form values associated with the saved search are used for searching. * - if user has done a submit with new values the regular post submissing is * done. * The processing consists of using a Selector / Controller framework for getting the * search results. * * @param * * @return void * @access public */ function postProcess() { if ($this->_done) { return; } $this->_done = true; $this->_formValues = $this->controller->exportValues($this->_name); $this->fixFormValues(); // we don't show test memberships in Contact Summary / User Dashboard // in Search mode by default we hide test memberships if (!CRM_Utils_Array::value('member_test', $this->_formValues)) { $this->_formValues["member_test"] = 0; } require_once 'CRM/Core/BAO/CustomValue.php'; CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($this->_formValues); require_once 'CRM/Contact/BAO/Query.php'; $this->_queryParams =& CRM_Contact_BAO_Query::convertFormValues($this->_formValues); $this->set('formValues', $this->_formValues); $this->set('queryParams', $this->_queryParams); $buttonName = $this->controller->getButtonName(); if ($buttonName == $this->_actionButtonName || $buttonName == $this->_printButtonName) { // check actionName and if next, then do not repeat a search, since we are going to the next page // hack, make sure we reset the task values $stateMachine =& $this->controller->getStateMachine(); $formName = $stateMachine->getTaskFormName(); $this->controller->resetPage($formName); return; } $sortID = null; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } require_once 'CRM/Contact/BAO/Query.php'; $this->_queryParams =& CRM_Contact_BAO_Query::convertFormValues($this->_formValues); require_once "CRM/Member/Selector/Search.php"; $selector = new CRM_Member_Selector_Search($this->_queryParams, $this->_action, null, $this->_single, $this->_limit, $this->_context); $selector->setKey($this->controller->_key); $prefix = null; if ($this->_context == 'basic') { $prefix = $this->_prefix; } $controller = new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SESSION, $prefix); $controller->setEmbedded(true); $query =& $selector->getQuery(); $controller->run(); }
/** * The post processing of the form gets done here. * * Key things done during post processing are * - check for reset or next request. if present, skip post procesing. * - now check if user requested running a saved search, if so, then * the form values associated with the saved search are used for searching. * - if user has done a submit with new values the regular post submissing is * done. * The processing consists of using a Selector / Controller framework for getting the * search results. * * @param * * @return void * @access public */ function postProcess() { if ($this->_done) { return; } $this->_done = true; if (!empty($_POST)) { $this->_formValues = $this->controller->exportValues($this->_name); } if (empty($this->_formValues)) { $this->_formValues = $this->controller->exportValues($this->_name); } $this->fixFormValues(); if (isset($this->_ssID) && empty($_POST)) { // if we are editing / running a saved search and the form has not been posted $this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID); } // we don't show test registrations in Contact Summary / User Dashboard // in Search mode by default we hide test registrations if (!CRM_Utils_Array::value('participant_test', $this->_formValues)) { $this->_formValues["participant_test"] = 0; } require_once 'CRM/Core/BAO/CustomValue.php'; CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($this->_formValues); require_once 'CRM/Contact/BAO/Query.php'; $this->_queryParams =& CRM_Contact_BAO_Query::convertFormValues($this->_formValues); $this->set('formValues', $this->_formValues); $this->set('queryParams', $this->_queryParams); $buttonName = $this->controller->getButtonName(); if ($buttonName == $this->_actionButtonName || $buttonName == $this->_printButtonName) { // check actionName and if next, then do not repeat a search, since we are going to the next page // hack, make sure we reset the task values $stateMachine =& $this->controller->getStateMachine(); $formName = $stateMachine->getTaskFormName(); $this->controller->resetPage($formName); return; } $sortID = null; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } require_once 'CRM/Contact/BAO/Query.php'; $this->_queryParams =& CRM_Contact_BAO_Query::convertFormValues($this->_formValues); $selector =& new CRM_Event_Selector_Search($this->_queryParams, $this->_action, null, $this->_single, $this->_limit, $this->_context); $prefix = null; if ($this->_context == 'user') { $prefix = $this->_prefix; } $this->assign("{$prefix}limit", $this->_limit); $this->assign("{$prefix}single", $this->_single); $controller =& new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SESSION, $prefix); $controller->setEmbedded(true); $query =& $selector->getQuery(); if ($this->_context == 'user') { $query->setSkipPermission(true); } $controller->run(); }
/** * Browse all activities for a particular contact * * @return none * * @access public */ function browse($contactId, $admin) { $config =& CRM_Core_Config::singleton(); if (!$config->civiHRD) { require_once 'CRM/Core/Selector/Controller.php'; $output = CRM_Core_Selector_Controller::SESSION; require_once 'CRM/Activity/Selector/Activity.php'; $selector =& new CRM_Activity_Selector_Activity($contactId, $this->_permission, $admin, 'home'); $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); $controller =& new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, $output); $controller->setEmbedded(true); $controller->run(); $controller->moveFromSessionToTemplate(); $displayName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactId, 'display_name'); $this->assign('contactId', $contactId); $this->assign('display_name', $displayName); $this->assign('context', 'home'); // check if case is enabled require_once 'CRM/Core/BAO/Preferences.php'; $viewOptions = CRM_Core_BAO_Preferences::valueOptions('contact_view_options', true, null, true); $enableCase = false; if ($viewOptions[ts('CiviCase')]) { $enableCase = true; } $this->assign('enableCase', $enableCase); } }
/** * Heart of the Controller. This is where all the action takes place * * - The rows are fetched and stored depending on the type of output needed * * - For export/printing all rows are selected. * * - for displaying on screen paging parameters are used to display the * required rows. * * - also depending on output type of session or template rows are appropriately stored in session * or template variables are updated. * * * @return void */ public function run() { // get the column headers $columnHeaders =& $this->_object->getColumnHeaders($this->_action, $this->_output); $contextArray = explode('_', get_class($this->_object)); $contextName = strtolower($contextArray[1]); // fix contribute and member if ($contextName == 'contribute') { $contextName = 'contribution'; } elseif ($contextName == 'member') { $contextName = 'membership'; } // we need to get the rows if we are exporting or printing them if ($this->_output == self::EXPORT || $this->_output == self::SCREEN) { // get rows (without paging criteria) $rows = self::getRows($this); CRM_Utils_Hook::searchColumns($contextName, $columnHeaders, $rows, $this); if ($this->_output == self::EXPORT) { // export the rows. CRM_Core_Report_Excel::writeCSVFile($this->_object->getExportFileName(), $columnHeaders, $rows); CRM_Utils_System::civiExit(); } else { // assign to template and display them. self::$_template->assign_by_ref('rows', $rows); self::$_template->assign_by_ref('columnHeaders', $columnHeaders); } } else { // output requires paging/sorting capability $rows = self::getRows($this); CRM_Utils_Hook::searchColumns($contextName, $columnHeaders, $rows, $this); $rowsEmpty = count($rows) ? FALSE : TRUE; $qill = $this->getQill(); $summary = $this->getSummary(); // if we need to store in session, lets update session if ($this->_output & self::SESSION) { $this->_store->set("{$this->_prefix}columnHeaders", $columnHeaders); if ($this->_dynamicAction) { $this->_object->removeActions($rows); } $this->_store->set("{$this->_prefix}rows", $rows); $this->_store->set("{$this->_prefix}rowCount", $this->_total); $this->_store->set("{$this->_prefix}rowsEmpty", $rowsEmpty); $this->_store->set("{$this->_prefix}qill", $qill); $this->_store->set("{$this->_prefix}summary", $summary); } else { self::$_template->assign_by_ref("{$this->_prefix}pager", $this->_pager); self::$_template->assign_by_ref("{$this->_prefix}sort", $this->_sort); self::$_template->assign_by_ref("{$this->_prefix}columnHeaders", $columnHeaders); self::$_template->assign_by_ref("{$this->_prefix}rows", $rows); self::$_template->assign("{$this->_prefix}rowsEmpty", $rowsEmpty); self::$_template->assign("{$this->_prefix}qill", $qill); self::$_template->assign("{$this->_prefix}summary", $summary); } // always store the current pageID and sortID $this->_store->set($this->_prefix . CRM_Utils_Pager::PAGE_ID, $this->_pager->getCurrentPageID()); $this->_store->set($this->_prefix . CRM_Utils_Sort::SORT_ID, $this->_sort->getCurrentSortID()); $this->_store->set($this->_prefix . CRM_Utils_Sort::SORT_DIRECTION, $this->_sort->getCurrentSortDirection()); $this->_store->set($this->_prefix . CRM_Utils_Sort::SORT_ORDER, $this->_sort->orderBy()); $this->_store->set($this->_prefix . CRM_Utils_Pager::PAGE_ROWCOUNT, $this->_pager->_perPage); } }
/** * The post processing of the form gets done here. * * Key things done during post processing are * - check for reset or next request. if present, skip post procesing. * - now check if user requested running a saved search, if so, then * the form values associated with the saved search are used for searching. * - if user has done a submit with new values the regular post submissing is * done. * The processing consists of using a Selector / Controller framework for getting the * search results. */ public function postProcess() { if ($this->_done) { return; } $this->_done = TRUE; $this->_formValues = $this->controller->exportValues($this->_name); $this->fixFormValues(); if (isset($this->_ssID) && empty($_POST)) { // if we are editing / running a saved search and the form has not been posted $this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID); } //search for civicase if (!$this->_force) { if (array_key_exists('case_owner', $this->_formValues) && !$this->_formValues['case_owner']) { $this->_formValues['case_owner'] = 0; } } if (empty($this->_formValues['case_deleted'])) { $this->_formValues['case_deleted'] = 0; } CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues); $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues); $this->set('formValues', $this->_formValues); $this->set('queryParams', $this->_queryParams); $buttonName = $this->controller->getButtonName(); if ($buttonName == $this->_actionButtonName) { // check actionName and if next, then do not repeat a search, since we are going to the next page // hack, make sure we reset the task values $stateMachine = $this->controller->getStateMachine(); $formName = $stateMachine->getTaskFormName(); $this->controller->resetPage($formName); return; } $sortID = NULL; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues); $selector = new CRM_Case_Selector_Search($this->_queryParams, $this->_action, NULL, $this->_single, $this->_limit, $this->_context); $selector->setKey($this->controller->_key); $prefix = NULL; if ($this->_context == 'user') { $prefix = $this->_prefix; } $this->assign("{$prefix}limit", $this->_limit); $this->assign("{$prefix}single", $this->_single); $controller = new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SESSION, $prefix); $controller->setEmbedded(TRUE); $query =& $selector->getQuery(); if ($this->_context == 'user') { $query->setSkipPermission(TRUE); } $controller->run(); }
static function preProcessCommon(&$form, $useTable = false) { $form->_contactIds = array(); $form->_contactTypes = array(); // get the submitted values of the search form // we'll need to get fv from either search or adv search in the future $fragment = 'search'; if ($form->_action == CRM_Core_Action::ADVANCED) { $values = $form->controller->exportValues('Advanced'); $fragment .= '/advanced'; } else { if ($form->_action == CRM_Core_Action::PROFILE) { $values = $form->controller->exportValues('Builder'); $fragment .= '/builder'; } else { if ($form->_action == CRM_Core_Action::COPY) { $values = $form->controller->exportValues('Custom'); $fragment .= '/custom'; } else { $values = $form->controller->exportValues('Basic'); } } } //set the user context for redirection of task actions $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $form); require_once 'CRM/Utils/Rule.php'; $urlParams = 'force=1'; if (CRM_Utils_Rule::qfKey($qfKey)) { $urlParams .= "&qfKey={$qfKey}"; } $url = CRM_Utils_System::url('civicrm/contact/' . $fragment, $urlParams); $session = CRM_Core_Session::singleton(); $session->replaceUserContext($url); require_once 'CRM/Contact/Task.php'; $form->_task = CRM_Utils_Array::value('task', $values); $crmContactTaskTasks = CRM_Contact_Task::taskTitles(); $form->assign('taskName', CRM_Utils_Array::value($form->_task, $crmContactTaskTasks)); if ($useTable) { $form->_componentTable = CRM_Core_DAO::createTempTableName('civicrm_task_action', false); $sql = " DROP TABLE IF EXISTS {$form->_componentTable}"; CRM_Core_DAO::executeQuery($sql); $sql = "CREATE TABLE {$form->_componentTable} ( contact_id int primary key) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci"; CRM_Core_DAO::executeQuery($sql); } // all contacts or action = save a search if (CRM_Utils_Array::value('radio_ts', $values) == 'ts_all' || $form->_task == CRM_Contact_Task::SAVE_SEARCH) { // need to perform action on all contacts // fire the query again and get the contact id's + display name $sortID = null; if ($form->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($form->get(CRM_Utils_Sort::SORT_ID), $form->get(CRM_Utils_Sort::SORT_DIRECTION)); } $selectorName = $form->controller->selectorName(); require_once str_replace('_', DIRECTORY_SEPARATOR, $selectorName) . '.php'; $fv = $form->get('formValues'); $customClass = $form->get('customSearchClass'); require_once "CRM/Core/BAO/Mapping.php"; $returnProperties = CRM_Core_BAO_Mapping::returnProperties($values); eval('$selector = new ' . $selectorName . '( $customClass, $fv, null, $returnProperties ); '); $params = $form->get('queryParams'); // fix for CRM-5165 $sortByCharacter = $form->get('sortByCharacter'); if ($sortByCharacter && $sortByCharacter != 1) { $params[] = array('sortByCharacter', '=', $sortByCharacter, 0, 0); } $dao =& $selector->contactIDQuery($params, $form->_action, $sortID); $form->_contactIds = array(); if ($useTable) { $count = 0; $insertString = array(); while ($dao->fetch()) { $count++; $insertString[] = " ( {$dao->contact_id} ) "; if ($count % 200 == 0) { $string = implode(',', $insertString); $sql = "REPLACE INTO {$form->_componentTable} ( contact_id ) VALUES {$string}"; CRM_Core_DAO::executeQuery($sql); $insertString = array(); } } if (!empty($insertString)) { $string = implode(',', $insertString); $sql = "REPLACE INTO {$form->_componentTable} ( contact_id ) VALUES {$string}"; CRM_Core_DAO::executeQuery($sql); } $dao->free(); } else { // filter duplicates here // CRM-7058 // might be better to do this in the query, but that logic is a bit complex // and it decides when to use distinct based on input criteria, which needs // to be fixed and optimized. $alreadySeen = array(); while ($dao->fetch()) { if (!array_key_exists($dao->contact_id, $alreadySeen)) { $form->_contactIds[] = $dao->contact_id; $alreadySeen[$dao->contact_id] = 1; } } unset($alreadySeen); $dao->free(); } } else { if (CRM_Utils_Array::value('radio_ts', $values) == 'ts_sel') { // selected contacts only // need to perform action on only selected contacts $insertString = array(); foreach ($values as $name => $value) { if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) { $contactID = substr($name, CRM_Core_Form::CB_PREFIX_LEN); if ($useTable) { $insertString[] = " ( {$contactID} ) "; } else { $form->_contactIds[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN); } } } if (!empty($insertString)) { $string = implode(',', $insertString); $sql = "REPLACE INTO {$form->_componentTable} ( contact_id ) VALUES {$string}"; CRM_Core_DAO::executeQuery($sql); } } } //contact type for pick up profiles as per selected contact types with subtypes //CRM-5521 if ($selectedTypes = CRM_Utils_Array::value('contact_type', $values)) { if (!is_array($selectedTypes)) { $selectedTypes = explode(" ", $selectedTypes); } foreach ($selectedTypes as $ct => $dontcare) { if (strpos($ct, CRM_Core_DAO::VALUE_SEPARATOR) === false) { $form->_contactTypes[] = $ct; } else { $separator = strpos($ct, CRM_Core_DAO::VALUE_SEPARATOR); $form->_contactTypes[] = substr($ct, $separator + 1); } } } if (!empty($form->_contactIds)) { $form->_componentClause = ' contact_a.id IN ( ' . implode(',', $form->_contactIds) . ' ) '; $form->assign('totalSelectedContacts', count($form->_contactIds)); $form->_componentIds = $form->_contactIds; } }
/** * @return string */ public function orderBy() { static $headers = NULL; if (!$headers) { $headers = array(); $headers[1] = array('name' => ts('Name'), 'sort' => 'civicrm_contact.sort_name', 'direction' => CRM_Utils_Sort::ASCENDING); $headers[2] = array('name' => ts('Status'), 'sort' => 'civicrm_participant.status_id', 'direction' => CRM_Utils_Sort::DONTCARE); $headers[3] = array('name' => ts('Register Date'), 'sort' => 'civicrm_participant.register_date', 'direction' => CRM_Utils_Sort::DONTCARE); } $sortID = NULL; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } $sort = new CRM_Utils_Sort($headers, $sortID); $this->assign_by_ref('headers', $headers); $this->assign_by_ref('sort', $sort); $this->set(CRM_Utils_Sort::SORT_ID, $sort->getCurrentSortID()); $this->set(CRM_Utils_Sort::SORT_DIRECTION, $sort->getCurrentSortDirection()); return $sort->orderBy(); }
/** * The post processing of the form gets done here. * * Key things done during post processing are * - check for reset or next request. if present, skip post procesing. * - now check if user requested running a saved search, if so, then * the form values associated with the saved search are used for searching. * - if user has done a submit with new values the regular post submissing is * done. * The processing consists of using a Selector / Controller framework for getting the * search results. * * @param * * @return void */ public function postProcess() { if ($this->_done) { return; } $this->_done = TRUE; if (!empty($_POST)) { $this->_formValues = $this->controller->exportValues($this->_name); CRM_Contact_BAO_Query::processSpecialFormValue($this->_formValues, array('participant_status_id')); } if (empty($this->_formValues)) { $this->_formValues = $this->controller->exportValues($this->_name); } $this->fixFormValues(); if (isset($this->_ssID) && empty($_POST)) { // if we are editing / running a saved search and the form has not been posted $this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID); } // We don't show test records in summaries or dashboards if (empty($this->_formValues['participant_test']) && $this->_force) { $this->_formValues["participant_test"] = 0; } CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues); $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues, 0, FALSE, NULL, array('event_id')); $this->set('formValues', $this->_formValues); $this->set('queryParams', $this->_queryParams); $buttonName = $this->controller->getButtonName(); if ($buttonName == $this->_actionButtonName) { // check actionName and if next, then do not repeat a search, since we are going to the next page // hack, make sure we reset the task values $stateMachine = $this->controller->getStateMachine(); $formName = $stateMachine->getTaskFormName(); $this->controller->resetPage($formName); return; } $sortID = NULL; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues, 0, FALSE, NULL, array('event_id')); $selector = new CRM_Event_Selector_Search($this->_queryParams, $this->_action, NULL, $this->_single, $this->_limit, $this->_context); $selector->setKey($this->controller->_key); $prefix = NULL; if ($this->_context == 'user') { $prefix = $this->_prefix; } $this->assign("{$prefix}limit", $this->_limit); $this->assign("{$prefix}single", $this->_single); $controller = new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SESSION, $prefix); $controller->setEmbedded(TRUE); $query = $selector->getQuery(); if ($this->_context == 'user') { $query->setSkipPermission(TRUE); } $controller->run(); }
/** * The post processing of the form gets done here. * * Key things done during post processing are * - check for reset or next request. if present, skip post procesing. * - now check if user requested running a saved search, if so, then * the form values associated with the saved search are used for searching. * - if user has done a submit with new values the regular post submissing is * done. * The processing consists of using a Selector / Controller framework for getting the * search results. * * @param * * @return void * @access public */ function postProcess() { if ($this->_done) { return; } $this->_done = TRUE; $this->_formValues = $this->controller->exportValues($this->_name); $this->fixFormValues(); // We don't show test records in summaries or dashboards if (empty($this->_formValues['member_test']) && $this->_force) { $this->_formValues["member_test"] = 0; } CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($this->_formValues); $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues); $this->set('formValues', $this->_formValues); $this->set('queryParams', $this->_queryParams); $buttonName = $this->controller->getButtonName(); if ($buttonName == $this->_actionButtonName) { // check actionName and if next, then do not repeat a search, since we are going to the next page // hack, make sure we reset the task values $stateMachine = $this->controller->getStateMachine(); $formName = $stateMachine->getTaskFormName(); $this->controller->resetPage($formName); return; } $sortID = NULL; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues); $selector = new CRM_Member_Selector_Search($this->_queryParams, $this->_action, NULL, $this->_single, $this->_limit, $this->_context); $selector->setKey($this->controller->_key); $prefix = NULL; if ($this->_context == 'basic') { $prefix = $this->_prefix; } $controller = new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SESSION, $prefix); $controller->setEmbedded(TRUE); $query =& $selector->getQuery(); $controller->run(); }
function orderBy() { static $headers = NULL; if (!$headers) { $headers = array(); $headers[1] = array('name' => ts('Name'), 'sort' => 'civicrm_contact.sort_name', 'direction' => CRM_Utils_Sort::ASCENDING); if ($this->_participantListingType == 'Name and Email') { $headers[2] = array('name' => ts('Email'), 'sort' => 'civicrm_email.email', 'direction' => CRM_Utils_Sort::DONTCARE); } } $sortID = NULL; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } $sort = new CRM_Utils_Sort($headers, $sortID); $this->assign_by_ref('headers', $headers); $this->assign_by_ref('sort', $sort); $this->set(CRM_Utils_Sort::SORT_ID, $sort->getCurrentSortID()); $this->set(CRM_Utils_Sort::SORT_DIRECTION, $sort->getCurrentSortDirection()); return $sort->orderBy(); }
/** * Get the contact id for custom search. * * we are not using prev/next table in case of custom search */ public function getContactIds() { // need to perform action on all contacts // fire the query again and get the contact id's + display name $sortID = NULL; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } $selectorName = $this->controller->selectorName(); require_once str_replace('_', DIRECTORY_SEPARATOR, $selectorName) . '.php'; $fv = $this->get('formValues'); $customClass = $this->get('customSearchClass'); require_once 'CRM/Core/BAO/Mapping.php'; $returnProperties = CRM_Core_BAO_Mapping::returnProperties(self::$_searchFormValues); $selector = new $selectorName($customClass, $fv, NULL, $returnProperties); $params = $this->get('queryParams'); // fix for CRM-5165 $sortByCharacter = $this->get('sortByCharacter'); if ($sortByCharacter && $sortByCharacter != 1) { $params[] = array('sortByCharacter', '=', $sortByCharacter, 0, 0); } $queryOperator = $this->get('queryOperator'); if (!$queryOperator) { $queryOperator = 'AND'; } $dao = $selector->contactIDQuery($params, $this->_action, $sortID, CRM_Utils_Array::value('display_relationship_type', $fv), $queryOperator); $contactIds = array(); while ($dao->fetch()) { $contactIds[$dao->contact_id] = $dao->contact_id; } return $contactIds; }
/** * The post processing of the form gets done here. * * Key things done during post processing are * - check for reset or next request. if present, skip post procesing. * - now check if user requested running a saved search, if so, then * the form values associated with the saved search are used for searching. * - if user has done a submit with new values the regular post submissing is * done. * The processing consists of using a Selector / Controller framework for getting the * search results. */ public function postProcess() { if ($this->_done) { return; } $this->_done = TRUE; if (!empty($_POST)) { $this->_formValues = $this->controller->exportValues($this->_name); } $this->fixFormValues(); //format params as per task. $this->formatParams(); $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues); $this->set('formValues', $this->_formValues); $this->set('queryParams', $this->_queryParams); $buttonName = $this->controller->getButtonName(); if ($buttonName == $this->_actionButtonName) { // check actionName and if next, then do not repeat a search, since we are going to the next page // hack, make sure we reset the task values $stateMachine = $this->controller->getStateMachine(); $formName = $stateMachine->getTaskFormName(); $this->controller->resetPage($formName); return; } $sortID = NULL; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } //get the voter clause. $voterClause = $this->voterClause(); $selector = new CRM_Campaign_Selector_Search($this->_queryParams, $this->_action, $voterClause, $this->_single, $this->_limit, $this->_context); $selector->setKey($this->controller->_key); $prefix = NULL; if ($this->_context == 'basic' || $this->_context == 'user') { $prefix = $this->_prefix; } $controller = new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SESSION, $prefix); $controller->setEmbedded(TRUE); $query = $selector->getQuery(); if ($this->_context == 'user') { $query->setSkipPermission(TRUE); } $controller->run(); }