コード例 #1
0
ファイル: DataSource.php プロジェクト: kidaa30/yes
 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     //Setting Upload File Size
     $config = CRM_Core_Config::singleton();
     $uploadFileSize = CRM_Core_Config_Defaults::formatUnitSize($config->maxFileSize . 'm', TRUE);
     $uploadSize = round($uploadFileSize / (1024 * 1024), 2);
     $this->assign('uploadSize', $uploadSize);
     $this->setMaxFileSize($uploadFileSize);
     $this->add('File', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=255', TRUE);
     $this->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', array(1 => $uploadSize, 2 => $uploadFileSize)), 'maxfilesize', $uploadFileSize);
     $this->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile');
     $this->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File');
     $this->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers'));
     $duplicateOptions = array();
     $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Skip'), CRM_Import_Parser::DUPLICATE_SKIP);
     $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Update'), CRM_Import_Parser::DUPLICATE_UPDATE);
     $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Fill'), CRM_Import_Parser::DUPLICATE_FILL);
     $this->addGroup($duplicateOptions, 'onDuplicate', ts('On duplicate entries'));
     //get the saved mapping details
     $mappingArray = CRM_Core_BAO_Mapping::getMappings(CRM_Core_OptionGroup::getValue('mapping_type', 'Import Activity', 'name'));
     $this->assign('savedMapping', $mappingArray);
     $this->add('select', 'savedMapping', ts('Mapping Option'), array('' => ts('- select -')) + $mappingArray);
     if ($loadeMapping = $this->get('loadedMapping')) {
         $this->assign('loadedMapping', $loadeMapping);
         $this->setDefaults(array('savedMapping' => $loadeMapping));
     }
     $this->setDefaults(array('onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP));
     //build date formats
     CRM_Core_Form_Date::buildAllowedDateFormats($this);
     $this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue'), 'spacing' => '          ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
 }
コード例 #2
0
ファイル: Setting.php プロジェクト: hampelm/Ginsberg-CiviDemo
 /**
  * This function sets the default values for the form.
  * default values are retrieved from the database
  * 
  * @access public
  * @return None
  */
 function setDefaultValues()
 {
     if (!$this->_defaults) {
         $this->_defaults = array();
         $formArray = array('Component', 'Localization');
         $formMode = false;
         if (in_array($this->_name, $formArray)) {
             $formMode = true;
         }
         require_once "CRM/Core/BAO/Setting.php";
         CRM_Core_BAO_Setting::retrieve($this->_defaults);
         require_once "CRM/Core/Config/Defaults.php";
         CRM_Core_Config_Defaults::setValues($this->_defaults, $formMode);
         require_once "CRM/Core/OptionGroup.php";
         $list = array_flip(CRM_Core_OptionGroup::values('contact_autocomplete_options', false, false, true, null, 'name'));
         require_once "CRM/Core/BAO/Preferences.php";
         $listEnabled = CRM_Core_BAO_Preferences::valueOptions('contact_autocomplete_options');
         $autoSearchFields = array();
         if (!empty($list) && !empty($listEnabled)) {
             $autoSearchFields = array_combine($list, $listEnabled);
         }
         //Set sort_name for default
         $this->_defaults['autocompleteContactSearch'] = array('1' => 1) + $autoSearchFields;
     }
     return $this->_defaults;
 }
コード例 #3
0
 /**
  * Basic setup.
  */
 public function preProcess()
 {
     $config = CRM_Core_Config::singleton();
     $this->_uploadMaxSize = (int) ini_get('upload_max_filesize');
     // check for post max size
     CRM_Core_Config_Defaults::formatUnitSize(ini_get('post_max_size'), TRUE);
 }
コード例 #4
0
 /**
  * Common form elements.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     $config = CRM_Core_Config::singleton();
     $uploadFileSize = CRM_Core_Config_Defaults::formatUnitSize($config->maxFileSize . 'm', TRUE);
     $uploadSize = round($uploadFileSize / (1024 * 1024), 2);
     $this->assign('uploadSize', $uploadSize);
     $this->add('File', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=255', TRUE);
     $this->setMaxFileSize($uploadFileSize);
     $this->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', array(1 => $uploadSize, 2 => $uploadFileSize)), 'maxfilesize', $uploadFileSize);
     $this->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile');
     $this->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File');
     $this->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers'));
     $this->add('text', 'fieldSeparator', ts('Import Field Separator'), array('size' => 2), TRUE);
     $this->setDefaults(array('fieldSeparator' => $config->fieldSeparator));
     //get the saved mapping details
     $mappingArray = CRM_Core_BAO_Mapping::getMappings(CRM_Core_OptionGroup::getValue('mapping_type', 'Import ' . static::IMPORT_ENTITY, 'name'));
     $this->assign('savedMapping', $mappingArray);
     $this->add('select', 'savedMapping', ts('Mapping Option'), array('' => ts('- select -')) + $mappingArray);
     if ($loadedMapping = $this->get('loadedMapping')) {
         $this->assign('loadedMapping', $loadedMapping);
         $this->setDefaults(array('savedMapping' => $loadedMapping));
     }
     //build date formats
     CRM_Core_Form_Date::buildAllowedDateFormats($this);
     $this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue'), 'spacing' => '          ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
 }
コード例 #5
0
 /**
  * This function sets the default values for the form.
  * default values are retrieved from the database
  *
  * @access public
  *
  * @return None
  */
 function setDefaultValues()
 {
     if (!$this->_defaults) {
         $this->_defaults = array();
         $formArray = array('Component', 'Localization');
         $formMode = FALSE;
         if (in_array($this->_name, $formArray)) {
             $formMode = TRUE;
         }
         CRM_Core_BAO_ConfigSetting::retrieve($this->_defaults);
         CRM_Core_Config_Defaults::setValues($this->_defaults, $formMode);
         $list = array_flip(CRM_Core_OptionGroup::values('contact_autocomplete_options', FALSE, FALSE, TRUE, NULL, 'name'));
         $cRlist = array_flip(CRM_Core_OptionGroup::values('contact_reference_options', FALSE, FALSE, TRUE, NULL, 'name'));
         $listEnabled = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options');
         $cRlistEnabled = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_reference_options');
         $autoSearchFields = array();
         if (!empty($list) && !empty($listEnabled)) {
             $autoSearchFields = array_combine($list, $listEnabled);
         }
         $cRSearchFields = array();
         if (!empty($cRlist) && !empty($cRlistEnabled)) {
             $cRSearchFields = array_combine($cRlist, $cRlistEnabled);
         }
         //Set defaults for autocomplete and contact reference options
         $this->_defaults['autocompleteContactSearch'] = array('1' => 1) + $autoSearchFields;
         $this->_defaults['autocompleteContactReference'] = array('1' => 1) + $cRSearchFields;
         $this->_defaults['enableSSL'] = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enableSSL', NULL, 0);
         $this->_defaults['verifySSL'] = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL', NULL, 1);
         $sql = "\nSELECT time_format\nFROM   civicrm_preferences_date\nWHERE  time_format IS NOT NULL\nAND    time_format <> ''\nLIMIT  1\n";
         $this->_defaults['timeInputFormat'] = CRM_Core_DAO::singleValueQuery($sql);
     }
     return $this->_defaults;
 }
コード例 #6
0
 /**
  * This is function is called by the form object to get the DataSource's
  * form snippet. It should add all fields necesarry to get the data
  * uploaded to the temporary table in the DB.
  *
  * @param CRM_Core_Form $form
  *
  * @return void
  *   (operates directly on form argument)
  */
 public function buildQuickForm(&$form)
 {
     $form->add('hidden', 'hidden_dataSource', 'CRM_Import_DataSource_CSV');
     $config = CRM_Core_Config::singleton();
     $uploadFileSize = CRM_Core_Config_Defaults::formatUnitSize($config->maxFileSize . 'm', TRUE);
     $uploadSize = round($uploadFileSize / (1024 * 1024), 2);
     $form->assign('uploadSize', $uploadSize);
     $form->add('File', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=255', TRUE);
     $form->setMaxFileSize($uploadFileSize);
     $form->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', array(1 => $uploadSize, 2 => $uploadFileSize)), 'maxfilesize', $uploadFileSize);
     $form->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File');
     $form->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile');
     $form->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers'));
 }
コード例 #7
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     //Test database user privilege to create table(Temporary) CRM-4725
     $errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
     $daoTestPrivilege = new CRM_Core_DAO();
     $daoTestPrivilege->query("CREATE TEMPORARY TABLE import_job_permission_one(test int) ENGINE=InnoDB");
     $daoTestPrivilege->query("CREATE TEMPORARY TABLE import_job_permission_two(test int) ENGINE=InnoDB");
     $daoTestPrivilege->query("DROP TABLE IF EXISTS import_job_permission_one, import_job_permission_two");
     unset($errorScope);
     if ($daoTestPrivilege->_lastError) {
         CRM_Core_Error::fatal(ts('Database Configuration Error: Insufficient permissions. Import requires that the CiviCRM database user has permission to create temporary tables. Contact your site administrator for assistance.'));
     }
     $results = array();
     $config = CRM_Core_Config::singleton();
     $handler = opendir($config->uploadDir);
     $errorFiles = array('sqlImport.errors', 'sqlImport.conflicts', 'sqlImport.duplicates', 'sqlImport.mismatch');
     // check for post max size avoid when called twice
     $snippet = CRM_Utils_Array::value('snippet', $_GET, 0);
     if (empty($snippet)) {
         CRM_Core_Config_Defaults::formatUnitSize(ini_get('post_max_size'), TRUE);
     }
     while ($file = readdir($handler)) {
         if ($file != '.' && $file != '..' && in_array($file, $errorFiles) && !is_writable($config->uploadDir . $file)) {
             $results[] = $file;
         }
     }
     closedir($handler);
     if (!empty($results)) {
         CRM_Core_Error::fatal(ts('<b>%1</b> file(s) in %2 directory are not writable. Listed file(s) might be used during the import to log the errors occurred during Import process. Contact your site administrator for assistance.', array(1 => implode(', ', $results), 2 => $config->uploadDir)));
     }
     $this->_dataSourceIsValid = FALSE;
     $this->_dataSource = CRM_Utils_Request::retrieve('dataSource', 'String', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET');
     $this->_params = $this->controller->exportValues($this->_name);
     if (!$this->_dataSource) {
         //considering dataSource as base criteria instead of hidden_dataSource.
         $this->_dataSource = CRM_Utils_Array::value('dataSource', $_POST, CRM_Utils_Array::value('dataSource', $this->_params));
         $this->assign('showOnlyDataSourceFormPane', FALSE);
     } else {
         $this->assign('showOnlyDataSourceFormPane', TRUE);
     }
     if (strpos($this->_dataSource, 'CRM_Import_DataSource_') === 0) {
         $this->_dataSourceIsValid = TRUE;
         $this->assign('showDataSourceFormPane', TRUE);
         $dataSourcePath = explode('_', $this->_dataSource);
         $templateFile = "CRM/Contact/Import/Form/" . $dataSourcePath[3] . ".tpl";
         $this->assign('dataSourceFormTemplateFile', $templateFile);
     }
 }
コード例 #8
0
 /**
  * Function to actually build the form
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     //Setting Upload File Size
     $config = CRM_Core_Config::singleton();
     $uploadFileSize = CRM_Core_Config_Defaults::formatUnitSize($config->maxFileSize . 'm');
     $uploadSize = round($uploadFileSize / (1024 * 1024), 2);
     $this->assign('uploadSize', $uploadSize);
     $this->add('File', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=255', TRUE);
     $this->setMaxFileSize($uploadFileSize);
     $this->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', array(1 => $uploadSize, 2 => $uploadFileSize)), 'maxfilesize', $uploadFileSize);
     $this->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile');
     $this->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File');
     $this->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers'));
     $duplicateOptions = array();
     $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Skip'), CRM_Import_Parser::DUPLICATE_SKIP);
     $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Update'), CRM_Import_Parser::DUPLICATE_UPDATE);
     $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('No Duplicate Checking'), CRM_Import_Parser::DUPLICATE_NOCHECK);
     // for contributions NOCHECK == SKIP
     //      $duplicateOptions[] = $this->createElement('radio',
     //          null, null, ts('No Duplicate Checking'), CRM_Import_Parser::DUPLICATE_NOCHECK);
     $this->addGroup($duplicateOptions, 'onDuplicate', ts('On Duplicate Entries'));
     //get the saved mapping details
     $mappingArray = CRM_Core_BAO_Mapping::getMappings(CRM_Core_OptionGroup::getValue('mapping_type', 'Import Participant', 'name'));
     $this->assign('savedMapping', $mappingArray);
     $this->add('select', 'savedMapping', ts('Mapping Option'), array('' => ts('- select -')) + $mappingArray);
     if ($loadeMapping = $this->get('loadedMapping')) {
         $this->assign('loadedMapping', $loadeMapping);
         $this->setDefaults(array('savedMapping' => $loadeMapping));
     }
     $this->setDefaults(array('onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP));
     //contact types option
     $contactOptions = array();
     if (CRM_Contact_BAO_ContactType::isActive('Individual')) {
         $contactOptions[] = $this->createElement('radio', NULL, NULL, ts('Individual'), CRM_Import_Parser::CONTACT_INDIVIDUAL);
     }
     if (CRM_Contact_BAO_ContactType::isActive('Household')) {
         $contactOptions[] = $this->createElement('radio', NULL, NULL, ts('Household'), CRM_Import_Parser::CONTACT_HOUSEHOLD);
     }
     if (CRM_Contact_BAO_ContactType::isActive('Organization')) {
         $contactOptions[] = $this->createElement('radio', NULL, NULL, ts('Organization'), CRM_Import_Parser::CONTACT_ORGANIZATION);
     }
     $this->addGroup($contactOptions, 'contactType', ts('Contact Type'));
     $this->setDefaults(array('contactType' => CRM_Import_Parser::CONTACT_INDIVIDUAL));
     //build date formats
     CRM_Core_Form_Date::buildAllowedDateFormats($this);
     $this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue >>'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
 }
コード例 #9
0
 /**
  * Set default values for the form.
  *
  * Default values are retrieved from the database.
  */
 public function setDefaultValues()
 {
     if (!$this->_defaults) {
         $this->_defaults = array();
         $formArray = array('Component', 'Localization');
         $formMode = FALSE;
         if (in_array($this->_name, $formArray)) {
             $formMode = TRUE;
         }
         CRM_Core_BAO_ConfigSetting::retrieve($this->_defaults);
         CRM_Core_Config_Defaults::setValues($this->_defaults, $formMode);
         $list = array_flip(CRM_Core_OptionGroup::values('contact_autocomplete_options', FALSE, FALSE, TRUE, NULL, 'name'));
         $cRlist = array_flip(CRM_Core_OptionGroup::values('contact_reference_options', FALSE, FALSE, TRUE, NULL, 'name'));
         $listEnabled = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options');
         $cRlistEnabled = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_reference_options');
         $autoSearchFields = array();
         if (!empty($list) && !empty($listEnabled)) {
             $autoSearchFields = array_combine($list, $listEnabled);
         }
         $cRSearchFields = array();
         if (!empty($cRlist) && !empty($cRlistEnabled)) {
             $cRSearchFields = array_combine($cRlist, $cRlistEnabled);
         }
         //Set defaults for autocomplete and contact reference options
         $this->_defaults['autocompleteContactSearch'] = array('1' => 1) + $autoSearchFields;
         $this->_defaults['autocompleteContactReference'] = array('1' => 1) + $cRSearchFields;
         // we can handle all the ones defined in the metadata here. Others to be converted
         foreach ($this->_settings as $setting => $group) {
             $settingMetaData = civicrm_api('setting', 'getfields', array('version' => 3, 'name' => $setting));
             $this->_defaults[$setting] = civicrm_api('setting', 'getvalue', array('version' => 3, 'name' => $setting, 'group' => $group, 'default_value' => CRM_Utils_Array::value('default', $settingMetaData['values'][$setting])));
         }
         $this->_defaults['enableSSL'] = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enableSSL', NULL, 0);
         $this->_defaults['verifySSL'] = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL', NULL, 1);
     }
     return $this->_defaults;
 }
コード例 #10
0
ファイル: Config.php プロジェクト: ksecor/civicrm
 /**
  * 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;
     }
 }
コード例 #11
0
 /**
  * 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();
 }
コード例 #12
0
 public function postProcess()
 {
     // store the submitted values in an array
     $config = CRM_Core_Config::singleton();
     $params = $this->controller->exportValues($this->_name);
     // update upload max size in DB
     $params['maxImportFileSize'] = CRM_Core_Config_Defaults::formatUnitSize(ini_get('upload_max_filesize'));
     CRM_Core_BAO_ConfigSetting::create($params);
     // get current logging status
     $values = $this->exportValues();
     parent::postProcess();
     if ($config->logging != $values['logging']) {
         $logging = new CRM_Logging_Schema();
         if ($values['logging']) {
             $logging->enableLogging();
         } else {
             $logging->disableLogging();
         }
     }
 }