예제 #1
0
 /**
  * Add civicrm settings.
  *
  * @param array $params
  *   Associated array of civicrm variables.
  */
 public static function add(&$params)
 {
     $domain = new CRM_Core_DAO_Domain();
     $domain->id = CRM_Core_Config::domainID();
     $domain->find(TRUE);
     if ($domain->config_backend) {
         $params = array_merge(unserialize($domain->config_backend), $params);
     }
     $params = CRM_Core_BAO_ConfigSetting::filterSkipVars($params);
     // also skip all Dir Params, we dont need to store those in the DB!
     foreach ($params as $name => $val) {
         if (substr($name, -3) == 'Dir') {
             unset($params[$name]);
         }
     }
     $domain->config_backend = serialize($params);
     $domain->save();
 }
예제 #2
0
파일: Setting.php 프로젝트: ksecor/civicrm
 /**
  * Function to add civicrm settings
  *
  * @params array $params associated array of civicrm variables
  *
  * @return null
  * @static
  */
 static function add(&$params)
 {
     CRM_Core_BAO_Setting::fixParams($params);
     require_once "CRM/Core/DAO/Domain.php";
     $domain = new CRM_Core_DAO_Domain();
     $domain->id = CRM_Core_Config::domainID();
     $domain->find(true);
     if ($domain->config_backend) {
         $values = unserialize($domain->config_backend);
         CRM_Core_BAO_Setting::formatParams($params, $values);
     }
     // unset any of the variables we read from file that should not be stored in the database
     // the username and certpath are stored flat with _test and _live
     // check CRM-1470
     $skipVars = array('dsn', 'templateCompileDir', 'userFrameworkDSN', 'userFrameworkBaseURL', 'userFrameworkClass', 'userHookClass', 'userPermissionClass', 'userFrameworkURLVar', 'qfKey', 'gettextResourceDir', 'cleanURL');
     foreach ($skipVars as $var) {
         unset($params[$var]);
     }
     $domain->config_backend = serialize($params);
     $domain->save();
 }
예제 #3
0
 /**
  * Function to add civicrm settings
  *
  * @params array $params associated array of civicrm variables
  *
  * @return null
  * @static
  */
 static function add(&$params)
 {
     CRM_Core_BAO_Setting::fixParams($params);
     // also set a template url so js files can use this
     // CRM-6194
     $params['civiRelativeURL'] = CRM_Utils_System::url('CIVI_BASE_TEMPLATE');
     $params['civiRelativeURL'] = str_replace('CIVI_BASE_TEMPLATE', '', $params['civiRelativeURL']);
     require_once "CRM/Core/DAO/Domain.php";
     $domain = new CRM_Core_DAO_Domain();
     $domain->id = CRM_Core_Config::domainID();
     $domain->find(true);
     if ($domain->config_backend) {
         $values = unserialize($domain->config_backend);
         CRM_Core_BAO_Setting::formatParams($params, $values);
     }
     // CRM-6151
     if (isset($params['localeCustomStrings']) && is_array($params['localeCustomStrings'])) {
         $domain->locale_custom_strings = serialize($params['localeCustomStrings']);
     }
     // unset any of the variables we read from file that should not be stored in the database
     // the username and certpath are stored flat with _test and _live
     // check CRM-1470
     $skipVars = array('dsn', 'templateCompileDir', 'userFrameworkDSN', 'userFrameworkBaseURL', 'userFrameworkClass', 'userHookClass', 'userPermissionClass', 'userFrameworkURLVar', 'newBaseURL', 'newBaseDir', 'newSiteName', 'configAndLogDir', 'qfKey', 'gettextResourceDir', 'cleanURL', 'locale_custom_strings', 'localeCustomStrings');
     foreach ($skipVars as $var) {
         unset($params[$var]);
     }
     require_once 'CRM/Core/BAO/Preferences.php';
     CRM_Core_BAO_Preferences::fixAndStoreDirAndURL($params);
     // also skip all Dir Params, we dont need to store those in the DB!
     foreach ($params as $name => $val) {
         if (substr($name, -3) == 'Dir') {
             unset($params[$name]);
         }
     }
     $domain->config_backend = serialize($params);
     $domain->save();
 }
