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


PHP CRM_Core_BAO_Setting::retrieveDirectoryAndURLPreferences方法代码示例

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


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

示例1: _initVariables

 /**
  * Initialize the config variables.
  *
  * @return void
  */
 private function _initVariables()
 {
     // retrieve serialised settings
     $variables = array();
     CRM_Core_BAO_ConfigSetting::retrieve($variables);
     // if settings are not available, go down the full path
     if (empty($variables)) {
         // Step 1. get system variables with their hardcoded defaults
         $variables = get_object_vars($this);
         // Step 2. get default values (with settings file overrides if
         // available - handled in CRM_Core_Config_Defaults)
         CRM_Core_Config_Defaults::setValues($variables);
         // retrieve directory and url preferences also
         CRM_Core_BAO_Setting::retrieveDirectoryAndURLPreferences($variables);
         // add component specific settings
         $this->componentRegistry->addConfig($this);
         // serialise settings
         $settings = $variables;
         CRM_Core_BAO_ConfigSetting::add($settings);
     }
     $urlArray = array('userFrameworkResourceURL', 'imageUploadURL');
     $dirArray = array('uploadDir', 'customFileUploadDir');
     foreach ($variables as $key => $value) {
         if (in_array($key, $urlArray)) {
             $value = CRM_Utils_File::addTrailingSlash($value, '/');
         } elseif (in_array($key, $dirArray)) {
             if ($value) {
                 $value = CRM_Utils_File::addTrailingSlash($value);
             }
             if (empty($value) || CRM_Utils_File::createDir($value, FALSE) === FALSE) {
                 // seems like we could not create the directories
                 // settings might have changed, lets suppress a message for now
                 // so we can make some more progress and let the user fix their settings
                 // for now we assign it to a know value
                 // CRM-4949
                 $value = $this->templateCompileDir;
                 $url = CRM_Utils_System::url('civicrm/admin/setting/path', 'reset=1');
                 CRM_Core_Session::setStatus(ts('%1 has an incorrect directory path. Please go to the <a href="%2">path setting page</a> and correct it.', array(1 => $key, 2 => $url)), ts('Check Settings'), 'alert');
             }
         } elseif ($key == 'lcMessages') {
             // reset the templateCompileDir to locale-specific and make sure it exists
             if (substr($this->templateCompileDir, -1 * strlen($value) - 1, -1) != $value) {
                 $this->templateCompileDir .= CRM_Utils_File::addTrailingSlash($value);
                 CRM_Utils_File::createDir($this->templateCompileDir);
                 CRM_Utils_File::restrictAccess($this->templateCompileDir);
             }
         }
         $this->{$key} = $value;
     }
     if ($this->userFrameworkResourceURL) {
         // we need to do this here so all blocks also load from an ssl server
         if (CRM_Utils_System::isSSL()) {
             CRM_Utils_System::mapConfigToSSL();
         }
         $rrb = parse_url($this->userFrameworkResourceURL);
         // don't use absolute path if resources are stored on a different server
         // CRM-4642
         $this->resourceBase = $this->userFrameworkResourceURL;
         if (isset($_SERVER['HTTP_HOST']) && isset($rrb['host'])) {
             $this->resourceBase = $rrb['host'] == $_SERVER['HTTP_HOST'] ? $rrb['path'] : $this->userFrameworkResourceURL;
         }
     }
     if (!$this->customFileUploadDir) {
         $this->customFileUploadDir = $this->uploadDir;
     }
     if ($this->geoProvider) {
         $this->geocodeMethod = 'CRM_Utils_Geocode_' . $this->geoProvider;
     } elseif ($this->mapProvider) {
         $this->geocodeMethod = 'CRM_Utils_Geocode_' . $this->mapProvider;
     }
     require_once str_replace('_', DIRECTORY_SEPARATOR, $this->userFrameworkClass) . '.php';
     $class = $this->userFrameworkClass;
     // redundant with _setUserFrameworkConfig
     $this->userSystem = new $class();
 }
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:80,代码来源:Config.php

示例2: retrieve


