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


PHP CRM_Contact_BAO_Group::buildClause方法代码示例

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


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

示例1: addGroup

 /**
  * This method populates the civicrm_group_contact table
  */
 private function addGroup()
 {
     // add the 3 groups first
     foreach ($this->sampleData['group'] as $groupName) {
         $group = new CRM_Contact_BAO_Group();
         $group->name = $group->title = $groupName;
         $group->group_type = "12";
         $group->visibility = 'Public Pages';
         $group->is_active = 1;
         $group->save();
         $group->buildClause();
         $group->save();
     }
     // 60 are for newsletter
     for ($i = 0; $i < 60; $i++) {
         $groupContact = new CRM_Contact_DAO_GroupContact();
         // newsletter subscribers
         $groupContact->group_id = 2;
         $groupContact->contact_id = $this->Individual[$i];
         // always add members
         $groupContact->status = 'Added';
         $subscriptionHistory = new CRM_Contact_DAO_SubscriptionHistory();
         $subscriptionHistory->contact_id = $groupContact->contact_id;
         $subscriptionHistory->group_id = $groupContact->group_id;
         $subscriptionHistory->status = $groupContact->status;
         // method
         $subscriptionHistory->method = $this->randomItem($this->subscriptionHistoryMethod);
         $subscriptionHistory->date = $this->randomDate();
         if ($groupContact->status != 'Pending') {
             $this->_insert($groupContact);
         }
         $this->_insert($subscriptionHistory);
     }
     // 15 volunteers
     for ($i = 0; $i < 15; $i++) {
         $groupContact = new CRM_Contact_DAO_GroupContact();
         // Volunteers
         $groupContact->group_id = 3;
         $groupContact->contact_id = $this->Individual[$i + 60];
         // membership status
         $groupContact->status = 'Added';
         $subscriptionHistory = new CRM_Contact_DAO_SubscriptionHistory();
         $subscriptionHistory->contact_id = $groupContact->contact_id;
         $subscriptionHistory->group_id = $groupContact->group_id;
         $subscriptionHistory->status = $groupContact->status;
         // method
         $subscriptionHistory->method = $this->randomItem($this->subscriptionHistoryMethod);
         $subscriptionHistory->date = $this->randomDate();
         if ($groupContact->status != 'Pending') {
             $this->_insert($groupContact);
         }
         $this->_insert($subscriptionHistory);
     }
     // 8 advisory board group
     for ($i = 0; $i < 8; $i++) {
         $groupContact = new CRM_Contact_DAO_GroupContact();
         // advisory board group
         $groupContact->group_id = 4;
         $groupContact->contact_id = $this->Individual[$i * 7];
         // membership status
         $groupContact->status = 'Added';
         $subscriptionHistory = new CRM_Contact_DAO_SubscriptionHistory();
         $subscriptionHistory->contact_id = $groupContact->contact_id;
         $subscriptionHistory->group_id = $groupContact->group_id;
         $subscriptionHistory->status = $groupContact->status;
         // method
         $subscriptionHistory->method = $this->randomItem($this->subscriptionHistoryMethod);
         $subscriptionHistory->date = $this->randomDate();
         if ($groupContact->status != 'Pending') {
             $this->_insert($groupContact);
         }
         $this->_insert($subscriptionHistory);
     }
     //In this function when we add groups that time we are cache the contact fields
     //But at the end of setup we are appending sample custom data, so for consistency
     //reset the cache.
     CRM_Core_BAO_Cache::deleteGroup('contact fields');
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:81,代码来源:GenerateData.php

示例2: addGroup

 public function addGroup()
 {
     // add the 3 groups first
     $numGroup = count($this->group);
     require_once 'CRM/Contact/BAO/Group.php';
     for ($i = 0; $i < $numGroup; $i++) {
         $group = new CRM_Contact_BAO_Group();
         $group->name = $this->group[$i];
         $group->title = $this->group[$i];
         $group->group_type = "12";
         $group->visibility = 'Public Pages';
         $group->is_active = 1;
         $group->save();
         $group->buildClause();
         $group->save();
     }
     // 60 are for newsletter
     for ($i = 0; $i < 60; $i++) {
         $groupContact = new CRM_Contact_DAO_GroupContact();
         // newsletter subscribers
         $groupContact->group_id = 2;
         $groupContact->contact_id = $this->individual[$i];
         // membership status
         $groupContact->status = $this->_getRandomElement($this->groupMembershipStatus);
         $subscriptionHistory = new CRM_Contact_DAO_SubscriptionHistory();
         $subscriptionHistory->contact_id = $groupContact->contact_id;
         $subscriptionHistory->group_id = $groupContact->group_id;
         $subscriptionHistory->status = $groupContact->status;
         // method
         $subscriptionHistory->method = $this->_getRandomElement($this->subscriptionHistoryMethod);
         $subscriptionHistory->date = $this->_getRandomDate();
         if ($groupContact->status != 'Pending') {
             $this->_insert($groupContact);
         }
         $this->_insert($subscriptionHistory);
     }
     // 15 volunteers
     for ($i = 0; $i < 15; $i++) {
         $groupContact = new CRM_Contact_DAO_GroupContact();
         // Volunteers
         $groupContact->group_id = 3;
         $groupContact->contact_id = $this->individual[$i + 60];
         // membership status
         $groupContact->status = $this->_getRandomElement($this->groupMembershipStatus);
         $subscriptionHistory = new CRM_Contact_DAO_SubscriptionHistory();
         $subscriptionHistory->contact_id = $groupContact->contact_id;
         $subscriptionHistory->group_id = $groupContact->group_id;
         $subscriptionHistory->status = $groupContact->status;
         // method
         $subscriptionHistory->method = $this->_getRandomElement($this->subscriptionHistoryMethod);
         $subscriptionHistory->date = $this->_getRandomDate();
         if ($groupContact->status != 'Pending') {
             $this->_insert($groupContact);
         }
         $this->_insert($subscriptionHistory);
     }
     // 8 advisory board group
     for ($i = 0; $i < 8; $i++) {
         $groupContact = new CRM_Contact_DAO_GroupContact();
         // advisory board group
         $groupContact->group_id = 4;
         $groupContact->contact_id = $this->individual[$i * 7];
         // membership status
         $groupContact->status = $this->_getRandomElement($this->groupMembershipStatus);
         $subscriptionHistory = new CRM_Contact_DAO_SubscriptionHistory();
         $subscriptionHistory->contact_id = $groupContact->contact_id;
         $subscriptionHistory->group_id = $groupContact->group_id;
         $subscriptionHistory->status = $groupContact->status;
         // method
         $subscriptionHistory->method = $this->_getRandomElement($this->subscriptionHistoryMethod);
         $subscriptionHistory->date = $this->_getRandomDate();
         if ($groupContact->status != 'Pending') {
             $this->_insert($groupContact);
         }
         $this->_insert($subscriptionHistory);
     }
     //In this function when we add groups that time we are cache the contact fields
     //But at the end of setup we are appending sample custom data, so for consistency
     //reset the cache.
     require_once 'CRM/Core/BAO/Cache.php';
     CRM_Core_BAO_Cache::deleteGroup('contact fields');
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:82,代码来源:GenerateReportData.php

示例3: implode

 /**
  * Create a new group.
  *
  * @param array $params
  *
  * @return CRM_Contact_BAO_Group|NULL
  *   The new group BAO (if created)
  */
 public static function &create(&$params)
 {
     if (!empty($params['id'])) {
         CRM_Utils_Hook::pre('edit', 'Group', $params['id'], $params);
     } else {
         CRM_Utils_Hook::pre('create', 'Group', NULL, $params);
     }
     // form the name only if missing: CRM-627
     $nameParam = CRM_Utils_Array::value('name', $params, NULL);
     if (!$nameParam && empty($params['id'])) {
         $params['name'] = CRM_Utils_String::titleToVar($params['title']);
     }
     // convert params if array type
     if (isset($params['group_type'])) {
         if (is_array($params['group_type'])) {
             $params['group_type'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($params['group_type'])) . CRM_Core_DAO::VALUE_SEPARATOR;
         }
     } else {
         $params['group_type'] = '';
     }
     $session = CRM_Core_Session::singleton();
     $cid = $session->get('userID');
     // this action is add
     if ($cid && empty($params['id'])) {
         $params['created_id'] = $cid;
     }
     // this action is update
     if ($cid && !empty($params['id'])) {
         $params['modified_id'] = $cid;
     }
     $group = new CRM_Contact_BAO_Group();
     $group->copyValues($params);
     //@todo very hacky fix for the fact this function wants to receive 'parents' as an array further down but
     // needs it as a separated string for the DB. Preferred approaches are having the copyParams or save fn
     // use metadata to translate the array to the appropriate DB type or altering the param in the api layer,
     // or at least altering the param in same section as 'group_type' rather than repeating here. However, further down
     // we need the $params one to be in it's original form & we are not sure what test coverage we have on that
     if (isset($group->parents) && is_array($group->parents)) {
         $group->parents = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($group->parents)) . CRM_Core_DAO::VALUE_SEPARATOR;
     }
     if (empty($params['id']) && !$nameParam) {
         $group->name .= "_tmp";
     }
     $group->save();
     if (!$group->id) {
         return NULL;
     }
     if (empty($params['id']) && !$nameParam) {
         $group->name = substr($group->name, 0, -4) . "_{$group->id}";
     }
     $group->buildClause();
     $group->save();
     // add custom field values
     if (!empty($params['custom'])) {
         CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_group', $group->id);
     }
     // make the group, child of domain/site group by default.
     $domainGroupID = CRM_Core_BAO_Domain::getGroupId();
     if (CRM_Utils_Array::value('no_parent', $params) !== 1) {
         if (empty($params['parents']) && $domainGroupID != $group->id && CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME, 'is_enabled') && !CRM_Contact_BAO_GroupNesting::hasParentGroups($group->id)) {
             // if no parent present and the group doesn't already have any parents,
             // make sure site group goes as parent
             $params['parents'] = array($domainGroupID => 1);
         } elseif (array_key_exists('parents', $params) && !is_array($params['parents'])) {
             $params['parents'] = array($params['parents'] => 1);
         }
         if (!empty($params['parents'])) {
             foreach ($params['parents'] as $parentId => $dnc) {
                 if ($parentId && !CRM_Contact_BAO_GroupNesting::isParentChild($parentId, $group->id)) {
                     CRM_Contact_BAO_GroupNesting::add($parentId, $group->id);
                 }
             }
         }
         // clear any descendant groups cache if exists
         $finalGroups = CRM_Core_BAO_Cache::deleteGroup('descendant groups for an org');
         // this is always required, since we don't know when a
         // parent group is removed
         CRM_Contact_BAO_GroupNestingCache::update();
         // update group contact cache for all parent groups
         $parentIds = CRM_Contact_BAO_GroupNesting::getParentGroupIds($group->id);
         foreach ($parentIds as $parentId) {
             CRM_Contact_BAO_GroupContactCache::add($parentId);
         }
     }
     if (!empty($params['organization_id'])) {
         $groupOrg = array();
         $groupOrg = $params;
         $groupOrg['group_id'] = $group->id;
         CRM_Contact_BAO_GroupOrganization::add($groupOrg);
     }
     CRM_Contact_BAO_GroupContactCache::add($group->id);
     if (!empty($params['id'])) {
//.........这里部分代码省略.........
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:101,代码来源:Group.php

示例4: implode

 /**
  * Create a new group
  *
  * @param array $params     Associative array of parameters
  *
  * @return object|null      The new group BAO (if created)
  * @access public
  * @static
  */
 public static function &create(&$params)
 {
     if (CRM_Utils_Array::value('id', $params)) {
         CRM_Utils_Hook::pre('edit', 'Group', $params['id'], $params);
     } else {
         CRM_Utils_Hook::pre('create', 'Group', NULL, $params);
     }
     // form the name only if missing: CRM-627
     if (!CRM_Utils_Array::value('name', $params) && !CRM_Utils_Array::value('id', $params)) {
         $params['name'] = CRM_Utils_String::titleToVar($params['title']);
     }
     // convert params if array type
     if (isset($params['group_type'])) {
         if (is_array($params['group_type'])) {
             $params['group_type'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($params['group_type'])) . CRM_Core_DAO::VALUE_SEPARATOR;
         }
     } else {
         $params['group_type'] = '';
     }
     $group = new CRM_Contact_BAO_Group();
     $group->copyValues($params);
     if (!CRM_Utils_Array::value('id', $params)) {
         $group->name .= "_tmp";
     }
     $group->save();
     if (!$group->id) {
         return NULL;
     }
     if (!CRM_Utils_Array::value('id', $params)) {
         $group->name = substr($group->name, 0, -4) . "_{$group->id}";
     }
     $group->buildClause();
     $group->save();
     // add custom field values
     if (CRM_Utils_Array::value('custom', $params)) {
         CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_group', $group->id);
     }
     // make the group, child of domain/site group by default.
     $domainGroupID = CRM_Core_BAO_Domain::getGroupId();
     if (CRM_Utils_Array::value('no_parent', $params) !== 1) {
         if (empty($params['parents']) && $domainGroupID != $group->id && CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME, 'is_enabled') && !CRM_Contact_BAO_GroupNesting::hasParentGroups($group->id)) {
             // if no parent present and the group doesn't already have any parents,
             // make sure site group goes as parent
             $params['parents'] = array($domainGroupID => 1);
         } elseif (array_key_exists('parents', $params) && !is_array($params['parents'])) {
             $params['parents'] = array($params['parents'] => 1);
         }
         if (!empty($params['parents'])) {
             foreach ($params['parents'] as $parentId => $dnc) {
                 if ($parentId && !CRM_Contact_BAO_GroupNesting::isParentChild($parentId, $group->id)) {
                     CRM_Contact_BAO_GroupNesting::add($parentId, $group->id);
                 }
             }
         }
         // clear any descendant groups cache if exists
         $finalGroups = CRM_Core_BAO_Cache::deleteGroup('descendant groups for an org');
         // this is always required, since we don't know when a
         // parent group is removed
         CRM_Contact_BAO_GroupNestingCache::update();
         // update group contact cache for all parent groups
         $parentIds = CRM_Contact_BAO_GroupNesting::getParentGroupIds($group->id);
         foreach ($parentIds as $parentId) {
             CRM_Contact_BAO_GroupContactCache::add($parentId);
         }
     }
     if (CRM_Utils_Array::value('organization_id', $params)) {
         $groupOrg = array();
         $groupOrg = $params;
         $groupOrg['group_id'] = $group->id;
         CRM_Contact_BAO_GroupOrganization::add($groupOrg);
     }
     CRM_Contact_BAO_GroupContactCache::add($group->id);
     if (CRM_Utils_Array::value('id', $params)) {
         CRM_Utils_Hook::post('edit', 'Group', $group->id, $group);
     } else {
         CRM_Utils_Hook::post('create', 'Group', $group->id, $group);
     }
     $recentOther = array();
     if (CRM_Core_Permission::check('edit groups')) {
         $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/group', 'reset=1&action=update&id=' . $group->id);
         // currently same permission we are using for delete a group
         $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/group', 'reset=1&action=delete&id=' . $group->id);
     }
     // add the recently added group (unless hidden: CRM-6432)
     if (!$group->is_hidden) {
         CRM_Utils_Recent::add($group->title, CRM_Utils_System::url('civicrm/group/search', 'reset=1&force=1&context=smog&gid=' . $group->id), $group->id, 'Group', NULL, NULL, $recentOther);
     }
     return $group;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:98,代码来源:Group.php


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