예제 #4
0
파일: Setting.php 프로젝트: kidaa30/yes
 /**
  * Move an item from being in the config array to being stored as a setting
  * remove from config - as appropriate based on metadata
  *
  * Note that where the key name is being changed the 'legacy_key' will give us the old name
  */
 public static function convertConfigToSetting($name, $domainID = NULL)
 {
     // we have to force this here in case more than one domain is in play.
     // whenever there is a possibility of more than one domain we must force it
     $config = CRM_Core_Config::singleton();
     if (empty($domainID)) {
         $domainID = CRM_Core_Config::domainID();
     }
     $domain = new CRM_Core_DAO_Domain();
     $domain->id = $domainID;
     $domain->find(TRUE);
     if ($domain->config_backend) {
         $values = unserialize($domain->config_backend);
     } else {
         $values = array();
     }
     $spec = self::getSettingSpecification(NULL, array('name' => $name), $domainID);
     $configKey = CRM_Utils_Array::value('config_key', $spec[$name], CRM_Utils_Array::value('legacy_key', $spec[$name], $name));
     //if the key is set to config_only we don't need to do anything
     if (empty($spec[$name]['config_only'])) {
         if (!empty($values[$configKey])) {
             civicrm_api('setting', 'create', array('version' => 3, $name => $values[$configKey], 'domain_id' => $domainID));
         } else {
             civicrm_api('setting', 'fill', array('version' => 3, 'name' => $name, 'domain_id' => $domainID));
         }
         if (empty($spec[$name]['prefetch']) && !empty($values[$configKey])) {
             unset($values[$configKey]);
             $domain->config_backend = serialize($values);
             $domain->save();
             unset($config->{$configKey});
         }
     }
 }
예제 #5
0
 /**
  * Add civicrm settings.
  *
  * @param array $params
  *   Associated array of civicrm variables.
  *
  * @return void
  */
 public static function add(&$params)
 {
     self::fixParams($params);
     // also set a template url so js files can use this
     // CRM-6194
     $params['civiRelativeURL'] = CRM_Utils_System::url('CIVI_BASE_TEMPLATE');
     $params['civiRelativeURL'] = str_replace('CIVI_BASE_TEMPLATE', '', $params['civiRelativeURL']);
     // also add the version number for use by template / js etc
     $params['civiVersion'] = CRM_Utils_System::version();
     $domain = new CRM_Core_DAO_Domain();
     $domain->id = CRM_Core_Config::domainID();
     $domain->find(TRUE);
     if ($domain->config_backend) {
         $values = unserialize($domain->config_backend);
         self::formatParams($params, $values);
     }
     // CRM-6151
     if (isset($params['localeCustomStrings']) && is_array($params['localeCustomStrings'])) {
         $domain->locale_custom_strings = serialize($params['localeCustomStrings']);
     }
     // unset any of the variables we read from file that should not be stored in the database
     // the username and certpath are stored flat with _test and _live
     // check CRM-1470
     $skipVars = self::skipVars();
     foreach ($skipVars as $var) {
         unset($params[$var]);
     }
     CRM_Core_BAO_Setting::fixAndStoreDirAndURL($params);
     // also skip all Dir Params, we dont need to store those in the DB!
     foreach ($params as $name => $val) {
         if (substr($name, -3) == 'Dir') {
             unset($params[$name]);
         }
     }
     //keep user preferred language upto date, CRM-7746
     $session = CRM_Core_Session::singleton();
     $lcMessages = CRM_Utils_Array::value('lcMessages', $params);
     if ($lcMessages && $session->get('userID')) {
         $languageLimit = CRM_Utils_Array::value('languageLimit', $params);
         if (is_array($languageLimit) && !in_array($lcMessages, array_keys($languageLimit))) {
             $lcMessages = $session->get('lcMessages');
         }
         $ufm = new CRM_Core_DAO_UFMatch();
         $ufm->contact_id = $session->get('userID');
         if ($lcMessages && $ufm->find(TRUE)) {
             $ufm->language = $lcMessages;
             $ufm->save();
             $session->set('lcMessages', $lcMessages);
             $params['lcMessages'] = $lcMessages;
         }
     }
     $domain->config_backend = serialize($params);
     $domain->save();
 }
