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


PHP CRM_Contact_BAO_GroupContactCache::check方法代码示例

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


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

示例1: where

 function where()
 {
     $petition_id = intval($this->_params['petition_id_value']);
     $group_id = NULL;
     if (array_key_exists('group_id_value', $this->_params)) {
         $group_id = intval($this->_params['group_id_value']);
     }
     $petition_activity_type_id = intval(CRM_Core_OptionGroup::getValue('activity_type', 'Petition', 'name'));
     $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
     $source_activity_record_type_id = intval(CRM_Utils_Array::key('Activity Source', $activityContacts));
     $this->_where = "WHERE ";
     $signed = '';
     $group = '';
     // Include people who have signed the petition OR people who are in the passed in group
     // First the signers.
     $signed = "{$this->_aliases['civicrm_contact']}.id IN (SELECT contact_id\n      FROM civicrm_activity_contact ac JOIN civicrm_activity a ON\n      ac.activity_id = a.id WHERE ac.record_type_id = {$source_activity_record_type_id}\n      AND source_record_id = {$petition_id} AND a.activity_type_id = {$petition_activity_type_id})";
     // Now the people in the specified group
     if ($group_id) {
         // Check if we are a smart group or regular group
         $results = civicrm_api3('Group', 'getsingle', array('id' => $group_id));
         if (!empty($results['id'])) {
             $group = "{$this->_aliases['civicrm_contact']}.id IN (SELECT contact_id FROM ";
             if (!empty($results['saved_search_id'])) {
                 // Populate the cache
                 CRM_Contact_BAO_GroupContactCache::check($group_id);
                 $group .= "civicrm_group_contact_cache cc WHERE cc.group_id = {$group_id})";
             } else {
                 $group .= "civicrm_group_contact gc WHERE gc.group_id = {$group_id}\n            AND gc.status = 'Added')";
             }
         }
     }
     if (!empty($group)) {
         $this->_where .= " ({$signed}) OR ({$group}) ";
     } else {
         $this->_where .= "{$signed}";
     }
 }
开发者ID:josephlacey,项目名称:cc.tadpole.petitionemail,代码行数:37,代码来源:PetitionEmail.php

示例2: buildRecipientContacts


