From 94c11eeb52fb3d28f2d662699797de0b12304e29 Mon Sep 17 00:00:00 2001 From: "Donald A. Lobo" Date: Wed, 29 May 2013 08:07:42 -0700 Subject: [PATCH] CRM-10682 - move wpBasePage to setting object, cache in config ---------------------------------------- * CRM-10682: Let frontend WordPress pages use template other than home page http://issues.civicrm.org/jira/browse/CRM-10682 --- CRM/Admin/Form/Setting.php | 2 +- CRM/Admin/Form/Setting/Miscellaneous.php | 35 ++++++++++++------- CRM/Admin/Form/Setting/UF.php | 28 ++++++++------- settings/Core.setting.php | 16 +++++++++ templates/CRM/Admin/Form/Setting/UF.tpl | 2 +- templates/CRM/common/civicrm.settings.php.tpl | 7 ---- 6 files changed, 56 insertions(+), 34 deletions(-) diff --git a/CRM/Admin/Form/Setting.php b/CRM/Admin/Form/Setting.php index 16b9db876b..80ea92057d 100644 --- a/CRM/Admin/Form/Setting.php +++ b/CRM/Admin/Form/Setting.php @@ -50,7 +50,7 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form { * * @return None */ - function setDefaultValues() { + function setDefaultValues() { if (!$this->_defaults) { $this->_defaults = array(); $formArray = array('Component', 'Localization'); diff --git a/CRM/Admin/Form/Setting/Miscellaneous.php b/CRM/Admin/Form/Setting/Miscellaneous.php index c5448037ca..5628c1f2e6 100644 --- a/CRM/Admin/Form/Setting/Miscellaneous.php +++ b/CRM/Admin/Form/Setting/Miscellaneous.php @@ -63,30 +63,37 @@ class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting { // 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; + $attribs = $domain->locales || !$validTriggerPermission ? + array('disabled' => 'disabled') : NULL; $this->assign('validTriggerPermission', $validTriggerPermission); $this->addYesNo('logging', ts('Logging'), NULL, NULL, $attribs); - $this->addElement('text', 'wkhtmltopdfPath', ts('Path to wkhtmltopdf executable'), + $this->addElement( + 'text', + 'wkhtmltopdfPath', ts('Path to wkhtmltopdf executable'), array('size' => 64, 'maxlength' => 256) ); - $this->addElement('text', 'recaptchaPublicKey', ts('Public Key'), + $this->addElement( + 'text', 'recaptchaPublicKey', ts('Public Key'), array('size' => 64, 'maxlength' => 64) ); - $this->addElement('text', 'recaptchaPrivateKey', ts('Private Key'), + $this->addElement( + 'text', 'recaptchaPrivateKey', ts('Private Key'), array('size' => 64, 'maxlength' => 64) ); - $this->addElement('text', 'dashboardCacheTimeout', ts('Dashboard cache timeout'), + $this->addElement( + 'text', 'dashboardCacheTimeout', ts('Dashboard cache timeout'), array('size' => 3, 'maxlength' => 5) ); - $this->addElement('text', 'checksumTimeout', ts('CheckSum Lifespan'), + $this->addElement( + 'text', 'checksumTimeout', ts('CheckSum Lifespan'), array('size' => 2, 'maxlength' => 8) ); - $this->addElement('text', 'recaptchaOptions', ts('Recaptcha Options'), + $this->addElement( + 'text', 'recaptchaOptions', ts('Recaptcha Options'), array('size' => 64, 'maxlength' => 64) ); @@ -98,11 +105,13 @@ class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting { function setDefaultValues() { parent::setDefaultValues(); - $this->_defaults['checksumTimeout'] = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, - 'checksum_timeout', - NULL, - 7 - ); + $this->_defaults['checksumTimeout'] = + CRM_Core_BAO_Setting::getItem( + CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, + 'checksum_timeout', + NULL, + 7 + ); return $this->_defaults; } diff --git a/CRM/Admin/Form/Setting/UF.php b/CRM/Admin/Form/Setting/UF.php index 3b85de3ccd..9c598d1fe2 100644 --- a/CRM/Admin/Form/Setting/UF.php +++ b/CRM/Admin/Form/Setting/UF.php @@ -39,6 +39,10 @@ */ class CRM_Admin_Form_Setting_UF extends CRM_Admin_Form_Setting { + protected $_settings = array(); + + protected $_uf = null; + /** * Function to build the form * @@ -47,31 +51,31 @@ class CRM_Admin_Form_Setting_UF extends CRM_Admin_Form_Setting { */ public function buildQuickForm() { $config = CRM_Core_Config::singleton(); - $uf = $config->userFramework; + $this->_uf = $config->userFramework; - CRM_Utils_System::setTitle(ts('Settings - %1 Integration', - array(1 => $uf) - )); + if ($this->_uf == 'WordPress') { + $this->_settings = array('wpBasePage' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME); + } - $this->addElement('text', 'userFrameworkUsersTableName', ts('%1 Users Table Name', array(1 => $uf))); - if (function_exists('module_exists') && + CRM_Utils_System::setTitle( + ts('Settings - %1 Integration', array(1 => $this->_uf)) + ); + + $this->addElement('text', 'userFrameworkUsersTableName', ts('%1 Users Table Name', array(1 => $this->_uf))); + if ( + function_exists('module_exists') && module_exists('views') && $config->dsn != $config->userFrameworkDSN ) { $dsnArray = DB::parseDSN($config->dsn); $tableNames = CRM_Core_DAO::GetStorageValues(NULL, 0, 'Name'); - $tablePrefixes = '$databases[\'default\'][\'default\'][\'prefix\']= array( - '; + $tablePrefixes = '$databases[\'default\'][\'default\'][\'prefix\']= array('; foreach ($tableNames as $tableName => $value) { $tablePrefixes .= "\n '" . str_pad($tableName . "'", 41) . " => '`{$dsnArray['database']}`.',"; } $tablePrefixes .= "\n);"; $this->assign('tablePrefixes', $tablePrefixes); } - - if ($uf == 'WordPress') { - $this->addElement('text', 'wpBasePage', ts('WordPress Base Page')); - } parent::buildQuickForm(); } diff --git a/settings/Core.setting.php b/settings/Core.setting.php index d8f06a2765..057e11e8be 100644 --- a/settings/Core.setting.php +++ b/settings/Core.setting.php @@ -562,4 +562,20 @@ When enabled, statistics about your CiviCRM installation are reported anonymousl 'description' => 'If disabled, backend HTTPS services will allow unverified, insecure connections', 'help_text' => 'Unless you are absolutely unable to configure your server to check the SSL certificate of the remote server you should leave this set to Yes', ), + 'wpBasePage' => array( + 'group_name' => 'CiviCRM Preferences', + 'group' => 'core', + 'name' => 'wpBasePage', + 'type' => 'String', + 'html_type' => 'text', + 'quick_form_type' => 'Element', + 'prefetch' => 1, + 'default' => '', + 'add' => '4.3', + 'title' => 'WordPress Base Page', + 'is_domain' => 1, + 'is_contact' => 0, + 'description' => 'If set, CiviCRM will use this setting as the base url.', + 'help_text' => 'By default, CiviCRM will generate front-facing pages using the home page at http://wp/ as its base. If you want to use a different template for CiviCRM pages, set the path here.', + ), ); diff --git a/templates/CRM/Admin/Form/Setting/UF.tpl b/templates/CRM/Admin/Form/Setting/UF.tpl index 8433689c2d..4540fc844f 100644 --- a/templates/CRM/Admin/Form/Setting/UF.tpl +++ b/templates/CRM/Admin/Form/Setting/UF.tpl @@ -37,7 +37,7 @@ {$form.wpBasePage.label} {$config->userFrameworkBaseURL}{$form.wpBasePage.html} -

