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


PHP CRM_Core_BAO_Cache::deleteGroup方法代码示例

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


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

示例1: flushCache

 /**
  * Reset the various system caches and some important static variables.
  */
 public static function flushCache()
 {
     // flush out all cache entries so we can reload new data
     // a bit aggressive, but livable for now
     $cache = CRM_Utils_Cache::singleton();
     $cache->flush();
     // also reset the various static memory caches
     // reset the memory or array cache
     CRM_Core_BAO_Cache::deleteGroup('contact fields', NULL, FALSE);
     // reset ACL cache
     CRM_ACL_BAO_Cache::resetCache();
     // reset various static arrays used here
     CRM_Contact_BAO_Contact::$_importableFields = CRM_Contact_BAO_Contact::$_exportableFields = CRM_Contribute_BAO_Contribution::$_importableFields = CRM_Contribute_BAO_Contribution::$_exportableFields = CRM_Pledge_BAO_Pledge::$_exportableFields = CRM_Contribute_BAO_Query::$_contributionFields = CRM_Core_BAO_CustomField::$_importFields = CRM_Core_BAO_Cache::$_cache = CRM_Core_DAO::$_dbColumnValueCache = NULL;
     CRM_Core_OptionGroup::flushAll();
     CRM_Utils_PseudoConstant::flushAll();
 }
开发者ID:rollox,项目名称:civicrm-core,代码行数:19,代码来源:System.php

