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


PHP CRM_Contact_BAO_Group类代码示例

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


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

示例1: testAddSmart

 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:archcidburnziso,项目名称:civicrm-core,代码行数:7,代码来源:GroupTest.php

示例2: getGroupList

 /**
  * Get list of groups.
  */
 public static function getGroupList()
 {
     $params = $_GET;
     if (isset($params['parent_id'])) {
         // requesting child groups for a given parent
         $params['page'] = 1;
         $params['rp'] = 0;
         $groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
         CRM_Utils_JSON::output($groups);
     } else {
         $params = CRM_Core_Page_AJAX::defaultSortAndPagerParams();
         $optionalParameters = array('parentsOnly' => 'Integer', 'showOrgInfo' => 'Boolean');
         $params += CRM_Core_Page_AJAX::validateParams(array(), $optionalParameters);
         // get group list
         $groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
         // if no groups found with parent-child hierarchy and logged in user say can view child groups only (an ACL case),
         // go ahead with flat hierarchy, CRM-12225
         if (empty($groups)) {
             $groupsAccessible = CRM_Core_PseudoConstant::group();
             $parentsOnly = CRM_Utils_Array::value('parentsOnly', $params);
             if (!empty($groupsAccessible) && $parentsOnly) {
                 // recompute group list with flat hierarchy
                 $params['parentsOnly'] = 0;
                 $groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
             }
         }
         CRM_Utils_JSON::output($groups);
     }
 }
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:32,代码来源:AJAX.php

示例3: 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

示例4: buildQuickForm

 /**
  * Build the form
  *
  * @access public
  *
  * @return void
  */
 function buildQuickForm()
 {
     // text for sort_name or email criteria
     $config = CRM_Core_Config::singleton();
     $label = empty($config->includeEmailInName) ? ts('Name') : ts('Name or Email');
     $this->add('text', 'sort_name', $label);
     $searchOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'advanced_search_options');
     $shortCuts = array();
     //@todo FIXME - using the CRM_Core_DAO::VALUE_SEPARATOR creates invalid html - if you can find the form
     // this is loaded onto then replace with something like '__' & test
     $separator = CRM_Core_DAO::VALUE_SEPARATOR;
     if (!empty($searchOptions['contactType'])) {
         $contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator);
         $this->add('select', 'contact_type', ts('is...'), $contactTypes, FALSE, array('class' => 'crm-select2'));
     }
     if (!empty($searchOptions['groups'])) {
         // Arrange groups into hierarchical listing (child groups follow their parents and have indentation spacing in title)
         $groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($this->_group, NULL, '  ', TRUE);
         // add select for groups
         $group = array('' => ts('- any group -')) + $groupHierarchy;
         $this->add('select', 'group', ts('in'), $group, FALSE, array('class' => 'crm-select2'));
     }
     if (!empty($searchOptions['tags'])) {
         // tag criteria
         if (!empty($this->_tag)) {
             $tag = array('' => ts('- any tag -')) + $this->_tag;
             $this->add('select', 'tag', ts('with'), $tag, FALSE, array('class' => 'crm-select2'));
         }
     }
     parent::buildQuickForm();
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:38,代码来源:Basic.php

示例5: buildQuickForm

 /**
  * Build the form
  *
  * @access public
  *
  * @return void
  */
 function buildQuickForm()
 {
     // text for sort_name or email criteria
     $config = CRM_Core_Config::singleton();
     $label = empty($config->includeEmailInName) ? ts('Name') : ts('Name or Email');
     $this->add('text', 'sort_name', $label);
     $searchOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'advanced_search_options');
     if (!empty($searchOptions['contactType'])) {
         $contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements();
         $this->add('select', 'contact_type', ts('is...'), $contactTypes);
     }
     if (!empty($searchOptions['groups'])) {
         // Arrange groups into hierarchical listing (child groups follow their parents and have indentation spacing in title)
         $groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($this->_group, NULL, '  ', TRUE);
         // add select for groups
         $group = array('' => ts('- any group -')) + $groupHierarchy;
         $this->_groupElement =& $this->addElement('select', 'group', ts('in'), $group);
     }
     if (!empty($searchOptions['tags'])) {
         // tag criteria
         if (!empty($this->_tag)) {
             $tag = array('' => ts('- any tag -')) + $this->_tag;
             $this->_tagElement =& $this->addElement('select', 'tag', ts('with'), $tag);
         }
     }
     parent::buildQuickForm();
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:34,代码来源:Basic.php

