Ejemplo n.º 1
0
 /**
  * reads session settings from db
  *
  * @return array session_settings
  */
 function getSessionSettings()
 {
     require_once 'Services/Authentication/classes/class.ilSessionControl.php';
     $db = $this->client->getDB();
     $setting_fields = ilSessionControl::getSettingFields();
     $query = "SELECT * FROM settings WHERE module = %s " . "AND " . $db->in('keyword', $setting_fields, false, 'text');
     $res = $db->queryF($query, array('text'), array('common'));
     $session_settings = array();
     while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) {
         $session_settings[$row['keyword']] = $row['value'];
     }
     foreach ($setting_fields as $field) {
         if (!isset($session_settings[$field])) {
             $value = 1;
             switch ($field) {
                 case 'session_max_count':
                     $value = ilSessionControl::DEFAULT_MAX_COUNT;
                     break;
                 case 'session_min_idle':
                     $value = ilSessionControl::DEFAULT_MIN_IDLE;
                     break;
                 case 'session_max_idle':
                     $value = ilSessionControl::DEFAULT_MAX_IDLE;
                     break;
                 case 'session_max_idle_after_first_request':
                     $value = ilSessionControl::DEFAULT_MAX_IDLE_AFTER_FIRST_REQUEST;
                     break;
                 case 'session_allow_client_maintenance':
                     $value = ilSessionControl::DEFAULT_ALLOW_CLIENT_MAINTENANCE;
                     break;
             }
             $session_settings[$field] = $value;
         }
     }
     return $session_settings;
 }
Ejemplo n.º 2
0
 /**
  * display sessions form and process form input
  */
 function displaySessions()
 {
     require_once 'Services/Authentication/classes/class.ilSessionControl.php';
     $this->checkDisplayMode("setup_sessions");
     if (!$this->setup->getClient()->db_installed) {
         // program should never come to this place
         $message = "No database found! Please install database first.";
         ilUtil::sendInfo($message);
     }
     $setting_fields = ilSessionControl::getSettingFields();
     $valid = true;
     $settings = array();
     foreach ($setting_fields as $field) {
         if ($field == 'session_allow_client_maintenance') {
             if (isset($_POST[$field])) {
                 $_POST[$field] = '1';
             } else {
                 $_POST[$field] = '0';
             }
         }
         if (isset($_POST[$field]) && $_POST[$field] != '') {
             $settings[$field] = $_POST[$field];
         } else {
             $valid = false;
             break;
         }
     }
     if ($valid) {
         $this->setup->setSessionSettings($settings);
     }
     $settings = $this->setup->getSessionSettings();
     include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     include_once 'Services/Authentication/classes/class.ilSession.php';
     // BEGIN SESSION SETTINGS
     // create session handling radio group
     $ssettings = new ilRadioGroupInputGUI($this->lng->txt('sess_mode'), 'session_handling_type');
     $ssettings->setValue($settings['session_handling_type'], ilSession::SESSION_HANDLING_FIXED);
     // first option, fixed session duration
     $fixed = new ilRadioOption($this->lng->txt('sess_fixed_duration'), ilSession::SESSION_HANDLING_FIXED);
     // add session handling to radio group
     $ssettings->addOption($fixed);
     // second option, session control
     $ldsh = new ilRadioOption($this->lng->txt('sess_load_dependent_session_handling'), ilSession::SESSION_HANDLING_LOAD_DEPENDENT);
     // this is the max count of active sessions
     // that are getting started simlutanously
     $ti = new ilTextInputGUI($this->lng->txt('sess_max_session_count'), "session_max_count");
     $ti->setInfo($this->lng->txt('sess_max_session_count_info'));
     $ti->setMaxLength(5);
     $ti->setSize(5);
     $ti->setValue($settings['session_max_count']);
     $ldsh->addSubItem($ti);
     // after this (min) idle time the session can be deleted,
     // if there are further requests for new sessions,
     // but max session count is reached yet
     $ti = new ilTextInputGUI($this->lng->txt('sess_min_session_idle'), "session_min_idle");
     $ti->setInfo($this->lng->txt('sess_min_session_idle_info'));
     $ti->setMaxLength(5);
     $ti->setSize(5);
     $ti->setValue($settings['session_min_idle']);
     $ldsh->addSubItem($ti);
     // after this (max) idle timeout the session expires
     // and become invalid, so it is not considered anymore
     // when calculating current count of active sessions
     $ti = new ilTextInputGUI($this->lng->txt('sess_max_session_idle'), "session_max_idle");
     $ti->setInfo($this->lng->txt('sess_max_session_idle_info'));
     $ti->setMaxLength(5);
     $ti->setSize(5);
     $ti->setValue($settings['session_max_idle']);
     $ldsh->addSubItem($ti);
     // this is the max duration that can elapse between the first and the secnd
     // request to the system before the session is immidietly deleted
     $ti = new ilTextInputGUI($this->lng->txt('sess_max_session_idle_after_first_request'), "session_max_idle_after_first_request");
     $ti->setInfo($this->lng->txt('sess_max_session_idle_after_first_request_info'));
     $ti->setMaxLength(5);
     $ti->setSize(5);
     $ti->setValue($settings['session_max_idle_after_first_request']);
     $ldsh->addSubItem($ti);
     // add session control to radio group
     $ssettings->addOption($ldsh);
     $form->addItem($ssettings);
     // controls the ability t maintenance the following
     // settings in client administration
     $chkb = new ilCheckboxInputGUI($this->lng->txt('sess_allow_client_maintenance'), "session_allow_client_maintenance");
     $chkb->setInfo($this->lng->txt('sess_allow_client_maintenance_info'));
     $chkb->setChecked($settings['session_allow_client_maintenance'] ? true : false);
     $form->addItem($chkb);
     // END SESSION SETTINGS
     // save and cancel commands
     $form->addCommandButton("sess", $this->lng->txt('save'));
     $form->setTitle($this->lng->txt("sess_sessions"));
     $form->setFormAction('setup.php?client_id=' . $this->client_id . '&cmd=sess');
     $this->tpl->setVariable("TXT_SETUP_TITLE", ucfirst(trim($this->lng->txt('sess_sessions'))));
     $this->tpl->setVariable("TXT_INFO", '');
     $this->tpl->setVariable("SETUP_CONTENT", $form->getHTML());
     /*$this->setButtonPrev("db");
     
     		if($this->setup->checkClientSessionSettings($this->client,true))
     		{
     			$this->setButtonNext("lang");
     		}*/
     $this->checkPanelMode();
 }