/**
  * Prepares and displays settings form.
  * @param ilPropertyFormGUI $settingsForm
  */
 public function general(ilPropertyFormGUI $settingsForm = null)
 {
     /**
      * @var $lng    ilLanguage
      * @var $tpl    ilTemplate
      * @var $ilCtrl ilCtrl
      */
     global $lng, $tpl, $ilCtrl;
     if (!ilChatroom::checkUserPermissions(array('read', 'write'), $this->gui->ref_id)) {
         $ilCtrl->setParameterByClass('ilrepositorygui', 'ref_id', ROOT_FOLDER_ID);
         $ilCtrl->redirectByClass('ilrepositorygui', '');
     }
     $chatSettings = new ilSetting('chatroom');
     if (!$chatSettings->get('chat_enabled')) {
         ilUtil::sendInfo($lng->txt('server_disabled'), true);
     }
     $this->gui->switchToVisibleMode();
     $formFactory = new ilChatroomFormFactory();
     if (!$settingsForm) {
         $settingsForm = $formFactory->getSettingsForm();
     }
     $room = ilChatRoom::byObjectId($this->gui->object->getId());
     $settings = array('title' => $this->gui->object->getTitle(), 'desc' => $this->gui->object->getDescription());
     if ($room) {
         ilChatroomFormFactory::applyValues($settingsForm, array_merge($settings, $room->getSettings()));
     } else {
         ilChatroomFormFactory::applyValues($settingsForm, $settings);
     }
     $settingsForm->setTitle($lng->txt('settings_title'));
     $settingsForm->addCommandButton('settings-saveGeneral', $lng->txt('save'));
     $settingsForm->setFormAction($ilCtrl->getFormAction($this->gui, 'settings-saveGeneral'));
     $tpl->setVariable('ADM_CONTENT', $settingsForm->getHtml());
 }
 /**
  * Chatroom and Chatuser get prepared before $this->showRoom method
  * is called. If custom usernames are allowed, $this->showNameSelection
  * method is called if user isn't already registered in the Chatroom.
  * @param string $method
  */
 public function executeDefault($method)
 {
     /**
      * @var $ilUser ilObjUser
      * @var $lng    ilLanguage
      * @var $ilCtrl ilCtrl
      */
     global $ilUser, $lng, $ilCtrl;
     include_once 'Modules/Chatroom/classes/class.ilChatroom.php';
     ilChatroom::checkUserPermissions('read', $this->gui->ref_id);
     $this->gui->switchToVisibleMode();
     $this->setupTemplate();
     $chatSettings = new ilSetting('chatroom');
     if (!$chatSettings->get('chat_enabled')) {
         $ilCtrl->redirect($this->gui, 'settings-general');
         exit;
     }
     $room = ilChatroom::byObjectId($this->gui->object->getId());
     if (!$room->getSetting('allow_anonymous') && $ilUser->isAnonymous()) {
         $this->cancelJoin($lng->txt('anonymous_not_allowed'));
         return;
     }
     $chat_user = new ilChatroomUser($ilUser, $room);
     if ($room->getSetting('allow_custom_usernames')) {
         if ($room->isSubscribed($chat_user->getUserId())) {
             $chat_user->setUsername($chat_user->getUsername());
             $this->showRoom($room, $chat_user);
         } else {
             $this->showNameSelection($chat_user);
         }
     } else {
         $chat_user->setUsername($ilUser->getLogin());
         $this->showRoom($room, $chat_user);
     }
 }
 /**
  * @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());
 }
 /**
  * Switches to visible mode and prepares template.
  *
  * @global ilTemplate $tpl
  * @param string $method
  */
 public function executeDefault($method)
 {
     global $tpl;
     $this->gui->switchToVisibleMode();
     $tpl->setVariable('ADM_CONTENT', 'hallo welt');
 }