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


PHP CRM_Core_BAO_Setting::add方法代码示例

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


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

示例1: verifyPreDBState

 function verifyPreDBState(&$errorMessage)
 {
     $errorMessage = ts('Pre-condition failed for upgrade step %1.', array(1 => '4'));
     if (CRM_Core_DAO::checkTableExists('civicrm_event_page')) {
         return false;
     }
     // check fields which MUST be present if a proper 2.2 db
     if (!CRM_Core_DAO::checkFieldExists('civicrm_event', 'intro_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'footer_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_title') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_footer_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'is_email_confirm') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_email_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_from_name') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_from_email') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'cc_confirm') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'bcc_confirm') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'default_fee_id') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'default_discount_id') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'thankyou_title') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'thankyou_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'thankyou_footer_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'is_pay_later') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'pay_later_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'pay_later_receipt') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'is_multiple_registrations')) {
         // db looks to have stuck somewhere between 2.1 & 2.2
         $errorMessage .= ' Few important fields were found missing in some of the tables.';
         return false;
     }
     if ($this->checkVersion('2.1.103')) {
         $this->setVersion('2.2');
     } else {
         return false;
     }
     // update config defaults
     require_once "CRM/Core/DAO/Domain.php";
     $domain =& new CRM_Core_DAO_Domain();
     $domain->selectAdd();
     $domain->selectAdd('config_backend');
     $domain->find(true);
     if ($domain->config_backend) {
         $defaults = unserialize($domain->config_backend);
         // reset components
         $defaults['enableComponents'] = array('CiviContribute', 'CiviPledge', 'CiviMember', 'CiviEvent', 'CiviMail');
         $defaults['enableComponentIDs'] = array(1, 6, 2, 3, 4);
         $defaults['moneyvalueformat'] = '%!i';
         $defaults['fieldSeparator'] = ',';
         $defaults['fatalErrorTemplate'] = 'CRM/common/fatal.tpl';
         // serialise settings
         CRM_Core_BAO_Setting::add($defaults);
     }
     return $this->checkVersion('2.2');
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:36,代码来源:Step4.php

