3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2013
37 * This class is a temporary place to store default setting values
38 * before they will be distributed in proper places (component configurations
39 * and core configuration). The name is intentionally stupid so that it will be fixed
43 class CRM_Core_Config_Defaults
{
44 function setCoreVariables() {
47 // set of base directories relying on $civicrm_root
48 $this->smartyDir
= $civicrm_root . DIRECTORY_SEPARATOR
. 'packages' . DIRECTORY_SEPARATOR
. 'Smarty' . DIRECTORY_SEPARATOR
;
50 $this->pluginsDir
= $civicrm_root . DIRECTORY_SEPARATOR
. 'CRM' . DIRECTORY_SEPARATOR
. 'Core' . DIRECTORY_SEPARATOR
. 'Smarty' . DIRECTORY_SEPARATOR
. 'plugins' . DIRECTORY_SEPARATOR
;
52 $this->templateDir
= array(
53 $civicrm_root . DIRECTORY_SEPARATOR
.
54 'templates' . DIRECTORY_SEPARATOR
,
57 $this->sqlDir
= $civicrm_root . DIRECTORY_SEPARATOR
. 'sql' . DIRECTORY_SEPARATOR
;
59 $this->importDataSourceDir
= $civicrm_root . DIRECTORY_SEPARATOR
. 'CRM' . DIRECTORY_SEPARATOR
. 'Import' . DIRECTORY_SEPARATOR
. 'DataSource' . DIRECTORY_SEPARATOR
;
61 $this->gettextResourceDir
= $civicrm_root . DIRECTORY_SEPARATOR
. 'l10n' . DIRECTORY_SEPARATOR
;
64 $this->groupTree
= defined('CIVICRM_GROUPTREE') ?
TRUE : FALSE;
66 // add UI revamp pages
67 //$this->revampPages = array( 'CRM/Admin/Form/Setting/Url.tpl', 'CRM/Admin/Form/Preferences/Address.tpl' );
68 $this->revampPages
= array();
71 $this->useIDS
= defined('CIVICRM_IDS_ENABLE') ?
(bool) CIVICRM_IDS_ENABLE
: TRUE;
74 $size = trim(ini_get('upload_max_filesize'));
76 $last = strtolower($size{strlen($size) - 1});
78 // The 'G' modifier is available since PHP 5.1.0
87 $this->maxImportFileSize
= $size;
92 * Function to set the default values
94 * @param array $defaults associated array of form elements
95 * @param boolena $formMode this funtion is called to set default
96 * values in an empty db, also called when setting component using GUI
97 * this variable is set true for GUI
98 * mode (eg: Global setting >> Components)
103 public static function setValues(&$defaults, $formMode = FALSE) {
104 $config = CRM_Core_Config
::singleton();
106 $baseURL = $config->userFrameworkBaseURL
;
108 // CRM-6216: Drupal’s $baseURL might have a trailing LANGUAGE_NEGOTIATION_PATH,
109 // which needs to be stripped before we start basing ResourceURL on it
110 if ($config->userSystem
->is_drupal
) {
112 if (isset($language->prefix
) and $language->prefix
) {
113 if (substr($baseURL, -(strlen($language->prefix
) +
1)) == $language->prefix
. '/') {
114 $baseURL = substr($baseURL, 0, -(strlen($language->prefix
) +
1));
119 $baseCMSURL = CRM_Utils_System
::baseCMSURL();
120 if ($config->templateCompileDir
) {
121 $path = CRM_Utils_File
::baseFilePath($config->templateCompileDir
);
123 if (!isset($defaults['enableSSL'])) {
124 $defaults['enableSSL'] = 0;
126 //set defaults if not set in db
127 if (!isset($defaults['userFrameworkResourceURL'])) {
128 if ($config->userFramework
== 'Joomla') {
129 $defaults['userFrameworkResourceURL'] = $baseURL . "components/com_civicrm/civicrm/";
131 elseif ($config->userFramework
== 'WordPress') {
132 $defaults['userFrameworkResourceURL'] = $baseURL . "wp-content/plugins/civicrm/civicrm/";
136 // check and see if we are installed in sites/all (for D5 and above)
137 // we dont use checkURL since drupal generates an error page and throws
138 // the system for a loop on lobo's macosx box
140 global $civicrm_root;
141 $cmsPath = $config->userSystem
->cmsRootPath();
142 $defaults['userFrameworkResourceURL'] = $baseURL . str_replace("$cmsPath/", '',
143 str_replace('\\', '/', $civicrm_root)
146 if (strpos($civicrm_root,
147 DIRECTORY_SEPARATOR
. 'sites' .
148 DIRECTORY_SEPARATOR
. 'all' .
149 DIRECTORY_SEPARATOR
. 'modules'
151 $startPos = strpos($civicrm_root,
152 DIRECTORY_SEPARATOR
. 'sites' . DIRECTORY_SEPARATOR
154 $endPos = strpos($civicrm_root,
155 DIRECTORY_SEPARATOR
. 'modules' . DIRECTORY_SEPARATOR
157 if ($startPos && $endPos) {
158 // if component is in sites/SITENAME/modules
159 $siteName = substr($civicrm_root,
161 $endPos - $startPos - 7
164 $civicrmDirName = trim(basename($civicrm_root));
165 $defaults['userFrameworkResourceURL'] = $baseURL . "sites/$siteName/modules/$civicrmDirName/";
166 if (!isset($defaults['imageUploadURL'])) {
167 $defaults['imageUploadURL'] = $baseURL . "sites/$siteName/files/civicrm/persist/contribute/";
174 if (!isset($defaults['imageUploadURL'])) {
175 if ($config->userFramework
== 'Joomla') {
177 // we need to remove the administrator/ from the end
178 $tempURL = str_replace("/administrator/", "/", $baseURL);
179 $defaults['imageUploadURL'] = $tempURL . "media/civicrm/persist/contribute/";
181 elseif ($config->userFramework
== 'WordPress') {
182 //for standalone no need of sites/defaults directory
183 $defaults['imageUploadURL'] = $baseURL . "wp-content/plugins/files/civicrm/persist/contribute/";
186 $defaults['imageUploadURL'] = $baseURL . "sites/default/files/civicrm/persist/contribute/";
190 if (!isset($defaults['imageUploadDir']) && is_dir($config->templateCompileDir
)) {
191 $imgDir = $path . "persist/contribute/";
193 CRM_Utils_File
::createDir($imgDir);
194 $defaults['imageUploadDir'] = $imgDir;
197 if (!isset($defaults['uploadDir']) && is_dir($config->templateCompileDir
)) {
198 $uploadDir = $path . "upload/";
200 CRM_Utils_File
::createDir($uploadDir);
201 CRM_Utils_File
::restrictAccess($uploadDir);
202 $defaults['uploadDir'] = $uploadDir;
205 if (!isset($defaults['customFileUploadDir']) && is_dir($config->templateCompileDir
)) {
206 $customDir = $path . "custom/";
208 CRM_Utils_File
::createDir($customDir);
209 $defaults['customFileUploadDir'] = $customDir;
212 /* FIXME: hack to bypass the step for generating defaults for components,
213 while running upgrade, to avoid any serious non-recoverable error
214 which might hinder the upgrade process. */
218 if (isset($_GET[$config->userFrameworkURLVar
])) {
219 $args = explode('/', $_GET[$config->userFrameworkURLVar
]);
222 if (isset($defaults['enableComponents'])) {
223 foreach ($defaults['enableComponents'] as $key => $name) {
224 $comp = $config->componentRegistry
->get($name);
226 $co = $comp->getConfigObject();
227 $co->setDefaults($defaults);