示例2: postProcess

 public function postProcess()
 {
     $values = $this->exportValues();
     // make the site multi-lang if requested
     if (CRM_Utils_Array::value('makeMultilingual', $values)) {
         require_once 'CRM/Core/I18n/Schema.php';
         CRM_Core_I18n_Schema::makeMultilingual($values['lcMessages']);
         $values['languageLimit'][$values['lcMessages']] = 1;
         // make the site single-lang if requested
     } elseif (CRM_Utils_Array::value('makeSinglelingual', $values)) {
         require_once 'CRM/Core/I18n/Schema.php';
         CRM_Core_I18n_Schema::makeSinglelingual($values['lcMessages']);
     }
     // add a new db locale if the requested language is not yet supported by the db
     if (!CRM_Utils_Array::value('makeSinglelingual', $values) and CRM_Utils_Array::value('addLanguage', $values)) {
         require_once 'CRM/Core/DAO/Domain.php';
         $domain =& new CRM_Core_DAO_Domain();
         $domain->find(true);
         if (!substr_count($domain->locales, $values['addLanguage'])) {
             require_once 'CRM/Core/I18n/Schema.php';
             CRM_Core_I18n_Schema::addLocale($values['addLanguage'], $values['lcMessages']);
         }
         $values['languageLimit'][$values['addLanguage']] = 1;
     }
     // if we manipulated the language list, return to the localization admin screen
     $return = (bool) (CRM_Utils_Array::value('makeMultilingual', $values) or CRM_Utils_Array::value('addLanguage', $values) or CRM_Utils_Array::value('makeSinglelingual', $values));
     //cache contact fields retaining localized titles
     //though we changed localization, so reseting cache.
     require_once 'CRM/Core/BAO/Cache.php';
     CRM_Core_BAO_Cache::deleteGroup('contact fields');
     // we do this only to initialize monetary decimal point and thousand separator
     $config =& CRM_Core_Config::singleton();
     if ($monetaryPointSeparator = $config->defaultMonetaryPointSeparator($values['lcMonetary'])) {
         $values['monetaryDecimalPoint'] = CRM_Utils_Array::value('decimal_point', $monetaryPointSeparator);
         $values['monetaryThousandSeparator'] = CRM_Utils_Array::value('thousands_sep', $monetaryPointSeparator);
     }
     // save all the settings
     parent::commonProcess($values);
     if ($return) {
         CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/setting/localization', 'reset=1'));
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:42,代码来源:Localization.php

示例3: postProcess

 /**
  * Process the form
  *
  * @param null
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     // store the submitted values in an array
     $params = $this->controller->exportValues($this->_name);
     if ($this->_action == CRM_Core_Action::UPDATE) {
         $dataTypeKey = $this->_defaultDataType[0];
         $params['data_type'] = self::$_dataTypeKeys[$this->_defaultDataType[0]];
         $params['html_type'] = self::$_dataToHTML[$this->_defaultDataType[0]][$this->_defaultDataType[1]];
     } else {
         $dataTypeKey = $params['data_type'][0];
         $params['html_type'] = self::$_dataToHTML[$params['data_type'][0]][$params['data_type'][1]];
         $params['data_type'] = self::$_dataTypeKeys[$params['data_type'][0]];
     }
     //fix for 'is_search_range' field.
     if (in_array($dataTypeKey, array(1, 2, 3, 5))) {
         if (!CRM_Utils_Array::value('is_searchable', $params)) {
             $params['is_search_range'] = 0;
         }
     } else {
         $params['is_search_range'] = 0;
     }
     $filter = 'null';
     if ($dataTypeKey == 11 && CRM_Utils_Array::value('filter_selected', $params)) {
         if ($params['filter_selected'] == 'Advance' && trim(CRM_Utils_Array::value('filter', $params))) {
             $filter = trim($params['filter']);
         } elseif ($params['filter_selected'] == 'Group' && CRM_Utils_Array::value('group_id', $params)) {
             $filter = 'action=lookup&group=' . implode(',', $params['group_id']);
         }
     }
     $params['filter'] = $filter;
     // fix for CRM-316
     $oldWeight = NULL;
     if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) {
         $fieldValues = array('custom_group_id' => $this->_gid);
         if ($this->_id) {
             $oldWeight = $this->_values['weight'];
         }
         $params['weight'] = CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_CustomField', $oldWeight, $params['weight'], $fieldValues);
     }
     $strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
     //store the primary key for State/Province or Country as default value.
     if (strlen(trim($params['default_value']))) {
         switch ($params['data_type']) {
             case 'StateProvince':
                 $fieldStateProvince = $strtolower($params['default_value']);
                 $query = "\nSELECT id\n  FROM civicrm_state_province\n WHERE LOWER(name) = '{$fieldStateProvince}'\n    OR abbreviation = '{$fieldStateProvince}'";
                 $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
                 if ($dao->fetch()) {
                     $params['default_value'] = $dao->id;
                 }
                 break;
             case 'Country':
                 $fieldCountry = $strtolower($params['default_value']);
                 $query = "\nSELECT id\n  FROM civicrm_country\n WHERE LOWER(name) = '{$fieldCountry}'\n    OR iso_code = '{$fieldCountry}'";
                 $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
                 if ($dao->fetch()) {
                     $params['default_value'] = $dao->id;
                 }
                 break;
         }
     }
     // The text_length attribute for Memo fields is in a different input as there
     // are different label, help text and default value than for other type fields
     if ($params['data_type'] == "Memo") {
         $params['text_length'] = $params['note_length'];
     }
     // need the FKEY - custom group id
     $params['custom_group_id'] = $this->_gid;
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $params['id'] = $this->_id;
     }
     $customField = CRM_Core_BAO_CustomField::create($params);
     // reset the cache
     CRM_Core_BAO_Cache::deleteGroup('contact fields');
     CRM_Core_Session::setStatus(ts('Your custom field \'%1\' has been saved.', array(1 => $customField->label)), ts('Saved'), 'success');
     $buttonName = $this->controller->getButtonName();
     $session = CRM_Core_Session::singleton();
     if ($buttonName == $this->getButtonName('next', 'new')) {
         CRM_Core_Session::setStatus(ts(' You can add another custom field.'), '', 'info');
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/admin/custom/group/field/add', 'reset=1&action=add&gid=' . $this->_gid));
     } else {
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/admin/custom/group/field', 'reset=1&action=browse&gid=' . $this->_gid));
     }
 }
开发者ID:hguru,项目名称:224Civi,代码行数:92,代码来源:Field.php

示例4: postProcess

 public function postProcess()
 {
     $values = $this->exportValues();
     //cache contact fields retaining localized titles
     //though we changed localization, so reseting cache.
     CRM_Core_BAO_Cache::deleteGroup('contact fields');
     //CRM-8559, cache navigation do not respect locale if it is changed, so reseting cache.
     CRM_Core_BAO_Cache::deleteGroup('navigation');
     // we do this only to initialize monetary decimal point and thousand separator
     $config = CRM_Core_Config::singleton();
     // save enabled currencies and defaul currency in option group 'currencies_enabled'
     // CRM-1496
     if (empty($values['currencyLimit'])) {
         $values['currencyLimit'] = array($values['defaultCurrency']);
     } elseif (!in_array($values['defaultCurrency'], $values['currencyLimit'])) {
         $values['currencyLimit'][] = $values['defaultCurrency'];
     }
     // sort so that when we display drop down, weights have right value
     sort($values['currencyLimit']);
     // get labels for all the currencies
     $options = array();
     $currencySymbols = self::getCurrencySymbols();
     for ($i = 0; $i < count($values['currencyLimit']); $i++) {
         $options[] = array('label' => $currencySymbols[$values['currencyLimit'][$i]], 'value' => $values['currencyLimit'][$i], 'weight' => $i + 1, 'is_active' => 1, 'is_default' => $values['currencyLimit'][$i] == $values['defaultCurrency']);
     }
     $dontCare = NULL;
     CRM_Core_OptionGroup::createAssoc('currencies_enabled', $options, $dontCare);
     // unset currencyLimit so we dont store there
     unset($values['currencyLimit']);
     // make the site multi-lang if requested
     if (!empty($values['makeMultilingual'])) {
         CRM_Core_I18n_Schema::makeMultilingual($values['lcMessages']);
         $values['languageLimit'][$values['lcMessages']] = 1;
         // make the site single-lang if requested
     } elseif (!empty($values['makeSinglelingual'])) {
         CRM_Core_I18n_Schema::makeSinglelingual($values['lcMessages']);
         $values['languageLimit'] = '';
     }
     // add a new db locale if the requested language is not yet supported by the db
     if (!CRM_Utils_Array::value('makeSinglelingual', $values) and CRM_Utils_Array::value('addLanguage', $values)) {
         $domain = new CRM_Core_DAO_Domain();
         $domain->find(TRUE);
         if (!substr_count($domain->locales, $values['addLanguage'])) {
             CRM_Core_I18n_Schema::addLocale($values['addLanguage'], $values['lcMessages']);
         }
         $values['languageLimit'][$values['addLanguage']] = 1;
     }
     // if we manipulated the language list, return to the localization admin screen
     $return = (bool) (CRM_Utils_Array::value('makeMultilingual', $values) or CRM_Utils_Array::value('addLanguage', $values));
     $filteredValues = $values;
     unset($filteredValues['makeMultilingual']);
     unset($filteredValues['makeSinglelingual']);
     unset($filteredValues['addLanguage']);
     unset($filteredValues['languageLimit']);
     Civi::settings()->set('languageLimit', CRM_Utils_Array::value('languageLimit', $values));
     // save all the settings
     parent::commonProcess($filteredValues);
     if ($return) {
         CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/setting/localization', 'reset=1'));
     }
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:61,代码来源:Localization.php

示例5: implode

 /**
  * Create a new group
  *
  * @param array $params     Associative array of parameters
  * @return object|null      The new group BAO (if created)
  * @access public
  * @static
  */
 public static function &create(&$params)
 {
     require_once 'CRM/Utils/Hook.php';
     if (CRM_Utils_Array::value('id', $params)) {
         CRM_Utils_Hook::pre('edit', 'Group', $params['id'], $params);
     } else {
         CRM_Utils_Hook::pre('create', 'Group', null, $params);
     }
     // form the name only if missing: CRM-627
     if (!CRM_Utils_Array::value('name', $params)) {
         require_once 'CRM/Utils/String.php';
         $params['name'] = CRM_Utils_String::titleToVar($params['title']);
     }
     // convert params if array type
     if (isset($params['group_type'])) {
         if (is_array($params['group_type'])) {
             $params['group_type'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($params['group_type'])) . CRM_Core_DAO::VALUE_SEPARATOR;
         }
     } else {
         $params['group_type'] = '';
     }
     $group =& new CRM_Contact_BAO_Group();
     $group->copyValues($params);
     $group->save();
     if (!$group->id) {
         return null;
     }
     $group->buildClause();
     $group->save();
     // add custom field values
     if (CRM_Utils_Array::value('custom', $params)) {
         require_once 'CRM/Core/BAO/CustomValueTable.php';
         CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_group', $group->id);
     }
     // make the group, child of domain/site group by default.
     require_once 'CRM/Contact/BAO/GroupContactCache.php';
     require_once 'CRM/Core/BAO/Domain.php';
     require_once 'CRM/Contact/BAO/GroupNesting.php';
     $domainGroupID = CRM_Core_BAO_Domain::getGroupId();
     if (CRM_Utils_Array::value('no_parent', $params) !== 1) {
         if (defined('CIVICRM_MULTISITE') && CIVICRM_MULTISITE && empty($params['parents']) && $domainGroupID != $group->id && !CRM_Contact_BAO_GroupNesting::hasParentGroups($group->id)) {
             // if no parent present and the group doesn't already have any parents,
             // make sure site group goes as parent
             $params['parents'] = array($domainGroupID => 1);
         } else {
             if (!is_array($params['parents'])) {
                 $params['parents'] = array($params['parents'] => 1);
             }
         }
         foreach ($params['parents'] as $parentId => $dnc) {
             if ($parentId && !CRM_Contact_BAO_GroupNesting::isParentChild($parentId, $group->id)) {
                 CRM_Contact_BAO_GroupNesting::add($parentId, $group->id);
             }
         }
         // clear any descendant groups cache if exists
         require_once 'CRM/Core/BAO/Cache.php';
         $finalGroups =& CRM_Core_BAO_Cache::deleteGroup('descendant groups for an org');
         // this is always required, since we don't know when a
         // parent group is removed
         require_once 'CRM/Contact/BAO/GroupNestingCache.php';
         CRM_Contact_BAO_GroupNestingCache::update();
         // update group contact cache for all parent groups
         $parentIds = CRM_Contact_BAO_GroupNesting::getParentGroupIds($group->id);
         foreach ($parentIds as $parentId) {
             CRM_Contact_BAO_GroupContactCache::add($parentId);
         }
     }
     if (CRM_Utils_Array::value('organization_id', $params)) {
         require_once 'CRM/Contact/BAO/GroupOrganization.php';
         $groupOrg = array();
         $groupOrg = $params;
         $groupOrg['group_id'] = $group->id;
         CRM_Contact_BAO_GroupOrganization::add($groupOrg);
     }
     CRM_Contact_BAO_GroupContactCache::add($group->id);
     if (CRM_Utils_Array::value('id', $params)) {
         CRM_Utils_Hook::post('edit', 'Group', $group->id, $group);
     } else {
         CRM_Utils_Hook::post('create', 'Group', $group->id, $group);
     }
     return $group;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:90,代码来源:Group.php

示例6: flush

 function flush()
 {
     CRM_Core_BAO_Cache::deleteGroup($this->group);
     $this->frontCache = array();
 }
开发者ID:hguru,项目名称:224Civi,代码行数:5,代码来源:SqlGroup.php

示例7: postProcess

 /**
  * Process the form
  * 
  * @param null
  * 
  * @return void
  * @access public
  */
 public function postProcess()
 {
     // store the submitted values in an array
     $params = $this->controller->exportValues($this->_name);
     if ($this->_action == CRM_Core_Action::UPDATE) {
         $dataTypeKey = $this->_defaultDataType[0];
         $params['data_type'] = self::$_dataTypeKeys[$this->_defaultDataType[0]];
         $params['html_type'] = self::$_dataToHTML[$this->_defaultDataType[0]][$this->_defaultDataType[1]];
     } else {
         $dataTypeKey = $params['data_type'][0];
         $params['html_type'] = self::$_dataToHTML[$params['data_type'][0]][$params['data_type'][1]];
         $params['data_type'] = self::$_dataTypeKeys[$params['data_type'][0]];
     }
     //fix for 'is_search_range' field.
     if (in_array($dataTypeKey, array(1, 2, 3, 5))) {
         if (!CRM_Utils_Array::value('is_searchable', $params)) {
             $params['is_search_range'] = 0;
         }
     } else {
         $params['is_search_range'] = 0;
     }
     // fix for CRM-316
     $oldWeight = null;
     if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) {
         $fieldValues = array('custom_group_id' => $this->_gid);
         if ($this->_id) {
             $oldWeight = $this->_values['weight'];
         }
         $params['weight'] = CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_CustomField', $oldWeight, $params['weight'], $fieldValues);
     }
     //store the primary key for State/Province or Country as default value.
     if (strlen(trim($params['default_value']))) {
         switch ($params['data_type']) {
             case 'StateProvince':
                 $fieldStateProvince = strtolower($params['default_value']);
                 $query = "\nSELECT id\n  FROM civicrm_state_province \n WHERE LOWER(name) = '{$fieldStateProvince}' \n    OR abbreviation = '{$fieldStateProvince}'";
                 $dao =& CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
                 if ($dao->fetch()) {
                     $params['default_value'] = $dao->id;
                 }
                 break;
             case 'Country':
                 $fieldCountry = strtolower($params['default_value']);
                 $query = "\nSELECT id\n  FROM civicrm_country\n WHERE LOWER(name) = '{$fieldCountry}' \n    OR iso_code = '{$fieldCountry}'";
                 $dao =& CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
                 if ($dao->fetch()) {
                     $params['default_value'] = $dao->id;
                 }
                 break;
         }
     }
     // need the FKEY - custom group id
     $params['custom_group_id'] = $this->_gid;
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $params['id'] = $this->_id;
     }
     $customField = CRM_Core_BAO_CustomField::create($params);
     // reset the cache
     require_once 'CRM/Core/BAO/Cache.php';
     CRM_Core_BAO_Cache::deleteGroup('contact fields');
     CRM_Core_Session::setStatus(ts('Your custom field \'%1\' has been saved.', array(1 => $customField->label)));
     $buttonName = $this->controller->getButtonName();
     $session =& CRM_Core_Session::singleton();
     if ($buttonName == $this->getButtonName('next', 'new')) {
         CRM_Core_Session::setStatus(ts(' You can add another custom field.'));
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/admin/custom/group/field', 'reset=1&action=add&gid=' . $this->_gid));
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:76,代码来源:Field.php

示例8: implode

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

示例9: upgrade_3_4_6

 /**
  * @param $rev
  */
 public function upgrade_3_4_6($rev)
 {
     $modifiedReportIds = array('event/summary', 'activity', 'Mailing/bounce', 'Mailing/clicks', 'Mailing/opened');
     $instances = CRM_Core_DAO::executeQuery("SELECT id, form_values, report_id FROM civicrm_report_instance WHERE report_id IN ('" . implode("','", $modifiedReportIds) . "')");
     while ($instances->fetch()) {
         $formValues = unserialize($instances->form_values);
         switch ($instances->report_id) {
             case 'event/summary':
                 $eventDates = array('event_start_date_from', 'event_start_date_to', 'event_end_date_from', 'event_end_date_to');
                 foreach ($eventDates as $date) {
                     if (isset($formValues[$date]) && $formValues[$date] == ' ') {
                         $formValues[$date] = '';
                     }
                 }
                 break;
             case 'activity':
                 if (isset($formValues['group_bys'])) {
                     if (is_array($formValues['group_bys'])) {
                         $orderBy = array();
                         $count = 0;
                         foreach ($formValues['group_bys'] as $col => $isSet) {
                             if (!$isSet) {
                                 continue;
                             }
                             $orderBy[++$count] = array('column' => $col, 'order' => 'ASC');
                         }
                         if (!empty($orderBy)) {
                             $formValues['order_bys'] = $orderBy;
                         }
                     }
                     unset($formValues['group_bys']);
                 }
                 break;
             case 'Mailing/bounce':
             case 'Mailing/clicks':
             case 'Mailing/opened':
                 $formValues['fields']['mailing_name'] = 1;
                 break;
         }
         // save updated instance criteria
         $dao = new CRM_Report_DAO_ReportInstance();
         $dao->id = $instances->id;
         $dao->form_values = serialize($formValues);
         $dao->save();
         $dao->free();
     }
     $bulkEmailActivityType = CRM_Core_DAO::singleValueQuery("\nSELECT v.id\nFROM   civicrm_option_value v,\n       civicrm_option_group g\nWHERE  v.option_group_id = g.id\n  AND  g.name      = %1\n  AND  g.is_active = 1\n  AND  v.name      = %2", array(1 => array('activity_type', 'String'), 2 => array('Bulk Email', 'String')));
     // CRM-8852, reset contact field cache
     CRM_Core_BAO_Cache::deleteGroup('contact fields');
     $upgrade = new CRM_Upgrade_Form();
     $upgrade->assign('bulkEmailActivityType', $bulkEmailActivityType);
     $upgrade->processSQL($rev);
 }
开发者ID:kidaa30,项目名称:yes,代码行数:56,代码来源:ThreeFour.php

示例10: implode

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

示例11: applyLocale

 /**
  * Evaluate locale preferences and activate a chosen locale by
  * updating session+global variables.
  *
  * @param \Civi\Core\SettingsBag $settings
  * @param string $activatedLocales
  *   Imploded list of locales which are supported in the DB.
  */
 public static function applyLocale($settings, $activatedLocales)
 {
     // are we in a multi-language setup?
     $multiLang = $activatedLocales ? TRUE : FALSE;
     // set the current language
     $chosenLocale = NULL;
     $session = CRM_Core_Session::singleton();
     // on multi-lang sites based on request and civicrm_uf_match
     if ($multiLang) {
         $languageLimit = array();
         if (is_array($settings->get('languageLimit'))) {
             $languageLimit = $settings->get('languageLimit');
         }
         $requestLocale = CRM_Utils_Request::retrieve('lcMessages', 'String');
         if (in_array($requestLocale, array_keys($languageLimit))) {
             $chosenLocale = $requestLocale;
             //CRM-8559, cache navigation do not respect locale if it is changed, so reseting cache.
             // Ed: This doesn't sound good.
             CRM_Core_BAO_Cache::deleteGroup('navigation');
         } else {
             $requestLocale = NULL;
         }
         if (!$requestLocale) {
             $sessionLocale = $session->get('lcMessages');
             if (in_array($sessionLocale, array_keys($languageLimit))) {
                 $chosenLocale = $sessionLocale;
             } else {
                 $sessionLocale = NULL;
             }
         }
         if ($requestLocale) {
             $ufm = new CRM_Core_DAO_UFMatch();
             $ufm->contact_id = $session->get('userID');
             if ($ufm->find(TRUE)) {
                 $ufm->language = $chosenLocale;
                 $ufm->save();
             }
             $session->set('lcMessages', $chosenLocale);
         }
         if (!$chosenLocale and $session->get('userID')) {
             $ufm = new CRM_Core_DAO_UFMatch();
             $ufm->contact_id = $session->get('userID');
             if ($ufm->find(TRUE) && in_array($ufm->language, array_keys($languageLimit))) {
                 $chosenLocale = $ufm->language;
             }
             $session->set('lcMessages', $chosenLocale);
         }
     }
     global $dbLocale;
     // try to inherit the language from the hosting CMS
     if ($settings->get('inheritLocale')) {
         // FIXME: On multilanguage installs, CRM_Utils_System::getUFLocale() in many cases returns nothing if $dbLocale is not set
         $dbLocale = $multiLang ? "_" . $settings->get('lcMessages') : '';
         $chosenLocale = CRM_Utils_System::getUFLocale();
         if ($activatedLocales and !in_array($chosenLocale, explode(CRM_Core_DAO::VALUE_SEPARATOR, $activatedLocales))) {
             $chosenLocale = NULL;
         }
     }
     if (empty($chosenLocale)) {
         //CRM-11993 - if a single-lang site, use default
         $chosenLocale = $settings->get('lcMessages');
     }
     // set suffix for table names - use views if more than one language
     $dbLocale = $multiLang ? "_{$chosenLocale}" : '';
     // FIXME: an ugly hack to fix CRM-4041
     global $tsLocale;
     $tsLocale = $chosenLocale;
     // FIXME: as bad aplace as any to fix CRM-5428
     // (to be moved to a sane location along with the above)
     if (function_exists('mb_internal_encoding')) {
         mb_internal_encoding('UTF-8');
     }
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:81,代码来源:ConfigSetting.php

示例12: postProcess

 /**
  * Process the form
  * 
  * @param null
  * 
  * @return void
  * @access public
  */
 public function postProcess()
 {
     // get the submitted form values.
     $params = $this->controller->exportValues('Group');
     $params['overrideFKConstraint'] = 0;
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $params['id'] = $this->_id;
         if ($this->_defaults['extends'][0] != $params['extends'][0]) {
             $params['overrideFKConstraint'] = 1;
         }
     } elseif ($this->_action & CRM_Core_Action::ADD) {
         //new custom set , so lets set the created_id
         $session = CRM_Core_Session::singleton();
         $params['created_id'] = $session->get('userID');
         $params['created_date'] = date('YmdHis');
     }
     $group = CRM_Core_BAO_CustomGroup::create($params);
     // reset the cache
     require_once 'CRM/Core/BAO/Cache.php';
     CRM_Core_BAO_Cache::deleteGroup('contact fields');
     if ($this->_action & CRM_Core_Action::UPDATE) {
         CRM_Core_Session::setStatus(ts('Your custom field set \'%1 \' has been saved.', array(1 => $group->title)));
     } else {
         $url = CRM_Utils_System::url('civicrm/admin/custom/group/field/add', 'reset=1&action=add&gid=' . $group->id);
         CRM_Core_Session::setStatus(ts('Your custom field set \'%1\' has been added. You can add it custom fields now.', array(1 => $group->title)));
         $session = CRM_Core_Session::singleton();
         $session->replaceUserContext($url);
     }
     // prompt Drupal Views users to update $db_prefix in settings.php, if necessary
     global $db_prefix;
     if (is_array($db_prefix) && CIVICRM_UF == 'Drupal' && module_exists('views')) {
         // get table_name for each custom group
         $tables = array();
         $sql = "SELECT table_name FROM civicrm_custom_group WHERE is_active = 1";
         $result = CRM_Core_DAO::executeQuery($sql);
         while ($result->fetch()) {
             $tables[$result->table_name] = $result->table_name;
         }
         // find out which tables are missing from the $db_prefix array
         $missingTableNames = array_diff_key($tables, $db_prefix);
         if (!empty($missingTableNames)) {
             CRM_Core_Session::setStatus('<br />' . ts('Note:To ensure that all of your custom data groups are available to Views, you may need to add the following key(s) to the $db_prefix array in your settings.php file: \'%1\'.', array(1 => implode(', ', $missingTableNames))));
         }
     }
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:53,代码来源:Group.php

示例13: resetNavigation

 /**
  * Reset navigation for all contacts
  */
 static function resetNavigation($contactId = NULL)
 {
     $params = array();
     $query = "UPDATE civicrm_setting SET value = NULL WHERE name='navigation'";
     if ($contactId) {
         $query .= " AND contact_id = %1";
         $params[1] = array((int) $contactId, 'Integer');
     } else {
         $query .= " AND contact_id IS NOT NULL";
     }
     CRM_Core_DAO::executeQuery($query, $params);
     CRM_Core_BAO_Cache::deleteGroup('navigation');
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:16,代码来源:Navigation.php

示例14: addGroup

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

示例15: postProcess

 /**
  * Process the form.
  *
  *
  * @return void
  */
 public function postProcess()
 {
     // get the submitted form values.
     $params = $this->controller->exportValues('Group');
     $params['overrideFKConstraint'] = 0;
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $params['id'] = $this->_id;
         if ($this->_defaults['extends'][0] != $params['extends'][0]) {
             $params['overrideFKConstraint'] = 1;
         }
         if (!empty($this->_subtypes)) {
             $subtypesToBeRemoved = array_diff($this->_subtypes, array_intersect($this->_subtypes, $params['extends'][1]));
             CRM_Contact_BAO_ContactType::deleteCustomRowsOfSubtype($this->_id, $subtypesToBeRemoved);
         }
     } elseif ($this->_action & CRM_Core_Action::ADD) {
         //new custom set , so lets set the created_id
         $session = CRM_Core_Session::singleton();
         $params['created_id'] = $session->get('userID');
         $params['created_date'] = date('YmdHis');
     }
     $group = CRM_Core_BAO_CustomGroup::create($params);
     // reset the cache
     CRM_Core_BAO_Cache::deleteGroup('contact fields');
     if ($this->_action & CRM_Core_Action::UPDATE) {
         CRM_Core_Session::setStatus(ts('Your custom field set \'%1 \' has been saved.', array(1 => $group->title)), ts('Saved'), 'success');
     } else {
         // Jump directly to adding a field if popups are disabled
         $action = CRM_Core_Resources::singleton()->ajaxPopupsEnabled ? '' : '/add';
         $url = CRM_Utils_System::url("civicrm/admin/custom/group/field{$action}", 'reset=1&new=1&gid=' . $group->id . '&action=' . ($action ? 'add' : 'browse'));
         CRM_Core_Session::setStatus(ts("Your custom field set '%1' has been added. You can add custom fields now.", array(1 => $group->title)), ts('Saved'), 'success');
         $session = CRM_Core_Session::singleton();
         $session->replaceUserContext($url);
     }
     // prompt Drupal Views users to update $db_prefix in settings.php, if necessary
     global $db_prefix;
     $config = CRM_Core_Config::singleton();
     if (is_array($db_prefix) && $config->userSystem->is_drupal && module_exists('views')) {
         // get table_name for each custom group
         $tables = array();
         $sql = "SELECT table_name FROM civicrm_custom_group WHERE is_active = 1";
         $result = CRM_Core_DAO::executeQuery($sql);
         while ($result->fetch()) {
             $tables[$result->table_name] = $result->table_name;
         }
         // find out which tables are missing from the $db_prefix array
         $missingTableNames = array_diff_key($tables, $db_prefix);
         if (!empty($missingTableNames)) {
             CRM_Core_Session::setStatus(ts("To ensure that all of your custom data groups are available to Views, you may need to add the following key(s) to the db_prefix array in your settings.php file: '%1'.", array(1 => implode(', ', $missingTableNames))), ts('Note'), 'info');
         }
     }
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:57,代码来源:Group.php


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