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();
70 $size = trim(ini_get('upload_max_filesize'));
72 $last = strtolower($size{strlen($size) - 1});
74 // The 'G' modifier is available since PHP 5.1.0
83 $this->maxImportFileSize
= $size;
88 * Function to set the default values
90 * @param array $defaults associated array of form elements
91 * @param boolena $formMode this funtion is called to set default
92 * values in an empty db, also called when setting component using GUI
93 * this variable is set true for GUI
94 * mode (eg: Global setting >> Components)
99 public static function setValues(&$defaults, $formMode = FALSE) {
100 $config = CRM_Core_Config
::singleton();
102 $baseURL = $config->userFrameworkBaseURL
;
104 // CRM-6216: Drupal’s $baseURL might have a trailing LANGUAGE_NEGOTIATION_PATH,
105 // which needs to be stripped before we start basing ResourceURL on it
106 if ($config->userSystem
->is_drupal
) {
108 if (isset($language->prefix
) and $language->prefix
) {
109 if (substr($baseURL, -(strlen($language->prefix
) +
1)) == $language->prefix
. '/') {
110 $baseURL = substr($baseURL, 0, -(strlen($language->prefix
) +
1));
115 $baseCMSURL = CRM_Utils_System
::baseCMSURL();
116 if ($config->templateCompileDir
) {
117 $path = CRM_Utils_File
::baseFilePath($config->templateCompileDir
);
119 if (!isset($defaults['enableSSL'])) {
120 $defaults['enableSSL'] = 0;
122 //set defaults if not set in db
123 if (!isset($defaults['userFrameworkResourceURL'])) {
124 if ($config->userFramework
== 'Joomla') {
125 $defaults['userFrameworkResourceURL'] = $baseURL . "components/com_civicrm/civicrm/";
127 elseif ($config->userFramework
== 'WordPress') {
128 $defaults['userFrameworkResourceURL'] = $baseURL . "wp-content/plugins/civicrm/civicrm/";
132 // check and see if we are installed in sites/all (for D5 and above)
133 // we dont use checkURL since drupal generates an error page and throws
134 // the system for a loop on lobo's macosx box
136 global $civicrm_root;
137 $cmsPath = $config->userSystem
->cmsRootPath();
138 $defaults['userFrameworkResourceURL'] = $baseURL . str_replace("$cmsPath/", '',
139 str_replace('\\', '/', $civicrm_root)
142 if (strpos($civicrm_root,
143 DIRECTORY_SEPARATOR
. 'sites' .
144 DIRECTORY_SEPARATOR
. 'all' .
145 DIRECTORY_SEPARATOR
. 'modules'
147 $startPos = strpos($civicrm_root,
148 DIRECTORY_SEPARATOR
. 'sites' . DIRECTORY_SEPARATOR
150 $endPos = strpos($civicrm_root,
151 DIRECTORY_SEPARATOR
. 'modules' . DIRECTORY_SEPARATOR
153 if ($startPos && $endPos) {
154 // if component is in sites/SITENAME/modules
155 $siteName = substr($civicrm_root,
157 $endPos - $startPos - 7
160 $civicrmDirName = trim(basename($civicrm_root));
161 $defaults['userFrameworkResourceURL'] = $baseURL . "sites/$siteName/modules/$civicrmDirName/";
162 if (!isset($defaults['imageUploadURL'])) {
163 $defaults['imageUploadURL'] = $baseURL . "sites/$siteName/files/civicrm/persist/contribute/";
170 if (!isset($defaults['imageUploadURL'])) {
171 if ($config->userFramework
== 'Joomla') {
173 // we need to remove the administrator/ from the end
174 $tempURL = str_replace("/administrator/", "/", $baseURL);
175 $defaults['imageUploadURL'] = $tempURL . "media/civicrm/persist/contribute/";
177 elseif ($config->userFramework
== 'WordPress') {
178 //for standalone no need of sites/defaults directory
179 $defaults['imageUploadURL'] = $baseURL . "wp-content/plugins/files/civicrm/persist/contribute/";
182 $defaults['imageUploadURL'] = $baseURL . "sites/default/files/civicrm/persist/contribute/";
186 if (!isset($defaults['imageUploadDir']) && is_dir($config->templateCompileDir
)) {
187 $imgDir = $path . "persist/contribute/";
189 CRM_Utils_File
::createDir($imgDir);
190 $defaults['imageUploadDir'] = $imgDir;
193 if (!isset($defaults['uploadDir']) && is_dir($config->templateCompileDir
)) {
194 $uploadDir = $path . "upload/";
196 CRM_Utils_File
::createDir($uploadDir);
197 CRM_Utils_File
::restrictAccess($uploadDir);
198 $defaults['uploadDir'] = $uploadDir;
201 if (!isset($defaults['customFileUploadDir']) && is_dir($config->templateCompileDir
)) {
202 $customDir = $path . "custom/";
204 CRM_Utils_File
::createDir($customDir);
205 $defaults['customFileUploadDir'] = $customDir;
208 /* FIXME: hack to bypass the step for generating defaults for components,
209 while running upgrade, to avoid any serious non-recoverable error
210 which might hinder the upgrade process. */
214 if (isset($_GET[$config->userFrameworkURLVar
])) {
215 $args = explode('/', $_GET[$config->userFrameworkURLVar
]);
218 if (isset($defaults['enableComponents'])) {
219 foreach ($defaults['enableComponents'] as $key => $name) {
220 $comp = $config->componentRegistry
->get($name);
222 $co = $comp->getConfigObject();
223 $co->setDefaults($defaults);