//.........这里部分代码省略.........
         }
         $skipVars = self::skipVars();
         foreach ($skipVars as $skip) {
             if (array_key_exists($skip, $defaults)) {
                 unset($defaults[$skip]);
             }
         }
         // check if there are any locale strings
         if ($domain->locale_custom_strings) {
             $defaults['localeCustomStrings'] = unserialize($domain->locale_custom_strings);
         } else {
             $defaults['localeCustomStrings'] = NULL;
         }
         // are we in a multi-language setup?
         $multiLang = $domain->locales ? TRUE : FALSE;
         // set the current language
         $lcMessages = NULL;
         $session = CRM_Core_Session::singleton();
         // on multi-lang sites based on request and civicrm_uf_match
         if ($multiLang) {
             $lcMessagesRequest = CRM_Utils_Request::retrieve('lcMessages', 'String', $this);
             $languageLimit = array();
             if (array_key_exists('languageLimit', $defaults) && is_array($defaults['languageLimit'])) {
                 $languageLimit = $defaults['languageLimit'];
             }
             if (in_array($lcMessagesRequest, array_keys($languageLimit))) {
                 $lcMessages = $lcMessagesRequest;
                 //CRM-8559, cache navigation do not respect locale if it is changed, so reseting cache.
                 CRM_Core_BAO_Cache::deleteGroup('navigation');
             } else {
                 $lcMessagesRequest = NULL;
             }
             if (!$lcMessagesRequest) {
                 $lcMessagesSession = $session->get('lcMessages');
                 if (in_array($lcMessagesSession, array_keys($languageLimit))) {
                     $lcMessages = $lcMessagesSession;
                 } else {
                     $lcMessagesSession = NULL;
                 }
             }
             if ($lcMessagesRequest) {
                 $ufm = new CRM_Core_DAO_UFMatch();
                 $ufm->contact_id = $session->get('userID');
                 if ($ufm->find(TRUE)) {
                     $ufm->language = $lcMessages;
                     $ufm->save();
                 }
                 $session->set('lcMessages', $lcMessages);
             }
             if (!$lcMessages 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))) {
                     $lcMessages = $ufm->language;
                 }
                 $session->set('lcMessages', $lcMessages);
             }
         }
         global $dbLocale;
         // try to inherit the language from the hosting CMS
         if (!empty($defaults['inheritLocale'])) {
             // FIXME: On multilanguage installs, CRM_Utils_System::getUFLocale() in many cases returns nothing if $dbLocale is not set
             $dbLocale = $multiLang ? "_{$defaults['lcMessages']}" : '';
             $lcMessages = CRM_Utils_System::getUFLocale();
             if ($domain->locales and !in_array($lcMessages, explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales))) {
                 $lcMessages = NULL;
             }
         }
         if (empty($lcMessages)) {
             //CRM-11993 - if a single-lang site, use default
             $lcMessages = CRM_Utils_Array::value('lcMessages', $defaults);
         }
         // set suffix for table names - use views if more than one language
         $dbLocale = $multiLang ? "_{$lcMessages}" : '';
         // FIXME: an ugly hack to fix CRM-4041
         global $tsLocale;
         $tsLocale = $lcMessages;
         // 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');
         }
     }
     // dont add if its empty
     if (!empty($defaults)) {
         // retrieve directory and url preferences also
         CRM_Core_BAO_Setting::retrieveDirectoryAndURLPreferences($defaults);
         // Pickup enabled-components from settings table if found.
         $enableComponents = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enable_components', NULL, array());
         if (!empty($enableComponents)) {
             $defaults['enableComponents'] = $enableComponents;
             $components = CRM_Core_Component::getComponents();
             $enabledComponentIDs = array();
             foreach ($defaults['enableComponents'] as $name) {
                 $enabledComponentIDs[] = $components[$name]->componentID;
             }
             $defaults['enableComponentIDs'] = $enabledComponentIDs;
         }
     }
 }
开发者ID:riyadennis,项目名称:my_civicrm,代码行数:101,代码来源:ConfigSetting.php

示例3: testRetrieveDirectoryAndURLPreferences_Override

 /**
  * Ensure that overrides in $civicrm_setting apply when
  * when using retrieveDirectoryAndURLPreferences().
  */
 function testRetrieveDirectoryAndURLPreferences_Override()
 {
     global $civicrm_setting;
     $civicrm_setting[CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME]['imageUploadDir'] = '/test/override';
     $params = array();
     CRM_Core_BAO_Setting::retrieveDirectoryAndURLPreferences($params);
     $this->assertEquals('/test/override', $params['imageUploadDir']);
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:12,代码来源:SettingTest.php


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