First commit

This commit is contained in:
Theodotos Andreou 2018-01-14 13:10:16 +00:00
commit c6e2478c40
13918 changed files with 2303184 additions and 0 deletions

View file

@ -0,0 +1,54 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
/**
* This class generates form components for CiviCase.
*/
class CRM_Admin_Form_Setting_Case extends CRM_Admin_Form_Setting {
protected $_settings = array(
'civicaseRedactActivityEmail' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'civicaseAllowMultipleClients' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'civicaseNaturalActivityTypeSort' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'civicaseActivityRevisions' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
);
/**
* Build the form object.
*/
public function buildQuickForm() {
CRM_Utils_System::setTitle(ts('Settings - CiviCase'));
parent::buildQuickForm();
}
}

View file

@ -0,0 +1,173 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
/**
* This class generates form components for Component.
*/
class CRM_Admin_Form_Setting_Component extends CRM_Admin_Form_Setting {
protected $_components;
/**
* Build the form object.
*/
public function buildQuickForm() {
CRM_Utils_System::setTitle(ts('Settings - Enable Components'));
$components = $this->_getComponentSelectValues();
$include = &$this->addElement('advmultiselect', 'enableComponents',
ts('Components') . ' ', $components,
array(
'size' => 5,
'style' => 'width:150px',
'class' => 'advmultiselect',
)
);
$include->setButtonAttributes('add', array('value' => ts('Enable >>')));
$include->setButtonAttributes('remove', array('value' => ts('<< Disable')));
$this->addFormRule(array('CRM_Admin_Form_Setting_Component', 'formRule'), $this);
parent::buildQuickForm();
}
/**
* Global form rule.
*
* @param array $fields
* The input form values.
* @param array $files
* The uploaded files if any.
* @param array $options
* Additional user data.
*
* @return bool|array
* true if no errors, else array of errors
*/
public static function formRule($fields, $files, $options) {
$errors = array();
if (array_key_exists('enableComponents', $fields) && is_array($fields['enableComponents'])) {
if (in_array('CiviPledge', $fields['enableComponents']) &&
!in_array('CiviContribute', $fields['enableComponents'])
) {
$errors['enableComponents'] = ts('You need to enable CiviContribute before enabling CiviPledge.');
}
if (in_array('CiviCase', $fields['enableComponents']) &&
!CRM_Core_DAO::checkTriggerViewPermission(TRUE, FALSE)
) {
$errors['enableComponents'] = ts('CiviCase requires CREATE VIEW and DROP VIEW permissions for the database.');
}
}
return $errors;
}
/**
* @return array
*/
private function _getComponentSelectValues() {
$ret = array();
$this->_components = CRM_Core_Component::getComponents();
foreach ($this->_components as $name => $object) {
$ret[$name] = $object->info['translatedName'];
}
return $ret;
}
public function postProcess() {
$params = $this->controller->exportValues($this->_name);
parent::commonProcess($params);
// reset navigation when components are enabled / disabled
CRM_Core_BAO_Navigation::resetNavigation();
}
/**
* Load case sample data.
*
* @param string $fileName
* @param bool $lineMode
*/
public static function loadCaseSampleData($fileName, $lineMode = FALSE) {
$dao = new CRM_Core_DAO();
$db = $dao->getDatabaseConnection();
$domain = new CRM_Core_DAO_Domain();
$domain->find(TRUE);
$multiLingual = (bool) $domain->locales;
$smarty = CRM_Core_Smarty::singleton();
$smarty->assign('multilingual', $multiLingual);
$smarty->assign('locales', explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales));
if (!$lineMode) {
$string = $smarty->fetch($fileName);
// change \r\n to fix windows issues
$string = str_replace("\r\n", "\n", $string);
//get rid of comments starting with # and --
$string = preg_replace("/^#[^\n]*$/m", "\n", $string);
$string = preg_replace("/^(--[^-]).*/m", "\n", $string);
$queries = preg_split('/;$/m', $string);
foreach ($queries as $query) {
$query = trim($query);
if (!empty($query)) {
$res = &$db->query($query);
if (PEAR::isError($res)) {
die("Cannot execute $query: " . $res->getMessage());
}
}
}
}
else {
$fd = fopen($fileName, "r");
while ($string = fgets($fd)) {
$string = preg_replace("/^#[^\n]*$/m", "\n", $string);
$string = preg_replace("/^(--[^-]).*/m", "\n", $string);
$string = trim($string);
if (!empty($string)) {
$res = &$db->query($string);
if (PEAR::isError($res)) {
die("Cannot execute $string: " . $res->getMessage());
}
}
}
}
}
}

View file

@ -0,0 +1,62 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
/**
* This class generates form components for Date Formatting.
*/
class CRM_Admin_Form_Setting_Date extends CRM_Admin_Form_Setting {
public $_settings = array(
'dateformatDatetime' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
'dateformatFull' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
'dateformatPartial' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
'dateformatYear' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
'dateformatTime' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
'dateformatFinancialBatch' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
'dateformatshortdate' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
'weekBegins' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
'dateInputFormat' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
'timeInputFormat' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
'fiscalYearStart' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
);
/**
* Build the form object.
*/
public function buildQuickForm() {
CRM_Utils_System::setTitle(ts('Settings - Date'));
parent::buildQuickForm();
}
}

