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


PHP CRM_Core_BAO_Cache::getItem方法代码示例

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


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

示例1: testFlush

 /**
  * Test system flush.
  */
 public function testFlush()
 {
     // Note: this operation actually flushes several different caches; we don't
     // check all of them -- just enough to make sure that the API is doing
     // something
     $this->assertTrue(NULL === CRM_Core_BAO_Cache::getItem(self::TEST_CACHE_GROUP, self::TEST_CACHE_PATH));
     $data = 'abc';
     CRM_Core_BAO_Cache::setItem($data, self::TEST_CACHE_GROUP, self::TEST_CACHE_PATH);
     $this->assertEquals('abc', CRM_Core_BAO_Cache::getItem(self::TEST_CACHE_GROUP, self::TEST_CACHE_PATH));
     $params = array();
     $result = $this->callAPIAndDocument('system', 'flush', $params, __FUNCTION__, __FILE__, "Flush all system caches", 'Flush');
     $this->assertTrue(NULL === CRM_Core_BAO_Cache::getItem(self::TEST_CACHE_GROUP, self::TEST_CACHE_PATH));
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:16,代码来源:SystemTest.php

示例2: testSetGetItem

 public function testSetGetItem()
 {
     $originalValue = array('abc' => 'def');
     CRM_Core_BAO_Cache::setItem($originalValue, __CLASS__, 'testSetGetItem');
     $return_1 = CRM_Core_BAO_Cache::getItem(__CLASS__, 'testSetGetItem');
     $this->assertEquals($originalValue, $return_1);
     // Wipe out any in-memory copies of the cache. Check to see if the SQL
     // read is correct.
     CRM_Core_BAO_Cache::$_cache = NULL;
     CRM_Utils_Cache::$_singleton = NULL;
     $return_2 = CRM_Core_BAO_Cache::getItem(__CLASS__, 'testSetGetItem');
     $this->assertEquals($originalValue, $return_2);
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:13,代码来源:CacheTest.php

示例3: getTotalCount

 /**
  * Returns total number of rows for the query.
  *
  * @param
  *
  * @return int Total number of rows
  * @access public
  */
 function getTotalCount($action)
 {
     // Use count from cache during paging/sorting
     if (!empty($_GET['crmPID']) || !empty($_GET['crmSID'])) {
         $count = CRM_Core_BAO_Cache::getItem('Search Results Count', $this->_key);
     }
     if (empty($count)) {
         $count = $this->_query->searchQuery(0, 0, NULL, TRUE);
         CRM_Core_BAO_Cache::setItem($count, 'Search Results Count', $this->_key);
     }
     return $count;
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:20,代码来源:Selector.php

示例4: setDefaultValues

 /**
  * This function sets the default values for the form.
  *
  * @access public
  *
  * @return None
  */
 function setDefaultValues()
 {
     if (empty($this->_fields)) {
         return;
     }
     // for add mode set smart defaults
     if ($this->_action & CRM_Core_Action::ADD) {
         list($currentDate, $currentTime) = CRM_Utils_Date::setDateDefaults(NULL, 'activityDateTime');
         //get all status
         $allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
         $completeStatus = array_search('Completed', $allStatus);
         $specialFields = array('join_date' => $currentDate, 'receive_date' => $currentDate, 'receive_date_time' => $currentTime, 'contribution_status_id' => $completeStatus);
         for ($rowNumber = 1; $rowNumber <= $this->_batchInfo['item_count']; $rowNumber++) {
             foreach ($specialFields as $key => $value) {
                 $defaults['field'][$rowNumber][$key] = $value;
             }
         }
     } else {
         // get the existing batch values from cache table
         $cacheKeyString = CRM_Core_BAO_Batch::getCacheKeyForBatch($this->_batchId);
         $defaults = CRM_Core_BAO_Cache::getItem('batch entry', $cacheKeyString);
     }
     return $defaults;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:31,代码来源:Entry.php

示例5: getNavigationList

 /**
  * Get formatted menu list
  * 
  * @return array $navigations returns associated array
  * @static
  */
 static function getNavigationList()
 {
     $cacheKeyString = "navigationList ";
     $whereClause = '';
     $config = CRM_Core_Config::singleton();
     if ($config->userFramework == 'Joomla') {
         $whereClause = " AND name NOT IN ('Access Control') ";
         $cacheKeyString .= "_1";
     }
     // check if we can retrieve from database cache
     require_once 'CRM/Core/BAO/Cache.php';
     $navigations =& CRM_Core_BAO_Cache::getItem('navigation', $cacheKeyString);
     if (!$navigations) {
         $domainID = CRM_Core_Config::domainID();
         $query = "\nSELECT id, label, parent_id, weight, is_active, name \nFROM civicrm_navigation WHERE domain_id = {$domainID} {$whereClause} ORDER BY parent_id, weight ASC";
         $result = CRM_Core_DAO::executeQuery($query);
         $pidGroups = array();
         while ($result->fetch()) {
             $pidGroups[$result->parent_id][$result->label] = $result->id;
         }
         foreach ($pidGroups[''] as $label => $val) {
             $pidGroups[''][$label] = self::_getNavigationValue($val, $pidGroups);
         }
         $navigations = array();
         self::_getNavigationLabel($pidGroups[''], $navigations);
         CRM_Core_BAO_Cache::setItem($navigations, 'navigation', $cacheKeyString);
     }
     return $navigations;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:35,代码来源:Navigation.php

示例6: get

 function get($key)
 {
     if (!array_key_exists($key, $this->frontCache)) {
         $this->frontCache[$key] = CRM_Core_BAO_Cache::getItem($this->group, $key, $this->componentID);
     }
     return $this->frontCache[$key];
 }
开发者ID:hguru,项目名称:224Civi,代码行数:7,代码来源:SqlGroup.php

示例7: getSettingSpecification

 /**
  * This provides information about the setting - similar to the fields concept for DAO information.
  * As the setting is serialized code creating validation setting input needs to know the data type
  * This also helps move information out of the form layer into the data layer where people can interact with
  * it via the API or other mechanisms. In order to keep this consistent it is important the form layer
  * also leverages it.
  *
  * Note that this function should never be called when using the runtime getvalue function. Caching works
  * around the expectation it will be called during setting administration
  *
  * Function is intended for configuration rather than runtime access to settings
  *
  * The following params will filter the result. If none are passed all settings will be returns
  *
  * @param int $componentID
  *   Id of relevant component.
  * @param array $filters
  * @param int $domainID
  * @param null $profile
  *
  * @return array
  *   the following information as appropriate for each setting
  *   - name
  *   - type
  *   - default
  *   - add (CiviCRM version added)
  *   - is_domain
  *   - is_contact
  *   - description
  *   - help_text
  */
 public static function getSettingSpecification($componentID = NULL, $filters = array(), $domainID = NULL, $profile = NULL)
 {
     $cacheString = 'settingsMetadata_' . $domainID . '_' . $profile;
     foreach ($filters as $filterField => $filterString) {
         $cacheString .= "_{$filterField}_{$filterString}";
     }
     $cached = 1;
     // the caching into 'All' seems to be a duplicate of caching to
     // settingsMetadata__ - I think the reason was to cache all settings as defined & then those altered by a hook
     $settingsMetadata = CRM_Core_BAO_Cache::getItem('CiviCRM setting Specs', $cacheString, $componentID);
     if ($settingsMetadata === NULL) {
         $settingsMetadata = CRM_Core_BAO_Cache::getItem('CiviCRM setting Spec', 'All', $componentID);
         if (empty($settingsMetadata)) {
             global $civicrm_root;
             $metaDataFolders = array($civicrm_root . '/settings');
             CRM_Utils_Hook::alterSettingsFolders($metaDataFolders);
             $settingsMetadata = self::loadSettingsMetaDataFolders($metaDataFolders);
             CRM_Core_BAO_Cache::setItem($settingsMetadata, 'CiviCRM setting Spec', 'All', $componentID);
         }
         $cached = 0;
     }
     CRM_Utils_Hook::alterSettingsMetaData($settingsMetadata, $domainID, $profile);
     self::_filterSettingsSpecification($filters, $settingsMetadata);
     if (!$cached) {
         // this is a bit 'heavy' if you are using hooks but this function
         // is expected to only be called during setting administration
         // it should not be called by 'getvalue' or 'getitem
         CRM_Core_BAO_Cache::setItem($settingsMetadata, 'CiviCRM setting Specs', $cacheString, $componentID);
     }
     return $settingsMetadata;
 }
开发者ID:kidaa30,项目名称:yes,代码行数:62,代码来源:Setting.php

示例8: array

 /**
  * Store and return an array of all active custom fields.
  *
  * @param string      $customDataType      type of Custom Data
  * @param boolean     $showAll             If true returns all fields (includes disabled fields)
  * @param boolean     $inline              If true returns all inline fields (includes disabled fields)
  * @param int         $customDataSubType   Custom Data sub type value
  * @param int         $customDataSubName   Custom Data sub name value
  * @param boolean     $onlyParent          return only top level custom data, for eg, only Participant and ignore subname and subtype  
  *
  * @return array      $fields - an array of active custom fields.
  *
  * @access public
  * @static
  */
 public static function &getFields($customDataType = 'Individual', $showAll = false, $inline = false, $customDataSubType = null, $customDataSubName = null, $onlyParent = false)
 {
     $onlySubType = false;
     if ($customDataType && !is_array($customDataType)) {
         if (in_array($customDataType, CRM_Contact_BAO_ContactType::subTypes())) {
             // This is the case when getFieldsForImport() requires fields
             // limited strictly to a subtype.
             $customDataSubType = $customDataType;
             $customDataType = CRM_Contact_BAO_ContactType::getBasicType($customDataType);
             $onlySubType = true;
         }
         if (in_array($customDataType, array_keys(CRM_Core_SelectValues::customGroupExtends()))) {
             // this makes the method flexible to support retrieving fields
             // for multiple extends value.
             $customDataType = array($customDataType);
         }
     }
     if (is_array($customDataType)) {
         $cacheKey = implode('_', $customDataType);
     } else {
         $cacheKey = $customDataType;
     }
     $cacheKey .= $customDataSubType ? "{$customDataSubType}_" : "_0";
     $cacheKey .= $customDataSubName ? "{$customDataSubName}_" : "_0";
     $cacheKey .= $showAll ? "_1" : "_0";
     $cacheKey .= $inline ? "_1_" : "_0_";
     $cacheKey .= $onlyParent ? "_1_" : "_0_";
     $cacheKey .= $onlySubType ? "_1_" : "_0_";
     $cgTable = CRM_Core_DAO_CustomGroup::getTableName();
     // also get the permission stuff here
     require_once 'CRM/Core/Permission.php';
     $permissionClause = CRM_Core_Permission::customGroupClause(CRM_Core_Permission::VIEW, "{$cgTable}.");
     // lets md5 permission clause and take first 8 characters
     $cacheKey .= substr(md5($permissionClause), 0, 8);
     if (strlen($cacheKey) > 40) {
         $cacheKey = md5($cacheKey);
     }
     if (!self::$_importFields || CRM_Utils_Array::value($cacheKey, self::$_importFields) === null) {
         if (!self::$_importFields) {
             self::$_importFields = array();
         }
         // check if we can retrieve from database cache
         require_once 'CRM/Core/BAO/Cache.php';
         $fields =& CRM_Core_BAO_Cache::getItem('contact fields', "custom importableFields {$cacheKey}");
         if ($fields === null) {
             $cfTable = self::getTableName();
             $extends = '';
             if (is_array($customDataType)) {
                 $value = null;
                 foreach ($customDataType as $dataType) {
                     if (in_array($dataType, array_keys(CRM_Core_SelectValues::customGroupExtends()))) {
                         if (in_array($dataType, array('Individual', 'Household', 'Organization'))) {
                             $val = "'" . CRM_Utils_Type::escape($dataType, 'String') . "', 'Contact' ";
                         } else {
                             $val = "'" . CRM_Utils_Type::escape($dataType, 'String') . "'";
                         }
                         $value = $value ? $value . ", {$val}" : $val;
                     }
                 }
                 if ($value) {
                     $extends = "AND   {$cgTable}.extends IN ( {$value} ) ";
                 }
             }
             if ($onlyParent) {
                 $extends .= " AND {$cgTable}.extends_entity_column_value IS NULL AND {$cgTable}.extends_entity_column_id IS NULL ";
             }
             $query = "SELECT {$cfTable}.id, {$cfTable}.label,\n                            {$cgTable}.title,\n                            {$cfTable}.data_type, {$cfTable}.html_type,\n                            {$cfTable}.options_per_line,\n                            {$cgTable}.extends, {$cfTable}.is_search_range,\n                            {$cgTable}.extends_entity_column_value,\n                            {$cgTable}.extends_entity_column_id,\n                            {$cfTable}.is_view,\n                            {$cfTable}.option_group_id,\n                            {$cfTable}.date_format,\n                            {$cfTable}.time_format,\n                            {$cgTable}.is_multiple\n                     FROM {$cfTable}\n                     INNER JOIN {$cgTable}\n                     ON {$cfTable}.custom_group_id = {$cgTable}.id\n                     WHERE ( 1 ) ";
             if (!$showAll) {
                 $query .= " AND {$cfTable}.is_active = 1 AND {$cgTable}.is_active = 1 ";
             }
             if ($inline) {
                 $query .= " AND {$cgTable}.style = 'Inline' ";
             }
             //get the custom fields for specific type in
             //combination with fields those support any type.
             if ($customDataSubType) {
                 $customDataSubType = CRM_Core_DAO::VALUE_SEPARATOR . $customDataSubType . CRM_Core_DAO::VALUE_SEPARATOR;
                 $query .= " AND ( {$cgTable}.extends_entity_column_value LIKE '%{$customDataSubType}%'";
                 if (!$onlySubType) {
                     $query .= " OR {$cgTable}.extends_entity_column_value IS NULL";
                 }
                 $query .= " )";
             }
             if ($customDataSubName) {
                 $query .= " AND ( {$cgTable}.extends_entity_column_id = {$customDataSubName} ) ";
//.........这里部分代码省略.........
开发者ID:bhirsch,项目名称:voipdev,代码行数:101,代码来源:CustomField.php

示例9: array

 /**
  * Combine all the exportable fields from the lower levels object.
  *
  * Currently we are using importable fields as exportable fields
  *
  * @param int|string $contactType contact Type
  * @param bool $status
  *   True while exporting primary contacts.
  * @param bool $export
  *   True when used during export.
  * @param bool $search
  *   True when used during search, might conflict with export param?.
  *
  * @param bool $withMultiRecord
  *
  * @return array
  *   array of exportable Fields
  */
 public static function &exportableFields($contactType = 'Individual', $status = FALSE, $export = FALSE, $search = FALSE, $withMultiRecord = FALSE)
 {
     if (empty($contactType)) {
         $contactType = 'All';
     }
     $cacheKeyString = "exportableFields {$contactType}";
     $cacheKeyString .= $export ? '_1' : '_0';
     $cacheKeyString .= $status ? '_1' : '_0';
     $cacheKeyString .= $search ? '_1' : '_0';
     //CRM-14501 it turns out that the impact of permissioning here is sometimes inconsistent. The field that
     //calculates custom fields takes into account the logged in user & caches that for all users
     //as an interim fix we will cache the fields by contact
     $cacheKeyString .= '_' . CRM_Core_Session::getLoggedInContactID();
     if (!self::$_exportableFields || !CRM_Utils_Array::value($cacheKeyString, self::$_exportableFields)) {
         if (!self::$_exportableFields) {
             self::$_exportableFields = array();
         }
         // check if we can retrieve from database cache
         $fields = CRM_Core_BAO_Cache::getItem('contact fields', $cacheKeyString);
         if (!$fields) {
             $fields = CRM_Contact_DAO_Contact::export();
             // The fields are meant for contact types.
             if (in_array($contactType, array('Individual', 'Household', 'Organization', 'All'))) {
                 $fields = array_merge($fields, CRM_Core_OptionValue::getFields('', $contactType));
             }
             // add current employer for individuals
             $fields = array_merge($fields, array('current_employer' => array('name' => 'organization_name', 'title' => ts('Current Employer'))));
             $locationType = array('location_type' => array('name' => 'location_type', 'where' => 'civicrm_location_type.name', 'title' => ts('Location Type')));
             $IMProvider = array('im_provider' => array('name' => 'im_provider', 'where' => 'civicrm_im.provider_id', 'title' => ts('IM Provider')));
             $locationFields = array_merge($locationType, CRM_Core_DAO_Address::export(), CRM_Core_DAO_Phone::export(), CRM_Core_DAO_Email::export(), $IMProvider, CRM_Core_DAO_IM::export(TRUE), CRM_Core_DAO_OpenID::export());
             $locationFields = array_merge($locationFields, CRM_Core_BAO_CustomField::getFieldsForImport('Address'));
             foreach ($locationFields as $key => $field) {
                 $locationFields[$key]['hasLocationType'] = TRUE;
             }
             $fields = array_merge($fields, $locationFields);
             //add world region
             $fields = array_merge($fields, CRM_Core_DAO_Worldregion::export());
             $fields = array_merge($fields, CRM_Contact_DAO_Contact::export());
             //website fields
             $fields = array_merge($fields, CRM_Core_DAO_Website::export());
             if ($contactType != 'All') {
                 $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($contactType, $status, FALSE, $search, TRUE, $withMultiRecord));
             } else {
                 foreach (array('Individual', 'Household', 'Organization') as $type) {
                     $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($type, FALSE, FALSE, $search, TRUE, $withMultiRecord));
                 }
             }
             //fix for CRM-791
             if ($export) {
                 $fields = array_merge($fields, array('groups' => array('title' => ts('Group(s)'), 'name' => 'groups'), 'tags' => array('title' => ts('Tag(s)'), 'name' => 'tags'), 'notes' => array('title' => ts('Note(s)'), 'name' => 'notes')));
             } else {
                 $fields = array_merge($fields, array('group' => array('title' => ts('Group(s)'), 'name' => 'group'), 'tag' => array('title' => ts('Tag(s)'), 'name' => 'tag'), 'note' => array('title' => ts('Note(s)'), 'name' => 'note')));
             }
             //Sorting fields in alphabetical order(CRM-1507)
             foreach ($fields as $k => $v) {
                 $sortArray[$k] = CRM_Utils_Array::value('title', $v);
             }
             $fields = array_merge($sortArray, $fields);
             //unset the field which are not related to their contact type.
             if ($contactType != 'All') {
                 $commonValues = array('Individual' => array('household_name', 'legal_name', 'sic_code', 'organization_name', 'email_greeting_custom', 'postal_greeting_custom', 'addressee_custom'), 'Household' => array('first_name', 'middle_name', 'last_name', 'formal_title', 'job_title', 'gender_id', 'prefix_id', 'suffix_id', 'birth_date', 'organization_name', 'legal_name', 'legal_identifier', 'sic_code', 'home_URL', 'is_deceased', 'deceased_date', 'current_employer', 'email_greeting_custom', 'postal_greeting_custom', 'addressee_custom', 'prefix_id', 'suffix_id'), 'Organization' => array('first_name', 'middle_name', 'last_name', 'formal_title', 'job_title', 'gender_id', 'prefix_id', 'suffix_id', 'birth_date', 'household_name', 'email_greeting_custom', 'postal_greeting_custom', 'prefix_id', 'suffix_id', 'gender_id', 'addressee_custom', 'is_deceased', 'deceased_date', 'current_employer'));
                 foreach ($commonValues[$contactType] as $value) {
                     unset($fields[$value]);
                 }
             }
             CRM_Core_BAO_Cache::setItem($fields, 'contact fields', $cacheKeyString);
         }
         self::$_exportableFields[$cacheKeyString] = $fields;
     }
     if (!$status) {
         $fields = self::$_exportableFields[$cacheKeyString];
     } else {
         $fields = array_merge(array('' => array('title' => ts('- Contact Fields -'))), self::$_exportableFields[$cacheKeyString]);
     }
     return $fields;
 }
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:94,代码来源:Contact.php

示例10: array

 /**
  * Store and return an array of all active custom fields.
  *
  * @param string $customDataType
  *   Type of Custom Data; empty is a synonym for "all contact data types".
  * @param bool $showAll
  *   If true returns all fields (includes disabled fields).
  * @param bool $inline
  *   If true returns all inline fields (includes disabled fields).
  * @param int $customDataSubType
  *   Custom Data sub type value.
  * @param int $customDataSubName
  *   Custom Data sub name value.
  * @param bool $onlyParent
  *   Return only top level custom data, for eg, only Participant and ignore subname and subtype.
  * @param bool $onlySubType
  *   Return only custom data for subtype.
  * @param bool $checkPermission
  *   If false, do not include permissioning clause.
  *
  * @return array
  *   an array of active custom fields.
  *
  */
 public static function &getFields($customDataType = 'Individual', $showAll = FALSE, $inline = FALSE, $customDataSubType = NULL, $customDataSubName = NULL, $onlyParent = FALSE, $onlySubType = FALSE, $checkPermission = TRUE)
 {
     if (empty($customDataType)) {
         $customDataType = array('Contact', 'Individual', 'Organization', 'Household');
     }
     if ($customDataType && !is_array($customDataType)) {
         if (in_array($customDataType, CRM_Contact_BAO_ContactType::subTypes())) {
             // This is the case when getFieldsForImport() requires fields
             // limited strictly to a subtype.
             $customDataSubType = $customDataType;
             $customDataType = CRM_Contact_BAO_ContactType::getBasicType($customDataType);
             $onlySubType = TRUE;
         }
         if (in_array($customDataType, array_keys(CRM_Core_SelectValues::customGroupExtends()))) {
             // this makes the method flexible to support retrieving fields
             // for multiple extends value.
             $customDataType = array($customDataType);
         }
     }
     $customDataSubType = CRM_Utils_Array::explodePadded($customDataSubType);
     if (is_array($customDataType)) {
         $cacheKey = implode('_', $customDataType);
     } else {
         $cacheKey = $customDataType;
     }
     $cacheKey .= !empty($customDataSubType) ? '_' . implode('_', $customDataSubType) : '_0';
     $cacheKey .= $customDataSubName ? "{$customDataSubName}_" : '_0';
     $cacheKey .= $showAll ? '_1' : '_0';
     $cacheKey .= $inline ? '_1_' : '_0_';
     $cacheKey .= $onlyParent ? '_1_' : '_0_';
     $cacheKey .= $onlySubType ? '_1_' : '_0_';
     $cacheKey .= $checkPermission ? '_1_' : '_0_';
     $cgTable = CRM_Core_DAO_CustomGroup::getTableName();
     // also get the permission stuff here
     if ($checkPermission) {
         $permissionClause = CRM_Core_Permission::customGroupClause(CRM_Core_Permission::VIEW, "{$cgTable}.");
     } else {
         $permissionClause = '(1)';
     }
     // lets md5 permission clause and take first 8 characters
     $cacheKey .= substr(md5($permissionClause), 0, 8);
     if (strlen($cacheKey) > 40) {
         $cacheKey = md5($cacheKey);
     }
     if (!self::$_importFields || CRM_Utils_Array::value($cacheKey, self::$_importFields) === NULL) {
         if (!self::$_importFields) {
             self::$_importFields = array();
         }
         // check if we can retrieve from database cache
         $fields = CRM_Core_BAO_Cache::getItem('contact fields', "custom importableFields {$cacheKey}");
         if ($fields === NULL) {
             $cfTable = self::getTableName();
             $extends = '';
             if (is_array($customDataType)) {
                 $value = NULL;
                 foreach ($customDataType as $dataType) {
                     if (in_array($dataType, array_keys(CRM_Core_SelectValues::customGroupExtends()))) {
                         if (in_array($dataType, array('Individual', 'Household', 'Organization'))) {
                             $val = "'" . CRM_Utils_Type::escape($dataType, 'String') . "', 'Contact' ";
                         } else {
                             $val = "'" . CRM_Utils_Type::escape($dataType, 'String') . "'";
                         }
                         $value = $value ? $value . ", {$val}" : $val;
                     }
                 }
                 if ($value) {
                     $extends = "AND   {$cgTable}.extends IN ( {$value} ) ";
                 }
             }
             if (!empty($customDataType) && empty($extends)) {
                 // $customDataType specified a filter, but there is no corresponding SQL ($extends)
                 self::$_importFields[$cacheKey] = array();
                 return self::$_importFields[$cacheKey];
             }
             if ($onlyParent) {
                 $extends .= " AND {$cgTable}.extends_entity_column_value IS NULL AND {$cgTable}.extends_entity_column_id IS NULL ";
//.........这里部分代码省略.........
开发者ID:Hack4Eugene,项目名称:Hack4Cause2016,代码行数:101,代码来源:CustomField.php

示例11: getVars

 /**
  * Gets all the variables in the current session scope
  * and stuffs them in an associate array
  *
  *
  * @param array $vars
  *   Associative array to store name/value pairs.
  * @param string $prefix
  *   Will be stripped from the key before putting it in the return.
  *
  * @return void
  */
 public function getVars(&$vars, $prefix = '')
 {
     // create session scope
     $this->createScope($prefix, TRUE);
     if (empty($prefix)) {
         $values =& $this->_session[$this->_key];
     } else {
         $values = CRM_Core_BAO_Cache::getItem('CiviCRM Session', "CiviCRM_{$prefix}");
     }
     if ($values) {
         foreach ($values as $name => $value) {
             $vars[$name] = $value;
         }
     }
 }
开发者ID:kidaa30,项目名称:yes,代码行数:27,代码来源:Session.php

示例12: _multisite_get_all_child_groups

/**
 * Get all groups that are children of the parent group
 * (iterate through all levels)
 *
 * @param integer $groupID
 * @param boolean $includeParent
 * @return array:child groups
 */
function _multisite_get_all_child_groups($groupID, $includeParent = TRUE)
{
    static $_cache = array();
    if (!array_key_exists($groupID, $_cache)) {
        $childGroups =& CRM_Core_BAO_Cache::getItem('descendant groups for an org', $groupID);
        if (empty($childGroups)) {
            $childGroups = array();
            $query = "\nSELECT children\nFROM   civicrm_group\nWHERE  children IS NOT NULL\nAND    id IN ";
            if (!is_array($groupID)) {
                $groupIDs = array($groupID);
            }
            while (!empty($groupIDs)) {
                $groupIDString = implode(',', $groupIDs);
                $realQuery = $query . " ( {$groupIDString} )";
                $dao = CRM_Core_DAO::executeQuery($realQuery);
                $groupIDs = array();
                while ($dao->fetch()) {
                    if ($dao->children) {
                        $childIDs = explode(',', $dao->children);
                        foreach ($childIDs as $childID) {
                            if (!array_key_exists($childID, $childGroups)) {
                                $childGroups[$childID] = 1;
                                $groupIDs[] = $childID;
                            }
                        }
                    }
                }
            }
            CRM_Core_BAO_Cache::setItem($childGroups, 'descendant groups for an org', $groupID);
        }
        $_cache[$groupID] = $childGroups;
    }
    if ($includeParent || CRM_Core_Permission::check('administer Multiple Organizations')) {
        return array_keys(array($groupID => 1) + $_cache[$groupID]);
    } else {
        return array_keys($_cache[$groupID]);
    }
}
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:46,代码来源:multisite.php

示例13: json

 /**
  * @return string
  */
 static function json()
 {
     $tree = CRM_Core_BAO_Cache::getItem('contact groups', 'nestable tree hierarchy');
     if ($tree === NULL) {
         self::update();
         $tree = CRM_Core_BAO_Cache::getItem('contact groups', 'nestable tree hierarchy');
     }
     // get all the groups
     $groups = CRM_Core_PseudoConstant::group();
     foreach ($groups as $id => $name) {
         $string = "id:'{$id}', name:'{$name}'";
         if (isset($tree[$id])) {
             $children = array();
             if (!empty($tree[$id]['children'])) {
                 foreach ($tree[$id]['children'] as $child) {
                     $children[] = "{_reference:'{$child}'}";
                 }
                 $children = implode(',', $children);
                 $string .= ", children:[{$children}]";
                 if (empty($tree[$id]['parents'])) {
                     $string .= ", type:'rootGroup'";
                 } else {
                     $string .= ", type:'middleGroup'";
                 }
             } else {
                 $string .= ", type:'leafGroup'";
             }
         } else {
             $string .= ", children:[], type:'rootGroup'";
         }
         $values[] = "{ {$string} }";
     }
     $items = implode(",\n", $values);
     $json = "{\n  identifier:'id',\n  label:'name',\n  items:[ {$items} ]\n}";
     return $json;
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:39,代码来源:GroupNestingCache.php

示例14: array

 /**
  * combine all the exportable fields from the lower levels object
  * 
  * currentlty we are using importable fields as exportable fields
  *
  * @param int     $contactType contact Type
  * $param boolean $status true while exporting primary contacts
  * $param boolean $export true when used during export
  *
  * @return array array of exportable Fields
  * @access public
  */
 function &exportableFields($contactType = 'Individual', $status = false, $export = false)
 {
     if (empty($contactType)) {
         $contactType = 'All';
     }
     $cacheKeyString = "exportableFields {$contactType}";
     $cacheKeyString .= $export ? "_1" : "_0";
     $cacheKeyString .= $status ? "_1" : "_0";
     if (!self::$_exportableFields || !CRM_Utils_Array::value($cacheKeyString, self::$_exportableFields)) {
         if (!self::$_exportableFields) {
             self::$_exportableFields = array();
         }
         // check if we can retrieve from database cache
         require_once 'CRM/Core/BAO/Cache.php';
         $fields =& CRM_Core_BAO_Cache::getItem('contact fields', $cacheKeyString);
         if (!$fields) {
             $fields = array();
             $fields = array_merge($fields, CRM_Contact_DAO_Contact::export());
             // the fields are meant for contact types
             if (in_array($contactType, array('Individual', 'Household', 'Organization', 'All'))) {
                 require_once 'CRM/Core/OptionValue.php';
                 $fields = array_merge($fields, CRM_Core_OptionValue::getFields('', $contactType));
             }
             // add current employer for individuals
             $fields = array_merge($fields, array('current_employer' => array('name' => 'organization_name', 'title' => ts('Current Employer'))));
             $locationType = array();
             if ($status) {
                 $locationType['location_type'] = array('name' => 'location_type', 'where' => 'civicrm_location_type.name', 'title' => ts('Location Type'));
             }
             $IMProvider = array();
             if ($status) {
                 $IMProvider['im_provider'] = array('name' => 'im_provider', 'where' => 'im_provider.name', 'title' => ts('IM Provider'));
             }
             $locationFields = array_merge($locationType, CRM_Core_DAO_Address::export(), CRM_Core_DAO_Phone::export(), CRM_Core_DAO_Email::export(), $IMProvider, CRM_Core_DAO_IM::export(true), CRM_Core_DAO_OpenID::export());
             foreach ($locationFields as $key => $field) {
                 $locationFields[$key]['hasLocationType'] = true;
             }
             $fields = array_merge($fields, $locationFields);
             //add world region
             require_once "CRM/Core/DAO/Worldregion.php";
             $fields = array_merge($fields, CRM_Core_DAO_Worldregion::export());
             $fields = array_merge($fields, CRM_Contact_DAO_Contact::export());
             if ($contactType != 'All') {
                 $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($contactType, $status, true));
             } else {
                 foreach (array('Individual', 'Household', 'Organization') as $type) {
                     $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($type));
                 }
             }
             //fix for CRM-791
             if ($export) {
                 $fields = array_merge($fields, array('groups' => array('title' => ts('Group(s)')), 'tags' => array('title' => ts('Tag(s)')), 'notes' => array('title' => ts('Note(s)'))));
             } else {
                 $fields = array_merge($fields, array('group' => array('title' => ts('Group(s)')), 'tag' => array('title' => ts('Tag(s)')), 'note' => array('title' => ts('Note(s)'))));
             }
             //Sorting fields in alphabetical order(CRM-1507)
             foreach ($fields as $k => $v) {
                 $sortArray[$k] = CRM_Utils_Array::value('title', $v);
             }
             $fields = array_merge($sortArray, $fields);
             //unset the field which are not related to their contact type.
             if ($contactType != 'All') {
                 $commonValues = array('Individual' => array('household_name', 'legal_name', 'sic_code', 'organization_name', 'email_greeting_custom', 'postal_greeting_custom', 'addressee_custom'), 'Household' => array('first_name', 'middle_name', 'last_name', 'job_title', 'gender_id', 'birth_date', 'organization_name', 'legal_name', 'legal_identifier', 'sic_code', 'home_URL', 'is_deceased', 'deceased_date', 'current_employer', 'email_greeting_custom', 'postal_greeting_custom', 'addressee_custom', 'individual_prefix', 'individual_suffix', 'gender'), 'Organization' => array('first_name', 'middle_name', 'last_name', 'job_title', 'gender_id', 'birth_date', 'household_name', 'email_greeting', 'postal_greeting', 'email_greeting_custom', 'postal_greeting_custom', 'individual_prefix', 'individual_suffix', 'gender', 'addressee_custom', 'is_deceased', 'deceased_date', 'current_employer'));
                 foreach ($commonValues[$contactType] as $value) {
                     unset($fields[$value]);
                 }
             }
             CRM_Core_BAO_Cache::setItem($fields, 'contact fields', $cacheKeyString);
         }
         self::$_exportableFields[$cacheKeyString] = $fields;
     }
     if (!$status) {
         $fields = self::$_exportableFields[$cacheKeyString];
     } else {
         $fields = array_merge(array('' => array('title' => ts('- Contact Fields -'))), self::$_exportableFields[$cacheKeyString]);
     }
     return $fields;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:90,代码来源:Contact.php

示例15: getVars

 /**
  * Gets all the variables in the current session scope
  * and stuffs them in an associate array
  *
  * @access public
  * @param  array  vars : associative array to store name/value pairs
  * @param  string  Strip prefix from the key before putting it in the return
  * @return void
  *
  */
 function getVars(&$vars, $prefix = '')
 {
     // create session scope
     $this->create();
     $this->createScope($prefix);
     if (empty($prefix)) {
         $values =& $this->_session[$this->_key];
     } else {
         require_once 'CRM/Core/BAO/Cache.php';
         $values = CRM_Core_BAO_Cache::getItem('CiviCRM Session', "CiviCRM_{$prefix}");
     }
     if ($values) {
         foreach ($values as $name => $value) {
             $vars[$name] = $value;
         }
     }
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:27,代码来源:Session.php


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