smartyDir = $civicrm_root . DIRECTORY_SEPARATOR . 'packages' . DIRECTORY_SEPARATOR . 'Smarty' . DIRECTORY_SEPARATOR; $this->pluginsDir = $civicrm_root . DIRECTORY_SEPARATOR . 'CRM' . DIRECTORY_SEPARATOR . 'Core' . DIRECTORY_SEPARATOR . 'Smarty' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR; $this->templateDir = array( $civicrm_root . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR, ); $this->sqlDir = $civicrm_root . DIRECTORY_SEPARATOR . 'sql' . DIRECTORY_SEPARATOR; $this->importDataSourceDir = $civicrm_root . DIRECTORY_SEPARATOR . 'CRM' . DIRECTORY_SEPARATOR . 'Import' . DIRECTORY_SEPARATOR . 'DataSource' . DIRECTORY_SEPARATOR; $this->gettextResourceDir = $civicrm_root . DIRECTORY_SEPARATOR . 'l10n' . DIRECTORY_SEPARATOR; // show tree widget $this->groupTree = defined('CIVICRM_GROUPTREE') ? TRUE : FALSE; // add UI revamp pages //$this->revampPages = array( 'CRM/Admin/Form/Setting/Url.tpl', 'CRM/Admin/Form/Preferences/Address.tpl' ); $this->revampPages = array(); $size = trim(ini_get('upload_max_filesize')); if ($size) { $this->maxImportFileSize = self::formatUnitSize($size); } } /** * Format size. * */ public static function formatUnitSize($size, $checkForPostMax = FALSE) { if ($size) { $last = strtolower($size{strlen($size) - 1}); switch ($last) { // The 'G' modifier is available since PHP 5.1.0 case 'g': $size *= 1024; case 'm': $size *= 1024; case 'k': $size *= 1024; } if ($checkForPostMax) { $maxImportFileSize = self::formatUnitSize(ini_get('upload_max_filesize')); $postMaxSize = self::formatUnitSize(ini_get('post_max_size')); if ($maxImportFileSize > $postMaxSize && $postMaxSize == $size) { CRM_Core_Session::setStatus(ts("Note: Upload max filesize ('upload_max_filesize') should not exceed Post max size ('post_max_size') as defined in PHP.ini, please check with your system administrator."), ts("Warning"), "alert"); } //respect php.ini upload_max_filesize if ($size > $maxImportFileSize && $size !== $postMaxSize) { $size = $maxImportFileSize; CRM_Core_Session::setStatus(ts("Note: Please verify your configuration for Maximum File Size (in MB) Administrator >> System Settings >> Misc. It should support 'upload_max_size' as defined in PHP.ini.Please check with your system administrator.", array(1 => CRM_Utils_System::url('civicrm/admin/setting/misc', 'reset=1'))), ts("Warning"), "alert"); } } return $size; } } /** * Set the default values. * in an empty db, also called when setting component using GUI * * @param array $defaults * Associated array of form elements. * @param bool $formMode * this variable is set true for GUI * mode (eg: Global setting >> Components) * */ public static function setValues(&$defaults, $formMode = FALSE) { $config = CRM_Core_Config::singleton(); $baseURL = $config->userFrameworkBaseURL; // CRM-6216: Drupal’s $baseURL might have a trailing LANGUAGE_NEGOTIATION_PATH, // which needs to be stripped before we start basing ResourceURL on it if ($config->userSystem->is_drupal) { global $language; if (isset($language->prefix) and $language->prefix) { if (substr($baseURL, -(strlen($language->prefix) + 1)) == $language->prefix . '/') { $baseURL = substr($baseURL, 0, -(strlen($language->prefix) + 1)); } } } $baseCMSURL = CRM_Utils_System::baseCMSURL(); if ($config->templateCompileDir) { $path = CRM_Utils_File::baseFilePath($config->templateCompileDir); } if (!isset($defaults['enableSSL'])) { $defaults['enableSSL'] = 0; } //set defaults if not set in db if (!isset($defaults['userFrameworkResourceURL'])) { if ($config->userFramework == 'Joomla') { $defaults['userFrameworkResourceURL'] = $baseURL . "components/com_civicrm/civicrm/"; } elseif ($config->userFramework == 'WordPress') { if (defined('CIVICRM_PLUGIN_URL')) { $defaults['userFrameworkResourceURL'] = CIVICRM_PLUGIN_URL . "civicrm/"; } else { $defaults['userFrameworkResourceURL'] = $baseURL . "wp-content/plugins/civicrm/civicrm/"; } } else { // Drupal setting // check and see if we are installed in sites/all (for D5 and above) // we dont use checkURL since drupal generates an error page and throws // the system for a loop on lobo's macosx box // or in modules global $civicrm_root; $cmsPath = $config->userSystem->cmsRootPath(); $defaults['userFrameworkResourceURL'] = $baseURL . str_replace("$cmsPath/", '', str_replace('\\', '/', $civicrm_root) ); if (strpos($civicrm_root, DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . 'all' . DIRECTORY_SEPARATOR . 'modules' ) === FALSE ) { $startPos = strpos($civicrm_root, DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR ); $endPos = strpos($civicrm_root, DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR ); if ($startPos && $endPos) { // if component is in sites/SITENAME/modules $siteName = substr($civicrm_root, $startPos + 7, $endPos - $startPos - 7 ); $civicrmDirName = trim(basename($civicrm_root)); $defaults['userFrameworkResourceURL'] = $baseURL . "sites/$siteName/modules/$civicrmDirName/"; if (!isset($defaults['imageUploadURL'])) { $defaults['imageUploadURL'] = $baseURL . "sites/$siteName/files/civicrm/persist/contribute/"; } } } } } if (!isset($defaults['imageUploadURL'])) { if ($config->userFramework == 'Joomla') { // gross hack // we need to remove the administrator/ from the end $tempURL = str_replace("/administrator/", "/", $baseURL); $defaults['imageUploadURL'] = $tempURL . "media/civicrm/persist/contribute/"; } elseif ($config->userFramework == 'WordPress') { //for standalone no need of sites/defaults directory if (defined('CIVICRM_PLUGIN_DIR')) { // CIVICRM_PLUGIN_DIR points to: wp-content/plugins/civicrm/ or similar (with trailing '/') $defaults['imageUploadURL'] = str_replace('civicrm', 'files/civicrm', CIVICRM_PLUGIN_DIR) . 'persist/contribute/'; } else { $defaults['imageUploadURL'] = $baseURL . "wp-content/plugins/files/civicrm/persist/contribute/"; } } else { $defaults['imageUploadURL'] = $baseURL . "sites/default/files/civicrm/persist/contribute/"; } } if (!isset($defaults['imageUploadDir']) && is_dir($config->templateCompileDir)) { $imgDir = $path . "persist/contribute/"; CRM_Utils_File::createDir($imgDir); $defaults['imageUploadDir'] = $imgDir; } if (!isset($defaults['uploadDir']) && is_dir($config->templateCompileDir)) { $uploadDir = $path . "upload/"; CRM_Utils_File::createDir($uploadDir); CRM_Utils_File::restrictAccess($uploadDir); $defaults['uploadDir'] = $uploadDir; } if (!isset($defaults['customFileUploadDir']) && is_dir($config->templateCompileDir)) { $customDir = $path . "custom/"; CRM_Utils_File::createDir($customDir); CRM_Utils_File::restrictAccess($customDir); $defaults['customFileUploadDir'] = $customDir; } // FIXME: hack to bypass the step for generating defaults for components, // while running upgrade, to avoid any serious non-recoverable error // which might hinder the upgrade process. $args = array(); if (isset($_GET[$config->userFrameworkURLVar])) { $args = explode('/', $_GET[$config->userFrameworkURLVar]); } if (isset($defaults['enableComponents'])) { foreach ($defaults['enableComponents'] as $key => $name) { $comp = $config->componentRegistry->get($name); if ($comp) { $co = $comp->getConfigObject(); $co->setDefaults($defaults); } } } } }