3bd63b2479568335d6961952bcc00efd3adaf674
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
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
{
45 function setCoreVariables() {
48 // set of base directories relying on $civicrm_root
49 $this->smartyDir
= $civicrm_root . DIRECTORY_SEPARATOR
. 'packages' . DIRECTORY_SEPARATOR
. 'Smarty' . DIRECTORY_SEPARATOR
;
51 $this->pluginsDir
= $civicrm_root . DIRECTORY_SEPARATOR
. 'CRM' . DIRECTORY_SEPARATOR
. 'Core' . DIRECTORY_SEPARATOR
. 'Smarty' . DIRECTORY_SEPARATOR
. 'plugins' . DIRECTORY_SEPARATOR
;
53 $this->templateDir
= array(
54 $civicrm_root . DIRECTORY_SEPARATOR
.
55 'templates' . DIRECTORY_SEPARATOR
,
58 $this->sqlDir
= $civicrm_root . DIRECTORY_SEPARATOR
. 'sql' . DIRECTORY_SEPARATOR
;
60 $this->importDataSourceDir
= $civicrm_root . DIRECTORY_SEPARATOR
. 'CRM' . DIRECTORY_SEPARATOR
. 'Import' . DIRECTORY_SEPARATOR
. 'DataSource' . DIRECTORY_SEPARATOR
;
62 $this->gettextResourceDir
= $civicrm_root . DIRECTORY_SEPARATOR
. 'l10n' . DIRECTORY_SEPARATOR
;
65 $this->groupTree
= defined('CIVICRM_GROUPTREE') ?
TRUE : FALSE;
67 // add UI revamp pages
68 //$this->revampPages = array( 'CRM/Admin/Form/Setting/Url.tpl', 'CRM/Admin/Form/Preferences/Address.tpl' );
69 $this->revampPages
= array();
71 $size = trim(ini_get('upload_max_filesize'));
73 $last = strtolower($size{strlen($size) - 1});
75 // The 'G' modifier is available since PHP 5.1.0
84 $this->maxImportFileSize
= $size;
89 * Function to set the default values
91 * @param array $defaults associated array of form elements
92 * @param boolena $formMode this funtion is called to set default
93 * values in an empty db, also called when setting component using GUI
94 * this variable is set true for GUI
95 * mode (eg: Global setting >> Components)
100 public static function setValues(&$defaults, $formMode = FALSE) {
101 $config = CRM_Core_Config
::singleton();
103 $baseURL = $config->userFrameworkBaseURL
;
105 // CRM-6216: Drupal’s $baseURL might have a trailing LANGUAGE_NEGOTIATION_PATH,
106 // which needs to be stripped before we start basing ResourceURL on it
107 if ($config->userSystem
->is_drupal
) {
109 if (isset($language->prefix
) and $language->prefix
) {
110 if (substr($baseURL, -(strlen($language->prefix
) +
1)) == $language->prefix
. '/') {
111 $baseURL = substr($baseURL, 0, -(strlen($language->prefix
) +
1));
116 $baseCMSURL = CRM_Utils_System
::baseCMSURL();
117 if ($config->templateCompileDir
) {
118 $path = CRM_Utils_File
::baseFilePath($config->templateCompileDir
);
120 if (!isset($defaults['enableSSL'])) {
121 $defaults['enableSSL'] = 0;
123 //set defaults if not set in db
124 if (!isset($defaults['userFrameworkResourceURL'])) {
125 if ($config->userFramework
== 'Joomla') {
126 $defaults['userFrameworkResourceURL'] = $baseURL . "components/com_civicrm/civicrm/";
128 elseif ($config->userFramework
== 'WordPress') {
129 $defaults['userFrameworkResourceURL'] = $baseURL . "wp-content/plugins/civicrm/civicrm/";
133 // check and see if we are installed in sites/all (for D5 and above)
134 // we dont use checkURL since drupal generates an error page and throws
135 // the system for a loop on lobo's macosx box
137 global $civicrm_root;
138 $cmsPath = $config->userSystem
->cmsRootPath();
139 $defaults['userFrameworkResourceURL'] = $baseURL . str_replace("$cmsPath/", '',
140 str_replace('\\', '/', $civicrm_root)
143 if (strpos($civicrm_root,
144 DIRECTORY_SEPARATOR
. 'sites' .
145 DIRECTORY_SEPARATOR
. 'all' .
146 DIRECTORY_SEPARATOR
. 'modules'
148 $startPos = strpos($civicrm_root,
149 DIRECTORY_SEPARATOR
. 'sites' . DIRECTORY_SEPARATOR
151 $endPos = strpos($civicrm_root,
152 DIRECTORY_SEPARATOR
. 'modules' . DIRECTORY_SEPARATOR
154 if ($startPos && $endPos) {
155 // if component is in sites/SITENAME/modules
156 $siteName = substr($civicrm_root,
158 $endPos - $startPos - 7
161 $civicrmDirName = trim(basename($civicrm_root));
162 $defaults['userFrameworkResourceURL'] = $baseURL . "sites/$siteName/modules/$civicrmDirName/";
163 if (!isset($defaults['imageUploadURL'])) {
164 $defaults['imageUploadURL'] = $baseURL . "sites/$siteName/files/civicrm/persist/contribute/";
171 if (!isset($defaults['imageUploadURL'])) {
172 if ($config->userFramework
== 'Joomla') {
174 // we need to remove the administrator/ from the end
175 $tempURL = str_replace("/administrator/", "/", $baseURL);
176 $defaults['imageUploadURL'] = $tempURL . "media/civicrm/persist/contribute/";
178 elseif ($config->userFramework
== 'WordPress') {
179 //for standalone no need of sites/defaults directory
180 $defaults['imageUploadURL'] = $baseURL . "wp-content/plugins/files/civicrm/persist/contribute/";
183 $defaults['imageUploadURL'] = $baseURL . "sites/default/files/civicrm/persist/contribute/";
187 if (!isset($defaults['imageUploadDir']) && is_dir($config->templateCompileDir
)) {
188 $imgDir = $path . "persist/contribute/";
190 CRM_Utils_File
::createDir($imgDir);
191 $defaults['imageUploadDir'] = $imgDir;
194 if (!isset($defaults['uploadDir']) && is_dir($config->templateCompileDir
)) {
195 $uploadDir = $path . "upload/";
197 CRM_Utils_File
::createDir($uploadDir);
198 CRM_Utils_File
::restrictAccess($uploadDir);
199 $defaults['uploadDir'] = $uploadDir;
202 if (!isset($defaults['customFileUploadDir']) && is_dir($config->templateCompileDir
)) {
203 $customDir = $path . "custom/";
205 CRM_Utils_File
::createDir($customDir);
206 $defaults['customFileUploadDir'] = $customDir;
209 /* FIXME: hack to bypass the step for generating defaults for components,
210 while running upgrade, to avoid any serious non-recoverable error
211 which might hinder the upgrade process. */
215 if (isset($_GET[$config->userFrameworkURLVar
])) {
216 $args = explode('/', $_GET[$config->userFrameworkURLVar
]);
219 if (isset($defaults['enableComponents'])) {
220 foreach ($defaults['enableComponents'] as $key => $name) {
221 $comp = $config->componentRegistry
->get($name);
223 $co = $comp->getConfigObject();
224 $co->setDefaults($defaults);