ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilChatroomSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
11 {
20  {
21  parent::__construct($gui);
22 
23  require_once 'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
24  require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
25  require_once 'Modules/Chatroom/classes/class.ilChatroomInstaller.php';
26  }
27 
31  public function saveGeneral()
32  {
37  global $ilCtrl, $lng;
38 
39  $formFactory = new ilChatroomFormFactory();
40  $settingsForm = $formFactory->getSettingsForm();
41 
42  if(!$settingsForm->checkInput())
43  {
44  $settingsForm->setValuesByPost();
45  $this->general($settingsForm);
46  }
47  else
48  {
49  $this->gui->object->setTitle($settingsForm->getInput('title'));
50  $this->gui->object->setDescription($settingsForm->getInput('desc'));
51  $this->gui->object->update();
52  // @todo: Do not rely on raw post data
53  $settings = $_POST;
54  $room = ilChatRoom::byObjectId($this->gui->object->getId());
55 
56  if(!$room)
57  {
58  $room = new ilChatRoom();
59  $settings['object_id'] = $this->gui->object->getId();
60  }
61  $room->saveSettings($settings);
62 
63  ilUtil::sendSuccess($lng->txt('saved_successfully'), true);
64  $ilCtrl->redirect($this->gui, 'settings-general');
65  }
66  }
67 
72  public function general(ilPropertyFormGUI $settingsForm = null)
73  {
79  global $lng, $tpl, $ilCtrl;
80 
82  'read',
83  'write'
84  ), $this->gui->ref_id)
85  )
86  {
87  $ilCtrl->setParameterByClass('ilrepositorygui', 'ref_id', ROOT_FOLDER_ID);
88  $ilCtrl->redirectByClass('ilrepositorygui', '');
89  }
90 
91  $chatSettings = new ilSetting('chatroom');
92  if(!$chatSettings->get('chat_enabled'))
93  {
94  ilUtil::sendInfo($lng->txt('server_disabled'), true);
95  }
96 
97  $this->gui->switchToVisibleMode();
98 
99  $formFactory = new ilChatroomFormFactory();
100 
101  $room = ilChatRoom::byObjectId($this->gui->object->getId());
102 
103  if(!$settingsForm)
104  {
105  $settingsForm = $formFactory->getSettingsForm();
106 
107  $settings = array(
108  'title' => $this->gui->object->getTitle(),
109  'desc' => $this->gui->object->getDescription(),
110  );
111 
112  if($room)
113  {
115  $settingsForm, array_merge($settings, $room->getSettings())
116  );
117  }
118  else
119  {
120  ilChatroomFormFactory::applyValues($settingsForm, $settings);
121  }
122  }
123 
124  $settingsForm->setTitle($lng->txt('settings_title'));
125  $settingsForm->addCommandButton('settings-saveGeneral', $lng->txt('save'));
126  $settingsForm->setFormAction($ilCtrl->getFormAction($this->gui, 'settings-saveGeneral'));
127 
128  $tpl->setVariable('ADM_CONTENT', $settingsForm->getHtml());
129  }
130 
135  public function executeDefault($requestedMethod)
136  {
137  $this->general();
138  }
139 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
ILIAS Setting Class.
Class ilChatroomSettingsGUI.
This class represents a property form user interface.
$errors general
Prepares and displays settings form.
Definition: imgupload.php:51
__construct(ilChatroomObjectGUI $gui)
Constructor Requires ilChatroomFormFactory, ilChatroom and ilChatroomInstaller, sets $this->gui using...
Class ilChatroomFormFactory.
global $tpl
Definition: ilias.php:8
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static checkUserPermissions($permissions, $ref_id, $send_info=true)
Checks user permissions by given array and ref_id.
Class ilChatroomGUIHandler.
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
static applyValues(ilPropertyFormGUI $form, array $values)
Applies given values to field in given form.
$_POST["username"]