本文整理汇总了PHP中CRM_Core_BAO_ConfigSetting::add方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_ConfigSetting::add方法的具体用法?PHP CRM_Core_BAO_ConfigSetting::add怎么用?PHP CRM_Core_BAO_ConfigSetting::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_ConfigSetting
的用法示例。
在下文中一共展示了CRM_Core_BAO_ConfigSetting::add方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgrade_4_1_alpha1
function upgrade_4_1_alpha1($rev)
{
$config = CRM_Core_Config::singleton();
if (in_array('CiviCase', $config->enableComponents)) {
if (!CRM_Case_BAO_Case::createCaseViews()) {
$template = CRM_Core_Smarty::singleton();
$afterUpgradeMessage = '';
if ($afterUpgradeMessage = $template->get_template_vars('afterUpgradeMessage')) {
$afterUpgradeMessage .= "<br/><br/>";
}
$afterUpgradeMessage .= '<div class="crm-upgrade-case-views-error" style="background-color: #E43D2B; padding: 10px;">' . ts("There was a problem creating CiviCase database views. Please create the following views manually before using CiviCase:");
$afterUpgradeMessage .= '<div class="crm-upgrade-case-views-query"><div>' . CRM_Case_BAO_Case::createCaseViewsQuery('upcoming') . '</div><div>' . CRM_Case_BAO_Case::createCaseViewsQuery('recent') . '</div>' . '</div></div>';
$template->assign('afterUpgradeMessage', $afterUpgradeMessage);
}
}
$upgrade = new CRM_Upgrade_Form();
$upgrade->processSQL($rev);
$this->transferPreferencesToSettings();
$this->createNewSettings();
// now modify the config so that the directories are now stored in the settings table
// CRM-8780
$params = array();
CRM_Core_BAO_ConfigSetting::add($params);
// also reset navigation
CRM_Core_BAO_Navigation::resetNavigation();
}
示例2: verifyPreDBState
/**
* @param $errorMessage
*
* @return bool
*/
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
$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_ConfigSetting::add($defaults);
}
return $this->checkVersion('2.2');
}
示例3: _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();
}
示例4: upgrade_4_4_1
/**
* @param $rev
*/
public function upgrade_4_4_1($rev)
{
$config = CRM_Core_Config::singleton();
// CRM-13327 upgrade handling for the newly added name badges
$ogID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'name_badge', 'id', 'name');
$nameBadges = array_flip(array_values(CRM_Core_BAO_OptionValue::getOptionValuesAssocArrayFromName('name_badge')));
unset($nameBadges['Avery 5395']);
if (!empty($nameBadges)) {
$dimension = '{"paper-size":"a4","orientation":"portrait","font-name":"times","font-size":6,"font-style":"","NX":2,"NY":4,"metric":"mm","lMargin":6,"tMargin":19,"SpaceX":0,"SpaceY":0,"width":100,"height":65,"lPadding":0,"tPadding":0}';
$query = "UPDATE civicrm_option_value\n SET value = '{$dimension}'\n WHERE option_group_id = %1 AND name = 'Fattorini Name Badge 100x65'";
CRM_Core_DAO::executeQuery($query, array(1 => array($ogID, 'Integer')));
} else {
$dimensions = array(1 => '{"paper-size":"a4","orientation":"landscape","font-name":"times","font-size":6,"font-style":"","NX":2,"NY":1,"metric":"mm","lMargin":25,"tMargin":27,"SpaceX":0,"SpaceY":35,"width":106,"height":150,"lPadding":5,"tPadding":5}', 2 => '{"paper-size":"a4","orientation":"portrait","font-name":"times","font-size":6,"font-style":"","NX":2,"NY":4,"metric":"mm","lMargin":6,"tMargin":19,"SpaceX":0,"SpaceY":0,"width":100,"height":65,"lPadding":0,"tPadding":0}', 3 => '{"paper-size":"a4","orientation":"portrait","font-name":"times","font-size":6,"font-style":"","NX":2,"NY":2,"metric":"mm","lMargin":10,"tMargin":28,"SpaceX":0,"SpaceY":0,"width":96,"height":121,"lPadding":5,"tPadding":5}');
$insertStatements = array(1 => "({$ogID}, %1, '{$dimensions[1]}', %1, NULL, 0, NULL, 2, NULL, 0, 0, 1, NULL, NULL)", 2 => "({$ogID}, %2, '{$dimensions[2]}', %2, NULL, 0, NULL, 3, NULL, 0, 0, 1, NULL, NULL)", 3 => "({$ogID}, %3, '{$dimensions[3]}', %3, NULL, 0, NULL, 4, NULL, 0, 0, 1, NULL, NULL)");
$queryParams = array(1 => array('A6 Badge Portrait 150x106', 'String'), 2 => array('Fattorini Name Badge 100x65', 'String'), 3 => array('Hanging Badge 3-3/4" x 4-3"/4', 'String'));
foreach ($insertStatements as $values) {
$query = 'INSERT INTO civicrm_option_value (`option_group_id`, `label`, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `description`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`) VALUES' . $values;
CRM_Core_DAO::executeQuery($query, $queryParams);
}
}
// CRM-12578 - Prior to this version a CSS file under drupal would disable core css
if (!empty($config->customCSSURL) && strpos($config->userFramework, 'Drupal') === 0) {
// The new setting doesn't exist yet - need to create it first
$sql = '
INSERT INTO civicrm_setting (group_name, name , value , domain_id , is_domain , created_date)
VALUES (%1, %2, %3, %4, %5, now())';
CRM_Core_DAO::executeQuery($sql, array(1 => array(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'String'), 2 => array('disable_core_css', 'String'), 3 => array(serialize(1), 'String'), 4 => array(CRM_Core_Config::domainID(), 'Positive'), 5 => array(1, 'Int')));
Civi::service('settings_manager')->flush();
}
// CRM-13701 - Fix $config->timeInputFormat
$sql = "\n SELECT time_format\n FROM civicrm_preferences_date\n WHERE time_format IS NOT NULL\n AND time_format <> ''\n LIMIT 1\n ";
$timeInputFormat = CRM_Core_DAO::singleValueQuery($sql);
if ($timeInputFormat && $timeInputFormat != $config->timeInputFormat) {
$params = array('timeInputFormat' => $timeInputFormat);
CRM_Core_BAO_ConfigSetting::add($params);
}
// CRM-13698 - add 'Available' and 'No-show' activity statuses
$insertStatus = array();
$nsinc = $avinc = $inc = 0;
if (!CRM_Core_OptionGroup::getValue('activity_status', 'Available', 'name')) {
$insertStatus[] = "(%1, 'Available', %2, 'Available', NULL, 0, NULL, %3, 0, 0, 1, NULL, NULL)";
$avinc = $inc = 1;
}
if (!CRM_Core_OptionGroup::getValue('activity_status', 'No_show', 'name')) {
$insertStatus[] = "(%1, 'No-show', %4, 'No_show', NULL, 0, NULL, %5, 0, 0, 1, NULL, NULL)";
$nsinc = $inc + 1;
}
if (!empty($insertStatus)) {
$acOptionGroupID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'activity_status', 'id', 'name');
$maxVal = CRM_Core_DAO::singleValueQuery("SELECT MAX(ROUND(op.value)) FROM civicrm_option_value op WHERE op.option_group_id = {$acOptionGroupID}");
$maxWeight = CRM_Core_DAO::singleValueQuery("SELECT MAX(weight) FROM civicrm_option_value WHERE option_group_id = {$acOptionGroupID}");
$p[1] = array($acOptionGroupID, 'Integer');
if ($avinc) {
$p[2] = array($avinc + $maxVal, 'Integer');
$p[3] = array($avinc + $maxWeight, 'Integer');
}
if ($nsinc) {
$p[4] = array($nsinc + $maxVal, 'Integer');
$p[5] = array($nsinc + $maxWeight, 'Integer');
}
$insertStatus = implode(',', $insertStatus);
$sql = "\nINSERT INTO\n civicrm_option_value (`option_group_id`, label, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)\nVALUES {$insertStatus}";
CRM_Core_DAO::executeQuery($sql, $p);
}
$this->addTask(ts('Upgrade DB to %1: SQL', array(1 => '4.4.1')), 'runSql', $rev);
$this->addTask('Patch word-replacement schema', 'wordReplacements_patch', $rev);
}
示例5: doFinish
public static function doFinish()
{
$upgrade = new CRM_Upgrade_Form();
list($ignore, $latestVer) = $upgrade->getUpgradeVersions();
// Seems extraneous in context, but we'll preserve old behavior
$upgrade->setVersion($latestVer);
// lets rebuild the config array in case we've made a few changes in the
// code base
// this also helps us always store the latest version of civi in the DB
$params = array();
CRM_Core_BAO_ConfigSetting::add($params);
// CRM-12804 comment-51411 : add any missing settings
// at the end of upgrade
CRM_Core_BAO_Setting::updateSettingsFromMetaData();
// cleanup caches CRM-8739
$config = CRM_Core_Config::singleton();
$config->cleanupCaches(1);
// Rebuild all triggers and re-enable logging if needed
$logging = new CRM_Logging_Schema();
$logging->fixSchemaDifferences();
//CRM-16257 update Config.IDS.ini might be an old copy
CRM_Core_IDS::createConfigFile(TRUE);
}
示例6: upgrade_2_2_7
/**
* Perform an incremental upgrade
*
* @param $rev string, the revision to which we are upgrading (Note: When processing a series of upgrades, this is the immediate upgrade - not the final)
*/
static 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
$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;
CRM_Core_BAO_ConfigSetting::add($defaults);
}
}
}
}
示例7: verifyPreDBState
function verifyPreDBState(&$errorMessage)
{
$config = CRM_Core_Config::singleton();
// Let's first update the config defaults
$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();
}
} elseif ($config->userSystem->is_drupal) {
$defaults['userFrameworkVersion'] = '6.3';
if (defined('VERSION')) {
$defaults['userFrameworkVersion'] = VERSION;
}
}
// serialise settings
CRM_Core_BAO_ConfigSetting::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"), ts('Redundant Tables'), 'info');
}
// 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;
}
示例8: testConvertConfigToSettingNoPrefetch
/**
* Ensure that overrides in $civicrm_setting apply when
* when using retrieveDirectoryAndURLPreferences().
*/
function testConvertConfigToSettingNoPrefetch()
{
$settings = array('maxAttachments' => 6);
CRM_Core_BAO_ConfigSetting::add($settings);
$config = CRM_Core_Config::singleton(TRUE, TRUE);
$this->assertEquals(6, $config->maxAttachments);
CRM_Core_BAO_Setting::convertConfigToSetting('max_attachments');
$value = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'max_attachments');
$this->assertEquals(6, $value);
$this->callAPISuccess('system', 'flush', array());
$config = CRM_Core_Config::singleton(TRUE, TRUE);
$maxAttachments = empty($config->maxAttachments) ? NULL : $config->maxAttachments;
$this->assertEmpty($maxAttachments);
}
示例9: enableDebug
/**
* Implementation of command 'enable-debug'
*/
private function enableDebug()
{
civicrm_initialize();
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) {
$config = unserialize($domain->config_backend);
$config['debug_enabled'] = 1;
$config['debug'] = 1;
$config['backtrace'] = 1;
require_once 'CRM/Core/BAO/ConfigSetting.php';
CRM_Core_BAO_ConfigSetting::add($config);
WP_CLI::success('Debug setting enabled.');
} else {
WP_CLI::error('Error retrieving current config_backend.');
}
}
示例10: commonProcess
public function commonProcess(&$params)
{
// save autocomplete search options
if (CRM_Utils_Array::value('autocompleteContactSearch', $params)) {
$value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($params['autocompleteContactSearch'])) . CRM_Core_DAO::VALUE_SEPARATOR;
CRM_Core_BAO_Setting::setItem($value, CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options');
unset($params['autocompleteContactSearch']);
}
// save autocomplete contact reference options
if (CRM_Utils_Array::value('autocompleteContactReference', $params)) {
$value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($params['autocompleteContactReference'])) . CRM_Core_DAO::VALUE_SEPARATOR;
CRM_Core_BAO_Setting::setItem($value, CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_reference_options');
unset($params['autocompleteContactReference']);
}
// save checksum timeout
if (CRM_Utils_Array::value('checksumTimeout', $params)) {
CRM_Core_BAO_Setting::setItem($params['checksumTimeout'], CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'checksum_timeout');
}
// update time for date formats when global time is changed
if (CRM_Utils_Array::value('timeInputFormat', $params)) {
$query = "\nUPDATE civicrm_preferences_date\nSET time_format = %1\nWHERE time_format IS NOT NULL\nAND time_format <> ''\n";
$sqlParams = array(1 => array($params['timeInputFormat'], 'String'));
CRM_Core_DAO::executeQuery($query, $sqlParams);
unset($params['timeInputFormat']);
}
// verify ssl peer option
if (isset($params['verifySSL'])) {
CRM_Core_BAO_Setting::setItem($params['verifySSL'], CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL');
unset($params['verifySSL']);
}
// force secure URLs
if (isset($params['enableSSL'])) {
CRM_Core_BAO_Setting::setItem($params['enableSSL'], CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enableSSL');
unset($params['enableSSL']);
}
CRM_Core_BAO_ConfigSetting::add($params);
// also delete the CRM_Core_Config key from the database
$cache = CRM_Utils_Cache::singleton();
$cache->delete('CRM_Core_Config');
CRM_Core_Session::setStatus(ts('Your changes have been saved.'));
}
示例11: 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
$sql = 'SELECT id, mailing_backend FROM civicrm_preferences';
$mailingDomain = CRM_Core_DAO::executeQuery($sql);
while ($mailingDomain->fetch()) {
if ($mailingDomain->mailing_backend) {
$values = unserialize($mailingDomain->mailing_backend);
if (isset($values['smtpPassword'])) {
$values['smtpPassword'] = CRM_Utils_Crypt::encrypt($values['smtpPassword']);
$updateSql = 'UPDATE civicrm_preferences SET mailing_backend = %1 WHERE id = %2';
$updateParams = array(1 => array(serialize($values), 'String'), 2 => array($mailingDomain->id, 'Integer'));
CRM_Core_DAO::executeQuery($updateSql, $updateParams);
}
}
}
$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';
} elseif ($dateFormat == '%d-%b-%Y') {
$defaults['dateInputFormat'] = 'dd-mm-yy';
} elseif (in_array('%b', $dateFormatArray)) {
$defaults['dateInputFormat'] = 'M d, yy';
} elseif (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']);
CRM_Core_BAO_ConfigSetting::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;
}
}
$fromVal = serialize($fromVal);
$updateSQL = "UPDATE civicrm_report_instance SET form_values = '{$fromVal}' WHERE id = {$instDAO->id}";
CRM_Core_DAO::executeQuery($updateSQL);
}
$customFieldSQL = "SELECT id, date_format FROM civicrm_custom_field WHERE data_type = 'Date' ";
$customDAO = CRM_Core_DAO::executeQuery($customFieldSQL);
while ($customDAO->fetch()) {
$datePartKey = $dateParts = explode(CRM_Core_DAO::VALUE_SEPARATOR, $customDAO->date_format);
//.........这里部分代码省略.........