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


PHP CRM_Utils_Array::index方法代码示例

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


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

示例1: importableFields

 static function importableFields($contactType = 'HRJobContractRevision', $status = FALSE, $showAll = FALSE, $isProfile = FALSE, $checkPermission = TRUE, $withMultiCustomFields = FALSE)
 {
     if (empty($contactType)) {
         $contactType = 'HRJobContractRevision';
     }
     $cacheKeyString = "";
     $cacheKeyString .= $status ? '_1' : '_0';
     $cacheKeyString .= $showAll ? '_1' : '_0';
     $cacheKeyString .= $isProfile ? '_1' : '_0';
     $cacheKeyString .= $checkPermission ? '_1' : '_0';
     $fields = CRM_Utils_Array::value($cacheKeyString, self::$_importableFields);
     if (!$fields) {
         $fields = CRM_Hrjobcontract_DAO_HRJobContractRevision::import();
         $fields = array_merge($fields, CRM_Hrjobcontract_DAO_HRJobContractRevision::import());
         //Sorting fields in alphabetical order(CRM-1507)
         $fields = CRM_Utils_Array::crmArraySortByField($fields, 'title');
         $fields = CRM_Utils_Array::index(array('name'), $fields);
         CRM_Core_BAO_Cache::setItem($fields, 'contact fields', $cacheKeyString);
     }
     self::$_importableFields[$cacheKeyString] = $fields;
     if (!$isProfile) {
         $fields = array_merge(array('do_not_import' => array('title' => ts('- do not import -'))), self::$_importableFields[$cacheKeyString]);
     }
     return $fields;
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:25,代码来源:HRJobContractRevision.php

示例2: importableFields

 /**
  * combine all the importable fields from the lower levels object
  *
  * The ordering is important, since currently we do not have a weight
  * scheme. Adding weight is super important
  *
  * @param int     $contactType     contact Type
  * @param boolean $status          status is used to manipulate first title
  * @param boolean $showAll         if true returns all fields (includes disabled fields)
  * @param boolean $isProfile       if its profile mode
  * @param boolean $checkPermission if false, do not include permissioning clause (for custom data)
  *
  * @return array array of importable Fields
  * @access public
  * @static
  */
 static function importableFields($contactType = 'HRJobLeave', $status = FALSE, $showAll = FALSE, $isProfile = FALSE, $checkPermission = TRUE, $withMultiCustomFields = FALSE)
 {
     if (empty($contactType)) {
         $contactType = 'HRJobLeave';
     }
     $cacheKeyString = "";
     $cacheKeyString .= $status ? '_1' : '_0';
     $cacheKeyString .= $showAll ? '_1' : '_0';
     $cacheKeyString .= $isProfile ? '_1' : '_0';
     $cacheKeyString .= $checkPermission ? '_1' : '_0';
     $fields = CRM_Utils_Array::value($cacheKeyString, self::$_importableFields);
     if (!$fields) {
         $fields = CRM_HRJob_DAO_HRJobLeave::import();
         $fields = array_merge($fields, CRM_HRJOB_DAO_HRJOBLEAVE::import());
         foreach ($fields as $key => $v) {
             $fields[$key]['hasLocationType'] = TRUE;
         }
         //Sorting fields in alphabetical order
         $fields = CRM_Utils_Array::crmArraySortByField($fields, 'title');
         $fields = CRM_Utils_Array::index(array('name'), $fields);
         CRM_Core_BAO_Cache::setItem($fields, 'contact fields', $cacheKeyString);
     }
     self::$_importableFields[$cacheKeyString] = $fields;
     if (!$isProfile) {
         $fields = array_merge(array('do_not_import' => array('title' => ts('- do not import -'))), self::$_importableFields[$cacheKeyString]);
     }
     return $fields;
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:44,代码来源:HRJobLeave.php

示例3: __construct

 /**
  * @param int $version
  *   API version.
  * @param string $entity
  *   API entity.
  * @param array $fields
  *   List of fields in this fake entity.
  * @param array $perms
  *   Array(string $action => string $perm).
  * @param array $records
  *   List of mock records to be read/updated by API calls.
  */
 public function __construct($version, $entity, $fields, $perms = array(), $records = array())
 {
     parent::__construct($version, $entity);
     $perms = array_merge(array('create' => \CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION, 'get' => \CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION, 'delete' => \CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION), $perms);
     $this->records = \CRM_Utils_Array::index(array('id'), $records);
     $this->fields = $fields;
     $this->addAction('create', $perms['create'], array($this, 'doCreate'));
     $this->addAction('get', $perms['get'], array($this, 'doGet'));
     $this->addAction('delete', $perms['delete'], array($this, 'doDelete'));
 }
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:22,代码来源:StaticProvider.php

示例4: testIndexArray

 function testIndexArray()
 {
     $inputs = array();
     $inputs[] = array('lang' => 'en', 'msgid' => 'greeting', 'familiar' => FALSE, 'value' => 'Hello');
     $inputs[] = array('lang' => 'en', 'msgid' => 'parting', 'value' => 'Goodbye');
     $inputs[] = array('lang' => 'fr', 'msgid' => 'greeting', 'value' => 'Bon jour');
     $inputs[] = array('lang' => 'fr', 'msgid' => 'parting', 'value' => 'Au revoir');
     $inputs[] = array('lang' => 'en', 'msgid' => 'greeting', 'familiar' => TRUE, 'value' => 'Hey');
     $byLangMsgid = CRM_Utils_Array::index(array('lang', 'msgid'), $inputs);
     $this->assertEquals($inputs[4], $byLangMsgid['en']['greeting']);
     $this->assertEquals($inputs[1], $byLangMsgid['en']['parting']);
     $this->assertEquals($inputs[2], $byLangMsgid['fr']['greeting']);
     $this->assertEquals($inputs[3], $byLangMsgid['fr']['parting']);
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:14,代码来源:ArrayTest.php

示例5: view

 /**
  * View details of a relationship.
  */
 public function view()
 {
     $viewRelationship = CRM_Contact_BAO_Relationship::getRelationship($this->_contactId, NULL, NULL, NULL, $this->_id);
     //To check whether selected contact is a contact_id_a in
     //relationship type 'a_b' in relationship table, if yes then
     //revert the permissionship text in template
     $relationship = new CRM_Contact_DAO_Relationship();
     $relationship->id = $viewRelationship[$this->_id]['id'];
     if ($relationship->find(TRUE)) {
         if ($viewRelationship[$this->_id]['rtype'] == 'a_b' && $this->_contactId == $relationship->contact_id_a) {
             $this->assign("is_contact_id_a", TRUE);
         }
     }
     $relType = $viewRelationship[$this->_id]['civicrm_relationship_type_id'];
     $this->assign('viewRelationship', $viewRelationship);
     $employerId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'employer_id');
     $this->assign('isCurrentEmployer', FALSE);
     $relTypes = CRM_Utils_Array::index(array('name_a_b'), CRM_Core_PseudoConstant::relationshipType('name'));
     if ($viewRelationship[$this->_id]['employer_id'] == $this->_contactId) {
         $this->assign('isCurrentEmployer', TRUE);
     } elseif ($relType == $relTypes['Employee of']['id'] && $viewRelationship[$this->_id]['cid'] == $employerId) {
         // make sure we are viewing employee of relationship
         $this->assign('isCurrentEmployer', TRUE);
     }
     $viewNote = CRM_Core_BAO_Note::getNote($this->_id);
     $this->assign('viewNote', $viewNote);
     $groupTree = CRM_Core_BAO_CustomGroup::getTree('Relationship', $this, $this->_id, 0, $relType);
     CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $this->_id);
     $rType = CRM_Utils_Array::value('rtype', $viewRelationship[$this->_id]);
     // add viewed contribution to recent items list
     $url = CRM_Utils_System::url('civicrm/contact/view/rel', "action=view&reset=1&id={$viewRelationship[$this->_id]['id']}&cid={$this->_contactId}&context=home");
     $session = CRM_Core_Session::singleton();
     $recentOther = array();
     if ($session->get('userID') == $this->_contactId || CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
         $recentOther = array('editUrl' => CRM_Utils_System::url('civicrm/contact/view/rel', "action=update&reset=1&id={$viewRelationship[$this->_id]['id']}&cid={$this->_contactId}&rtype={$rType}&context=home"), 'deleteUrl' => CRM_Utils_System::url('civicrm/contact/view/rel', "action=delete&reset=1&id={$viewRelationship[$this->_id]['id']}&cid={$this->_contactId}&rtype={$rType}&context=home"));
     }
     $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
     $this->assign('displayName', $displayName);
     CRM_Utils_System::setTitle(ts('View Relationship for') . ' ' . $displayName);
     $title = $displayName . ' (' . $viewRelationship[$this->_id]['relation'] . ' ' . CRM_Contact_BAO_Contact::displayName($viewRelationship[$this->_id]['cid']) . ')';
     // add the recently viewed Relationship
     CRM_Utils_Recent::add($title, $url, $viewRelationship[$this->_id]['id'], 'Relationship', $this->_contactId, NULL, $recentOther);
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:46,代码来源:Relationship.php

示例6: testReplaceUFFields

 /**
  * Create / updating field
  */
 public function testReplaceUFFields()
 {
     $baseFields = array();
     $baseFields[] = array('field_name' => 'first_name', 'field_type' => 'Contact', 'visibility' => 'Public Pages and Listings', 'weight' => 3, 'label' => 'Test First Name', 'is_searchable' => 1, 'is_active' => 1);
     $baseFields[] = array('field_name' => 'country', 'field_type' => 'Contact', 'visibility' => 'Public Pages and Listings', 'weight' => 2, 'label' => 'Test Country', 'is_searchable' => 1, 'is_active' => 1, 'location_type_id' => 1);
     $baseFields[] = array('field_name' => 'phone', 'field_type' => 'Contact', 'visibility' => 'Public Pages and Listings', 'weight' => 1, 'label' => 'Test Phone', 'is_searchable' => 1, 'is_active' => 1, 'location_type_id' => 1, 'phone_type_id' => 1);
     $params = array('uf_group_id' => $this->_ufGroupId, 'option.autoweight' => FALSE, 'values' => $baseFields, 'check_permissions' => TRUE);
     $result = $this->callAPIAndDocument('uf_field', 'replace', $params, __FUNCTION__, __FILE__);
     $inputsByName = CRM_Utils_Array::index(array('field_name'), $params['values']);
     $this->assertEquals(count($params['values']), count($result['values']));
     foreach ($result['values'] as $outUfField) {
         $this->assertTrue(is_string($outUfField['field_name']));
         $inUfField = $inputsByName[$outUfField['field_name']];
         foreach ($inUfField as $key => $inValue) {
             $this->assertEquals($inValue, $outUfField[$key], sprintf("field_name=[%s] key=[%s] expected=[%s] actual=[%s]", $outUfField['field_name'], $key, $inValue, $outUfField[$key]));
         }
     }
 }
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:21,代码来源:UFFieldTest.php

示例7: __construct

 /**
  * Class constructor
  */
 public function __construct()
 {
     // initialize all the vars
     $this->numIndividual = self::INDIVIDUAL_PERCENT * self::NUM_CONTACT / 100;
     $this->numHousehold = self::HOUSEHOLD_PERCENT * self::NUM_CONTACT / 100;
     $this->numOrganization = self::ORGANIZATION_PERCENT * self::NUM_CONTACT / 100;
     $this->numStrictIndividual = $this->numIndividual - $this->numHousehold * self::NUM_INDIVIDUAL_PER_HOUSEHOLD;
     // Parse data file
     foreach ((array) simplexml_load_file(self::DATA_FILENAME) as $key => $val) {
         $val = (array) $val;
         $this->sampleData[$key] = (array) $val['item'];
     }
     // Init DB
     $config = CRM_Core_Config::singleton();
     // Relationship types indexed by name_a_b from the table civicrm_relationship_type
     $this->relTypes = CRM_Utils_Array::index(array('name_a_b'), CRM_Core_PseudoConstant::relationshipType('name'));
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:20,代码来源:GenerateData.php

示例8: clearCurrentEmployer

 /**
  * Delete current employer relationship.
  *
  * @param int $id
  * @param int $action
  *
  * @return CRM_Contact_DAO_Relationship
  */
 public static function clearCurrentEmployer($id, $action)
 {
     $relationship = new CRM_Contact_DAO_Relationship();
     $relationship->id = $id;
     $relationship->find(TRUE);
     //to delete relationship between household and individual                                                                                          \
     //or between individual and organization
     if ($action & CRM_Core_Action::DISABLE || $action & CRM_Core_Action::DELETE) {
         $relTypes = CRM_Utils_Array::index(array('name_a_b'), CRM_Core_PseudoConstant::relationshipType('name'));
         if (isset($relTypes['Employee of']) && $relationship->relationship_type_id == $relTypes['Employee of']['id'] || isset($relTypes['Household Member of']) && $relationship->relationship_type_id == $relTypes['Household Member of']['id']) {
             $sharedContact = new CRM_Contact_DAO_Contact();
             $sharedContact->id = $relationship->contact_id_a;
             $sharedContact->find(TRUE);
             // CRM-15881 UPDATES
             // changed FROM "...relationship->relationship_type_id == 4..." TO "...relationship->relationship_type_id == 5..."
             // As the system should be looking for type "employer of" (id 5) and not "sibling of" (id 4)
             // As suggested by @davecivicrm, the employee relationship type id is fetched using the CRM_Core_DAO::getFieldValue() class and method, since these ids differ from system to system.
             $employerRelTypeId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', 'Employee of', 'id', 'name_a_b');
             if ($relationship->relationship_type_id == $employerRelTypeId && $relationship->contact_id_b == $sharedContact->employer_id) {
                 CRM_Contact_BAO_Contact_Utils::clearCurrentEmployer($relationship->contact_id_a);
             }
         }
     }
     return $relationship;
 }
开发者ID:scardinius,项目名称:civicrm-core,代码行数:33,代码来源:Relationship.php

示例9: getActivityIndex

 /**
  * Get a list of all activities in the case (indexed by some property/properties)
  *
  * @param array $keys list of properties by which to index activities
  * @return array list of activity records (api/v3 format), indexed by $keys
  */
 public function getActivityIndex($keys)
 {
     $key = implode(";", $keys);
     if (!$this->indices) {
         $this->indices = CRM_Utils_Array::index(array('activity_type_id', 'status_id'), $this->getActivities());
     }
     return $this->indices;
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:14,代码来源:Analyzer.php

示例10: moveFileIDs

 /**
  * For any records in $toTable that originated with this query,
  * append file information.
  *
  * @param string $toTable
  * @param string $parentIdColumn
  * @param array $files see return format of CRM_Core_FileSearchInterface::search
  */
 public function moveFileIDs($toTable, $parentIdColumn, $files)
 {
     if (empty($files)) {
         return;
     }
     $filesIndex = CRM_Utils_Array::index(array('xparent_id', 'file_id'), $files);
     // ex: $filesIndex[$xparent_id][$file_id] = array(...the file record...);
     $dao = CRM_Core_DAO::executeQuery("\n      SELECT distinct {$parentIdColumn}\n      FROM {$toTable}\n      WHERE table_name = %1\n    ", array(1 => array($this->getName(), 'String')));
     while ($dao->fetch()) {
         if (empty($filesIndex[$dao->{$parentIdColumn}])) {
             continue;
         }
         CRM_Core_DAO::executeQuery("UPDATE {$toTable}\n        SET file_ids = %1\n        WHERE table_name = %2 AND {$parentIdColumn} = %3\n      ", array(1 => array(implode(',', array_keys($filesIndex[$dao->{$parentIdColumn}])), 'String'), 2 => array($this->getName(), 'String'), 3 => array($dao->{$parentIdColumn}, 'Int')));
     }
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:23,代码来源:AbstractPartialQuery.php

示例11: initializeDashlets

 /**
  * Setup default dashlets for new users.
  *
  * When a user accesses their dashboard for the first time, set up
  * the default dashlets.
  *
  * @param bool $flatFormat
  *
  * @return array
  *    Array of dashboard_id's
  * @throws \CiviCRM_API3_Exception
  */
 public static function initializeDashlets($flatFormat = FALSE)
 {
     $dashlets = array();
     $getDashlets = civicrm_api3("Dashboard", "get", array('domain_id' => CRM_Core_Config::domainID(), 'option.limit' => 0));
     $contactID = CRM_Core_Session::singleton()->getLoggedInContactID();
     $allDashlets = CRM_Utils_Array::index(array('name'), $getDashlets['values']);
     $defaultDashlets = array();
     $defaults = array('blog' => 1, 'getting-started' => '0');
     foreach ($defaults as $name => $column) {
         if (!empty($allDashlets[$name])) {
             $defaultDashlets[$name] = array('dashboard_id' => $allDashlets[$name]['id'], 'is_active' => 1, 'column_no' => $column, 'contact_id' => $contactID);
         }
     }
     CRM_Utils_Hook::dashboard_defaults($allDashlets, $defaultDashlets);
     if (is_array($defaultDashlets) && !empty($defaultDashlets)) {
         foreach ($defaultDashlets as $id => $defaultDashlet) {
             $dashboard_id = $defaultDashlet['dashboard_id'];
             if (!self::checkPermission($getDashlets['values'][$dashboard_id]['permission'], CRM_Utils_Array::value('permission_operator', $getDashlets['values'][$dashboard_id]))) {
                 continue;
             } else {
                 $assignDashlets = civicrm_api3("dashboard_contact", "create", $defaultDashlet);
                 if (!$flatFormat) {
                     $values = $assignDashlets['values'][$assignDashlets['id']];
                     $dashlets[$values['column_no']][$values['weight'] - $values['dashboard_id']] = $values['is_minimized'];
                 } else {
                     $dashlets[$dashboard_id] = $defaultDashlet['dashboard_id'];
                 }
             }
         }
     }
     return $dashlets;
 }
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:44,代码来源:Dashboard.php

示例12: getActivityIndex

 /**
  * Get a list of all activities in the case (indexed by some property/properties)
  *
  * @param array $keys
  *   List of properties by which to index activities.
  * @return array
  *   list of activity records (api/v3 format), indexed by $keys
  */
 public function getActivityIndex($keys)
 {
     $key = implode(";", $keys);
     if (!isset($this->indices[$key])) {
         $this->indices[$key] = \CRM_Utils_Array::index($keys, $this->getActivities());
     }
     return $this->indices[$key];
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:16,代码来源:Analyzer.php

示例13: getDelegate

 /**
  * @param int $id
  *   e.g. file ID.
  * @return array
  *   (0 => bool $isValid, 1 => string $entityTable, 2 => int $entityId)
  * @throws \Exception
  */
 public function getDelegate($id)
 {
     $query = \CRM_Core_DAO::executeQuery($this->lookupDelegateSql, array(1 => array($id, 'Positive')));
     if ($query->fetch()) {
         if (!preg_match('/^civicrm_value_/', $query->entity_table)) {
             // A normal attachment directly on its entity.
             return array($query->is_valid, $query->entity_table, $query->entity_id);
         }
         // Ex: Translate custom-field table ("civicrm_value_foo_4") to
         // entity table ("civicrm_activity").
         $tblIdx = \CRM_Utils_Array::index(array('table_name'), $this->getCustomFields());
         if (isset($tblIdx[$query->entity_table])) {
             return array($query->is_valid, $tblIdx[$query->entity_table]['entity_table'], $query->entity_id);
         }
         throw new \Exception('Failed to lookup entity table for custom field.');
     } else {
         return array(FALSE, NULL, NULL);
     }
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:26,代码来源:DynamicFKAuthorization.php

示例14: importableFields

 /**
  * combine all the importable fields from the lower levels object
  *
  * The ordering is important, since currently we do not have a weight
  * scheme. Adding weight is super important
  *
  * @param int     $contactType     contact Type
  * @param boolean $status          status is used to manipulate first title
  * @param boolean $showAll         if true returns all fields (includes disabled fields)
  * @param boolean $isProfile       if its profile mode
  * @param boolean $checkPermission if false, do not include permissioning clause (for custom data)
  *
  * @return array array of importable Fields
  * @access public
  * @static
  */
 static function importableFields($contactType = 'Individual', $status = FALSE, $showAll = FALSE, $isProfile = FALSE, $checkPermission = TRUE, $withMultiCustomFields = FALSE)
 {
     $cacheKeyString = "";
     $cacheKeyString .= $status ? '_1' : '_0';
     $cacheKeyString .= $showAll ? '_1' : '_0';
     $cacheKeyString .= $isProfile ? '_1' : '_0';
     $cacheKeyString .= $checkPermission ? '_1' : '_0';
     $contactType = 'Individual';
     $fields = CRM_Utils_Array::value($cacheKeyString, self::$_importableFields);
     if (!$fields) {
         $fields = CRM_Appraisals_DAO_AppraisalCycle::import();
         $tmpContactField = $contactFields = array();
         $contactFields = CRM_Contact_BAO_Contact::importableFields($contactType, NULL);
         // Using new Dedupe rule.
         $ruleParams = array('contact_type' => $contactType, 'used' => 'Unsupervised');
         $fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
         if (is_array($fieldsArray)) {
             foreach ($fieldsArray as $value) {
                 $customFieldId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $value, 'id', 'column_name');
                 $value = $customFieldId ? 'custom_' . $customFieldId : $value;
                 $tmpContactField[trim($value)] = CRM_Utils_Array::value(trim($value), $contactFields);
                 if (!$status) {
                     $title = $tmpContactField[trim($value)]['title'] . ' (match to contact)';
                 } else {
                     $title = $tmpContactField[trim($value)]['title'];
                 }
                 $tmpContactField[trim($value)]['title'] = $title;
             }
         }
         $extIdentifier = CRM_Utils_Array::value('external_identifier', $contactFields);
         if ($extIdentifier) {
             $tmpContactField['external_identifier'] = $extIdentifier;
             $tmpContactField['external_identifier']['title'] = CRM_Utils_Array::value('title', $extIdentifier) . ' (match to contact)';
         }
         $fields = array_merge($fields, $tmpContactField);
         //Sorting fields in alphabetical order(CRM-1507)
         $fields = CRM_Utils_Array::crmArraySortByField($fields, 'title');
         $fields = CRM_Utils_Array::index(array('name'), $fields);
         CRM_Core_BAO_Cache::setItem($fields, 'contact fields', $cacheKeyString);
     }
     self::$_importableFields[$cacheKeyString] = $fields;
     if (!$isProfile) {
         $fields = array_merge(array('do_not_import' => array('title' => ts('- do not import -'))), self::$_importableFields[$cacheKeyString]);
     }
     return $fields;
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:62,代码来源:AppraisalCycle.php

示例15: testGetReferenceCounts

 /**
  * Test get ref api - gets a list of references to an entity.
  */
 public function testGetReferenceCounts()
 {
     $result = $this->callAPISuccess('Contact', 'create', array('first_name' => 'Testily', 'last_name' => 'McHaste', 'contact_type' => 'Individual', 'api.Address.replace' => array('values' => array()), 'api.Email.replace' => array('values' => array(array('email' => 'spam@dev.null', 'is_primary' => 0, 'location_type_id' => 1))), 'api.Phone.replace' => array('values' => array(array('phone' => '234-567-0001', 'is_primary' => 1, 'location_type_id' => 1), array('phone' => '234-567-0002', 'is_primary' => 0, 'location_type_id' => 1)))));
     //$dao = new CRM_Contact_BAO_Contact();
     //$dao->id = $result['id'];
     //$this->assertTrue((bool) $dao->find(TRUE));
     //
     //$refCounts = $dao->getReferenceCounts();
     //$this->assertTrue(is_array($refCounts));
     //$refCountsIdx = CRM_Utils_Array::index(array('name'), $refCounts);
     $refCounts = $this->callAPISuccess('Contact', 'getrefcount', array('id' => $result['id']));
     $refCountsIdx = CRM_Utils_Array::index(array('name'), $refCounts['values']);
     $this->assertEquals(1, $refCountsIdx['sql:civicrm_email:contact_id']['count']);
     $this->assertEquals('civicrm_email', $refCountsIdx['sql:civicrm_email:contact_id']['table']);
     $this->assertEquals(2, $refCountsIdx['sql:civicrm_phone:contact_id']['count']);
     $this->assertEquals('civicrm_phone', $refCountsIdx['sql:civicrm_phone:contact_id']['table']);
     $this->assertTrue(!isset($refCountsIdx['sql:civicrm_address:contact_id']));
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:21,代码来源:ContactTest.php


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