View file

@ -0,0 +1,64 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
/**
* This class generates form components for Error Handling and Debugging.
*/
class CRM_Admin_Form_Setting_Debugging extends CRM_Admin_Form_Setting {
protected $_settings = array(
'debug_enabled' => CRM_Core_BAO_Setting::DEVELOPER_PREFERENCES_NAME,
'backtrace' => CRM_Core_BAO_Setting::DEVELOPER_PREFERENCES_NAME,
'fatalErrorHandler' => CRM_Core_BAO_Setting::DEVELOPER_PREFERENCES_NAME,
'assetCache' => CRM_Core_BAO_Setting::DEVELOPER_PREFERENCES_NAME,
'environment' => CRM_Core_BAO_Setting::DEVELOPER_PREFERENCES_NAME,
);
/**
* Build the form object.
*/
public function buildQuickForm() {
CRM_Utils_System::setTitle(ts(' Settings - Debugging and Error Handling '));
if (CRM_Core_Config::singleton()->userSystem->supports_UF_Logging == '1') {
$this->_settings['userFrameworkLogging'] = CRM_Core_BAO_Setting::DEVELOPER_PREFERENCES_NAME;
}
parent::buildQuickForm();
if (Civi::settings()->getMandatory('environment') !== NULL) {
$element = $this->getElement('environment');
$element->freeze();
CRM_Core_Session::setStatus(ts('The environment settings have been disabled because it has been overridden in the settings file.'), ts('Environment settings'), 'info');
}
}
}

View file

