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


PHP CRM_Contact_DAO_Relationship::query方法代码示例

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


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

示例1: getRelationship

 /**
  * Get a list of relationships.
  *
  * @param int $contactId
  *   Contact id.
  * @param int $status
  *   1: Past 2: Disabled 3: Current.
  * @param int $numRelationship
  *   No of relationships to display (limit).
  * @param int $count
  *   Get the no of relationships.
  * @param int $relationshipId
  * @param array $links
  *   the list of links to display
  * @param int $permissionMask
  *   the permission mask to be applied for the actions
  * @param bool $permissionedContact
  *   to return only permissioned Contact
  * @param array $params
  *
  * @return array|int
  *   relationship records
  */
 public static function getRelationship($contactId = NULL, $status = 0, $numRelationship = 0, $count = 0, $relationshipId = 0, $links = NULL, $permissionMask = NULL, $permissionedContact = FALSE, $params = array())
 {
     $values = array();
     if (!$contactId && !$relationshipId) {
         return $values;
     }
     list($select1, $from1, $where1) = self::makeURLClause($contactId, $status, $numRelationship, $count, $relationshipId, 'a_b', $params);
     list($select2, $from2, $where2) = self::makeURLClause($contactId, $status, $numRelationship, $count, $relationshipId, 'b_a', $params);
     $order = $limit = '';
     if (!$count) {
         if (empty($params['sort'])) {
             $order = ' ORDER BY civicrm_relationship_type_id, sort_name ';
         } else {
             $order = " ORDER BY {$params['sort']} ";
         }
         $offset = 0;
         if (!empty($params['offset']) && $params['offset'] > 0) {
             $offset = $params['offset'];
         }
         if ($numRelationship) {
             $limit = " LIMIT {$offset}, {$numRelationship}";
         }
     }
     // building the query string
     $queryString = $select1 . $from1 . $where1 . $select2 . $from2 . $where2 . $order . $limit;
     $relationship = new CRM_Contact_DAO_Relationship();
     $relationship->query($queryString);
     $row = array();
     if ($count) {
         $relationshipCount = 0;
         while ($relationship->fetch()) {
             $relationshipCount += $relationship->cnt1 + $relationship->cnt2;
         }
         return $relationshipCount;
     } else {
         $mask = NULL;
         if ($status != self::INACTIVE) {
             if ($links) {
                 $mask = array_sum(array_keys($links));
                 if ($mask & CRM_Core_Action::DISABLE) {
                     $mask -= CRM_Core_Action::DISABLE;
                 }
                 if ($mask & CRM_Core_Action::ENABLE) {
                     $mask -= CRM_Core_Action::ENABLE;
                 }
                 if ($status == self::CURRENT) {
                     $mask |= CRM_Core_Action::DISABLE;
                 } elseif ($status == self::DISABLED) {
                     $mask |= CRM_Core_Action::ENABLE;
                 }
                 $mask = $mask & $permissionMask;
             }
         }
         while ($relationship->fetch()) {
             $rid = $relationship->civicrm_relationship_id;
             $cid = $relationship->civicrm_contact_id;
             if ($permissionedContact && !CRM_Contact_BAO_Contact_Permission::allow($cid)) {
                 continue;
             }
             $values[$rid]['id'] = $rid;
             $values[$rid]['cid'] = $cid;
             $values[$rid]['contact_id_a'] = $relationship->contact_id_a;
             $values[$rid]['contact_id_b'] = $relationship->contact_id_b;
             $values[$rid]['contact_type'] = $relationship->contact_type;
             $values[$rid]['relationship_type_id'] = $relationship->civicrm_relationship_type_id;
             $values[$rid]['relation'] = $relationship->relation;
             $values[$rid]['name'] = $relationship->sort_name;
             $values[$rid]['display_name'] = $relationship->display_name;
             $values[$rid]['job_title'] = $relationship->job_title;
             $values[$rid]['email'] = $relationship->email;
             $values[$rid]['phone'] = $relationship->phone;
             $values[$rid]['employer_id'] = $relationship->employer_id;
             $values[$rid]['organization_name'] = $relationship->organization_name;
             $values[$rid]['country'] = $relationship->country;
             $values[$rid]['city'] = $relationship->city;
             $values[$rid]['state'] = $relationship->state;
             $values[$rid]['start_date'] = $relationship->start_date;
//.........这里部分代码省略.........
开发者ID:scardinius,项目名称:civicrm-core,代码行数:101,代码来源:Relationship.php


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