示例6: buildQuickForm

 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     // get the list of all the groups
     if ($this->_context == 'user') {
         $onlyPublicGroups = CRM_Utils_Request::retrieve('onlyPublicGroups', 'Boolean', $this, FALSE);
         $allGroups = CRM_Core_PseudoConstant::staticGroup($onlyPublicGroups);
     } else {
         $allGroups = CRM_Core_PseudoConstant::group();
     }
     // Arrange groups into hierarchical listing (child groups follow their parents and have indentation spacing in title)
     $groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($allGroups, NULL, '  ', TRUE);
     // get the list of groups contact is currently in ("Added") or unsubscribed ("Removed").
     $currentGroups = CRM_Contact_BAO_GroupContact::getGroupList($this->_contactId);
     // Remove current groups from drowdown options ($groupSelect)
     if (is_array($currentGroups)) {
         // Compare array keys, since the array values (group title) in $groupList may have extra spaces for indenting child groups
         $groupSelect = array_diff_key($groupHierarchy, $currentGroups);
     } else {
         $groupSelect = $groupHierarchy;
     }
     $groupSelect = array('' => ts('- select group -')) + $groupSelect;
     if (count($groupSelect) > 1) {
         $session = CRM_Core_Session::singleton();
         // user dashboard
         if (strstr($session->readUserContext(), 'user')) {
             $msg = ts('Join a Group');
         } else {
             $msg = ts('Add to a group');
         }
         $this->add('select', 'group_id', '', $groupSelect, TRUE, array('class' => 'crm-select2 crm-action-menu action-icon-plus', 'placeholder' => $msg));
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Add'), 'isDefault' => TRUE)));
     }
 }
开发者ID:kidaa30,项目名称:yes,代码行数:38,代码来源:GroupContact.php

示例7: buildQuickForm

 function buildQuickForm()
 {
     // Contact
     $this->add('hidden', 'contact_id', ts('Contact id'), '', true);
     // get the list of all the groups
     $allGroups = CRM_Core_PseudoConstant::group();
     // Arrange groups into hierarchical listing (child groups follow their parents and have indentation spacing in title)
     $groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($allGroups, NULL, '  ', TRUE);
     // get the list of groups contact is currently in ("Added") or unsubscribed ("Removed").
     $currentGroups = CRM_Contact_BAO_GroupContact::getGroupList($this->_contactId);
     // Remove current groups from drowdown options ($groupSelect)
     if (is_array($currentGroups)) {
         // Compare array keys, since the array values (group title) in $groupList may have extra spaces for indenting child groups
         $groupSelect = array_diff_key($groupHierarchy, $currentGroups);
     } else {
         $groupSelect = $groupHierarchy;
     }
     $groupSelect = array('' => ts('- select group -')) + $groupSelect;
     if (count($groupSelect) > 1) {
         $session = CRM_Core_Session::singleton();
         $msg = ts('Add to a group');
         $this->add('select', 'group_id', $msg, $groupSelect, false);
         $this->addButtons(array(array('type' => 'submit', 'name' => ts('Opslaan / Volgende'), 'isDefault' => TRUE)));
         // export form elements
         $this->assign('elementNames', $this->getRenderableElementNames());
     }
     parent::buildQuickForm();
 }
开发者ID:jvos,项目名称:nl.vnv.lidmaatschapwijziging_old,代码行数:28,代码来源:LidmaatschapWijzigingGroup.php