예제 #6
0
파일: Domain.php 프로젝트: bhirsch/voipdev
 /**
  * Create a new domain
  *
  * @return domain array
  * @access public
  */
 static function create($params)
 {
     $domain = new CRM_Core_DAO_Domain();
     $domain->copyValues($params);
     $domain->save();
     return $domain;
 }
예제 #7
0
파일: Schema.php 프로젝트: ksecor/civicrm
 /**
  * Switch database from multi-lang back to single (by dropping 
  * additional columns and views and retaining only the selected locale).
  *
  * @param $retain string  the locale to retain
  * @return void
  */
 function makeSinglelingual($retain)
 {
     $domain = new CRM_Core_DAO_Domain();
     $domain->find(true);
     $locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
     // break early if the db is already single-lang
     if (!$locales) {
         return;
     }
     // build the column-dropping SQL queries
     $columns =& CRM_Core_I18n_SchemaStructure::columns();
     $indices =& CRM_Core_I18n_SchemaStructure::indices();
     $queries = array();
     foreach ($columns as $table => $hash) {
         // drop old indices
         if (isset($indices[$table])) {
             foreach ($indices[$table] as $index) {
                 foreach ($locales as $loc) {
                     $queries[] = "DROP INDEX {$index['name']}_{$loc} ON {$table}";
                 }
             }
         }
         // drop triggers
         $queries[] = "DROP TRIGGER IF EXISTS {$table}_before_insert";
         $queries[] = "DROP TRIGGER IF EXISTS {$table}_before_update";
         // deal with columns
         foreach ($hash as $column => $type) {
             $queries[] = "ALTER TABLE {$table} ADD {$column} {$type}";
             $queries[] = "UPDATE {$table} SET {$column} = {$column}_{$retain}";
             foreach ($locales as $loc) {
                 $queries[] = "ALTER TABLE {$table} DROP {$column}_{$loc}";
             }
         }
         // drop views
         foreach ($locales as $loc) {
             $queries[] = "DROP VIEW {$table}_{$loc}";
         }
         // add original indices
         $queries = array_merge($queries, self::createIndexQueries(null, $table));
     }
     // execute the queries without i18n rewriting
     $dao = new CRM_Core_DAO();
     foreach ($queries as $query) {
         $dao->query($query, false);
     }
     // update civicrm_domain.locales
     $domain->locales = 'NULL';
     $domain->save();
 }
예제 #8
0
 function mailerPreferences()
 {
     $mailerValues = array();
     $mailerFields = array('outBound_option', 'smtpServer', 'smtpPort', 'smtpAuth', 'smtpUsername', 'smtpPassword', 'sendmail_path', 'sendmail_args');
     //get the mailer preferences from backend
     //store in civicrm_preferences and unset from backend.
     $domain = new CRM_Core_DAO_Domain();
     $domain->find(TRUE);
     if ($domain->config_backend) {
         $backendValues = unserialize($domain->config_backend);
         foreach ($mailerFields as $field) {
             $mailerValues[$field] = CRM_Utils_Array::value($field, $backendValues);
             if (array_key_exists($field, $backendValues)) {
                 unset($backendValues[$field]);
             }
         }
         $domain->config_backend = serialize($backendValues);
         $domain->save();
         $sql = 'SELECT id, mailing_backend FROM civicrm_preferences';
         $mailingDomain = CRM_Core_DAO::executeQuery($sql);
         $mailingDomain->find(TRUE);
         $mailingDomain->mailing_backend = serialize($mailerValues);
         $mailingDomain->save();
     }
 }
