当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Contact_BAO_Query类代码示例

本文整理汇总了PHP中CRM_Contact_BAO_Query的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Query类的具体用法?PHP CRM_Contact_BAO_Query怎么用?PHP CRM_Contact_BAO_Query使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CRM_Contact_BAO_Query类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: buildQuickForm

 /**
  * Build the form object - it consists of
  *    - displaying the QILL (query in local language)
  *    - displaying elements for saving the search
  *
  *
  * @return void
  */
 public function buildQuickForm()
 {
     // get the qill
     $query = new CRM_Contact_BAO_Query($this->get('queryParams'));
     $qill = $query->qill();
     // need to save qill for the smarty template
     $this->assign('qill', $qill);
     // the name and description are actually stored with the group and not the saved search
     $this->add('text', 'title', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'title'), TRUE);
     $this->addElement('textarea', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'description'));
     $groupTypes = CRM_Core_OptionGroup::values('group_type', TRUE);
     unset($groupTypes['Access Control']);
     if (!CRM_Core_Permission::access('CiviMail')) {
         $isWorkFlowEnabled = CRM_Mailing_Info::workflowEnabled();
         if ($isWorkFlowEnabled && !CRM_Core_Permission::check('create mailings') && !CRM_Core_Permission::check('schedule mailings') && !CRM_Core_Permission::check('approve mailings')) {
             unset($groupTypes['Mailing List']);
         }
     }
     if (!empty($groupTypes)) {
         $this->addCheckBox('group_type', ts('Group Type'), $groupTypes, NULL, NULL, NULL, NULL, '   ');
     }
     //CRM-14190
     CRM_Group_Form_Edit::buildParentGroups($this);
     // get the group id for the saved search
     $groupID = NULL;
     if (isset($this->_id)) {
         $groupID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_id, 'id', 'saved_search_id');
         $this->addDefaultButtons(ts('Update Smart Group'));
     } else {
         $this->addDefaultButtons(ts('Save Smart Group'));
     }
     $this->addRule('title', ts('Name already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Group', $groupID, 'title'));
 }
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:41,代码来源:SaveSearch.php

示例2: preProcessCommon

 static function preProcessCommon(&$form, $useTable = true)
 {
     $form->_contactIds = array();
     $form->_contactTypes = array();
     $form->_searchFrom = $searchformName = 'contact';
     $searchFrom = $form->get('searchFormName');
     $pages = $form->controller->_pages;
     $prefix = 'contact';
     if ($pages[$searchFrom]) {
         $prefix = $pages[$searchFrom]->getVar('_prefix');
         if ($prefix == 'member_') {
             $searchformName = 'member';
         }
     }
     if ($searchformName == 'member') {
         $form->_searchFrom = $searchformName;
         $values = $form->controller->exportValues($form->get('searchFormName'));
         $ids = array();
         if ($values['radio_ts'] == 'ts_sel') {
             foreach ($values as $name => $value) {
                 if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) {
                     $ids[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN);
                 }
             }
         } else {
             $queryParams = $form->get('queryParams');
             $sortOrder = null;
             if ($form->get(CRM_Utils_Sort::SORT_ORDER)) {
                 $sortOrder = $form->get(CRM_Utils_Sort::SORT_ORDER);
             }
             $query = new CRM_Contact_BAO_Query($queryParams, NULL, NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_MEMBER);
             $query->_distinctComponentClause = ' civicrm_membership.id';
             $query->_groupByComponentClause = ' GROUP BY civicrm_membership.id ';
             $result = $query->searchQuery(0, 0, $sortOrder);
             while ($result->fetch()) {
                 $ids[] = $result->membership_id;
             }
         }
         if (!empty($ids)) {
             $form->_componentClause = ' civicrm_membership.id IN ( ' . implode(',', $ids) . ' ) ';
             $form->assign('totalSelectedMembers', count($ids));
         }
         $form->_memberIds = $form->_componentIds = $ids;
         $form->_contactIds =& CRM_Core_DAO::getContactIDsFromComponent($ids, 'civicrm_membership');
         $form->assign('totalSelectedContacts', count($form->_contactIds));
     } else {
         parent::preProcessCommon($form);
     }
 }