示例2: verifyPreDBState

 function verifyPreDBState(&$errorMessage)
 {
     $config =& CRM_Core_Config::singleton();
     // Let's first update the config defaults
     require_once "CRM/Core/DAO/Domain.php";
     $domain =& new CRM_Core_DAO_Domain();
     $domain->selectAdd();
     $domain->selectAdd('config_backend');
     $domain->find(true);
     if ($domain->config_backend) {
         $defaults = unserialize($domain->config_backend);
         // reset components
         $defaults['enableComponents'] = array('CiviContribute', 'CiviPledge', 'CiviMember', 'CiviEvent', 'CiviMail');
         $defaults['enableComponentIDs'] = array(1, 6, 2, 3, 4);
         $defaults['moneyvalueformat'] = '%!i';
         $defaults['fieldSeparator'] = ',';
         $defaults['fatalErrorTemplate'] = 'CRM/common/fatal.tpl';
         // update cms-version
         if ($config->userFramework == 'Joomla') {
             $defaults['userFrameworkVersion'] = '1.5';
             if (class_exists('JVersion')) {
                 $version =& new JVersion();
                 $defaults['userFrameworkVersion'] = $version->getShortVersion();
             }
         } else {
             if ($config->userFramework == 'Drupal') {
                 $defaults['userFrameworkVersion'] = '6.3';
                 if (defined('VERSION')) {
                     $defaults['userFrameworkVersion'] = VERSION;
                 }
             }
         }
         // serialise settings
         require_once "CRM/Core/BAO/Setting.php";
         CRM_Core_BAO_Setting::add($defaults);
         $config =& CRM_Core_Config::singleton();
     }
     // check if log file is writable
     if (!is_writable($config->uploadDir . 'CiviCRM.log')) {
         $errorMessage = ts('Log file CiviCRM.log is not writable. Make sure files directory is writable.', array(1 => $config->uploadDir));
         return false;
     }
     $errorMessage = ts('Database check failed - the current database is not v2.0.');
     $is20db = true;
     // abort if partial upgraded db found.
     if ($this->checkVersion('2.01') || $this->checkVersion('2.02') || $this->checkVersion('2.03')) {
         $errorMessage = ts('Corrupt / Partial Upgraded database found. Looks like upgrade wizard failed to complete all the required steps to convert your database to v2.1. Please fix any errors and start the upgrade process again with a clean v2.0 database.');
         return false;
     }
     // abort if already 2.1
     if ($this->checkVersion('2.1')) {
         $errorMessage = ts('Database check failed - looks like you have already upgraded to the latest version (v2.1) of the database.');
         return false;
     }
     // check if 2.0 version
     if (!$this->checkVersion('2.0')) {
         $is20db = false;
     }
     // check if 2.0 tables exists
     if (!CRM_Core_DAO::checkTableExists('civicrm_activity') || !CRM_Core_DAO::checkTableExists('civicrm_activity_assignment') || !CRM_Core_DAO::checkTableExists('civicrm_activity_target') || !CRM_Core_DAO::checkTableExists('civicrm_address') || !CRM_Core_DAO::checkTableExists('civicrm_address') || !CRM_Core_DAO::checkTableExists('civicrm_case') || !CRM_Core_DAO::checkTableExists('civicrm_case_activity') || !CRM_Core_DAO::checkTableExists('civicrm_component') || !CRM_Core_DAO::checkTableExists('civicrm_contribution_widget') || !CRM_Core_DAO::checkTableExists('civicrm_grant') || !CRM_Core_DAO::checkTableExists('civicrm_group_nesting') || !CRM_Core_DAO::checkTableExists('civicrm_group_organization') || !CRM_Core_DAO::checkTableExists('civicrm_loc_block') || !CRM_Core_DAO::checkTableExists('civicrm_openid') || !CRM_Core_DAO::checkTableExists('civicrm_openid_associations') || !CRM_Core_DAO::checkTableExists('civicrm_openid_nonces') || !CRM_Core_DAO::checkTableExists('civicrm_preferences_date') || !CRM_Core_DAO::checkTableExists('civicrm_tell_friend') || !CRM_Core_DAO::checkTableExists('civicrm_timezone') || !CRM_Core_DAO::checkTableExists('civicrm_worldregion')) {
         // db is not 2.0
         $errorMessage .= ' Few 2.0 tables were found missing.';
         $is20db = false;
     }
     // check fields which MUST be present if a proper 2.0 db
     if ($is20db) {
         if (!CRM_Core_DAO::checkFieldExists('civicrm_activity', 'source_record_id') || !CRM_Core_DAO::checkFieldExists('civicrm_activity', 'activity_date_time') || !CRM_Core_DAO::checkFieldExists('civicrm_activity', 'status_id') || !CRM_Core_DAO::checkFieldExists('civicrm_contact', 'first_name') || !CRM_Core_DAO::checkFieldExists('civicrm_contact', 'last_name') || !CRM_Core_DAO::checkFieldExists('civicrm_contact', 'gender_id') || !CRM_Core_DAO::checkFieldExists('civicrm_contact', 'mail_to_household_id') || !CRM_Core_DAO::checkFieldExists('civicrm_contact', 'user_unique_id') || !CRM_Core_DAO::checkFieldExists('civicrm_contact', 'household_name') || !CRM_Core_DAO::checkFieldExists('civicrm_contact', 'organization_name') || !CRM_Core_DAO::checkFieldExists('civicrm_contribution', 'honor_type_id') || !CRM_Core_DAO::checkFieldExists('civicrm_contribution_page', 'is_pay_later') || !CRM_Core_DAO::checkFieldExists('civicrm_contribution_page', 'pay_later_text') || !CRM_Core_DAO::checkFieldExists('civicrm_country', 'region_id') || !CRM_Core_DAO::checkFieldExists('civicrm_custom_field', 'column_name') || !CRM_Core_DAO::checkFieldExists('civicrm_custom_field', 'option_group_id') || !CRM_Core_DAO::checkFieldExists('civicrm_custom_group', 'table_name') || !CRM_Core_DAO::checkFieldExists('civicrm_custom_group', 'is_multiple') || !CRM_Core_DAO::checkFieldExists('civicrm_domain', 'version') || !CRM_Core_DAO::checkFieldExists('civicrm_domain', 'loc_block_id') || !CRM_Core_DAO::checkFieldExists('civicrm_email', 'contact_id') || !CRM_Core_DAO::checkFieldExists('civicrm_email', 'location_type_id') || !CRM_Core_DAO::checkFieldExists('civicrm_email', 'is_billing') || !CRM_Core_DAO::checkFieldExists('civicrm_entity_tag', 'contact_id') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'participant_listing_id') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'loc_block_id') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'receipt_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event_page', 'is_pay_later') || !CRM_Core_DAO::checkFieldExists('civicrm_event_page', 'pay_later_text') || !CRM_Core_DAO::checkFieldExists('civicrm_financial_trxn', 'contribution_id') || !CRM_Core_DAO::checkFieldExists('civicrm_im', 'contact_id') || !CRM_Core_DAO::checkFieldExists('civicrm_im', 'location_type_id') || !CRM_Core_DAO::checkFieldExists('civicrm_membership_payment', 'contribution_id') || !CRM_Core_DAO::checkFieldExists('civicrm_membership_type', 'receipt_text_signup') || !CRM_Core_DAO::checkFieldExists('civicrm_membership_type', 'receipt_text_renewal') || !CRM_Core_DAO::checkFieldExists('civicrm_option_value', 'component_id') || !CRM_Core_DAO::checkFieldExists('civicrm_participant_payment', 'contribution_id') || !CRM_Core_DAO::checkFieldExists('civicrm_payment_processor', 'url_api') || !CRM_Core_DAO::checkFieldExists('civicrm_payment_processor_type', 'url_api_default') || !CRM_Core_DAO::checkFieldExists('civicrm_phone', 'contact_id') || !CRM_Core_DAO::checkFieldExists('civicrm_phone', 'location_type_id') || !CRM_Core_DAO::checkFieldExists('civicrm_uf_match', 'uf_name')) {
             // db looks to have stuck somewhere between 2.0 & 2.1
             $errorMessage .= ' Few important fields were found missing in some of the tables.';
             $is20db = false;
         }
     }
     if (!$is20db) {
         // check if the db is 2.1
         if (CRM_Core_DAO::checkTableExists('civicrm_cache') && CRM_Core_DAO::checkFieldExists('civicrm_cache', 'group_name') && CRM_Core_DAO::checkFieldExists('civicrm_cache', 'created_date') && CRM_Core_DAO::checkFieldExists('civicrm_cache', 'expired_date') && CRM_Core_DAO::checkTableExists('civicrm_group_contact_cache') && CRM_Core_DAO::checkFieldExists('civicrm_group_contact_cache', 'contact_id') && CRM_Core_DAO::checkTableExists('civicrm_menu') && CRM_Core_DAO::checkFieldExists('civicrm_menu', 'path_arguments') && CRM_Core_DAO::checkFieldExists('civicrm_menu', 'is_exposed') && CRM_Core_DAO::checkFieldExists('civicrm_menu', 'page_type') && CRM_Core_DAO::checkTableExists('civicrm_discount') && CRM_Core_DAO::checkFieldExists('civicrm_discount', 'option_group_id') && CRM_Core_DAO::checkFieldExists('civicrm_discount', 'end_date')) {
             $errorMessage = ts('Database check failed - it looks like you have already upgraded to the latest version (v2.1) of the database.');
         }
         return false;
     }
     // check tables which should not exist for v2.x
     if (CRM_Core_DAO::checkTableExists('civicrm_custom_option') || CRM_Core_DAO::checkTableExists('civicrm_custom_value') || CRM_Core_DAO::checkTableExists('civicrm_email_history') || CRM_Core_DAO::checkTableExists('civicrm_geo_coord') || CRM_Core_DAO::checkTableExists('civicrm_individual') || CRM_Core_DAO::checkTableExists('civicrm_location') || CRM_Core_DAO::checkTableExists('civicrm_meeting') || CRM_Core_DAO::checkTableExists('civicrm_organization') || CRM_Core_DAO::checkTableExists('civicrm_phonecall') || CRM_Core_DAO::checkTableExists('civicrm_sms_history') || CRM_Core_DAO::checkTableExists('civicrm_validation')) {
         // table(s) found in the db which are no longer required
         // for v2.x, though would not do any harm it's recommended
         // to remove them.
         CRM_Core_Session::setStatus(ts("Table(s) found in your db which are no longer required for v2.x, though would not do any harm it's recommended to remove them"));
     }
     // show error if any of the tables, use 'MyISAM' storage engine.
     // just check the first 10 civicrm tables, rather than checking all 106!
     if (CRM_Core_DAO::isDBMyISAM(10)) {
         $errorMessage = ts('Your database is configured to use the MyISAM database engine. CiviCRM  requires InnoDB. You will need to convert any MyISAM tables in your database to InnoDB before proceeding.');
         return false;
     }
     // check FK constraint names are in valid format.
     if (!CRM_Core_DAO::checkFKConstraintInFormat('civicrm_contact', 'domain_id') || !CRM_Core_DAO::checkFKConstraintInFormat('civicrm_contribution_page', 'domain_id') || !CRM_Core_DAO::checkFKConstraintInFormat('civicrm_contribution_recur', 'domain_id') || !CRM_Core_DAO::checkFKConstraintInFormat('civicrm_membership_status', 'domain_id') || !CRM_Core_DAO::checkFKConstraintInFormat('civicrm_contribution', 'contact_id') || !CRM_Core_DAO::checkFKConstraintInFormat('civicrm_contribution', 'contribution_type_id')) {
         $errorMessage = ts('Database consistency check failed. FK constraint names not in the required format. Please rebuild your 2.0 database to ensure schema integrity.');
         return false;
     }
     return true;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:99,代码来源:Step1.php