{ts 1=$config->userFrameworkBaseURL}By default, CiviCRM will generate front-facing pages using the home page at %1 as its base. If you want to use a different template for CiviCRM pages, set the path here.{/ts}

+

{ts 1=$config->userFrameworkBaseURL}By default, CiviCRM will generate front-facing pages using the home page at %1 as its base. If you want to use a different template for CiviCRM pages, set the path here.{/ts}

{/if} diff --git a/templates/CRM/common/civicrm.settings.php.tpl b/templates/CRM/common/civicrm.settings.php.tpl index dd57f443eb..2f456ffb4d 100644 --- a/templates/CRM/common/civicrm.settings.php.tpl +++ b/templates/CRM/common/civicrm.settings.php.tpl @@ -192,13 +192,6 @@ define( 'CIVICRM_MAIL_SMARTY', 0 ); define( 'CIVICRM_DOMAIN_ID' , 1 ); -/** - * For Wordpress users if your public pages are using a different template than the home page - * you should set the name of the template with the below constant - * This will be moved to a DB setting in a future version, check CRM-10682 - */ -// define( 'CIVICRM_UF_WP_BASEPAGE', 'YOUR TEMPLATE NAME HERE'); - /** * Settings to enable external caching using a Memcache server. This is an * advanced feature, and you should read and understand the documentation -- 2.25.1