开发者ID:krishgopi,项目名称:uk.co.vedaconsulting.module.wordmailmerge,代码行数:49,代码来源:WordMailMergeForm.php

示例3: testSearch

 /**
  *  Test CRM_Contact_BAO_Query::searchQuery()
  *  @dataProvider dataProvider
  */
 function testSearch($fv, $count, $ids, $full)
 {
     $op = new PHPUnit_Extensions_Database_Operation_Insert();
     $op->execute($this->_dbconn, new PHPUnit_Extensions_Database_DataSet_FlatXMLDataSet(dirname(__FILE__) . '/queryDataset.xml'));
     $params = CRM_Contact_BAO_Query::convertFormValues($fv);
     $obj = new CRM_Contact_BAO_Query($params);
     $obj->_useGroupBy = TRUE;
     $dao = $obj->searchQuery();
     $contacts = array();
     while ($dao->fetch()) {
         $contacts[] = $dao->contact_id;
     }
     sort($contacts, SORT_NUMERIC);
     $this->assertEquals($ids, $contacts, 'In line ' . __LINE__);
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:19,代码来源:QueryTest.php

示例4: onEvaluate

 /**
  * Load token data.
  *
  * @param TokenValueEvent $e
  * @throws TokenException
  */
 public function onEvaluate(TokenValueEvent $e)
 {
     // For reasons unknown, replaceHookTokens requires a pre-computed list of
     // hook *categories* (aka entities aka namespaces). We'll cache
     // this in the TokenProcessor's context.
     $hookTokens = array();
     \CRM_Utils_Hook::tokens($hookTokens);
     $categories = array_keys($hookTokens);
     $e->getTokenProcessor()->context['hookTokenCategories'] = $categories;
     $messageTokens = $e->getTokenProcessor()->getMessageTokens();
     foreach ($e->getRows() as $row) {
         if (empty($row->context['contact'])) {
             $params = array(array('contact_id', '=', $row->context['contactId'], 0, 0));
             list($contact, $_) = \CRM_Contact_BAO_Query::apiQuery($params);
             $contact = reset($contact);
             //CRM-4524
             if (!$contact || is_a($contact, 'CRM_Core_Error')) {
                 // FIXME: Need to differentiate errors which kill the batch vs the individual row.
                 throw new TokenException("Failed to generate token data. Invalid contact ID: " . $row->context['contactId']);
             }
         } else {
             $contact = $row->context['contact'];
         }
         if (!empty($row->context['tmpTokenParams'])) {
             // merge activity tokens with contact array
             // this is pretty weird.
             $contact = array_merge($contact, $row->context['tmpTokenParams']);
         }
         // Note: This is a small contract change from the past; data should be missing
         // less randomly.
         //\CRM_Utils_Hook::tokenValues($contact, $row->context['contactId']);
         \CRM_Utils_Hook::tokenValues($contact, $row->context['contactId'], empty($row->context['mailingJob']) ? NULL : $row->context['mailingJob']->id, $messageTokens, $row->context['controller']);
         $row->context('contact', $contact);
     }
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:41,代码来源:TokenCompatSubscriber.php

示例5: testConvertEntityFieldMultipleValueEntityRefDoubleRun

 /**
  * Check that running convertFormValues more than one doesn't mangle the array.
  *
  * Unfortunately the convertFormValues & indeed much of the query code is run in pre-process AND post-process.
  *
  * The convertFormValues function should cope with this until such time as we can rationalise that.
  */
 public function testConvertEntityFieldMultipleValueEntityRefDoubleRun()
 {
     $formValues = array('membership_type_id' => '1,2');
     $params = CRM_Contact_BAO_Query::convertFormValues($formValues, 0, FALSE, NULL, array('membership_type_id'));
     $this->assertEquals(array('membership_type_id', 'IN', array(1, 2), 0, 0), $params[0]);
     $params = CRM_Contact_BAO_Query::convertFormValues($params, 0, FALSE, NULL, array('membership_type_id'));
     $this->assertEquals(array('membership_type_id', 'IN', array(1, 2), 0, 0), $params[0]);
     $obj = new CRM_Contact_BAO_Query($params);
     $this->assertEquals(array('civicrm_membership.membership_type_id IN ("1", "2")'), $obj->_where[0]);
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:17,代码来源:QueryTest.php

示例6: isContactInGroup

 /**
  * Checks wether a contact is a member of a group
  *
  * This function is a copy of CRM_Contact_BAO_GroupContact::isContactInGroup but with
  * a change so that the group contact cache won't be rebuild. Which somehow resulted
  * in a deadlock
  *
  * @param $contact_id
  * @param $group_id
  * @return bool
  */
 public static function isContactInGroup($contact_id, $group_id)
 {
     if (!CRM_Utils_Rule::positiveInteger($contact_id) || !CRM_Utils_Rule::positiveInteger($group_id)) {
         return FALSE;
     }
     $params = array(array('group', 'IN', array($group_id => 1), 0, 0), array('contact_id', '=', $contact_id, 0, 0));
     list($contacts, $_) = CRM_Contact_BAO_Query::apiQuery($params, array('contact_id'), null, null, 0, 1, false, false, true);
     if (!empty($contacts)) {
         return TRUE;
     }
     return FALSE;
 }
开发者ID:alejandro-ixiam,项目名称:org.civicoop.civirules,代码行数:23,代码来源:GroupContact.php

示例7: __construct

 function __construct(&$formValues)
 {
     parent::__construct($formValues);
     $this->normalize();
     $this->_columns = array(ts('') => 'contact_type', ts('Name') => 'sort_name', ts('Address') => 'street_address', ts('City') => 'city', ts('State') => 'state_province', ts('Postal') => 'postal_code', ts('Country') => 'country', ts('Email') => 'email', ts('Phone') => 'phone');
     $params =& CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
     $returnProperties = array();
     foreach ($this->_columns as $name => $field) {
         $returnProperties[$field] = 1;
     }
     $this->_query =& new CRM_Contact_BAO_Query($params, $returnProperties, null, false, false, 1, false, false);
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:12,代码来源:Basic.php

示例8: testGetExportStructureArrays

 /**
  * Test the function that extracts the arrays used to structure the output.
  *
  * The keys in the output fields array should by matched by field aliases in the sql query (with
  * exceptions of course - currently country is one - although maybe a future refactor can change that!).
  *
  * We are trying to move towards simpler processing in the per row iteration as that may be
  * repeated 100,000 times and in general we should simply be able to match the query fields to
  * our expected rows & do a little pseudoconstant mapping.
  */
 public function testGetExportStructureArrays()
 {
     // This is how return properties are formatted internally within the function for passing to the BAO query.
     $returnProperties = array('first_name' => 1, 'last_name' => 1, 'receive_date' => 1, 'contribution_source' => 1, 'location' => array('Home' => array('street_address' => 1, 'city' => 1, 'country' => 1, 'email' => 1, 'im-1' => 1, 'im_provider' => 1, 'phone-1' => 1)), 'phone' => 1, 'trxn_id' => 1, 'contribution_id' => 1);
     $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
     $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
     $contactRelationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, NULL, TRUE, 'name', FALSE);
     $query = new CRM_Contact_BAO_Query(array(), $returnProperties, NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_CONTRIBUTE, FALSE, TRUE, TRUE, NULL, 'AND');
     list($select) = $query->query();
     $pattern = '/as `?([^`,]*)/';
     $queryFieldAliases = array();
     preg_match_all($pattern, $select, $queryFieldAliases, PREG_PATTERN_ORDER);
     list($outputFields) = CRM_Export_BAO_Export::getExportStructureArrays($returnProperties, $query, $phoneTypes, $imProviders, $contactRelationshipTypes, '', array());
     foreach (array_keys($outputFields) as $fieldAlias) {
         if ($fieldAlias == 'Home-country') {
             $this->assertTrue(in_array($fieldAlias . '_id', $queryFieldAliases[1]), 'Country is subject to some funky translate so we make sure country id is present');
         } else {
             $this->assertTrue(in_array($fieldAlias, $queryFieldAliases[1]), 'looking for field ' . $fieldAlias . ' in generaly the alias fields need to match the outputfields');
         }
     }
 }
开发者ID:GuGuss,项目名称:civicrm-core,代码行数:31,代码来源:ExportTest.php

示例9: testSelectorQuery

 /**
  * Test the query from the selector class is consistent with the dataset expectation.
  *
  * @param array $dataSet
  *   The data set to be tested. Note that when adding new datasets often only form_values and expected where
  *   clause will need changing.
  *
  * @dataProvider querySets
  */
 public function testSelectorQuery($dataSet)
 {
     $params = CRM_Contact_BAO_Query::convertFormValues($dataSet['form_values'], 0, FALSE, NULL, array());
     foreach ($dataSet['settings'] as $setting) {
         $this->callAPISuccess('Setting', 'create', array($setting['name'] => $setting['value']));
     }
     $selector = new CRM_Contact_Selector($dataSet['class'], $dataSet['form_values'], $params, $dataSet['return_properties'], $dataSet['action'], $dataSet['includeContactIds'], $dataSet['searchDescendentGroups'], $dataSet['context']);
     $queryObject = $selector->getQueryObject();
     $sql = $queryObject->query();
     $this->wrangleDefaultClauses($dataSet['expected_query']);
     foreach ($dataSet['expected_query'] as $index => $queryString) {
         $this->assertEquals($this->strWrangle($queryString), $this->strWrangle($sql[$index]));
     }
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:23,代码来源:SelectorTest.php

示例10: __construct

 /**
  * Class constructor.
  *
  * @param array $formValues
  */
 public function __construct(&$formValues)
 {
     parent::__construct($formValues);
     $this->_columns = array('' => 'contact_type', ts('Name') => 'sort_name', ts('Address') => 'street_address', ts('City') => 'city', ts('State') => 'state_province', ts('Postal') => 'postal_code', ts('Country') => 'country', ts('Email') => 'email', ts('Phone') => 'phone');
     $params = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
     $returnProperties = array();
     $returnProperties['contact_sub_type'] = 1;
     $addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options', TRUE, NULL, TRUE);
     foreach ($this->_columns as $name => $field) {
         if (in_array($field, array('street_address', 'city', 'state_province', 'postal_code', 'country')) && empty($addressOptions[$field])) {
             unset($this->_columns[$name]);
             continue;
         }
         $returnProperties[$field] = 1;
     }
     $this->_query = new CRM_Contact_BAO_Query($params, $returnProperties, NULL, FALSE, FALSE, 1, FALSE, FALSE);
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:22,代码来源:Basic.php

示例11: postProcess

 /**
  * process the form after the input has been submitted and validated
  *
  * @access public
  * @return void
  */
 function postProcess()
 {
     // create the selector, controller and run - store results in session
     $fv = $this->get('formValues');
     $query =& new CRM_Contact_BAO_Query($fv, null, null, false, false, CRM_CONTACT_BAO_QUERY_MODE_ALL);
     $returnProperties =& CRM_Contact_BAO_Query::defaultReturnProperties(CRM_CONTACT_BAO_QUERY_MODE_ALL);
     $properties = array('contact_id', 'contribution_id');
     $header = array(ts('Contact ID'), ts('Contribution ID'));
     foreach ($returnProperties as $name => $dontCare) {
         $properties[] = $name;
         if (CRM_Utils_Array::value($name, $query->_fields) && CRM_Utils_Array::value('title', $query->_fields[$name])) {
             $header[] = $query->_fields[$name]['title'];
         } else {
             $header[] = $name;
         }
     }
     // header fixed for colomns are not expotable
     $headerArray = array('image_URL' => 'Image URL', 'contact_type' => 'Contact Type', 'sort_name' => 'Sort Name', 'display_name' => 'Display Name');
     foreach ($header as $key => $value) {
         if (array_key_exists($value, $headerArray)) {
             $header[$key] = $headerArray[$value];
         }
     }
     $result = $query->searchQuery(0, 0, null, false, false, false, false, false, $this->_contributionClause);
     $rows = array();
     while ($result->fetch()) {
         $row = array();
         $valid = false;
         foreach ($properties as $property) {
             $row[] = $result->{$property};
             if (!CRM_Utils_System::isNull($result->{$property})) {
                 $valid = true;
             }
         }
         if ($valid) {
             $rows[] = $row;
         }
     }
     require_once 'CRM/Core/Report/Excel.php';
     CRM_Core_Report_Excel::writeCSVFile(CRM_Contribute_Form_Task_Export::getExportFileName(), $header, $rows);
     exit;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:48,代码来源:Export.php

示例12: postProcess

 function postProcess()
 {
     $params = $this->controller->exportValues($this->_name);
     CRM_Contact_BAO_Query::fixDateValues($params["mailing_relative"], $params['mailing_from'], $params['mailing_to']);
     $parent = $this->controller->getParent();
     if (!empty($params)) {
         $fields = array('mailing_name', 'mailing_from', 'mailing_to', 'sort_name', 'campaign_id', 'mailing_status', 'sms', 'status_unscheduled', 'is_archived', 'hidden_find_mailings');
         foreach ($fields as $field) {
             if (isset($params[$field]) && !CRM_Utils_System::isNull($params[$field])) {
                 if (in_array($field, array('mailing_from', 'mailing_to')) && !$params["mailing_relative"]) {
                     $time = $field == 'mailing_to' ? '235959' : NULL;
                     $parent->set($field, CRM_Utils_Date::processDate($params[$field], $time));
                 } else {
                     $parent->set($field, $params[$field]);
                 }
             } else {
                 $parent->set($field, NULL);
             }
         }
     }
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:21,代码来源:Search.php

示例13: whereClauseSingle

 /**
  * Generate where for a single parameter.
  *
  * @param array $values
  * @param CRM_Contact_BAO_Query $query
  */
 public static function whereClauseSingle(&$values, &$query)
 {
     list($name, $op, $value, $grouping) = $values;
     switch ($name) {
         case 'member_join_date_low':
         case 'member_join_date_high':
             $query->dateQueryBuilder($values, 'civicrm_membership', 'member_join_date', 'join_date', 'Member Since');
             return;
         case 'member_start_date_low':
         case 'member_start_date_high':
             $query->dateQueryBuilder($values, 'civicrm_membership', 'member_start_date', 'start_date', 'Start Date');
             return;
         case 'member_end_date_low':
         case 'member_end_date_high':
             $query->dateQueryBuilder($values, 'civicrm_membership', 'member_end_date', 'end_date', 'End Date');
             return;
         case 'member_join_date':
             $op = '>=';
             $date = CRM_Utils_Date::format($value);
             if ($date) {
                 $query->_where[$grouping][] = "civicrm_membership.join_date {$op} {$date}";
                 $format = CRM_Utils_Date::customFormat(CRM_Utils_Date::format(array_reverse($value), '-'));
                 $query->_qill[$grouping][] = ts('Member Since %2 %1', array(1 => $format, 2 => $op));
             }
             return;
         case 'member_source':
             $strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
             $value = $strtolower(CRM_Core_DAO::escapeString(trim($value)));
             $query->_where[$grouping][] = "civicrm_membership.source {$op} '{$value}'";
             $query->_qill[$grouping][] = ts('Source %2 %1', array(1 => $value, 2 => $op));
             $query->_tables['civicrm_membership'] = $query->_whereTables['civicrm_membership'] = 1;
             return;
             // CRM-17011 These 2 variants appear in some smart groups saved at some time prior to 4.6.6.
         // CRM-17011 These 2 variants appear in some smart groups saved at some time prior to 4.6.6.
         case 'member_status_id':
         case 'member_membership_type_id':
             if (is_array($value)) {
                 $op = 'IN';
                 $value = array_keys($value);
             }
         case 'membership_type_id':
             // CRM-17075 we are specifically handling the possibility we are dealing with the entity reference field
             // for membership_type_id here (although status would be handled if converted). The unhandled pathway at the moment
             // is from groupContactCache::load and this is a small fix to get the entity reference field to work.
             // However, it would seem the larger fix would be to NOT invoke the form formValues for
             // the load function. The where clause and the whereTables are saved so they should suffice to generate the query
             // to get a contact list. But, better to deal with in 4.8 now...
             if (is_string($value) && strpos($value, ',') && $op == '=') {
                 $value = array('IN' => explode(',', $value));
             }
         case 'membership_status':
         case 'membership_status_id':
         case 'membership_type':
         case 'member_id':
             if (strstr($name, 'status') && is_string($value) && !is_numeric($value)) {
                 $value = CRM_Core_PseudoConstant::getKey('CRM_Member_BAO_Membership', 'status_id', $value);
             }
             if (strpos($name, 'status') !== FALSE) {
                 $name = 'status_id';
                 $qillName = 'Membership Status(s)';
             } elseif ($name == 'member_id') {
                 $name = 'id';
                 $qillName = 'Membership ID';
             } else {
                 $name = 'membership_type_id';
                 $qillName = 'Membership Type(s)';
             }
             $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_membership.{$name}", $op, $value, "Integer");
             list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Member_DAO_Membership', $name, $value, $op);
             $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $qillName, 2 => $op, 3 => $value));
             $query->_tables['civicrm_membership'] = $query->_whereTables['civicrm_membership'] = 1;
             return;
         case 'member_test':
             // We dont want to include all tests for sql OR CRM-7827
             if (!$value || $query->getOperator() != 'OR') {
                 $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_membership.is_test", $op, $value, "Boolean");
                 if ($value) {
                     $query->_qill[$grouping][] = ts('Membership is a Test');
                 }
             }
             $query->_tables['civicrm_membership'] = $query->_whereTables['civicrm_membership'] = 1;
             return;
         case 'member_auto_renew':
             $op = "!=";
             if ($value) {
                 $query->_where[$grouping][] = " civicrm_membership.contribution_recur_id IS NOT NULL";
                 $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("ccr.contribution_status_id", $op, array_search('Cancelled', CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name')), "Integer");
                 $query->_qill[$grouping][] = ts("Membership is Auto-Renew");
             } else {
                 $query->_where[$grouping][] = " civicrm_membership.contribution_recur_id IS NULL";
                 $query->_qill[$grouping][] = ts("Membership is NOT Auto-Renew");
             }
             $query->_tables['civicrm_membership'] = $query->_whereTables['civicrm_membership'] = 1;
             return;
//.........这里部分代码省略.........
开发者ID:kidaa30,项目名称:yes,代码行数:101,代码来源:Query.php

示例14: preProcess

 /**
  * Processing needed for buildForm and later.
  */
 public function preProcess()
 {
     // set the various class variables
     $this->_group = CRM_Core_PseudoConstant::group();
     $this->_groupIterator = CRM_Core_PseudoConstant::groupIterator();
     $this->_tag = CRM_Core_BAO_Tag::getTags();
     $this->_done = FALSE;
     /*
      * we allow the controller to set force/reset externally, useful when we are being
      * driven by the wizard framework
      */
     $this->_reset = CRM_Utils_Request::retrieve('reset', 'Boolean', CRM_Core_DAO::$_nullObject);
     $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', CRM_Core_DAO::$_nullObject);
     $this->_groupID = CRM_Utils_Request::retrieve('gid', 'Positive', $this);
     $this->_amtgID = CRM_Utils_Request::retrieve('amtgID', 'Positive', $this);
     $this->_ssID = CRM_Utils_Request::retrieve('ssID', 'Positive', $this);
     $this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter', 'String', $this);
     $this->_ufGroupID = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->_componentMode = CRM_Utils_Request::retrieve('component_mode', 'Positive', $this, FALSE, 1, $_REQUEST);
     $this->_operator = CRM_Utils_Request::retrieve('operator', 'String', $this, FALSE, 1, $_REQUEST, 'AND');
     /**
      * set the button names
      */
     $this->_searchButtonName = $this->getButtonName('refresh');
     $this->_actionButtonName = $this->getButtonName('next', 'action');
     $this->assign('actionButtonName', $this->_actionButtonName);
     // reset from session, CRM-3526
     $session = CRM_Core_Session::singleton();
     if ($this->_force && $session->get('selectedSearchContactIds')) {
         $session->resetScope('selectedSearchContactIds');
     }
     // if we dont get this from the url, use default if one exsts
     $config = CRM_Core_Config::singleton();
     if ($this->_ufGroupID == NULL && $config->defaultSearchProfileID != NULL) {
         $this->_ufGroupID = $config->defaultSearchProfileID;
     }
     // assign context to drive the template display, make sure context is valid
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'search');
     if (!CRM_Utils_Array::value($this->_context, self::validContext())) {
         $this->_context = 'search';
     }
     $this->set('context', $this->_context);
     $this->assign('context', $this->_context);
     $this->_modeValue = self::getModeValue($this->_componentMode);
     $this->assign($this->_modeValue);
     $this->set('selectorName', self::$_selectorName);
     // get user submitted values
     // get it from controller only if form has been submitted, else preProcess has set this
     // $this->controller->isModal( ) returns TRUE if page is
     // valid, i.e all the validations are TRUE
     if (!empty($_POST) && !$this->controller->isModal()) {
         $this->_formValues = $this->controller->exportValues($this->_name);
         $this->normalizeFormValues();
         $this->_params = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
         $this->_returnProperties =& $this->returnProperties();
         // also get the uf group id directly from the post value
         $this->_ufGroupID = CRM_Utils_Array::value('uf_group_id', $_POST, $this->_ufGroupID);
         $this->_formValues['uf_group_id'] = $this->_ufGroupID;
         $this->set('id', $this->_ufGroupID);
         // also get the object mode directly from the post value
         $this->_componentMode = CRM_Utils_Array::value('component_mode', $_POST, $this->_componentMode);
         // also get the operator from the post value if set
         $this->_operator = CRM_Utils_Array::value('operator', $_POST, $this->_operator);
         $this->_formValues['operator'] = $this->_operator;
         $this->set('operator', $this->_operator);
     } else {
         $this->_formValues = $this->get('formValues');
         $this->_params = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
         $this->_returnProperties =& $this->returnProperties();
         if (!empty($this->_ufGroupID)) {
             $this->set('id', $this->_ufGroupID);
         }
     }
     if (empty($this->_formValues)) {
         //check if group is a smart group (fix for CRM-1255)
         if ($this->_groupID) {
             if ($ssId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID, 'saved_search_id')) {
                 $this->_ssID = $ssId;
             }
         }
         // fix for CRM-1907
         if (isset($this->_ssID) && $this->_context != 'smog') {
             // we only retrieve the saved search values if out current values are null
             $this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID);
             //fix for CRM-1505
             if (CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID, 'mapping_id')) {
                 $this->_params = CRM_Contact_BAO_SavedSearch::getSearchParams($this->_ssID);
             } else {
                 $this->_params = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
             }
             $this->_returnProperties =& $this->returnProperties();
         } else {
             if (isset($this->_ufGroupID)) {
                 // also set the uf group id if not already present
                 $this->_formValues['uf_group_id'] = $this->_ufGroupID;
             }
             if (isset($this->_componentMode)) {
//.........这里部分代码省略.........
开发者ID:nganivet,项目名称:civicrm-core,代码行数:101,代码来源:Search.php

示例15: getTokenDetails

 /**
  * Gives required details of contacts in an indexed array format so we
  * can iterate in a nice loop and do token evaluation
  *
  * @param $contactIDs
  * @param array $returnProperties
  *   Of required properties.
  * @param bool $skipOnHold Don't return on_hold contact info also.
  *   Don't return on_hold contact info also.
  * @param bool $skipDeceased Don't return deceased contact info.
  *   Don't return deceased contact info.
  * @param array $extraParams
  *   Extra params.
  * @param array $tokens
  *   The list of tokens we've extracted from the content.
  * @param null $className
  * @param int $jobID
  *   The mailing list jobID - this is a legacy param.
  *
  * @return array
  */
 public static function getTokenDetails($contactIDs, $returnProperties = NULL, $skipOnHold = TRUE, $skipDeceased = TRUE, $extraParams = NULL, $tokens = array(), $className = NULL, $jobID = NULL)
 {
     if (empty($contactIDs)) {
         // putting a fatal here so we can track if/when this happens
         CRM_Core_Error::fatal();
     }
     // @todo this functions needs unit tests.
     $params = array();
     foreach ($contactIDs as $key => $contactID) {
         $params[] = array(CRM_Core_Form::CB_PREFIX . $contactID, '=', 1, 0, 0);
     }
     // fix for CRM-2613
     if ($skipDeceased) {
         $params[] = array('is_deceased', '=', 0, 0, 0);
     }
     //fix for CRM-3798
     if ($skipOnHold) {
         $params[] = array('on_hold', '=', 0, 0, 0);
     }
     if ($extraParams) {
         $params = array_merge($params, $extraParams);
     }
     // if return properties are not passed then get all return properties
     if (empty($returnProperties)) {
         $fields = array_merge(array_keys(CRM_Contact_BAO_Contact::exportableFields()), array('display_name', 'checksum', 'contact_id'));
         foreach ($fields as $key => $val) {
             // The unavailable fields are not available as tokens, do not have a one-2-one relationship
             // with contacts and are expensive to resolve.
             // @todo see CRM-17253 - there are some other fields (e.g note) that should be excluded
             // and upstream calls to this should populate return properties.
             $unavailableFields = array('group', 'tag');
             if (!in_array($val, $unavailableFields)) {
                 $returnProperties[$val] = 1;
             }
         }
     }
     $custom = array();
     foreach ($returnProperties as $name => $dontCare) {
         $cfID = CRM_Core_BAO_CustomField::getKeyID($name);
         if ($cfID) {
             $custom[] = $cfID;
         }
     }
     //get the total number of contacts to fetch from database.
     $numberofContacts = count($contactIDs);
     $query = new CRM_Contact_BAO_Query($params, $returnProperties);
     $details = $query->apiQuery($params, $returnProperties, NULL, NULL, 0, $numberofContacts);
     $contactDetails =& $details[0];
     foreach ($contactIDs as $key => $contactID) {
         if (array_key_exists($contactID, $contactDetails)) {
             if (CRM_Utils_Array::value('preferred_communication_method', $returnProperties) == 1 && array_key_exists('preferred_communication_method', $contactDetails[$contactID])) {
                 $pcm = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method');
                 // communication Preference
                 $contactPcm = explode(CRM_Core_DAO::VALUE_SEPARATOR, $contactDetails[$contactID]['preferred_communication_method']);
                 $result = array();
                 foreach ($contactPcm as $key => $val) {
                     if ($val) {
                         $result[$val] = $pcm[$val];
                     }
                 }
                 $contactDetails[$contactID]['preferred_communication_method'] = implode(', ', $result);
             }
             foreach ($custom as $cfID) {
                 if (isset($contactDetails[$contactID]["custom_{$cfID}"])) {
                     $contactDetails[$contactID]["custom_{$cfID}"] = CRM_Core_BAO_CustomField::getDisplayValue($contactDetails[$contactID]["custom_{$cfID}"], $cfID, $details[1]);
                 }
             }
             // special case for greeting replacement
             foreach (array('email_greeting', 'postal_greeting', 'addressee') as $val) {
                 if (!empty($contactDetails[$contactID][$val])) {
                     $contactDetails[$contactID][$val] = $contactDetails[$contactID]["{$val}_display"];
                 }
             }
         }
     }
     // also call a hook and get token details
     CRM_Utils_Hook::tokenValues($details[0], $contactIDs, $jobID, $tokens, $className);
     return $details;
 }
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:100,代码来源:Token.php


注:本文中的CRM_Contact_BAO_Query类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。