@ -0,0 +1,393 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
/**
* This class generates form components for Localization.
*/
class CRM_Admin_Form_Setting_Localization extends CRM_Admin_Form_Setting {
protected $_settings = array(
'contact_default_language' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
'countryLimit' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
'customTranslateFunction' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
'defaultContactCountry' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
'defaultContactStateProvince' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
'defaultCurrency' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
'fieldSeparator' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
'inheritLocale' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
'lcMessages' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
'legacyEncoding' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
'monetaryThousandSeparator' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
'monetaryDecimalPoint' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
'moneyformat' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
'moneyvalueformat' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
'provinceLimit' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
);
/**
* Build the form object.
*/
public function buildQuickForm() {
$config = CRM_Core_Config::singleton();
CRM_Utils_System::setTitle(ts('Settings - Localization'));
$warningTitle = json_encode(ts("Warning"));
$defaultLocaleOptions = CRM_Admin_Form_Setting_Localization::getDefaultLocaleOptions();
$domain = new CRM_Core_DAO_Domain();
$domain->find(TRUE);
if ($domain->locales) {
// add language limiter and language adder
$this->addCheckBox('languageLimit', ts('Available Languages'), array_flip($defaultLocaleOptions), NULL, NULL, NULL, NULL, ' &nbsp; ');
$this->addElement('select', 'addLanguage', ts('Add Language'), array_merge(array('' => ts('- select -')), array_diff(CRM_Core_I18n::languages(), $defaultLocaleOptions)));
// add the ability to return to single language
$warning = ts('This will make your CiviCRM installation a single-language one again. THIS WILL DELETE ALL DATA RELATED TO LANGUAGES OTHER THAN THE DEFAULT ONE SELECTED ABOVE (and only that language will be preserved).');
$this->assign('warning', $warning);
$warning = json_encode($warning);
$this->addElement('checkbox', 'makeSinglelingual', ts('Return to Single Language'),
NULL, array('onChange' => "if (this.checked) CRM.alert($warning, $warningTitle)")
);
}
else {
$warning = ts('Enabling multiple languages changes the schema of your database, so make sure you know what you are doing when enabling this function; making a database backup is strongly recommended.');
$this->assign('warning', $warning);
$warning = json_encode($warning);
$validTriggerPermission = CRM_Core_DAO::checkTriggerViewPermission(TRUE);
if ($validTriggerPermission &&
!\Civi::settings()->get('logging')
) {
$this->addElement('checkbox', 'makeMultilingual', ts('Enable Multiple Languages'),
NULL, array('onChange' => "if (this.checked) CRM.alert($warning, $warningTitle)")
);
}
}
$this->addElement('select', 'contact_default_language', ts('Default Language for users'),
CRM_Admin_Form_Setting_Localization::getDefaultLanguageOptions());
$includeCurrency = &$this->addElement('advmultiselect', 'currencyLimit',
ts('Available Currencies') . ' ', self::getCurrencySymbols(),
array(
'size' => 5,
'style' => 'width:150px',
'class' => 'advmultiselect',
)
);
$includeCurrency->setButtonAttributes('add', array('value' => ts('Add >>')));
$includeCurrency->setButtonAttributes('remove', array('value' => ts('<< Remove')));
$this->addFormRule(array('CRM_Admin_Form_Setting_Localization', 'formRule'));
parent::buildQuickForm();
}
/**
* @param $fields
*
* @return array|bool
*/
public static function formRule($fields) {
$errors = array();
if (CRM_Utils_Array::value('monetaryThousandSeparator', $fields) ==
CRM_Utils_Array::value('monetaryDecimalPoint', $fields)
) {
$errors['monetaryThousandSeparator'] = ts('Thousands Separator and Decimal Delimiter can not be the same.');
}
if (strlen($fields['monetaryThousandSeparator']) == 0) {
$errors['monetaryThousandSeparator'] = ts('Thousands Separator can not be empty. You can use a space character instead.');
}
if (strlen($fields['monetaryThousandSeparator']) > 1) {
$errors['monetaryThousandSeparator'] = ts('Thousands Separator can not have more than 1 character.');
}
if (strlen($fields['monetaryDecimalPoint']) > 1) {
$errors['monetaryDecimalPoint'] = ts('Decimal Delimiter can not have more than 1 character.');
}
if (trim($fields['customTranslateFunction']) &&
!function_exists(trim($fields['customTranslateFunction']))
) {
$errors['customTranslateFunction'] = ts('Please define the custom translation function first.');
}
// CRM-7962, CRM-7713, CRM-9004
if (!empty($fields['defaultContactCountry']) &&
(!empty($fields['countryLimit']) &&
(!in_array($fields['defaultContactCountry'], $fields['countryLimit']))
)
) {
$errors['defaultContactCountry'] = ts('Please select a default country that is in the list of available countries.');
}
return empty($errors) ? TRUE : $errors;
}
/**
* Set the default values for the form.
*
* @return array
*/
public function setDefaultValues() {
parent::setDefaultValues();
// CRM-1496
// retrieve default values for currencyLimit
$this->_defaults['currencyLimit'] = array_keys(CRM_Core_OptionGroup::values('currencies_enabled'));
$this->_defaults['languageLimit'] = Civi::settings()->get('languageLimit');
// CRM-5111: unset these two unconditionally, we dont want them to stick ever
unset($this->_defaults['makeMultilingual']);
unset($this->_defaults['makeSinglelingual']);
return $this->_defaults;
}
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 default 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'];
}
self::updateEnabledCurrencies($values['currencyLimit'], $values['defaultCurrency']);
// 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'));
}
}
/**
* Replace available currencies by the ones provided
*
* @param $currencies array of currencies ['USD', 'CAD']
* @param $default default currency
*/
public static function updateEnabledCurrencies($currencies, $default) {
// sort so that when we display drop down, weights have right value
sort($currencies);
// get labels for all the currencies
$options = array();
$currencySymbols = CRM_Admin_Form_Setting_Localization::getCurrencySymbols();
for ($i = 0; $i < count($currencies); $i++) {
$options[] = array(
'label' => $currencySymbols[$currencies[$i]],
'value' => $currencies[$i],
'weight' => $i + 1,
'is_active' => 1,
'is_default' => $currencies[$i] == $default,
);
}
$dontCare = NULL;
CRM_Core_OptionGroup::createAssoc('currencies_enabled', $options, $dontCare);
}
/**
* @return array
*/
public static function getAvailableCountries() {
$i18n = CRM_Core_I18n::singleton();
$country = array();
CRM_Core_PseudoConstant::populate($country, 'CRM_Core_DAO_Country', TRUE, 'name', 'is_active');
$i18n->localizeArray($country, array('context' => 'country'));
asort($country);
return $country;
}
/**
* Get the default locale options.
*
* @return array
*/
public static function getDefaultLocaleOptions() {
$domain = new CRM_Core_DAO_Domain();
$domain->find(TRUE);
$locales = CRM_Core_I18n::languages();
if ($domain->locales) {
// for multi-lingual sites, populate default language drop-down with available languages
$defaultLocaleOptions = array();
foreach ($locales as $loc => $lang) {
if (substr_count($domain->locales, $loc)) {
$defaultLocaleOptions[$loc] = $lang;
}
}
}
else {
$defaultLocaleOptions = $locales;
}
return $defaultLocaleOptions;
}
/**
* Get a list of currencies (with their symbols).
*
* @return array
* Array('USD' => 'USD ($)').
*/
public static function getCurrencySymbols() {
$symbols = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'currency', array(
'labelColumn' => 'symbol',
'orderColumn' => TRUE,
));
$_currencySymbols = array();
foreach ($symbols as $key => $value) {
$_currencySymbols[$key] = "$key";
if ($value) {
$_currencySymbols[$key] .= " ($value)";
}
}
return $_currencySymbols;
}
/**
* Update session and uf_match table when the locale is updated.
*
* @param string $oldLocale
* @param string $newLocale
* @param array $metadata
* @param int $domainID
*/
public static function onChangeLcMessages($oldLocale, $newLocale, $metadata, $domainID) {
if ($oldLocale == $newLocale) {
return;
}
$session = CRM_Core_Session::singleton();
if ($newLocale && $session->get('userID')) {
$ufm = new CRM_Core_DAO_UFMatch();
$ufm->contact_id = $session->get('userID');
if ($newLocale && $ufm->find(TRUE)) {
$ufm->language = $newLocale;
$ufm->save();
$session->set('lcMessages', $newLocale);
}
}
}
public static function onChangeDefaultCurrency($oldCurrency, $newCurrency, $metadata) {
if ($oldCurrency == $newCurrency) {
return;
}
// ensure that default currency is always in the list of enabled currencies
$currencies = array_keys(CRM_Core_OptionGroup::values('currencies_enabled'));
if (!in_array($newCurrency, $currencies)) {
if (empty($currencies)) {
$currencies = array($values['defaultCurrency']);
}
else {
$currencies[] = $newCurrency;
}
CRM_Admin_Form_Setting_Localization::updateEnabledCurrencies($currencies, $newCurrency);
}
}
/**
* @return array
*/
public static function getDefaultLanguageOptions() {
return array(
'*default*' => ts('Use default site language'),
'undefined' => ts('Leave undefined'),
'current_site_language' => ts('Use language in use at the time'),
);
}
}