示例3: commonProcess

 public function commonProcess(&$params)
 {
     require_once "CRM/Core/BAO/Setting.php";
     CRM_Core_BAO_Setting::add($params);
     // also delete the CRM_Core_Config key from the database
     $cache =& CRM_Utils_Cache::singleton();
     $cache->delete('CRM_Core_Config');
     // save autocomplete search options
     if (CRM_Utils_Array::value('autocompleteContactSearch', $params)) {
         $config =& new CRM_Core_DAO_Preferences();
         $config->domain_id = CRM_Core_Config::domainID();
         $config->find(true);
         $config->contact_autocomplete_options = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($params['autocompleteContactSearch'])) . CRM_Core_DAO::VALUE_SEPARATOR;
         $config->save();
     }
     // update time for date formats when global time is changed
     if (CRM_Utils_Array::value('timeInputFormat', $params)) {
         $query = "UPDATE civicrm_preferences_date SET time_format = " . $params['timeInputFormat'] . " \n                      WHERE time_format IS NOT NULL AND time_format <> ''";
         CRM_Core_DAO::executeQuery($query);
     }
     CRM_Core_Session::setStatus(ts('Your changes have been saved.'));
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:22,代码来源:Setting.php

示例4: commonProcess

 public function commonProcess(&$params)
 {
     require_once "CRM/Core/BAO/Setting.php";
     CRM_Core_BAO_Setting::add($params);
     // also delete the CRM_Core_Config key from the database
     $cache =& CRM_Utils_Cache::singleton();
     $cache->delete('CRM_Core_Config');
     // save autocomplete search options
     if (CRM_Utils_Array::value('autocompleteContactSearch', $params)) {
         $config =& new CRM_Core_DAO_Preferences();
         $config->domain_id = CRM_Core_Config::domainID();
         $config->find(true);
         $config->contact_autocomplete_options = CRM_Core_BAO_CustomOption::VALUE_SEPERATOR . implode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, array_keys($params['autocompleteContactSearch'])) . CRM_Core_BAO_CustomOption::VALUE_SEPERATOR;
         $config->save();
     }
     CRM_Core_Session::setStatus(ts('Your changes have been saved.'));
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:17,代码来源:Setting.php

