Example #1
0
 /**
  * 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, '   ');
         $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 && !$config->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();
 }
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     CRM_Utils_System::setTitle(ts('Settings - Undelete, Logging and ReCAPTCHA'));
     $this->addYesNo('contactUndelete', ts('Contact Trash & Undelete'));
     // also check if we can enable triggers
     $validTriggerPermission = CRM_Core_DAO::checkTriggerViewPermission(FALSE);
     // FIXME: for now, disable logging for multilingual sites OR if triggers are not permittted
     $domain = new CRM_Core_DAO_Domain();
     $domain->find(TRUE);
     $attribs = $domain->locales || !$validTriggerPermission ? array('disabled' => 'disabled') : NULL;
     $this->assign('validTriggerPermission', $validTriggerPermission);
     $this->addYesNo('logging', ts('Logging'), NULL, NULL, $attribs);
     $this->addYesNo('versionCheck', ts('Version Check & Statistics Reporting'));
     $this->addYesNo('doNotAttachPDFReceipt', ts('Attach PDF copy to receipts'));
     $this->addElement('text', 'wkhtmltopdfPath', ts('Path to wkhtmltopdf executable'), array('size' => 64, 'maxlength' => 256));
     $this->addElement('text', 'maxAttachments', ts('Maximum Attachments'), array('size' => 2, 'maxlength' => 8));
     $this->addElement('text', 'maxFileSize', ts('Maximum File Size'), array('size' => 2, 'maxlength' => 8));
     $this->addElement('text', 'recaptchaPublicKey', ts('Public Key'), array('size' => 64, 'maxlength' => 64));
     $this->addElement('text', 'recaptchaPrivateKey', ts('Private Key'), array('size' => 64, 'maxlength' => 64));
     $this->addElement('text', 'dashboardCacheTimeout', ts('Dashboard cache timeout'), array('size' => 3, 'maxlength' => 5));
     $this->addElement('text', 'checksumTimeout', ts('CheckSum Lifespan'), array('size' => 2, 'maxlength' => 8));
     $this->addElement('text', 'recaptchaOptions', ts('Recaptcha Options'), array('size' => 64, 'maxlength' => 64));
     $this->addRule('maxAttachments', ts('Value should be a positive number'), 'positiveInteger');
     $this->addRule('maxFileSize', ts('Value should be a positive number'), 'positiveInteger');
     $this->addRule('checksumTimeout', ts('Value should be a positive number'), 'positiveInteger');
     parent::buildQuickForm();
 }
Example #3
0
 /**
  * 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');
 }
Example #4
0
 /**
  * Setting Callback - Validate.
  *
  * @param mixed $value
  * @param array $fieldSpec
  *
  * @return bool
  * @throws API_Exception
  */
 public static function checkLoggingSupport(&$value, $fieldSpec)
 {
     $domain = new CRM_Core_DAO_Domain();
     $domain->find(TRUE);
     if (!CRM_Core_DAO::checkTriggerViewPermission(FALSE) && $value) {
         throw new API_Exception("In order to use this functionality, the installation's database user must have privileges to create triggers (in MySQL 5.0 – and in MySQL 5.1 if binary logging is enabled – this means the SUPER privilege). This install either does not seem to have the required privilege enabled.");
     }
     return TRUE;
 }
Example #5
0
 /**
  * @param $errors
  *
  * @return bool
  */
 public function verifyPreDBstate(&$errors)
 {
     $config = CRM_Core_Config::singleton();
     if (in_array('CiviCase', $config->enableComponents)) {
         if (!CRM_Core_DAO::checkTriggerViewPermission(TRUE, FALSE)) {
             $errors[] = 'CiviCase now requires CREATE VIEW and DROP VIEW permissions for the database user.';
             return FALSE;
         }
     }
     return TRUE;
 }