//.........这里部分代码省略.........
                 $customGroup = $customField = array();
                 CRM_Core_BAO_CustomField::retrieve($customFieldParams, $customField);
                 $dateDBField = $customField['column_name'];
                 $customGroupParams = array('id' => $customField['custom_group_id'], $customGroup);
                 CRM_Core_BAO_CustomGroup::retrieve($customGroupParams, $customGroup);
                 $from = $table = "{$customGroup['table_name']} e";
                 $contactField = 'e.entity_id';
                 $where[] = '1';
                 // possible to have no "where" in this case
             }
             $status_ = explode(',', $status);
             if (in_array(2, $status_)) {
                 // anniversary mode:
                 $dateField = 'DATE_ADD(e.' . $dateDBField . ', INTERVAL ROUND(DATEDIFF(DATE(' . $now . '), e.' . $dateDBField . ') / 365) YEAR)';
                 $anniversary = true;
             } else {
                 // regular mode:
                 $dateField = 'e.' . $dateDBField;
             }
             // TODO get this working
             // TODO: Make sure everything's provided for repetition, etc.
         }
         // CRM-13577 Introduce Smart Groups Handling
         if ($actionSchedule->group_id) {
             // Need to check if its a smart group or not
             // Then decide which table to join onto the query
             $group = CRM_Contact_DAO_Group::getTableName();
             // Get the group information
             $sql = "\nSELECT     {$group}.id, {$group}.cache_date, {$group}.saved_search_id, {$group}.children\nFROM       {$group}\nWHERE      {$group}.id = {$actionSchedule->group_id}\n";
             $groupDAO = CRM_Core_DAO::executeQuery($sql);
             $isSmartGroup = FALSE;
             if ($groupDAO->fetch() && !empty($groupDAO->saved_search_id)) {
                 // Check that the group is in place in the cache and up to date
                 CRM_Contact_BAO_GroupContactCache::check($actionSchedule->group_id);
                 // Set smart group flag
                 $isSmartGroup = TRUE;
             }
         }
         // CRM-13577 End Introduce Smart Groups Handling
         if ($limitTo) {
             if ($actionSchedule->group_id) {
                 // CRM-13577 If smart group then use Cache table
                 if ($isSmartGroup) {
                     $join[] = "INNER JOIN civicrm_group_contact_cache grp ON {$contactField} = grp.contact_id";
                     $where[] = "grp.group_id IN ({$actionSchedule->group_id})";
                 } else {
                     $join[] = "INNER JOIN civicrm_group_contact grp ON {$contactField} = grp.contact_id AND grp.status = 'Added'";
                     $where[] = "grp.group_id IN ({$actionSchedule->group_id})";
                 }
             } elseif (!empty($actionSchedule->recipient_manual)) {
                 $rList = CRM_Utils_Type::escape($actionSchedule->recipient_manual, 'String');
                 $where[] = "{$contactField} IN ({$rList})";
             }
         } else {
             $addGroup = $addWhere = '';
             if ($actionSchedule->group_id) {
                 // CRM-13577 If smart group then use Cache table
                 if ($isSmartGroup) {
                     $addGroup = " INNER JOIN civicrm_group_contact_cache grp ON c.id = grp.contact_id";
                     $addWhere = " grp.group_id IN ({$actionSchedule->group_id})";
                 } else {
                     $addGroup = " INNER JOIN civicrm_group_contact grp ON c.id = grp.contact_id AND grp.status = 'Added'";
                     $addWhere = " grp.group_id IN ({$actionSchedule->group_id})";
                 }
             }
             if (!empty($actionSchedule->recipient_manual)) {
开发者ID:ruchirapingale,项目名称:civicrm-core,代码行数:67,代码来源:ActionSchedule.php

示例3: whereGroupClause

 /**
  * Build where clause for groups.
  *
  * @param string $field
  * @param mixed $value
  * @param string $op
  *
  * @return string
  */
 public function whereGroupClause($field, $value, $op)
 {
     $smartGroupQuery = "";
     $group = new CRM_Contact_DAO_Group();
     $group->is_active = 1;
     $group->find();
     $smartGroups = array();
     while ($group->fetch()) {
         if (in_array($group->id, $this->_params['gid_value']) && $group->saved_search_id) {
             $smartGroups[] = $group->id;
         }
     }
     CRM_Contact_BAO_GroupContactCache::check($smartGroups);
     $smartGroupQuery = '';
     if (!empty($smartGroups)) {
         $smartGroups = implode(',', $smartGroups);
         $smartGroupQuery = " UNION DISTINCT\n                  SELECT DISTINCT smartgroup_contact.contact_id\n                  FROM civicrm_group_contact_cache smartgroup_contact\n                  WHERE smartgroup_contact.group_id IN ({$smartGroups}) ";
     }
     $sqlOp = $this->getSQLOperator($op);
     if (!is_array($value)) {
         $value = array($value);
     }
     $clause = "{$field['dbAlias']} IN (" . implode(', ', $value) . ")";
     $contactAlias = $this->_aliases['civicrm_contact'];
     if (!empty($this->relationType) && $this->relationType == 'b_a') {
         $contactAlias = $this->_aliases['civicrm_contact_b'];
     }
     return " {$contactAlias}.id {$sqlOp} (\n                          SELECT DISTINCT {$this->_aliases['civicrm_group']}.contact_id\n                          FROM civicrm_group_contact {$this->_aliases['civicrm_group']}\n                          WHERE {$clause} AND {$this->_aliases['civicrm_group']}.status = 'Added'\n                          {$smartGroupQuery} ) ";
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:38,代码来源:Form.php

示例4: buildGroupTempTable

 /**
  * Create a table of the contact ids included by the group filter.
  *
  * This function is called by both the api (tests) and the UI.
  */
 public function buildGroupTempTable()
 {
     if (!empty($this->groupTempTable) || empty($this->_params['gid_value']) || $this->groupFilterNotOptimised) {
         return;
     }
     $filteredGroups = (array) $this->_params['gid_value'];
     $groups = civicrm_api3('Group', 'get', array('is_active' => 1, 'id' => array('IN' => $filteredGroups), 'saved_search_id' => array('>' => 0), 'return' => 'id'));
     $smartGroups = array_keys($groups['values']);
     $query = "\n       SELECT group_contact.contact_id as id\n       FROM civicrm_group_contact group_contact\n       WHERE group_contact.group_id IN (" . implode(', ', $filteredGroups) . ")\n       AND group_contact.status = 'Added' ";
     if (!empty($smartGroups)) {
         CRM_Contact_BAO_GroupContactCache::check($smartGroups);
         $smartGroups = implode(',', $smartGroups);
         $query .= "\n        UNION DISTINCT\n        SELECT smartgroup_contact.contact_id as id\n        FROM civicrm_group_contact_cache smartgroup_contact\n        WHERE smartgroup_contact.group_id IN ({$smartGroups}) ";
     }
     $this->groupTempTable = 'civicrm_report_temp_group_' . date('Ymd_') . uniqid();
     $this->executeReportQuery("\n      CREATE TEMPORARY TABLE {$this->groupTempTable}\n      {$query}\n    ");
     CRM_Core_DAO::executeQuery("ALTER TABLE {$this->groupTempTable} ADD INDEX i_id(id)");
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:23,代码来源:Form.php

示例5: whereGroupClause

 /**
  * Build where clause for groups.
  *
  * This has been overridden in order to:
  *  1) only build the group clause when filtering
  *  2) render the id field as id rather than contact_id in
  *   order to allow us to join on hte created temp table as if it
  *   were the contact table.
  *
  * Further refactoring could break down the parent function so it can be selectively
  * leveraged.
  *
  * @param string $field
  * @param mixed $value
  * @param string $op
  *
  * @return string
  */
 public function whereGroupClause($field, $value, $op)
 {
     if ($op == 'notin') {
         // We do not have an optimisation for this scenario at this stage. Use
         // parent.
         return parent::whereGroupClause($field, $value, $op);
     }
     if (empty($this->groupTempTable)) {
         $group = new CRM_Contact_DAO_Group();
         $group->is_active = 1;
         $group->find();
         $smartGroups = array();
         while ($group->fetch()) {
             if (in_array($group->id, $this->_params['gid_value']) && $group->saved_search_id) {
                 $smartGroups[] = $group->id;
             }
         }
         CRM_Contact_BAO_GroupContactCache::check($smartGroups);
         $smartGroupQuery = '';
         if (!empty($smartGroups)) {
             $smartGroups = implode(',', $smartGroups);
             $smartGroupQuery = " UNION DISTINCT\n                  SELECT DISTINCT smartgroup_contact.contact_id as id\n                  FROM civicrm_group_contact_cache smartgroup_contact\n                  WHERE smartgroup_contact.group_id IN ({$smartGroups}) ";
         }
         $sqlOp = $this->getSQLOperator($op);
         if (!is_array($value)) {
             $value = array($value);
         }
         $clause = "{$field['dbAlias']} IN (" . implode(', ', $value) . ")";
         $query = "SELECT DISTINCT {$this->_aliases['civicrm_group']}.contact_id as id\n                 FROM civicrm_group_contact {$this->_aliases['civicrm_group']}\n                 WHERE {$clause} AND {$this->_aliases['civicrm_group']}.status = 'Added'\n                 {$smartGroupQuery}  ";
         $this->buildGroupTempTable($query);
     }
     return "1";
 }
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:51,代码来源:Lybunt.php

示例6: prepareContactFilter

 /**
  * Prepare filter options for limiting by contact ID or group ID.
  *
  * @param string $contactIdField
  * @return \CRM_Utils_SQL_Select
  */
 protected function prepareContactFilter($contactIdField)
 {
     $actionSchedule = $this->actionSchedule;
     if ($actionSchedule->group_id) {
         if ($this->isSmartGroup($actionSchedule->group_id)) {
             // Check that the group is in place in the cache and up to date
             \CRM_Contact_BAO_GroupContactCache::check($actionSchedule->group_id);
             return \CRM_Utils_SQL_Select::fragment()->join('grp', "INNER JOIN civicrm_group_contact_cache grp ON {$contactIdField} = grp.contact_id")->where(" grp.group_id IN ({$actionSchedule->group_id})");
         } else {
             return \CRM_Utils_SQL_Select::fragment()->join('grp', " INNER JOIN civicrm_group_contact grp ON {$contactIdField} = grp.contact_id AND grp.status = 'Added'")->where(" grp.group_id IN ({$actionSchedule->group_id})");
         }
     } elseif (!empty($actionSchedule->recipient_manual)) {
         $rList = \CRM_Utils_Type::escape($actionSchedule->recipient_manual, 'String');
         return \CRM_Utils_SQL_Select::fragment()->where("{$contactIdField} IN ({$rList})");
     }
     return NULL;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:23,代码来源:RecipientBuilder.php

示例7: whereGroupClause

 function whereGroupClause($clause)
 {
     $smartGroupQuery = "";
     require_once 'CRM/Contact/DAO/Group.php';
     require_once 'CRM/Contact/BAO/SavedSearch.php';
     $group = new CRM_Contact_DAO_Group();
     $group->is_active = 1;
     $group->find();
     while ($group->fetch()) {
         if (in_array($group->id, $this->_params['gid_value']) && $group->saved_search_id) {
             $smartGroups[] = $group->id;
         }
     }
     require_once 'CRM/Contact/BAO/GroupContactCache.php';
     CRM_Contact_BAO_GroupContactCache::check($smartGroups);
     if (!empty($smartGroups)) {
         $smartGroups = implode(',', $smartGroups);
         $smartGroupQuery = " UNION DISTINCT \n                  SELECT DISTINCT smartgroup_contact.contact_id                                    \n                  FROM civicrm_group_contact_cache smartgroup_contact        \n                  WHERE smartgroup_contact.group_id IN ({$smartGroups}) ";
     }
     return " {$this->_aliases['civicrm_contact']}.id IN ( \n                          SELECT DISTINCT {$this->_aliases['civicrm_group']}.contact_id \n                          FROM civicrm_group_contact {$this->_aliases['civicrm_group']}\n                          WHERE {$clause} AND {$this->_aliases['civicrm_group']}.status = 'Added' \n                          {$smartGroupQuery} ) ";
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:21,代码来源:Form.php

示例8: petitionemail_get_recipients


//.........这里部分代码省略.........
            } else {
                // FIXME This is an error
                continue;
            }
        }
        // Initialize variables to build the SQL statement
        $from = array();
        // The master $where clause will be put together using AND
        $where = array();
        $params = array();
        $added_tables = array();
        // Initialize the from clause and where clause
        $from[] = 'civicrm_contact c';
        $where[] = 'c.is_deleted = 0';
        // We build a sub where clause that limits results based on the
        // matching group and matching field that will be put together using
        // OR since we match any any of the matching field => group
        // combinations.
        $sub_where = array();
        reset($matching_fields);
        $id = 0;
        while (list($matching_field, $value) = each($matching_fields)) {
            // The $where_fragment will be put together using AND because
            // you have to match both the group and the field.
            $where_fragment = array();
            // Gather information about the group that is paired with this
            // matching field.
            $group_id = $petition_vars['matching'][$matching_field];
            // Retrieve details (specifically, find out if it's a smart group)
            $results = civicrm_api3('Group', 'getsingle', array('id' => $group_id));
            if (!empty($results['id'])) {
                if (!empty($results['saved_search_id'])) {
                    // Populate the cache
                    CRM_Contact_BAO_GroupContactCache::check($group_id);
                    if (!in_array('civicrm_group_contact_cache', $added_tables)) {
                        $from[] = 'LEFT JOIN civicrm_group_contact_cache cc ON
              c.id = cc.contact_id';
                        $added_tables[] = 'civicrm_group_contact_cache';
                    }
                    $where_fragment[] = 'cc.group_id = %' . $id;
                    $params[$id] = array($group_id, 'Integer');
                    $id++;
                } else {
                    if (!in_array('civicrm_group_contact', $added_tables)) {
                        $from[] = 'LEFT JOIN civicrm_group_contact gc ON
              c.id = gc.contact_id';
                        $added_tables[] = 'civicrm_group_contact';
                    }
                    $where_fragment[] = 'gc.group_id = %' . $id;
                    $where_fragment[] = 'gc.status = "Added"';
                    $params[$id] = array($group_id, 'Integer');
                    $id++;
                }
                // Now add in the matching field
                if (empty($value)) {
                    // We should never match in this case
                    $where_fragment[] = "(0)";
                } else {
                    if (preg_match('/^custom_/', $matching_field)) {
                        $sql = "SELECT column_name, table_name FROM civicrm_custom_group g \n              JOIN civicrm_custom_field f ON g.id = f.custom_group_id WHERE \n              f.id = %0";
                        $custom_field_id = str_replace('custom_', '', $matching_field);
                        $dao = CRM_Core_DAO::executeQuery($sql, array(0 => array($custom_field_id, 'Integer')));
                        $dao->fetch();
                        if (!in_array($dao->table_name, $added_tables)) {
                            $from[] = "LEFT JOIN " . $dao->table_name . " ON " . $dao->table_name . ".entity_id = \n                c.id";
                            $added_tables[] = $dao->table_name;
开发者ID:josephlacey,项目名称:cc.tadpole.petitionemail,代码行数:67,代码来源:petitionemail.php


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