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


PHP CRM_Contact_BAO_Group::createSmartGroup方法代码示例

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


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

示例1: testRemoveFromParentSmartGroup

 /**
  * Allow removing contact from a parent group even if contact is in
  * a child group. (CRM-8858)
  */
 function testRemoveFromParentSmartGroup()
 {
     // Create smart group $parent
     $params = array('name' => 'Deceased Contacts', 'title' => 'Deceased Contacts', 'is_active' => 1, 'formValues' => array('is_deceased' => 1));
     $parent = CRM_Contact_BAO_Group::createSmartGroup($params);
     $this->registerTestObjects(array($parent));
     // Create group $child in $parent
     $params = array('name' => 'Child Group', 'title' => 'Child Group', 'is_active' => 1, 'parents' => array($parent->id => 1));
     $child = CRM_Contact_BAO_Group::create($params);
     $this->registerTestObjects(array($child));
     // Create $c1, $c2, $c3
     $deceased = $this->createTestObject('CRM_Contact_DAO_Contact', array('is_deceased' => 1), 3);
     // Add $c1, $c2, $c3 to $child
     foreach ($deceased as $contact) {
         $result = $this->callAPISuccess('group_contact', 'create', array('contact_id' => $contact->id, 'group_id' => $child->id));
     }
     // GroupContactCache::load()
     CRM_Contact_BAO_GroupContactCache::load($parent, TRUE);
     $this->assertCacheMatches(array($deceased[0]->id, $deceased[1]->id, $deceased[2]->id), $parent->id);
     // Remove $c1 from $parent
     $result = civicrm_api('group_contact', 'create', array('contact_id' => $deceased[0]->id, 'group_id' => $parent->id, 'status' => 'Removed', 'version' => '3'));
     $this->assertAPISuccess($result);
     // Assert $c1 not in $parent
     CRM_Contact_BAO_GroupContactCache::load($parent, TRUE);
     $this->assertCacheMatches(array($deceased[1]->id, $deceased[2]->id), $parent->id);
     // Assert $c1 still in $child
     $this->assertDBQuery(1, 'select count(*) from civicrm_group_contact where group_id=%1 and contact_id=%2 and status=%3', array(1 => array($child->id, 'Integer'), 2 => array($deceased[0]->id, 'Integer'), 3 => array('Added', 'String')));
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:32,代码来源:GroupContactCacheTest.php

示例2: testAddSmart

 /**
  * Test adding a smart group.
  */
 public function testAddSmart()
 {
     $checkParams = $params = array('title' => 'Group Dos', 'description' => 'Group Two', 'visibility' => 'User and User Admin Only', 'is_active' => 1, 'formValues' => array('sort_name' => 'Adams'));
     $group = CRM_Contact_BAO_Group::createSmartGroup($params);
     unset($checkParams['formValues']);
     $this->assertDBCompareValues('CRM_Contact_DAO_Group', array('id' => $group->id), $checkParams);
 }
开发者ID:scardinius,项目名称:civicrm-core,代码行数:10,代码来源:GroupTest.php

示例3: setupSmartGroup

 /**
  * Set up a smart group testing scenario.
  *
  * @return array
  */
 protected function setupSmartGroup()
 {
     $params = array('name' => 'Deceased Contacts', 'title' => 'Deceased Contacts', 'is_active' => 1, 'formValues' => array('is_deceased' => 1));
     $group = CRM_Contact_BAO_Group::createSmartGroup($params);
     $this->registerTestObjects(array($group));
     // Create contacts $y1, $y2, $y3 which do match $g; create $n1, $n2, $n3 which do not match $g
     $living = $this->createTestObject('CRM_Contact_DAO_Contact', array('is_deceased' => 0), 3);
     $deceased = $this->createTestObject('CRM_Contact_DAO_Contact', array('is_deceased' => 1), 3);
     $this->assertEquals(3, count($deceased));
     $this->assertEquals(3, count($living));
     // Assert: $g cache has exactly $y1, $y2, $y3
     CRM_Contact_BAO_GroupContactCache::load($group, TRUE);
     $group->find(TRUE);
     $this->assertCacheMatches(array($deceased[0]->id, $deceased[1]->id, $deceased[2]->id), $group->id);
     // Reload the group so we have the cache_date & refresh_date.
     return array($group, $living, $deceased);
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:22,代码来源:GroupContactCacheTest.php

示例4: testAccurateCountWithSmartGroups

 /**
  * CRM-16945 duplicate groups are showing up when contacts are hard-added to child groups or smart groups.
  *
  * Fix documented in
  *
  * Test illustrates this (& ensures once fixed it will stay fixed).
  */
 public function testAccurateCountWithSmartGroups()
 {
     $childGroupID = $this->groupCreate(array('name' => 'Child group', 'domain_id' => 1, 'title' => 'Child group', 'description' => 'Child group', 'is_active' => 1, 'parents' => $this->_groupId1, 'visibility' => 'User and User Admin Only'));
     $params = array('name' => 'Individuals', 'title' => 'Individuals', 'is_active' => 1, 'parents' => $this->_groupId1, 'formValues' => array('contact_type' => 'Goat'));
     $smartGroup2 = CRM_Contact_BAO_Group::createSmartGroup($params);
     $this->callAPISuccess('GroupContact', 'create', array('contact_id' => $this->_contactId, 'status' => 'Added', 'group_id' => $this->_groupId2));
     $this->callAPISuccess('GroupContact', 'create', array('contact_id' => $this->_contactId, 'status' => 'Added', 'group_id' => $smartGroup2->id));
     $this->callAPISuccess('GroupContact', 'create', array('contact_id' => $this->_contactId, 'status' => 'Added', 'group_id' => $childGroupID));
     $groups = $this->callAPISuccess('GroupContact', 'get', array('contact_id' => $this->_contactId));
     // Although the contact is actually hard-added to 4 groups the smart groups are conventionally not returned by the api or displayed
     // on the main part of the groups tab on the contact (which calls the same function. So, 3 groups is an OK number to return.
     // However, as of writing this test 4 groups are returned (indexed by group_contact_id, but more seriously 3/4 of those have the group id 1
     // so 2 on them have group ids that do not match the group contact id they have been keyed by.
     foreach ($groups['values'] as $groupContactID => $groupContactRecord) {
         $this->assertEquals($groupContactRecord['group_id'], CRM_Core_DAO::singleValueQuery("SELECT group_id FROM civicrm_group_contact WHERE id = {$groupContactID}"), 'Group contact record mis-returned for id ' . $groupContactID);
     }
     $this->assertEquals(3, $groups['count']);
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:25,代码来源:GroupContactTest.php

示例5: testNumericPostal

 /**
  * Test smart groups with non-numeric don't fail on range queries.
  *
  * CRM-14720
  */
 public function testNumericPostal()
 {
     $this->individualCreate(array('api.address.create' => array('postal_code' => 5, 'location_type_id' => 'Main')));
     $this->individualCreate(array('api.address.create' => array('postal_code' => 'EH10 4RB-889', 'location_type_id' => 'Main')));
     $this->individualCreate(array('api.address.create' => array('postal_code' => '4', 'location_type_id' => 'Main')));
     $this->individualCreate(array('api.address.create' => array('postal_code' => '6', 'location_type_id' => 'Main')));
     $params = array(array('postal_code_low', '=', 5, 0, 0));
     CRM_Contact_BAO_Query::convertFormValues($params);
     $query = new CRM_Contact_BAO_Query($params, array('contact_id'), NULL, TRUE, FALSE, 1, TRUE, TRUE, FALSE);
     $sql = $query->query(FALSE);
     $result = CRM_Core_DAO::executeQuery(implode(' ', $sql));
     $this->assertEquals(2, $result->N);
     // We save this as a smart group and then load it. With mysql warnings on & CRM-14720 this
     // results in mysql warnings & hence fatal errors.
     /// I was unable to get mysql warnings to activate in the context of the unit tests - but
     // felt this code still provided a useful bit of coverage as it runs the various queries to load
     // the group & could generate invalid sql if a bug were introduced.
     $groupParams = array('title' => 'postal codes', 'formValues' => $params, 'is_active' => 1);
     $group = CRM_Contact_BAO_Group::createSmartGroup($groupParams);
     CRM_Contact_BAO_GroupContactCache::load($group, TRUE);
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:26,代码来源:QueryTest.php


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