Example #6
0
 /**
  * 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;
 }
 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     CRM_Utils_System::setTitle(ts('Misc (Undelete, PDFs, Limits, Logging, Captcha, etc.)'));
     $this->assign('validTriggerPermission', CRM_Core_DAO::checkTriggerViewPermission(FALSE));
     $this->addElement('text', 'wkhtmltopdfPath', ts('Path to wkhtmltopdf executable'), array('size' => 64, 'maxlength' => 256));
     $this->addElement('text', 'recaptchaPublicKey', ts('Public Key'), array('size' => 64, 'maxlength' => 64));
     $this->addElement('text', 'recaptchaPrivateKey', ts('Private Key'), array('size' => 64, 'maxlength' => 64));
     $this->addElement('text', 'dashboardCacheTimeout', ts('Dashboard cache timeout'), array('size' => 3, 'maxlength' => 5));
     $this->addElement('text', 'recaptchaOptions', ts('Recaptcha Options'), array('size' => 64, 'maxlength' => 64));
     $this->addFormRule(array('CRM_Admin_Form_Setting_Miscellaneous', 'formRule'), $this);
     parent::buildQuickForm();
     $this->addRule('checksumTimeout', ts('Value should be a positive number'), 'positiveInteger');
 }
 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     CRM_Utils_System::setTitle(ts('Misc (Undelete, PDFs, Limits, Logging, Captcha, etc.)'));
     // also check if we can enable triggers
     $validTriggerPermission = CRM_Core_DAO::checkTriggerViewPermission(FALSE);
     // FIXME: for now, disable logging for multilingual sites OR if triggers are not permittted
     $domain = new CRM_Core_DAO_Domain();
     $domain->find(TRUE);
     $attribs = $domain->locales || !$validTriggerPermission ? array('disabled' => 'disabled') : array();
     $this->assign('validTriggerPermission', $validTriggerPermission);
     $this->addYesNo('logging', ts('Logging'), NULL, NULL, $attribs);
     $this->addElement('text', 'wkhtmltopdfPath', ts('Path to wkhtmltopdf executable'), array('size' => 64, 'maxlength' => 256));
     $this->addElement('text', 'recaptchaPublicKey', ts('Public Key'), array('size' => 64, 'maxlength' => 64));
     $this->addElement('text', 'recaptchaPrivateKey', ts('Private Key'), array('size' => 64, 'maxlength' => 64));
     $this->addElement('text', 'dashboardCacheTimeout', ts('Dashboard cache timeout'), array('size' => 3, 'maxlength' => 5));
     $this->addElement('text', 'recaptchaOptions', ts('Recaptcha Options'), array('size' => 64, 'maxlength' => 64));
     $this->addFormRule(array('CRM_Admin_Form_Setting_Miscellaneous', 'formRule'), $this);
     parent::buildQuickForm();
     $this->addRule('checksumTimeout', ts('Value should be a positive number'), 'positiveInteger');
 }
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     CRM_Utils_System::setTitle(ts('Settings - Miscellaneous'));
     $this->addYesNo('contactUndelete', ts('Contact Trash & Undelete'));
     // also check if we can enable triggers
     $validTriggerPermission = CRM_Core_DAO::checkTriggerViewPermission(false);
     // FIXME: for now, disable logging for multilingual sites OR if triggers are not permittted
     $domain = new CRM_Core_DAO_Domain();
     $domain->find(true);
     $attribs = $domain->locales || !$validTriggerPermission ? array('disabled' => 'disabled') : null;
     $this->assign('validTriggerPermission', $validTriggerPermission);
     $this->addYesNo('logging', ts('Logging'), null, null, $attribs);
     $this->addYesNo('versionCheck', ts('Version Check & Statistics Reporting'));
     $this->addElement('text', 'maxAttachments', ts('Maximum Attachments'), array('size' => 2, 'maxlength' => 8));
     $this->addElement('text', 'maxFileSize', ts('Maximum File Size'), array('size' => 2, 'maxlength' => 8));
     $this->addElement('text', 'recaptchaPublicKey', ts('Public Key'), array('size' => 64, 'maxlength' => 64));
     $this->addElement('text', 'recaptchaPrivateKey', ts('Private Key'), array('size' => 64, 'maxlength' => 64));
     $this->addElement('text', 'dashboardCacheTimeout', ts('Dashboard cache timeout'), array('size' => 3, 'maxlength' => 5));
     $this->addRule('maxAttachments', ts('Value should be a positive number'), 'positiveInteger');
     $this->addRule('maxFileSize', ts('Value should be a positive number'), 'positiveInteger');
     parent::buildQuickForm();
 }
 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     $config = CRM_Core_Config::singleton();
     $i18n = CRM_Core_I18n::singleton();
     CRM_Utils_System::setTitle(ts('Settings - Localization'));
     $locales = CRM_Core_I18n::languages();
     $warningTitle = json_encode(ts("Warning"));
     $domain = new CRM_Core_DAO_Domain();
     $domain->find(TRUE);
     if ($domain->locales) {
         // for multi-lingual sites, populate default language drop-down with available languages
         $lcMessages = array();
         foreach ($locales as $loc => $lang) {
             if (substr_count($domain->locales, $loc)) {
                 $lcMessages[$loc] = $lang;
             }
         }
         $this->addElement('select', 'lcMessages', ts('Default Language'), $lcMessages);
         // add language limiter and language adder
         $this->addCheckBox('languageLimit', ts('Available Languages'), array_flip($lcMessages), NULL, NULL, NULL, NULL, ' &nbsp; ');
         $this->addElement('select', 'addLanguage', ts('Add Language'), array_merge(array('' => ts('- select -')), array_diff($locales, $lcMessages)));
         // 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 {
         // for single-lingual sites, populate default language drop-down with all languages
         $this->addElement('select', 'lcMessages', ts('Default Language'), $locales);
         $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 && !$config->logging) {
             $this->addElement('checkbox', 'makeMultilingual', ts('Enable Multiple Languages'), NULL, array('onChange' => "if (this.checked) CRM.alert({$warning}, {$warningTitle})"));
         }
     }
     $this->addElement('checkbox', 'inheritLocale', ts('Inherit CMS Language'));
     $this->addElement('text', 'monetaryThousandSeparator', ts('Thousands Separator'), array('size' => 2));
     $this->addElement('text', 'monetaryDecimalPoint', ts('Decimal Delimiter'), array('size' => 2));
     $this->addElement('text', 'moneyformat', ts('Monetary Amount Display'));
     $this->addElement('text', 'moneyvalueformat', ts('Monetary Value Display'));
     $country = array();
     CRM_Core_PseudoConstant::populate($country, 'CRM_Core_DAO_Country', TRUE, 'name', 'is_active');
     $i18n->localizeArray($country, array('context' => 'country'));
     asort($country);
     $includeCountry =& $this->addElement('advmultiselect', 'countryLimit', ts('Available Countries') . ' ', $country, array('size' => 5, 'style' => 'width:150px', 'class' => 'advmultiselect'));
     $includeCountry->setButtonAttributes('add', array('value' => ts('Add >>')));
     $includeCountry->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $includeState =& $this->addElement('advmultiselect', 'provinceLimit', ts('Available States and Provinces') . ' ', $country, array('size' => 5, 'style' => 'width:150px', 'class' => 'advmultiselect'));
     $includeState->setButtonAttributes('add', array('value' => ts('Add >>')));
     $includeState->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $this->addElement('select', 'defaultContactCountry', ts('Default Country'), array('' => ts('- select -')) + $country);
     $this->addChainSelect('defaultContactStateProvince', array('label' => ts('Default State/Province')));
     // we do this only to initialize currencySymbols, kinda hackish but works!
     $config->defaultCurrencySymbol();
     $symbol = $config->currencySymbols;
     foreach ($symbol as $key => $value) {
         $this->_currencySymbols[$key] = "{$key}";
         if ($value) {
             $this->_currencySymbols[$key] .= " ({$value})";
         }
     }
     $this->addElement('select', 'defaultCurrency', ts('Default Currency'), $this->_currencySymbols);
     $includeCurrency =& $this->addElement('advmultiselect', 'currencyLimit', ts('Available Currencies') . ' ', $this->_currencySymbols, array('size' => 5, 'style' => 'width:150px', 'class' => 'advmultiselect'));
     $includeCurrency->setButtonAttributes('add', array('value' => ts('Add >>')));
     $includeCurrency->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $this->addElement('text', 'legacyEncoding', ts('Legacy Encoding'));
     $this->addElement('text', 'customTranslateFunction', ts('Custom Translate Function'));
     $this->addElement('text', 'fieldSeparator', ts('Import / Export Field Separator'), array('size' => 2));
     $this->addFormRule(array('CRM_Admin_Form_Setting_Localization', 'formRule'));
     parent::buildQuickForm();
 }
Example #11
0
 /**
  * Determine if $currentVer can be upgraded to $latestVer
  *
  * @param $currentVer
  * @param $latestVer
  *
  * @return mixed, a string error message or boolean 'false' if OK
  */
 public function checkUpgradeableVersion($currentVer, $latestVer)
 {
     $error = FALSE;
     // since version is suppose to be in valid format at this point, especially after conversion ($convertVer),
     // lets do a pattern check -
     if (!CRM_Utils_System::isVersionFormatValid($currentVer)) {
         $error = ts('Database is marked with invalid version format. You may want to investigate this before you proceed further.');
     } elseif (version_compare($currentVer, $latestVer) > 0) {
         // DB version number is higher than codebase being upgraded to. This is unexpected condition-fatal error.
         $error = ts('Your database is marked with an unexpected version number: %1. The automated upgrade to version %2 can not be run - and the %2 codebase may not be compatible with your database state. You will need to determine the correct version corresponding to your current database state. You may want to revert to the codebase you were using prior to beginning this upgrade until you resolve this problem.', array(1 => $currentVer, 2 => $latestVer));
     } elseif (version_compare($currentVer, $latestVer) == 0) {
         $error = ts('Your database has already been upgraded to CiviCRM %1', array(1 => $latestVer));
     } elseif (version_compare($currentVer, self::MINIMUM_UPGRADABLE_VERSION) < 0) {
         $error = ts('CiviCRM versions prior to %1 cannot be upgraded directly to %2. This upgrade will need to be done in stages. First download an intermediate version (the LTS may be a good choice) and upgrade to that before proceeding to this version.', array(1 => self::MINIMUM_UPGRADABLE_VERSION, 2 => $latestVer));
     }
     if (version_compare(phpversion(), self::MINIMUM_PHP_VERSION) < 0) {
         $error = ts('CiviCRM %3 requires PHP version %1 (or newer), but the current system uses %2 ', array(1 => self::MINIMUM_PHP_VERSION, 2 => phpversion(), 3 => $latestVer));
     }
     // check for mysql trigger privileges
     if (!CRM_Core_DAO::checkTriggerViewPermission(FALSE, TRUE)) {
         $error = ts('CiviCRM %1 requires MySQL trigger privileges.', array(1 => $latestVer));
     }
     if (CRM_Core_DAO::getGlobalSetting('thread_stack', 0) < 1024 * self::MINIMUM_THREAD_STACK) {
         $error = ts('CiviCRM %1 requires MySQL thread stack >= %2k', array(1 => $latestVer, 2 => self::MINIMUM_THREAD_STACK));
     }
     return $error;
 }