public function preProcess() { $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE); $this->_system = CRM_Utils_Request::retrieve('system', 'Boolean', $this, FALSE, TRUE); $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'update'); if (isset($action)) { $this->assign('action', $action); } $session = CRM_Core_Session::singleton(); $this->_config = new CRM_Core_DAO(); if ($this->_system) { if (CRM_Core_Permission::check('administer CiviCRM')) { $this->_contactID = NULL; } else { CRM_Utils_System::fatal('You do not have permission to edit preferences'); } $this->_config->contact_id = NULL; } else { if (!$this->_contactID) { $this->_contactID = $session->get('userID'); if (!$this->_contactID) { CRM_Utils_System::fatal('Could not retrieve contact id'); } $this->set('cid', $this->_contactID); } $this->_config->contact_id = $this->_contactID; } $settings = Civi::settings(); foreach ($this->_varNames as $groupName => $settingNames) { foreach ($settingNames as $settingName => $options) { $this->_config->{$settingName} = $settings->get($settingName); } } $session->pushUserContext(CRM_Utils_System::url('civicrm/admin', 'reset=1')); }
function preProcess() { $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, false); $this->_system = CRM_Utils_Request::retrieve('system', 'Boolean', $this, false, true); $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'update'); if (isset($action)) { $this->assign('action', $action); } $session = CRM_Core_Session::singleton(); require_once 'CRM/Core/DAO/Preferences.php'; $this->_config = new CRM_Core_DAO_Preferences(); $this->_config->domain_id = CRM_Core_Config::domainID(); if ($this->_system) { if (CRM_Core_Permission::check('administer CiviCRM')) { $this->_contactID = null; } else { CRM_Utils_System::fatal('You do not have permission to edit preferences'); } $this->_config->is_domain = 1; $this->_config->contact_id = null; } else { if (!$this->_contactID) { $this->_contactID = $session->get('userID'); if (!$this->_contactID) { CRM_Utils_System::fatal('Could not retrieve contact id'); } $this->set('cid', $this->_contactID); } $this->_config->is_domain = 0; $this->_config->contact_id = $this->_contactID; } $this->_config->find(true); $session->pushUserContext(CRM_Utils_System::url('civicrm/admin/setting', 'reset=1')); }