View file

@ -0,0 +1,80 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
/**
* This class generates form components for CiviMail.
*/
class CRM_Admin_Form_Setting_Mail extends CRM_Admin_Form_Setting {
protected $_settings = array(
'mailerBatchLimit' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
'mailThrottleTime' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
'mailerJobSize' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
'mailerJobsMax' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
'verpSeparator' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
'replyTo' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
);
/**
* Build the form object.
*/
public function buildQuickForm() {
CRM_Utils_System::setTitle(ts('Settings - CiviMail'));
$this->addFormRule(array('CRM_Admin_Form_Setting_Mail', 'formRule'));
parent::buildQuickForm();
}
/**
* @param $fields
*
* @return array|bool
*/
public static function formRule($fields) {
$errors = array();
if (CRM_Utils_Array::value('mailerJobSize', $fields) > 0) {
if (CRM_Utils_Array::value('mailerJobSize', $fields) < 1000) {
$errors['mailerJobSize'] = ts('The job size must be at least 1000 or set to 0 (unlimited).');
}
elseif (CRM_Utils_Array::value('mailerJobSize', $fields) <
CRM_Utils_Array::value('mailerBatchLimit', $fields)
) {
$errors['mailerJobSize'] = ts('A job size smaller than the batch limit will negate the effect of the batch limit.');
}
}
return empty($errors) ? TRUE : $errors;
}
}

View file

@ -0,0 +1,90 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
/**
* This class generates form components for Mapping and Geocoding.
*/
class CRM_Admin_Form_Setting_Mapping extends CRM_Admin_Form_Setting {
protected $_settings = array(
'mapAPIKey' => CRM_Core_BAO_Setting::MAP_PREFERENCES_NAME,
'mapProvider' => CRM_Core_BAO_Setting::MAP_PREFERENCES_NAME,
'geoAPIKey' => CRM_Core_BAO_Setting::MAP_PREFERENCES_NAME,
'geoProvider' => CRM_Core_BAO_Setting::MAP_PREFERENCES_NAME,
);
/**
* Build the form object.
*/
public function buildQuickForm() {
CRM_Utils_System::setTitle(ts('Settings - Mapping and Geocoding Providers'));
parent::buildQuickForm();
}
/**
* Global form rule.
*
* @param array $fields
* The input form values.
*
* @return bool|array
* true if no errors, else array of errors
*/
public static function formRule($fields) {
$errors = array();
if (!CRM_Utils_System::checkPHPVersion(5, FALSE)) {
$errors['_qf_default'] = ts('Mapping features require PHP version 5 or greater');
}
if (!$fields['mapAPIKey'] && ($fields['mapProvider'] != '' && $fields['mapProvider'] == 'Yahoo')) {
$errors['mapAPIKey'] = "Map Provider key is a required field.";
}
if ($fields['mapProvider'] == 'OpenStreetMaps' && $fields['geoProvider'] == '') {
$errors['geoProvider'] = "Please select a Geocoding Provider - Open Street Maps does not provide geocoding.";
}
return $errors;
}
/**
* Add the rules (mainly global rules) for form.
*
* All local rules are added near the element
*/
public function addRules() {
$this->addFormRule(array('CRM_Admin_Form_Setting_Mapping', 'formRule'));
}
}

View file

