本文整理汇总了PHP中CRM_Utils_Sort类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Sort类的具体用法?PHP CRM_Utils_Sort怎么用?PHP CRM_Utils_Sort使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Utils_Sort类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
//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();
}
示例2: preProcess
/**
* 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();
}
示例3: preProcess
/**
* 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();
}
示例4: 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();
}
示例5: browse
/**
* 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();
}
}
示例6: preProcess
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();
}
示例7: 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();
}
示例8: preProcess
/**
* 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();
}
示例9: browse
/**
* 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');
}
示例10: postProcessCommon
/**
* 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();
}
}
示例11: postProcess
/**
* 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();
}
}
示例12: postProcess
/**
* 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();
}
示例13: postProcess
/**
* 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);
//.........这里部分代码省略.........
示例14: postProcess
/**
* 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();
}
示例15: postProcess
/**
* 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();
}
}