예제 #9
0
파일: Schema.php 프로젝트: hguru/224Civi
 /**
  * Add a new locale to a multi-lang db, setting
  * its values to the current default locale.
  *
  * @param $locale string  the new locale to add
  * @param $source string  the locale to copy from
  *
  * @return void
  */
 static function addLocale($locale, $source)
 {
     // get the current supported locales
     $domain = new CRM_Core_DAO_Domain();
     $domain->find(TRUE);
     $locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
     // break early if the locale is already supported
     if (in_array($locale, $locales)) {
         return;
     }
     $dao = new CRM_Core_DAO();
     // build the required SQL queries
     $columns = CRM_Core_I18n_SchemaStructure::columns();
     $indices = CRM_Core_I18n_SchemaStructure::indices();
     $queries = array();
     foreach ($columns as $table => $hash) {
         // add new columns
         foreach ($hash as $column => $type) {
             // CRM-7854: skip existing columns
             if (CRM_Core_DAO::checkFieldExists($table, "{$column}_{$locale}", FALSE)) {
                 continue;
             }
             $queries[] = "ALTER TABLE {$table} ADD {$column}_{$locale} {$type}";
             $queries[] = "UPDATE {$table} SET {$column}_{$locale} = {$column}_{$source}";
         }
         // add view
         $queries[] = self::createViewQuery($locale, $table, $dao);
         // add new indices
         $queries = array_merge($queries, array_values(self::createIndexQueries($locale, $table)));
     }
     // execute the queries without i18n rewriting
     foreach ($queries as $query) {
         $dao->query($query, FALSE);
     }
     // update civicrm_domain.locales
     $locales[] = $locale;
     $domain->locales = implode(CRM_Core_DAO::VALUE_SEPARATOR, $locales);
     $domain->save();
     // invoke the meta trigger creation call
     CRM_Core_DAO::triggerRebuild();
 }
예제 #10
0
 /**
  * Add a new locale to a multi-lang db, setting 
  * its values to the current default locale.
  *
  * @param $locale string  the new locale to add
  * @param $source string  the locale to copy from
  * @return void
  */
 function addLocale($locale, $source)
 {
     // get the current supported locales
     $domain = new CRM_Core_DAO_Domain();
     $domain->find(true);
     $locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
     // break early if the locale is already supported
     if (in_array($locale, $locales)) {
         return;
     }
     $dao = new CRM_Core_DAO();
     // build the required SQL queries
     $columns =& CRM_Core_I18n_SchemaStructure::columns();
     $indices =& CRM_Core_I18n_SchemaStructure::indices();
     $queries = array();
     foreach ($columns as $table => $hash) {
         // add new columns
         foreach ($hash as $column => $type) {
             $queries[] = "ALTER TABLE {$table} ADD {$column}_{$locale} {$type}";
             $queries[] = "UPDATE {$table} SET {$column}_{$locale} = {$column}_{$source}";
         }
         // add view
         $queries[] = self::createViewQuery($locale, $table, $dao);
         // add new indices
         $queries = array_merge($queries, self::createIndexQueries($locale, $table));
     }
     // add triggers
     $queries = array_merge($queries, self::createTriggerQueries($locales, $locale));
     // execute the queries without i18n rewriting
     foreach ($queries as $query) {
         $dao->query($query, false);
     }
     // update civicrm_domain.locales
     $locales[] = $locale;
     $domain->locales = implode(CRM_Core_DAO::VALUE_SEPARATOR, $locales);
     $domain->save();
 }
예제 #11
0
 function mailerPreferences()
 {
     require_once "CRM/Core/DAO/Domain.php";
     require_once 'CRM/Core/BAO/Preferences.php';
     $mailerValues = array();
     $mailerFields = array('outBound_option', 'smtpServer', 'smtpPort', 'smtpAuth', 'smtpUsername', 'smtpPassword', 'sendmail_path', 'sendmail_args');
     //get the mailer preferences from backend
     //store in civicrm_preferences and unset from backend.
     $domain = new CRM_Core_DAO_Domain();
     $domain->find(true);
     if ($domain->config_backend) {
         $backendValues = unserialize($domain->config_backend);
         foreach ($mailerFields as $field) {
             $mailerValues[$field] = CRM_Utils_Array::value($field, $backendValues);
             if (array_key_exists($field, $backendValues)) {
                 unset($backendValues[$field]);
             }
         }
         $domain->config_backend = serialize($backendValues);
         $domain->save();
         $mailingDomain = new CRM_Core_DAO_Preferences();
         $mailingDomain->find(true);
         $mailingDomain->mailing_backend = serialize($mailerValues);
         $mailingDomain->save();
     }
 }