/** * initialize the config variables * * @return void * @access private */ private function _initVariables() { // initialize component registry early to avoid "race" // between CRM_Core_Config and CRM_Core_Component (they // are co-dependant) require_once 'CRM/Core/Component.php'; $this->componentRegistry = new CRM_Core_Component(); // retrieve serialised settings require_once "CRM/Core/BAO/Setting.php"; $variables = array(); CRM_Core_BAO_Setting::retrieve($variables); // if settings are not available, go down the full path if (empty($variables)) { // Step 1. get system variables with their hardcoded defaults $variables = get_object_vars($this); // Step 2. get default values (with settings file overrides if // available - handled in CRM_Core_Config_Defaults) require_once 'CRM/Core/Config/Defaults.php'; CRM_Core_Config_Defaults::setValues($variables); // add component specific settings $this->componentRegistry->addConfig($this); // serialise settings CRM_Core_BAO_Setting::add($variables); } $urlArray = array('userFrameworkResourceURL', 'imageUploadURL'); $dirArray = array('uploadDir', 'customFileUploadDir'); foreach ($variables as $key => $value) { if (in_array($key, $urlArray)) { $value = CRM_Utils_File::addTrailingSlash($value, '/'); } else { if (in_array($key, $dirArray)) { $value = CRM_Utils_File::addTrailingSlash($value); if (CRM_Utils_File::createDir($value, false) === false) { // seems like we could not create the directories // settings might have changed, lets suppress a message for now // so we can make some more progress and let the user fix their settings // for now we assign it to a know value // CRM-4949 $value = $this->templateCompileDir; } } else { if ($key == 'lcMessages') { // reset the templateCompileDir to locale-specific and make sure it exists $this->templateCompileDir .= CRM_Utils_File::addTrailingSlash($value); CRM_Utils_File::createDir($this->templateCompileDir); } } } $this->{$key} = $value; } if ($this->userFrameworkResourceURL) { // we need to do this here so all blocks also load from an ssl server if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') { CRM_Utils_System::mapConfigToSSL(); } $rrb = parse_url($this->userFrameworkResourceURL); // dont use absolute path if resources are stored on a different server // CRM-4642 $this->resourceBase = $this->userFrameworkResourceURL; if (isset($_SERVER['HTTP_HOST'])) { $this->resourceBase = $rrb['host'] == $_SERVER['HTTP_HOST'] ? $rrb['path'] : $this->userFrameworkResourceURL; } } if (!$this->customFileUploadDir) { $this->customFileUploadDir = $this->uploadDir; } if ($this->mapProvider) { $this->geocodeMethod = 'CRM_Utils_Geocode_' . $this->mapProvider; } }
function main(&$args) { if ($args[1] !== 'contribute') { return; } $session =& CRM_Core_Session::singleton(); $config =& CRM_Core_Config::singleton(); if ($args[2] == 'transact') { if ($config->enableSSL && CRM_Core_Invoke::onlySSL($args)) { if (!isset($_SERVER['HTTPS'])) { CRM_Utils_System::redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); } else { CRM_Utils_System::mapConfigToSSL(); } } require_once 'CRM/Contribute/Controller/Contribution.php'; $controller =& new CRM_Contribute_Controller_Contribution($title, $mode); return $controller->run(); } elseif ($args[2] == 'search') { require_once 'CRM/Contribute/Controller/Search.php'; $controller =& new CRM_Contribute_Controller_Search($title, $mode); $url = 'civicrm/contribute/search'; $session->pushUserContext(CRM_Utils_System::url($url, 'force=1')); $controller->set('context', 'search'); return $controller->run(); } elseif ($args[2] == 'import') { require_once 'CRM/Contribute/Import/Controller.php'; $controller =& new CRM_Contribute_Import_Controller(ts('Import Contributions')); return $controller->run(); } else { if ($args[2] == 'add') { $session =& CRM_Core_Session::singleton(); $session->pushUserContext(CRM_Utils_System::url('civicrm/contribute', 'action=browse&reset=1')); require_once 'CRM/Contribute/Controller/ContributionPage.php'; $controller =& new CRM_Contribute_Controller_ContributionPage(); return $controller->run(); } else { if ($args[2] == 'contribution') { require_once 'CRM/Contribute/Page/Contribution.php'; $page =& new CRM_Contribute_Page_Contribution(); return $page->run(); } else { require_once 'CRM/Contribute/Page/DashBoard.php'; $view =& new CRM_Contribute_Page_DashBoard(ts('DashBoard')); return $view->run(); } } } }
/** * Initialize the config variables. * * @return void */ private function _initVariables() { // retrieve serialised settings $variables = array(); CRM_Core_BAO_ConfigSetting::retrieve($variables); // if settings are not available, go down the full path if (empty($variables)) { // Step 1. get system variables with their hardcoded defaults $variables = get_object_vars($this); // Step 2. get default values (with settings file overrides if // available - handled in CRM_Core_Config_Defaults) CRM_Core_Config_Defaults::setValues($variables); // retrieve directory and url preferences also CRM_Core_BAO_Setting::retrieveDirectoryAndURLPreferences($variables); // add component specific settings $this->componentRegistry->addConfig($this); // serialise settings $settings = $variables; CRM_Core_BAO_ConfigSetting::add($settings); } $urlArray = array('userFrameworkResourceURL', 'imageUploadURL'); $dirArray = array('uploadDir', 'customFileUploadDir'); foreach ($variables as $key => $value) { if (in_array($key, $urlArray)) { $value = CRM_Utils_File::addTrailingSlash($value, '/'); } elseif (in_array($key, $dirArray)) { if ($value) { $value = CRM_Utils_File::addTrailingSlash($value); } if (empty($value) || CRM_Utils_File::createDir($value, FALSE) === FALSE) { // seems like we could not create the directories // settings might have changed, lets suppress a message for now // so we can make some more progress and let the user fix their settings // for now we assign it to a know value // CRM-4949 $value = $this->templateCompileDir; $url = CRM_Utils_System::url('civicrm/admin/setting/path', 'reset=1'); CRM_Core_Session::setStatus(ts('%1 has an incorrect directory path. Please go to the <a href="%2">path setting page</a> and correct it.', array(1 => $key, 2 => $url)), ts('Check Settings'), 'alert'); } } elseif ($key == 'lcMessages') { // reset the templateCompileDir to locale-specific and make sure it exists if (substr($this->templateCompileDir, -1 * strlen($value) - 1, -1) != $value) { $this->templateCompileDir .= CRM_Utils_File::addTrailingSlash($value); CRM_Utils_File::createDir($this->templateCompileDir); CRM_Utils_File::restrictAccess($this->templateCompileDir); } } $this->{$key} = $value; } if ($this->userFrameworkResourceURL) { // we need to do this here so all blocks also load from an ssl server if (CRM_Utils_System::isSSL()) { CRM_Utils_System::mapConfigToSSL(); } $rrb = parse_url($this->userFrameworkResourceURL); // don't use absolute path if resources are stored on a different server // CRM-4642 $this->resourceBase = $this->userFrameworkResourceURL; if (isset($_SERVER['HTTP_HOST']) && isset($rrb['host'])) { $this->resourceBase = $rrb['host'] == $_SERVER['HTTP_HOST'] ? $rrb['path'] : $this->userFrameworkResourceURL; } } if (!$this->customFileUploadDir) { $this->customFileUploadDir = $this->uploadDir; } if ($this->geoProvider) { $this->geocodeMethod = 'CRM_Utils_Geocode_' . $this->geoProvider; } elseif ($this->mapProvider) { $this->geocodeMethod = 'CRM_Utils_Geocode_' . $this->mapProvider; } require_once str_replace('_', DIRECTORY_SEPARATOR, $this->userFrameworkClass) . '.php'; $class = $this->userFrameworkClass; // redundant with _setUserFrameworkConfig $this->userSystem = new $class(); }