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


PHP CRM_Contact_BAO_Query::_relationshipTempTable方法代码示例

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


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

示例1: relationship

 /**
  * Where / qill clause for relationship.
  *
  * @param array $values
  */
 public function relationship(&$values)
 {
     list($name, $op, $value, $grouping, $wildcard) = $values;
     if ($this->_relationshipValuesAdded) {
         return;
     }
     // also get values array for relation_target_name
     // for relationship search we always do wildcard
     $relationType = $this->getWhereValues('relation_type_id', $grouping);
     $targetName = $this->getWhereValues('relation_target_name', $grouping);
     $relStatus = $this->getWhereValues('relation_status', $grouping);
     $relPermission = $this->getWhereValues('relation_permission', $grouping);
     $targetGroup = $this->getWhereValues('relation_target_group', $grouping);
     $nameClause = $name = NULL;
     if ($targetName) {
         $name = trim($targetName[2]);
         if (substr($name, 0, 1) == '"' && substr($name, -1, 1) == '"') {
             $name = substr($name, 1, -1);
             $name = strtolower(CRM_Core_DAO::escapeString($name));
             $nameClause = "= '{$name}'";
         } else {
             $name = strtolower(CRM_Core_DAO::escapeString($name));
             $nameClause = "LIKE '%{$name}%'";
         }
     }
     $rTypeValues = array();
     if (!empty($relationType)) {
         $rel = explode('_', $relationType[2]);
         self::$_relType = $rel[1];
         $params = array('id' => $rel[0]);
         $rType = CRM_Contact_BAO_RelationshipType::retrieve($params, $rTypeValues);
     }
     if (!empty($rTypeValues) && $rTypeValues['name_a_b'] == $rTypeValues['name_b_a']) {
         // if we don't know which end of the relationship we are dealing with we'll create a temp table
         //@todo unless we are dealing with a target group
         self::$_relType = 'reciprocal';
     }
     // if we are creating a temp table we build our own where for the relationship table
     $relationshipTempTable = NULL;
     if (self::$_relType == 'reciprocal' && empty($targetGroup)) {
         $where = array();
         self::$_relationshipTempTable = $relationshipTempTable = CRM_Core_DAO::createTempTableName('civicrm_rel');
         if ($nameClause) {
             $where[$grouping][] = " sort_name {$nameClause} ";
         }
     } else {
         $where =& $this->_where;
         if ($nameClause) {
             $where[$grouping][] = "( contact_b.sort_name {$nameClause} AND contact_b.id != contact_a.id )";
         }
     }
     $allRelationshipType = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, NULL, TRUE);
     if ($nameClause || !$targetGroup) {
         if (!empty($relationType)) {
             $this->_qill[$grouping][] = $allRelationshipType[$relationType[2]] . " {$name}";
         } else {
             $this->_qill[$grouping][] = $name;
         }
     }
     //check to see if the target contact is in specified group
     if ($targetGroup) {
         //add contacts from static groups
         $this->_tables['civicrm_relationship_group_contact'] = $this->_whereTables['civicrm_relationship_group_contact'] = " LEFT JOIN civicrm_group_contact civicrm_relationship_group_contact ON civicrm_relationship_group_contact.contact_id = contact_b.id AND civicrm_relationship_group_contact.status = 'Added'";
         $groupWhere[] = "( civicrm_relationship_group_contact.group_id IN  (" . implode(",", $targetGroup[2]) . ") ) ";
         //add contacts from saved searches
         $ssWhere = $this->addGroupContactCache($targetGroup[2], "civicrm_relationship_group_contact_cache", "contact_b", $op);
         //set the group where clause
         if ($ssWhere) {
             $groupWhere[] = "( " . $ssWhere . " )";
         }
         $this->_where[$grouping][] = "( " . implode(" OR ", $groupWhere) . " )";
         //Get the names of the target groups for the qill
         $groupNames = CRM_Core_PseudoConstant::group();
         $qillNames = array();
         foreach ($targetGroup[2] as $groupId) {
             if (array_key_exists($groupId, $groupNames)) {
                 $qillNames[] = $groupNames[$groupId];
             }
         }
         if (!empty($relationType)) {
             $this->_qill[$grouping][] = $allRelationshipType[$relationType[2]] . " ( " . implode(", ", $qillNames) . " )";
         } else {
             $this->_qill[$grouping][] = implode(", ", $qillNames);
         }
     }
     // Note we do not currently set mySql to handle timezones, so doing this the old-fashioned way
     $today = date('Ymd');
     //check for active, inactive and all relation status
     if ($relStatus[2] == 0) {
         $where[$grouping][] = "(\ncivicrm_relationship.is_active = 1 AND\n( civicrm_relationship.end_date IS NULL OR civicrm_relationship.end_date >= {$today} ) AND\n( civicrm_relationship.start_date IS NULL OR civicrm_relationship.start_date <= {$today} )\n)";
         $this->_qill[$grouping][] = ts('Relationship - Active and Current');
     } elseif ($relStatus[2] == 1) {
         $where[$grouping][] = "(\ncivicrm_relationship.is_active = 0 OR\ncivicrm_relationship.end_date < {$today} OR\ncivicrm_relationship.start_date > {$today}\n)";
         $this->_qill[$grouping][] = ts('Relationship - Inactive or not Current');
     }
//.........这里部分代码省略.........
开发者ID:hoegrammer,项目名称:civicrm-core,代码行数:101,代码来源:Query.php


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