示例8: setDefaultValues

 /**
  * This function sets the default values for the form.
  * the default values are retrieved from the database
  *
  * @access public
  * @return None
  */
 function setDefaultValues()
 {
     $defaults = array();
     $params = array();
     $params = array('saved_search_id' => $this->_id);
     CRM_Contact_BAO_Group::retrieve($params, $defaults);
     return $defaults;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:15,代码来源:Update.php

示例9: testForceMailchimpToCiviSync

 function testForceMailchimpToCiviSync()
 {
     $mailchimp_export_url = __DIR__ . '/../../../sample_mailchimp_export.txt';
     $mailchimp_export_url = 'file:///' . realpath($mailchimp_export_url);
     $mailchimp_sync_setting = CRM_CiviMailchimp_BAO_SyncSettingsTest::createTestGroupAndSyncSettings('Test Group testForceMailchimpToCiviSync');
     $mailchimp_members = CRM_CiviMailchimp_Form_Sync::forceMailchimpToCiviSync($mailchimp_export_url, $mailchimp_sync_setting);
     $contacts = CRM_Contact_BAO_Group::getGroupContacts($mailchimp_sync_setting->civicrm_group_id);
     $this->assertCount(3, $mailchimp_members);
     $this->assertCount(3, $contacts);
 }
开发者ID:jaapjansma,项目名称:com.giantrabbit.civimailchimp,代码行数:10,代码来源:SyncTest.php

示例10: delete

 /**
  * Delete a saved search.
  *
  * @param int $id
  *   Id of saved search.
  */
 public function delete($id)
 {
     // first delete the group associated with this saved search
     $group = new CRM_Contact_DAO_Group();
     $group->saved_search_id = $id;
     if ($group->find(TRUE)) {
         CRM_Contact_BAO_Group::discard($group->id);
     }
     $savedSearch = new CRM_Contact_DAO_SavedSearch();
     $savedSearch->id = $id;
     $savedSearch->is_active = 0;
     $savedSearch->save();
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:19,代码来源:SavedSearch.php

示例11: buildQuickForm

 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     // add the email address
     $this->add('text', 'email', ts('Email'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', 'email'), TRUE);
     $this->addRule('email', ts("Please enter a valid email address."), 'email');
     if (!$this->_groupID) {
         // create a selector box of all public groups
         $groupTypeCondition = CRM_Contact_BAO_Group::groupTypeCondition('Mailing');
         $query = "\nSELECT   id, title, description\n  FROM   civicrm_group\n WHERE   ( saved_search_id = 0\n    OR     saved_search_id IS NULL )\n   AND   visibility != 'User and User Admin Only'\n   AND   {$groupTypeCondition}\nORDER BY title";
         $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
         $rows = array();
         while ($dao->fetch()) {
             $row = array();
             $row['id'] = $dao->id;
             $row['title'] = $dao->title;
             $row['description'] = $dao->description;
             $row['checkbox'] = CRM_Core_Form::CB_PREFIX . $row['id'];
             $this->addElement('checkbox', $row['checkbox'], NULL, NULL);
             $rows[] = $row;
         }
         if (empty($rows)) {
             CRM_Core_Error::fatal(ts('There are no public mailing list groups to display.'));
         }
         $this->assign('rows', $rows);
         $this->addFormRule(array('CRM_Mailing_Form_Subscribe', 'formRule'));
     }
     $addCaptcha = TRUE;
     // if recaptcha is not configured, then dont add it
     // CRM-11316 Only enable ReCAPTCHA for anonymous visitors
     $config = CRM_Core_Config::singleton();
     $session = CRM_Core_Session::singleton();
     $contactID = $session->get('userID');
     if (empty($config->recaptchaPublicKey) || empty($config->recaptchaPrivateKey) || $contactID) {
         $addCaptcha = FALSE;
     } else {
         // if this is POST request and came from a block,
         // lets add recaptcha only if already present
         // gross hack for now
         if (!empty($_POST) && !array_key_exists('recaptcha_challenge_field', $_POST)) {
             $addCaptcha = FALSE;
         }
     }
     if ($addCaptcha) {
         // add captcha
         $captcha = CRM_Utils_ReCAPTCHA::singleton();
         $captcha->add($this);
         $this->assign('isCaptcha', TRUE);
     }
     $this->addButtons(array(array('type' => 'next', 'name' => ts('Subscribe'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
 }
开发者ID:kidaa30,项目名称:yes,代码行数:55,代码来源:Subscribe.php

示例12: getGroupList

 /**
  * Get list of groups.
  *
  * @return array
  */
 public static function getGroupList()
 {
     $params = $_REQUEST;
     if (isset($params['parent_id'])) {
         // requesting child groups for a given parent
         $params['page'] = 1;
         $params['rp'] = 0;
         $groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
         CRM_Utils_JSON::output($groups);
     } else {
         $sortMapper = array(0 => 'groups.title', 1 => 'count', 2 => 'createdBy.sort_name', 3 => '', 4 => 'groups.group_type', 5 => 'groups.visibility');
         $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
         $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
         $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
         $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : NULL;
         $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
         if ($sort && $sortOrder) {
             $params['sortBy'] = $sort . ' ' . $sortOrder;
         }
         $params['page'] = $offset / $rowCount + 1;
         $params['rp'] = $rowCount;
         // get group list
         $groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
         // if no groups found with parent-child hierarchy and logged in user say can view child groups only (an ACL case),
         // go ahead with flat hierarchy, CRM-12225
         if (empty($groups)) {
             $groupsAccessible = CRM_Core_PseudoConstant::group();
             $parentsOnly = CRM_Utils_Array::value('parentsOnly', $params);
             if (!empty($groupsAccessible) && $parentsOnly) {
                 // recompute group list with flat hierarchy
                 $params['parentsOnly'] = 0;
                 $groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
             }
         }
         $iFilteredTotal = $iTotal = $params['total'];
         $selectorElements = array('group_name', 'count', 'created_by', 'group_description', 'group_type', 'visibility', 'org_info', 'links', 'class');
         if (empty($params['showOrgInfo'])) {
             unset($selectorElements[6]);
         }
         //add setting so this can be tested by unit test
         //@todo - ideally the portion of this that retrieves the groups should be extracted into a function separate
         // from the one which deals with web inputs & outputs so we have a properly testable & re-usable function
         if (!empty($params['is_unit_test'])) {
             return array($groups, $iFilteredTotal);
         }
         CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
         echo CRM_Utils_JSON::encodeDataTableSelector($groups, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
         CRM_Utils_System::civiExit();
     }
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:55,代码来源:AJAX.php

示例13: create

 /**
  * Takes an associative array and creates a campaign object.
  *
  * the function extract all the params it needs to initialize the create a
  * contact object. the params array could contain additional unused name/value
  * pairs
  *
  * @param array $params
  *   (reference ) an assoc array of name/value pairs.
  *
  * @return CRM_Campaign_DAO_Campaign
  */
 public static function create(&$params)
 {
     if (empty($params)) {
         return NULL;
     }
     if (!CRM_Utils_Array::value('id', $params)) {
         if (!CRM_Utils_Array::value('created_id', $params)) {
             $session = CRM_Core_Session::singleton();
             $params['created_id'] = $session->get('userID');
         }
         if (!CRM_Utils_Array::value('created_date', $params)) {
             $params['created_date'] = date('YmdHis');
         }
         if (!CRM_Utils_Array::value('name', $params)) {
             $params['name'] = CRM_Utils_String::titleToVar($params['title'], 64);
         }
         CRM_Utils_Hook::pre('create', 'Campaign', NULL, $params);
     } else {
         CRM_Utils_Hook::pre('edit', 'Campaign', $params['id'], $params);
     }
     $campaign = new CRM_Campaign_DAO_Campaign();
     $campaign->copyValues($params);
     $campaign->save();
     if (!empty($params['id'])) {
         CRM_Utils_Hook::post('edit', 'Campaign', $campaign->id, $campaign);
     } else {
         CRM_Utils_Hook::post('create', 'Campaign', $campaign->id, $campaign);
     }
     /* Create the campaign group record */
     $groupTableName = CRM_Contact_BAO_Group::getTableName();
     if (isset($params['groups']) && !empty($params['groups']['include']) && is_array($params['groups']['include'])) {
         foreach ($params['groups']['include'] as $entityId) {
             $dao = new CRM_Campaign_DAO_CampaignGroup();
             $dao->campaign_id = $campaign->id;
             $dao->entity_table = $groupTableName;
             $dao->entity_id = $entityId;
             $dao->group_type = 'Include';
             $dao->save();
             $dao->free();
         }
     }
     //store custom data
     if (!empty($params['custom']) && is_array($params['custom'])) {
         CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_campaign', $campaign->id);
     }
     return $campaign;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:59,代码来源:Campaign.php

示例14: getGroupList

 /**
  * Get list of groups.
  *
  * @return array
  */
 public static function getGroupList()
 {
     $params = $_GET;
     if (isset($params['parent_id'])) {
         // requesting child groups for a given parent
         $params['page'] = 1;
         $params['rp'] = 0;
         $groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
         CRM_Utils_JSON::output($groups);
     } else {
         $sortMapper = array();
         $columns = CRM_Utils_Array::value('columns', $params, array());
         foreach ($columns as $key => $value) {
             $sortMapper[$key] = $value['data'];
         }
         $offset = isset($_GET['start']) ? CRM_Utils_Type::escape($_GET['start'], 'Integer') : 0;
         $rowCount = isset($_GET['length']) ? CRM_Utils_Type::escape($_GET['length'], 'Integer') : 25;
         $sort = isset($_GET['order'][0]['column']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_GET['order'][0]['column'], 'Integer'), $sortMapper) : NULL;
         $sortOrder = isset($_GET['order'][0]['dir']) ? CRM_Utils_Type::escape($_GET['order'][0]['dir'], 'String') : 'asc';
         if ($sort && $sortOrder) {
             $params['sortBy'] = $sort . ' ' . $sortOrder;
         }
         $params['page'] = $offset / $rowCount + 1;
         $params['rp'] = $rowCount;
         // get group list
         $groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
         // if no groups found with parent-child hierarchy and logged in user say can view child groups only (an ACL case),
         // go ahead with flat hierarchy, CRM-12225
         if (empty($groups)) {
             $groupsAccessible = CRM_Core_PseudoConstant::group();
             $parentsOnly = CRM_Utils_Array::value('parentsOnly', $params);
             if (!empty($groupsAccessible) && $parentsOnly) {
                 // recompute group list with flat hierarchy
                 $params['parentsOnly'] = 0;
                 $groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
             }
         }
         //add setting so this can be tested by unit test
         //@todo - ideally the portion of this that retrieves the groups should be extracted into a function separate
         // from the one which deals with web inputs & outputs so we have a properly testable & re-usable function
         if (!empty($params['is_unit_test'])) {
             return array($groups['data'], $params['total']);
         }
         CRM_Utils_JSON::output($groups);
     }
 }
开发者ID:agroknow,项目名称:mermix,代码行数:51,代码来源:AJAX.php

示例15: getGroupList

 static function getGroupList()
 {
     $params = $_REQUEST;
     if (isset($params['parent_id'])) {
         // requesting child groups for a given parent
         $params['page'] = 1;
         $params['rp'] = 25;
         $groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
         echo json_encode($groups);
         CRM_Utils_System::civiExit();
     } else {
         $sortMapper = array(0 => 'groups.title', 1 => 'groups.id', 2 => 'createdBy.sort_name', 3 => '', 4 => 'groups.group_type', 5 => 'groups.visibility');
         $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
         $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
         $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
         $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : NULL;
         $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
         if ($sort && $sortOrder) {
             $params['sortBy'] = $sort . ' ' . $sortOrder;
         }
         $params['page'] = $offset / $rowCount + 1;
         $params['rp'] = $rowCount;
         // get group list
         $groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
         // if no groups found with parent-child hierarchy and logged in user say can view child groups only (an ACL case),
         // go ahead with flat hierarchy, CRM-12225
         if (empty($groups)) {
             $groupsAccessible = CRM_Core_PseudoConstant::group();
             $parentsOnly = CRM_Utils_Array::value('parentsOnly', $params);
             if (!empty($groupsAccessible) && $parentsOnly) {
                 // recompute group list with flat hierarchy
                 $params['parentsOnly'] = 0;
                 $groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
             }
         }
         $iFilteredTotal = $iTotal = $params['total'];
         $selectorElements = array('group_name', 'group_id', 'created_by', 'group_description', 'group_type', 'visibility', 'org_info', 'links', 'class');
         if (empty($params['showOrgInfo'])) {
             unset($selectorElements[6]);
         }
         echo CRM_Utils_JSON::encodeDataTableSelector($groups, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
         CRM_Utils_System::civiExit();
     }
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:44,代码来源:AJAX.php


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