/**
  * Saves settings fetched from $_POST.
  */
 public function saveGeneral()
 {
     /**
      * @var $ilCtrl ilCtrl
      * @var $lng    ilLanguage
      */
     global $ilCtrl, $lng;
     $formFactory = new ilChatroomFormFactory();
     $settingsForm = $formFactory->getSettingsForm();
     if (!$settingsForm->checkInput()) {
         $this->general($settingsForm);
     } else {
         $this->gui->object->setTitle($settingsForm->getInput('title'));
         $this->gui->object->setDescription($settingsForm->getInput('desc'));
         $this->gui->object->update();
         // @todo: Do not rely on raw post data
         $settings = $_POST;
         $room = ilChatRoom::byObjectId($this->gui->object->getId());
         if (!$room) {
             $room = new ilChatRoom();
             $settings['object_id'] = $this->gui->object->getId();
         }
         $room->saveSettings($settings);
         ilUtil::sendSuccess($lng->txt('saved_successfully'), true);
         $ilCtrl->redirect($this->gui, 'settings-general');
     }
 }
 /**
  * Inserts new object into gui.
  *
  * @global ilCtrl2 $ilCtrl
  */
 public function save()
 {
     global $ilCtrl;
     require_once 'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
     $formFactory = new ilChatroomFormFactory();
     $form = $formFactory->getCreationForm();
     if ($form->checkInput()) {
         $this->gui->insertObject();
         $ilCtrl->setParameter($this->gui, 'ref_id', $this->gui->getRefId());
         $ilCtrl->redirect($this->gui, 'settings-general');
     } else {
         $this->executeDefault('create');
     }
 }
 /**
  * Saves settings fetched from $_POST.
  *
  * @global ilCtrl2 $ilCtrl
  */
 public function saveGeneral()
 {
     global $ilCtrl, $lng;
     $formFactory = new ilChatroomFormFactory();
     $settingsForm = $formFactory->getSettingsForm();
     if (!$settingsForm->checkInput()) {
         $this->general($settingsForm);
     } else {
         $this->gui->object->setTitle($_POST['title']);
         $this->gui->object->setDescription($_POST['desc']);
         $this->gui->object->update();
         $settings = $_POST;
         $room = ilChatRoom::byObjectId($this->gui->object->getId());
         if (!$room) {
             $room = new ilChatRoom();
             $settings['object_id'] = $this->gui->object->getId();
         }
         //var_dump($settings);exit;
         $room->saveSettings($settings);
         ilUtil::sendSuccess($lng->txt('saved_successfully'), true);
         $ilCtrl->redirect($this->gui, 'settings-general');
     }
 }
 /**
  * Prepares and displays history period form by session.
  *
  * @global ilLanguage $lng
  * @global ilCtrl2 $ilCtrl
  * @global ilObjUser $ilUser
  */
 public function bySession($export = false)
 {
     global $lng, $ilCtrl, $ilUser;
     $room = ilChatroom::byObjectId($this->gui->object->getId());
     $scope = $room->getRoomId();
     $chat_user = new ilChatroomUser($ilUser, $room);
     $formFactory = new ilChatroomFormFactory();
     $durationForm = $formFactory->getSessionForm($room->getSessions($chat_user));
     $durationForm->setTitle($lng->txt('history_bysession_title'));
     $durationForm->addCommandButton('history-bySessionExport', $lng->txt('export'));
     $durationForm->addCommandButton('history-bySession', $lng->txt('show'));
     $durationForm->setFormAction($ilCtrl->getFormAction($this->gui), 'history-bySession');
     if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
         $durationForm->checkInput();
         $postVals = explode(',', $_POST['session']);
         $durationForm->setValuesByArray(array('session' => $_POST['session']));
         $messages = $room->getHistory($from = new ilDateTime($postVals[0], IL_CAL_UNIX), $to = new ilDateTime($postVals[1], IL_CAL_UNIX), $chat_user->getUserId(), isset($_REQUEST['scope']) ? $_REQUEST['scope'] : 0);
     } else {
         $last_session = $room->getLastSession($chat_user);
         if ($last_session) {
             $from = new ilDateTime($last_session['connected'], IL_CAL_UNIX);
             $to = new ilDateTime($last_session['disconnected'], IL_CAL_UNIX);
         } else {
             $from = null;
             $to = null;
         }
         $messages = $room->getHistory($from, $to, $chat_user->getUserId(), isset($_REQUEST['scope']) ? $_REQUEST['scope'] : 0);
     }
     if ($from && $to) {
         $psessions = $room->getPrivateRoomSessions($from, $to, $chat_user->getUserId(), $scope);
     } else {
         $from = new ilDateTime();
         $to = new ilDateTime();
         $psessions = array();
     }
     $psessions = $room->getPrivateRoomSessions($from, $to, $chat_user->getUserId(), $scope);
     $this->showMessages($messages, $durationForm, $export, $psessions, $from, $to);
 }
 /**
  * Prepares Fileupload form and displays it.
  * @param ilTemplate $roomTpl
  */
 public function renderFileUploadForm(ilTemplate $roomTpl)
 {
     // @todo: Not implemented yet
     return;
     require_once 'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
     $formFactory = new ilChatroomFormFactory();
     $file_upload = $formFactory->getFileUploadForm();
     //$file_upload->setFormAction( $ilCtrl->getFormAction($this->gui, 'UploadFile-uploadFile') );
     $roomTpl->setVariable('FILE_UPLOAD', $file_upload->getHTML());
 }
 /**
  * @param ilPropertyFormGUI $form
  */
 public function clientsettings(ilPropertyFormGUI $form = null)
 {
     /**
      * @var $tpl    ilTemplate
      * @var $ilCtrl ilCtrl
      * @var $lng    ilLanguage
      */
     global $tpl, $ilCtrl, $lng;
     ilChatroom::checkUserPermissions('read', $this->gui->ref_id);
     $this->defaultActions();
     $this->gui->switchToVisibleMode();
     $this->showSoapWarningIfNeeded();
     require_once 'Modules/Chatroom/classes/class.ilChatroomAdmin.php';
     $adminSettings = new ilChatroomAdmin($this->gui->object->getId());
     if ($form === null) {
         require_once 'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
         $factory = new ilChatroomFormFactory();
         $form = $factory->getClientSettingsForm();
         if (!$this->commonSettings->get('soap_user_administration')) {
             $form->getItemByPostVar('chat_enabled')->setDisabled(!(bool) $this->commonSettings->get('soap_user_administration'));
             $form->getItemByPostVar('chat_enabled')->setChecked(0);
         }
         $data = (array) $adminSettings->loadClientSettings();
         if (!$data['osd_intervall']) {
             $data['osd_intervall'] = 60;
         }
         if (!$data) {
             $data = array();
         }
         if (!$data['url']) {
             $data['url'] = ilUtil::_getHttpPath();
         }
         if (!$data['client']) {
             $data['client'] = CLIENT_ID;
         }
         $data['password_retype'] = $data['password'];
         $form->setValuesByArray($data);
     }
     require_once 'Modules/Chatroom/classes/class.ilChatroomServerConnector.php';
     $serverSettings = (array) $adminSettings->loadGeneralSettings();
     if ($serverSettings['port'] && $serverSettings['address'] && !(bool) @ilChatroomServerConnector::checkServerConnection()) {
         ilUtil::sendInfo($lng->txt('chat_cannot_connect_to_server'));
     }
     $form->setTitle($lng->txt('general_settings_title'));
     $form->addCommandButton('view-saveClientSettings', $lng->txt('save'));
     $form->setFormAction($ilCtrl->getFormAction($this->gui, 'view-saveClientSettings'));
     $settingsTpl = new ilTemplate('tpl.chatroom_serversettings.html', true, true, 'Modules/Chatroom');
     $settingsTpl->setVariable('VAL_SERVERSETTINGS_FORM', $form->getHTML());
     $settingsTpl->setVariable('LBL_SERVERSETTINGS_FURTHER_INFORMATION', sprintf($lng->txt('server_further_information'), ilUtil::_getHttpPath() . '/Modules/Chatroom/server/README.txt'));
     $tpl->setVariable('ADM_CONTENT', $settingsTpl->get());
 }