@ -0,0 +1,138 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
/**
* This class generates form components for Miscellaneous.
*/
class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting {
protected $_settings = array(
'max_attachments' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'contact_undelete' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'empoweredBy' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'logging' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'maxFileSize' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'doNotAttachPDFReceipt' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'recordGeneratedLetters' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'secondDegRelPermissions' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'checksum_timeout' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'recaptchaOptions' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'recaptchaPublicKey' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'recaptchaPrivateKey' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'wkhtmltopdfPath' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'recentItemsMaxCount' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'recentItemsProviders' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'dedupe_default_limit' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'remote_profile_submissions' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
);
public $_uploadMaxSize;
/**
* Basic setup.
*/
public function preProcess() {
$this->_uploadMaxSize = (int) ini_get('upload_max_filesize');
// check for post max size
CRM_Utils_Number::formatUnitSize(ini_get('post_max_size'), TRUE);
// This is a temp hack for the fact we really don't need to hard-code each setting in the tpl but
// we haven't worked through NOT doing that. These settings have been un-hardcoded.
$this->assign('pure_config_settings', array(
'empoweredBy',
'max_attachments',
'maxFileSize',
'secondDegRelPermissions',
'recentItemsMaxCount',
'recentItemsProviders',
'dedupe_default_limit',
));
}
/**
* Build the form object.
*/
public function buildQuickForm() {
CRM_Utils_System::setTitle(ts('Misc (Undelete, PDFs, Limits, Logging, Captcha, etc.)'));
$this->assign('validTriggerPermission', CRM_Core_DAO::checkTriggerViewPermission(FALSE));
$this->addFormRule(array('CRM_Admin_Form_Setting_Miscellaneous', 'formRule'), $this);
parent::buildQuickForm();
$this->addRule('checksum_timeout', ts('Value should be a positive number'), 'positiveInteger');
}
/**
* Global form rule.
*
* @param array $fields
* The input form values.
* @param array $files
* The uploaded files if any.
* @param array $options
* Additional user data.
*
* @return bool|array
* true if no errors, else array of errors
*/
public static function formRule($fields, $files, $options) {
$errors = array();
// validate max file size
if ($fields['maxFileSize'] > $options->_uploadMaxSize) {
$errors['maxFileSize'] = ts("Maximum file size cannot exceed Upload max size ('upload_max_filesize') as defined in PHP.ini.");
}
// validate recent items stack size
if ($fields['recentItemsMaxCount'] && ($fields['recentItemsMaxCount'] < 1 || $fields['recentItemsMaxCount'] > CRM_Utils_Recent::MAX_ITEMS)) {
$errors['recentItemsMaxCount'] = ts("Illegal stack size. Use values between 1 and %1.", array(1 => CRM_Utils_Recent::MAX_ITEMS));
}
if (!empty($fields['wkhtmltopdfPath'])) {
// check and ensure that thi leads to the wkhtmltopdf binary
// and it is a valid executable binary
// Only check the first space separated piece to allow for a value
// such as /usr/bin/xvfb-run -- wkhtmltopdf (CRM-13292)
$pieces = explode(' ', $fields['wkhtmltopdfPath']);
$path = $pieces[0];
if (
!file_exists($path) ||
!is_executable($path)
) {
$errors['wkhtmltopdfPath'] = ts('The wkhtmltodfPath does not exist or is not valid');
}
}
return $errors;
}
}

View file

@ -0,0 +1,81 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
/**
* This class generates form components for File System Path.
*/
class CRM_Admin_Form_Setting_Path extends CRM_Admin_Form_Setting {
protected $_settings = array(
'uploadDir' => CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME,
'imageUploadDir' => CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME,
'customFileUploadDir' => CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME,
'customTemplateDir' => CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME,
'customPHPPathDir' => CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME,
'extensionsDir' => CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME,
);
/**
* Build the form object.
*/
public function buildQuickForm() {
CRM_Utils_System::setTitle(ts('Settings - Upload Directories'));
parent::buildQuickForm();
$directories = array(
'uploadDir' => ts('Temporary Files'),
'imageUploadDir' => ts('Images'),
'customFileUploadDir' => ts('Custom Files'),
'customTemplateDir' => ts('Custom Templates'),
'customPHPPathDir' => ts('Custom PHP Path Directory'),
'extensionsDir' => ts('CiviCRM Extensions Directory'),
);
foreach ($directories as $name => $title) {
//$this->add('text', $name, $title);
$this->addRule($name,
ts("'%1' directory does not exist",
array(1 => $title)
),
'settingPath'
);
}
}
public function postProcess() {
parent::postProcess();
parent::rebuildMenu();
}
}

View file

@ -0,0 +1,108 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
/**
* This class generates form components for Search Parameters
*
*/
class CRM_Admin_Form_Setting_Search extends CRM_Admin_Form_Setting {
protected $_settings = array(
'contact_reference_options' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
'contact_autocomplete_options' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
'search_autocomplete_count' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
'enable_innodb_fts' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
'includeWildCardInName' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
'includeEmailInName' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
'includeNickNameInName' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
'includeAlphabeticalPager' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
'includeOrderByClause' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
'smartGroupCacheTimeout' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
'defaultSearchProfileID' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
'searchPrimaryDetailsOnly' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
);
/**
* Build the form object.
*/
public function buildQuickForm() {
CRM_Utils_System::setTitle(ts('Settings - Search Preferences'));
parent::buildQuickForm();
// @todo remove the following adds in favour of setting via the settings array (above).
// Autocomplete for Contact Search (quick search etc.)
$element = $this->getElement('contact_autocomplete_options');
$element->_elements[0]->_flagFrozen = TRUE;
// Autocomplete for Contact Reference (custom fields)
$element = $this->getElement('contact_reference_options');
$element->_elements[0]->_flagFrozen = TRUE;
}
/**
* @return array
*/
public static function getContactAutocompleteOptions() {
return array(
ts('Contact Name') => 1,
) + array_flip(CRM_Core_OptionGroup::values('contact_autocomplete_options',
FALSE, FALSE, TRUE
));
}
/**
* @return array
*/
public static function getAvailableProfiles() {
return array('' => ts('- none -')) + CRM_Core_BAO_UFGroup::getProfiles(array(
'Contact',
'Individual',
'Organization',
'Household',
));
}
/**
* @return array
*/
public static function getContactReferenceOptions() {
return array(
ts('Contact Name') => 1,
) + array_flip(CRM_Core_OptionGroup::values('contact_reference_options',
FALSE, FALSE, TRUE
));
}
}

