3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * This class generates form components for Site Url.
21 class CRM_Admin_Form_Setting_Url
extends CRM_Admin_Form_Setting
{
22 protected $_settings = [
23 'disable_core_css' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
24 'defaultExternUrl' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
25 'userFrameworkResourceURL' => CRM_Core_BAO_Setting
::URL_PREFERENCES_NAME
,
26 'imageUploadURL' => CRM_Core_BAO_Setting
::URL_PREFERENCES_NAME
,
27 'customCSSURL' => CRM_Core_BAO_Setting
::URL_PREFERENCES_NAME
,
28 'extensionsURL' => CRM_Core_BAO_Setting
::URL_PREFERENCES_NAME
,
32 * Build the form object.
34 public function buildQuickForm() {
35 $this->setTitle(ts('Settings - Resource URLs'));
36 $settingFields = civicrm_api('setting', 'getfields', [
40 $this->addYesNo('enableSSL', ts('Force Secure URLs (SSL)'));
41 $this->addYesNo('verifySSL', ts('Verify SSL Certs'));
42 // FIXME: verifySSL should use $_settings instead of manually adding fields
43 $this->assign('verifySSL_description', $settingFields['values']['verifySSL']['description']);
45 $this->addFormRule(['CRM_Admin_Form_Setting_Url', 'formRule']);
47 parent
::buildQuickForm();
51 * @param array $fields
55 public static function formRule($fields) {
56 if (isset($fields['enableSSL']) &&
59 $config = CRM_Core_Config
::singleton();
60 $url = str_replace('http://', 'https://',
61 CRM_Utils_System
::url('civicrm/dashboard', 'reset=1', TRUE,
65 if (!CRM_Utils_System
::checkURL($url, TRUE)) {
67 'enableSSL' => ts('You need to set up a secure server before you can use the Force Secure URLs option'),
75 public function postProcess() {
76 // if extensions url is set, lets clear session status messages to avoid
77 // a potentially spurious message which might already have been set. This
80 $session = CRM_Core_Session
::singleton();
81 $session->getStatus(TRUE);
83 parent
::postProcess();