示例5: _initVariables

 /**
  * initialize the config variables
  *
  * @return void
  * @access private
  */
 private function _initVariables()
 {
     // initialize component registry early to avoid "race"
     // between CRM_Core_Config and CRM_Core_Component (they
     // are co-dependant)
     require_once 'CRM/Core/Component.php';
     $this->componentRegistry = new CRM_Core_Component();
     // retrieve serialised settings
     require_once "CRM/Core/BAO/Setting.php";
     $variables = array();
     CRM_Core_BAO_Setting::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)
         require_once 'CRM/Core/Config/Defaults.php';
         CRM_Core_Config_Defaults::setValues($variables);
         // add component specific settings
         $this->componentRegistry->addConfig($this);
         // serialise settings
         CRM_Core_BAO_Setting::add($variables);
     }
     $urlArray = array('userFrameworkResourceURL', 'imageUploadURL');
     $dirArray = array('uploadDir', 'customFileUploadDir');
     foreach ($variables as $key => $value) {
         if (in_array($key, $urlArray)) {
             $value = CRM_Utils_File::addTrailingSlash($value, '/');
         } else {
             if (in_array($key, $dirArray)) {
                 $value = CRM_Utils_File::addTrailingSlash($value);
                 if (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;
                 }
             } else {
                 if ($key == 'lcMessages') {
                     // reset the templateCompileDir to locale-specific and make sure it exists
                     $this->templateCompileDir .= CRM_Utils_File::addTrailingSlash($value);
                     CRM_Utils_File::createDir($this->templateCompileDir);
                 }
             }
         }
         $this->{$key} = $value;
     }
     if ($this->userFrameworkResourceURL) {
         // we need to do this here so all blocks also load from an ssl server
         if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') {
             CRM_Utils_System::mapConfigToSSL();
         }
         $rrb = parse_url($this->userFrameworkResourceURL);
         // dont use absolute path if resources are stored on a different server
         // CRM-4642
         $this->resourceBase = $this->userFrameworkResourceURL;
         if (isset($_SERVER['HTTP_HOST'])) {
             $this->resourceBase = $rrb['host'] == $_SERVER['HTTP_HOST'] ? $rrb['path'] : $this->userFrameworkResourceURL;
         }
     }
     if (!$this->customFileUploadDir) {
         $this->customFileUploadDir = $this->uploadDir;
     }
     if ($this->mapProvider) {
         $this->geocodeMethod = 'CRM_Utils_Geocode_' . $this->mapProvider;
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:76,代码来源:Config.php

示例6: upgrade_2_2_7

 function upgrade_2_2_7($rev)
 {
     $upgrade =& new CRM_Upgrade_Form();
     $upgrade->processSQL($rev);
     $sql = "UPDATE civicrm_report_instance \n                       SET form_values = REPLACE(form_values,'#',';') ";
     CRM_Core_DAO::executeQuery($sql, CRM_Core_DAO::$_nullArray);
     // make report component enabled by default
     require_once "CRM/Core/DAO/Domain.php";
     $domain =& new CRM_Core_DAO_Domain();
     $domain->selectAdd();
     $domain->selectAdd('config_backend');
     $domain->find(true);
     if ($domain->config_backend) {
         $defaults = unserialize($domain->config_backend);
         if (is_array($defaults['enableComponents'])) {
             $compId = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_component WHERE name = 'CiviReport'");
             if ($compId) {
                 $defaults['enableComponents'][] = 'CiviReport';
                 $defaults['enableComponentIDs'][] = $compId;
                 require_once "CRM/Core/BAO/Setting.php";
                 CRM_Core_BAO_Setting::add($defaults);
             }
         }
     }
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:25,代码来源:Upgrade.php

示例7: upgrade

 function upgrade($rev)
 {
     $upgrade =& new CRM_Upgrade_Form();
     //Run the SQL file
     $upgrade->processSQL($rev);
     // fix for CRM-5162
     // we need to encrypt all smtpPasswords if present
     require_once "CRM/Core/DAO/Preferences.php";
     $mailingDomain =& new CRM_Core_DAO_Preferences();
     $mailingDomain->find();
     while ($mailingDomain->fetch()) {
         if ($mailingDomain->mailing_backend) {
             $values = unserialize($mailingDomain->mailing_backend);
             if (isset($values['smtpPassword'])) {
                 require_once 'CRM/Utils/Crypt.php';
                 $values['smtpPassword'] = CRM_Utils_Crypt::encrypt($values['smtpPassword']);
                 $mailingDomain->mailing_backend = serialize($values);
                 $mailingDomain->save();
             }
         }
     }
     require_once "CRM/Core/DAO/Domain.php";
     $domain =& new CRM_Core_DAO_Domain();
     $domain->selectAdd();
     $domain->selectAdd('config_backend');
     $domain->find(true);
     if ($domain->config_backend) {
         $defaults = unserialize($domain->config_backend);
         if ($dateFormat = CRM_Utils_Array::value('dateformatQfDate', $defaults)) {
             $dateFormatArray = explode(" ", $dateFormat);
             //replace new date format based on previous month format
             //%b month name [abbreviated]
             //%B full month name ('January'..'December')
             //%m decimal number, 0-padded ('01'..'12')
             if ($dateFormat == '%b %d %Y') {
                 $defaults['dateInputFormat'] = 'mm/dd/yy';
             } else {
                 if ($dateFormat == '%d-%b-%Y') {
                     $defaults['dateInputFormat'] = 'dd-mm-yy';
                 } else {
                     if (in_array('%b', $dateFormatArray)) {
                         $defaults['dateInputFormat'] = 'M d, yy';
                     } else {
                         if (in_array('%B', $dateFormatArray)) {
                             $defaults['dateInputFormat'] = 'MM d, yy';
                         } else {
                             $defaults['dateInputFormat'] = 'mm/dd/yy';
                         }
                     }
                 }
             }
         }
         // %p - lowercase ante/post meridiem ('am', 'pm')
         // %P - uppercase ante/post meridiem ('AM', 'PM')
         if ($dateTimeFormat = CRM_Utils_Array::value('dateformatQfDatetime', $defaults)) {
             $defaults['timeInputFormat'] = 2;
             $dateTimeFormatArray = explode(" ", $dateFormat);
             if (in_array('%P', $dateTimeFormatArray) || in_array('%p', $dateTimeFormatArray)) {
                 $defaults['timeInputFormat'] = 1;
             }
             unset($defaults['dateformatQfDatetime']);
         }
         unset($defaults['dateformatQfDate']);
         unset($defaults['dateformatTime']);
         require_once "CRM/Core/BAO/Setting.php";
         CRM_Core_BAO_Setting::add($defaults);
     }
     $sql = "SELECT id, form_values FROM civicrm_report_instance";
     $instDAO = CRM_Core_DAO::executeQuery($sql);
     while ($instDAO->fetch()) {
         $fromVal = @unserialize($instDAO->form_values);
         foreach ((array) $fromVal as $key => $value) {
             if (strstr($key, '_relative')) {
                 $elementName = substr($key, 0, strlen($key) - strlen('_relative'));
                 $fromNamekey = $elementName . '_from';
                 $toNamekey = $elementName . '_to';
                 $fromNameVal = $fromVal[$fromNamekey];
                 $toNameVal = $fromVal[$toNamekey];
                 //check 'choose date range' is set
                 if ($value == '0') {
                     if (CRM_Utils_Date::isDate($fromNameVal)) {
                         $fromDate = CRM_Utils_Date::setDateDefaults(CRM_Utils_Date::format($fromNameVal));
                         $fromNameVal = $fromDate[0];
                     } else {
                         $fromNameVal = '';
                     }
                     if (CRM_Utils_Date::isDate($toNameVal)) {
                         $toDate = CRM_Utils_Date::setDateDefaults(CRM_Utils_Date::format($toNameVal));
                         $toNameVal = $toDate[0];
                     } else {
                         $toNameVal = '';
                     }
                 } else {
                     $fromNameVal = '';
                     $toNameVal = '';
                 }
                 $fromVal[$fromNamekey] = $fromNameVal;
                 $fromVal[$toNamekey] = $toNameVal;
                 continue;
             }
//.........这里部分代码省略.........
开发者ID:bhirsch,项目名称:voipdev,代码行数:101,代码来源:ThreeOne.php

示例8: upgrade

 function upgrade($rev)
 {
     $upgrade =& new CRM_Upgrade_Form();
     //Run the SQL file
     $upgrade->processSQL($rev);
     // fix for CRM-5162
     // we need to encrypt all smtpPasswords if present
     require_once "CRM/Core/DAO/Preferences.php";
     $mailingDomain =& new CRM_Core_DAO_Preferences();
     $mailingDomain->find();
     while ($mailingDomain->fetch()) {
         if ($mailingDomain->mailing_backend) {
             $values = unserialize($mailingDomain->mailing_backend);
             if (isset($values['smtpPassword'])) {
                 require_once 'CRM/Utils/Crypt.php';
                 $values['smtpPassword'] = CRM_Utils_Crypt::encrypt($values['smtpPassword']);
                 $mailingDomain->mailing_backend = setialize($values);
                 $mailingDomain->save();
             }
         }
     }
     require_once "CRM/Core/DAO/Domain.php";
     $domain =& new CRM_Core_DAO_Domain();
     $domain->selectAdd();
     $domain->selectAdd('config_backend');
     $domain->find(true);
     if ($domain->config_backend) {
         $defaults = unserialize($domain->config_backend);
         if ($dateFormat = $defaults['dateformatQfDate']) {
             $dateFormatArray = explode(" ", $dateFormat);
             //replace new date format based on previous month format
             //%b month name [abbreviated]
             //%B full month name ('January'..'December')
             //%m decimal number, 0-padded ('01'..'12')
             if (in_array('%b', $dateFormatArray)) {
                 $defaults['dateInputFormat'] = 'd M, y';
             } else {
                 if (in_array('%B', $dateFormatArray)) {
                     $defaults['dateInputFormat'] = 'd MM, y';
                 } else {
                     $defaults['dateInputFormat'] = 'mm/dd/yy';
                 }
             }
         }
         //Need to fix
         // %p - lowercase ante/post meridiem ('am', 'pm')
         // %P - uppercase ante/post meridiem ('AM', 'PM')
         $defaults['timeInputFormat'] = 1;
         unset($defaults['dateformatQfDate']);
         unset($defaults['dateformatQfDatetime']);
         unset($defaults['dateformatTime']);
         require_once "CRM/Core/BAO/Setting.php";
         CRM_Core_BAO_Setting::add($defaults);
     }
     $template =& CRM_Core_Smarty::singleton();
     $afterUpgradeMessage = '';
     if ($afterUpgradeMessage = $template->get_template_vars('afterUpgradeMessage')) {
         $afterUpgradeMessage .= "<br/><br/>";
     }
     $afterUpgradeMessage .= ts("Most of the Date Format has been changed to mm/dd/yy format. If you want to use a different format please check Date settings");
     $template->assign('afterUpgradeMessage', $afterUpgradeMessage);
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:62,代码来源:ThreeOne.php

示例9: _initVariables

 /**
  * initialize the config variables
  *
  * @return void
  * @access private
  */
 private function _initVariables()
 {
     // retrieve serialised settings
     require_once "CRM/Core/BAO/Setting.php";
     $variables = array();
     CRM_Core_BAO_Setting::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)
         require_once 'CRM/Core/Config/Defaults.php';
         CRM_Core_Config_Defaults::setValues($variables);
         // retrieve directory and url preferences also
         require_once 'CRM/Core/BAO/Preferences.php';
         CRM_Core_BAO_Preferences::retrieveDirectoryAndURLPreferences($defaults);
         // add component specific settings
         $this->componentRegistry->addConfig($this);
         // serialise settings
         CRM_Core_BAO_Setting::add($variables);
     }
     $urlArray = array('userFrameworkResourceURL', 'imageUploadURL');
     $dirArray = array('uploadDir', 'customFileUploadDir');
     foreach ($variables as $key => $value) {
         if (in_array($key, $urlArray)) {
             $value = CRM_Utils_File::addTrailingSlash($value, '/');
         } else {
             if (in_array($key, $dirArray)) {
                 $value = CRM_Utils_File::addTrailingSlash($value);
                 if (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)) . '<br/>');
                 }
             } else {
                 if ($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);
                     }
                 }
             }
         }
         $this->{$key} = $value;
     }
     if ($this->userFrameworkResourceURL) {
         // we need to do this here so all blocks also load from an ssl server
         if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') {
             CRM_Utils_System::mapConfigToSSL();
         }
         $rrb = parse_url($this->userFrameworkResourceURL);
         // dont use absolute path if resources are stored on a different server
         // CRM-4642
         $this->resourceBase = $this->userFrameworkResourceURL;
         if (isset($_SERVER['HTTP_HOST'])) {
             $this->resourceBase = $rrb['host'] == $_SERVER['HTTP_HOST'] ? $rrb['path'] : $this->userFrameworkResourceURL;
         }
     }
     if (!$this->customFileUploadDir) {
         $this->customFileUploadDir = $this->uploadDir;
     }
     if ($this->mapProvider) {
         $this->geocodeMethod = 'CRM_Utils_Geocode_' . $this->mapProvider;
     }
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:78,代码来源:Config.php


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