View file

@ -0,0 +1,265 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
/**
* This class generates form components for Smtp Server.
*/
class CRM_Admin_Form_Setting_Smtp extends CRM_Admin_Form_Setting {
protected $_testButtonName;
/**
* Build the form object.
*/
public function buildQuickForm() {
$outBoundOption = array(
CRM_Mailing_Config::OUTBOUND_OPTION_MAIL => ts('mail()'),
CRM_Mailing_Config::OUTBOUND_OPTION_SMTP => ts('SMTP'),
CRM_Mailing_Config::OUTBOUND_OPTION_SENDMAIL => ts('Sendmail'),
CRM_Mailing_Config::OUTBOUND_OPTION_DISABLED => ts('Disable Outbound Email'),
CRM_Mailing_Config::OUTBOUND_OPTION_REDIRECT_TO_DB => ts('Redirect to Database'),
);
$this->addRadio('outBound_option', ts('Select Mailer'), $outBoundOption);
CRM_Utils_System::setTitle(ts('Settings - Outbound Mail'));
$this->add('text', 'sendmail_path', ts('Sendmail Path'));
$this->add('text', 'sendmail_args', ts('Sendmail Argument'));
$this->add('text', 'smtpServer', ts('SMTP Server'));
$this->add('text', 'smtpPort', ts('SMTP Port'));
$this->addYesNo('smtpAuth', ts('Authentication?'));
$this->addElement('text', 'smtpUsername', ts('SMTP Username'));
$this->addElement('password', 'smtpPassword', ts('SMTP Password'));
$this->_testButtonName = $this->getButtonName('refresh', 'test');
$this->addFormRule(array('CRM_Admin_Form_Setting_Smtp', 'formRule'));
parent::buildQuickForm();
$buttons = $this->getElement('buttons')->getElements();
$buttons[] = $this->createElement('submit', $this->_testButtonName, ts('Save & Send Test Email'), array('crm-icon' => 'fa-envelope-o'));
$this->getElement('buttons')->setElements($buttons);
}
/**
* Process the form submission.
*/
public function postProcess() {
// flush caches so we reload details for future requests
// CRM-11967
CRM_Utils_System::flushCache();
$formValues = $this->controller->exportValues($this->_name);
$buttonName = $this->controller->getButtonName();
// check if test button
if ($buttonName == $this->_testButtonName) {
if ($formValues['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_DISABLED) {
CRM_Core_Session::setStatus(ts('You have selected "Disable Outbound Email". A test email can not be sent.'), ts("Email Disabled"), "error");
}
elseif ($formValues['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_REDIRECT_TO_DB) {
CRM_Core_Session::setStatus(ts('You have selected "Redirect to Database". A test email can not be sent.'), ts("Email Disabled"), "error");
}
else {
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
list($toDisplayName, $toEmail, $toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($userID);
//get the default domain email address.CRM-4250
list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail();
if (!$domainEmailAddress || $domainEmailAddress == 'info@EXAMPLE.ORG') {
$fixUrl = CRM_Utils_System::url("civicrm/admin/domain", 'action=update&reset=1');
CRM_Core_Error::fatal(ts('The site administrator needs to enter a valid \'FROM Email Address\' in <a href="%1">Administer CiviCRM &raquo; Communications &raquo; FROM Email Addresses</a>. The email address used may need to be a valid mail account with your email service provider.', array(1 => $fixUrl)));
}
if (!$toEmail) {
CRM_Core_Error::statusBounce(ts('Cannot send a test email because your user record does not have a valid email address.'));
}
if (!trim($toDisplayName)) {
$toDisplayName = $toEmail;
}
$to = '"' . $toDisplayName . '"' . "<$toEmail>";
$from = '"' . $domainEmailName . '" <' . $domainEmailAddress . '>';
$testMailStatusMsg = ts('Sending test email. FROM: %1 TO: %2.<br />', array(
1 => $domainEmailAddress,
2 => $toEmail,
));
$params = array();
if ($formValues['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_SMTP) {
$subject = "Test for SMTP settings";
$message = "SMTP settings are correct.";
$params['host'] = $formValues['smtpServer'];
$params['port'] = $formValues['smtpPort'];
if ($formValues['smtpAuth']) {
$params['username'] = $formValues['smtpUsername'];
$params['password'] = $formValues['smtpPassword'];
$params['auth'] = TRUE;
}
else {
$params['auth'] = FALSE;
}
// set the localhost value, CRM-3153, CRM-9332
$params['localhost'] = $_SERVER['SERVER_NAME'];
// also set the timeout value, lets set it to 30 seconds
// CRM-7510, CRM-9332
$params['timeout'] = 30;
$mailerName = 'smtp';
}
elseif ($formValues['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_SENDMAIL) {
$subject = "Test for Sendmail settings";
$message = "Sendmail settings are correct.";
$params['sendmail_path'] = $formValues['sendmail_path'];
$params['sendmail_args'] = $formValues['sendmail_args'];
$mailerName = 'sendmail';
}
elseif ($formValues['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_MAIL) {
$subject = "Test for PHP mail settings";
$message = "mail settings are correct.";
$mailerName = 'mail';
}
$headers = array(
'From' => $from,
'To' => $to,
'Subject' => $subject,
);
$mailer = Mail::factory($mailerName, $params);
$errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
$result = $mailer->send($toEmail, $headers, $message);
unset($errorScope);
if (defined('CIVICRM_MAIL_LOG')) {
CRM_Core_Session::setStatus($testMailStatusMsg . ts('You have defined CIVICRM_MAIL_LOG - no mail will be sent. Your %1 settings have not been tested.', array(1 => strtoupper($mailerName))), ts("Mail not sent"), "warning");
}
elseif (!is_a($result, 'PEAR_Error')) {
CRM_Core_Session::setStatus($testMailStatusMsg . ts('Your %1 settings are correct. A test email has been sent to your email address.', array(1 => strtoupper($mailerName))), ts("Mail Sent"), "success");
}
else {
$message = CRM_Utils_Mail::errorMessage($mailer, $result);
CRM_Core_Session::setStatus($testMailStatusMsg . ts('Oops. Your %1 settings are incorrect. No test mail has been sent.', array(1 => strtoupper($mailerName))) . $message, ts("Mail Not Sent"), "error");
}
}
}
$mailingBackend = Civi::settings()->get('mailing_backend');
if (!empty($mailingBackend)) {
$formValues = array_merge($mailingBackend, $formValues);
}
// if password is present, encrypt it
if (!empty($formValues['smtpPassword'])) {
$formValues['smtpPassword'] = CRM_Utils_Crypt::encrypt($formValues['smtpPassword']);
}
Civi::settings()->set('mailing_backend', $formValues);
}
/**
* Global validation rules for the form.
*
* @param array $fields
* Posted values of the form.
*
* @return array
* list of errors to be posted back to the form
*/
public static function formRule($fields) {
if ($fields['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_SMTP) {
if (empty($fields['smtpServer'])) {
$errors['smtpServer'] = 'SMTP Server name is a required field.';
}
if (empty($fields['smtpPort'])) {
$errors['smtpPort'] = 'SMTP Port is a required field.';
}
if (!empty($fields['smtpAuth'])) {
if (empty($fields['smtpUsername'])) {
$errors['smtpUsername'] = 'If your SMTP server requires authentication please provide a valid user name.';
}
if (empty($fields['smtpPassword'])) {
$errors['smtpPassword'] = 'If your SMTP server requires authentication, please provide a password.';
}
}
}
if ($fields['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_SENDMAIL) {
if (!$fields['sendmail_path']) {
$errors['sendmail_path'] = 'Sendmail Path is a required field.';
}
if (!$fields['sendmail_args']) {
$errors['sendmail_args'] = 'Sendmail Argument is a required field.';
}
}
return empty($errors) ? TRUE : $errors;
}
/**
* Set default values for the form.
*/
public function setDefaultValues() {
if (!$this->_defaults) {
$this->_defaults = array();
$mailingBackend = Civi::settings()->get('mailing_backend');
if (!empty($mailingBackend)) {
$this->_defaults = $mailingBackend;
if (!empty($this->_defaults['smtpPassword'])) {
$this->_defaults['smtpPassword'] = CRM_Utils_Crypt::decrypt($this->_defaults['smtpPassword']);
}
}
else {
if (!isset($this->_defaults['smtpServer'])) {
$this->_defaults['smtpServer'] = 'localhost';
$this->_defaults['smtpPort'] = 25;
$this->_defaults['smtpAuth'] = 0;
}
if (!isset($this->_defaults['sendmail_path'])) {
$this->_defaults['sendmail_path'] = '/usr/sbin/sendmail';
$this->_defaults['sendmail_args'] = '-i';
}
}
}
return $this->_defaults;
}
}

View file

@ -0,0 +1,100 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
/**
* This class generates form components for Site Url.
*/
class CRM_Admin_Form_Setting_UF extends CRM_Admin_Form_Setting {
protected $_settings = array();
protected $_uf = NULL;
/**
* Build the form object.
*/
public function buildQuickForm() {
$config = CRM_Core_Config::singleton();
$this->_uf = $config->userFramework;
$this->_settings['syncCMSEmail'] = CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME;
if ($this->_uf == 'WordPress') {
$this->_settings['wpBasePage'] = CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME;
}
CRM_Utils_System::setTitle(
ts('Settings - %1 Integration', array(1 => $this->_uf))
);
if ($config->userSystem->is_drupal) {
$this->_settings['userFrameworkUsersTableName'] = CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME;
}
// find out if drupal has its database prefixed
global $databases;
$drupal_prefix = '';
if (isset($databases['default']['default']['prefix'])) {
if (is_array($databases['default']['default']['prefix'])) {
$drupal_prefix = $databases['default']['default']['prefix']['default'];
}
else {
$drupal_prefix = $databases['default']['default']['prefix'];
}
}
if (
function_exists('module_exists') &&
module_exists('views') &&
(
$config->dsn != $config->userFrameworkDSN || !empty($drupal_prefix)
)
) {
$dsnArray = DB::parseDSN($config->dsn);
$tableNames = CRM_Core_DAO::getTableNames();
$tablePrefixes = '$databases[\'default\'][\'default\'][\'prefix\']= array(';
$tablePrefixes .= "\n 'default' => '$drupal_prefix',"; // add default prefix: the drupal database prefix
$prefix = "";
if ($config->dsn != $config->userFrameworkDSN) {
$prefix = "`{$dsnArray['database']}`.";
}
foreach ($tableNames as $tableName) {
$tablePrefixes .= "\n '" . str_pad($tableName . "'", 41) . " => '{$prefix}',";
}
$tablePrefixes .= "\n);";
$this->assign('tablePrefixes', $tablePrefixes);
}
parent::buildQuickForm();
}
}

View file

@ -0,0 +1,86 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
/**
* This class generates form components for Error Handling and Debugging
*/
class CRM_Admin_Form_Setting_UpdateConfigBackend extends CRM_Admin_Form_Setting {
/**
* Build the form object.
*/
public function buildQuickForm() {
CRM_Utils_System::setTitle(ts('Settings - Cleanup Caches and Update Paths'));
$this->addElement(
'submit', $this->getButtonName('next', 'cleanup'), 'Cleanup Caches',
array('class' => 'crm-form-submit', 'id' => 'cleanup-cache')
);
$this->addElement(
'submit', $this->getButtonName('next', 'resetpaths'), 'Reset Paths',
array('class' => 'crm-form-submit', 'id' => 'resetpaths')
);
//parent::buildQuickForm();
}
public function postProcess() {
if (!empty($_POST['_qf_UpdateConfigBackend_next_cleanup'])) {
$config = CRM_Core_Config::singleton();
// cleanup templates_c directory
$config->cleanup(1, FALSE);
// clear all caches
CRM_Core_Config::clearDBCache();
CRM_Utils_System::flushCache();
parent::rebuildMenu();
CRM_Core_BAO_WordReplacement::rebuild();
CRM_Core_Session::setStatus(ts('Cache has been cleared and menu has been rebuilt successfully.'), ts("Success"), "success");
}
if (!empty($_POST['_qf_UpdateConfigBackend_next_resetpaths'])) {
$msg = CRM_Core_BAO_ConfigSetting::doSiteMove();
CRM_Core_Session::setStatus($msg, ts("Success"), "success");
}
return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/setting/updateConfigBackend', 'reset=1'));
}
}

View file

@ -0,0 +1,103 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
/**
* This class generates form components for Site Url.
*/
class CRM_Admin_Form_Setting_Url extends CRM_Admin_Form_Setting {
protected $_settings = array(
'disable_core_css' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'userFrameworkResourceURL' => CRM_Core_BAO_Setting::URL_PREFERENCES_NAME,
'imageUploadURL' => CRM_Core_BAO_Setting::URL_PREFERENCES_NAME,
'customCSSURL' => CRM_Core_BAO_Setting::URL_PREFERENCES_NAME,
'extensionsURL' => CRM_Core_BAO_Setting::URL_PREFERENCES_NAME,
);
/**
* Build the form object.
*/
public function buildQuickForm() {
CRM_Utils_System::setTitle(ts('Settings - Resource URLs'));
$settingFields = civicrm_api('setting', 'getfields', array(
'version' => 3,
));
$this->addYesNo('enableSSL', ts('Force Secure URLs (SSL)'));
$this->addYesNo('verifySSL', ts('Verify SSL Certs'));
// FIXME: verifySSL should use $_settings instead of manually adding fields
$this->assign('verifySSL_description', $settingFields['values']['verifySSL']['description']);
$this->addFormRule(array('CRM_Admin_Form_Setting_Url', 'formRule'));
parent::buildQuickForm();
}
/**
* @param $fields
*
* @return array|bool
*/
public static function formRule($fields) {
if (isset($fields['enableSSL']) &&
$fields['enableSSL']
) {
$config = CRM_Core_Config::singleton();
$url = str_replace('http://', 'https://',
CRM_Utils_System::url('civicrm/dashboard', 'reset=1', TRUE,
NULL, FALSE, FALSE
)
);
if (!CRM_Utils_System::checkURL($url, TRUE)) {
$errors = array(
'enableSSL' => ts('You need to set up a secure server before you can use the Force Secure URLs option'),
);
return $errors;
}
}
return TRUE;
}
public function postProcess() {
// if extensions url is set, lets clear session status messages to avoid
// a potentially spurious message which might already have been set. This
// is a bit hackish
// CRM-10629
$session = CRM_Core_Session::singleton();
$session->getStatus(TRUE);
parent::postProcess();
parent::rebuildMenu();
}
}