ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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  $settingsForm->setValuesByPost();
44  $this->general($settingsForm);
45  } else {
46  $this->gui->object->setTitle($settingsForm->getInput('title'));
47  $this->gui->object->setDescription($settingsForm->getInput('desc'));
48 
49  require_once 'Services/Object/classes/class.ilObjectActivation.php';
50 
51  $period = $settingsForm->getItemByPostVar('access_period');
52  if ($period->getStart() && $period->getEnd()) {
53  $this->gui->object->setAccessType(ilObjectActivation::TIMINGS_ACTIVATION);
54  $this->gui->object->setAccessBegin($period->getStart()->get(IL_CAL_UNIX));
55  $this->gui->object->setAccessEnd($period->getEnd()->get(IL_CAL_UNIX));
56  $this->gui->object->setAccessVisibility((int) $settingsForm->getInput('access_visibility'));
57  } else {
58  $this->gui->object->setAccessType(ilObjectActivation::TIMINGS_DEACTIVATED);
59  }
60 
61  $this->gui->object->update();
62  // @todo: Do not rely on raw post data
63  $settings = $_POST;
64  $room = ilChatRoom::byObjectId($this->gui->object->getId());
65 
66  if (!$room) {
67  $room = new ilChatRoom();
68  $settings['object_id'] = $this->gui->object->getId();
69  }
70  $room->saveSettings($settings);
71 
72  ilUtil::sendSuccess($lng->txt('saved_successfully'), true);
73  $ilCtrl->redirect($this->gui, 'settings-general');
74  }
75  }
76 
81  public function general(ilPropertyFormGUI $settingsForm = null)
82  {
88  global $lng, $tpl, $ilCtrl;
89 
91  'read',
92  'write'
93  ), $this->gui->ref_id)
94  ) {
95  $ilCtrl->setParameterByClass('ilrepositorygui', 'ref_id', ROOT_FOLDER_ID);
96  $ilCtrl->redirectByClass('ilrepositorygui', '');
97  }
98 
99  $chatSettings = new ilSetting('chatroom');
100  if (!$chatSettings->get('chat_enabled')) {
101  ilUtil::sendInfo($lng->txt('server_disabled'), true);
102  }
103 
104  $this->gui->switchToVisibleMode();
105 
106  $formFactory = new ilChatroomFormFactory();
107 
108  $room = ilChatRoom::byObjectId($this->gui->object->getId());
109 
110  if (!$settingsForm) {
111  $settingsForm = $formFactory->getSettingsForm();
112 
113  require_once 'Services/Object/classes/class.ilObjectActivation.php';
114  $settings = array(
115  'title' => $this->gui->object->getTitle(),
116  'desc' => $this->gui->object->getDescription(),
117  'access_period' => array(
118  'start' => $this->gui->object->getAccessBegin() ? new ilDateTime($this->gui->object->getAccessBegin(), IL_CAL_UNIX) : null,
119  'end' => $this->gui->object->getAccessEnd() ? new ilDateTime($this->gui->object->getAccessEnd(), IL_CAL_UNIX) : null
120  ),
121  'access_visibility' => $this->gui->object->getAccessVisibility()
122  );
123 
124  if ($room) {
126  $settingsForm,
127  array_merge($settings, $room->getSettings())
128  );
129  } else {
130  ilChatroomFormFactory::applyValues($settingsForm, $settings);
131  }
132  }
133 
134  $settingsForm->setTitle($lng->txt('settings_title'));
135  $settingsForm->addCommandButton('settings-saveGeneral', $lng->txt('save'));
136  $settingsForm->setFormAction($ilCtrl->getFormAction($this->gui, 'settings-saveGeneral'));
137 
138  $tpl->setVariable('ADM_CONTENT', $settingsForm->getHtml());
139  }
140 
145  public function executeDefault($requestedMethod)
146  {
147  $this->general();
148  }
149 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
Class ilChatroomSettingsGUI.
This class represents a property form user interface.
$errors general
Prepares and displays settings form.
Definition: imgupload.php:50
$tpl
Definition: ilias.php:10
__construct(ilChatroomObjectGUI $gui)
Constructor Requires ilChatroomFormFactory, ilChatroom and ilChatroomInstaller, sets $this->gui using...
const IL_CAL_UNIX
Class ilChatroomFormFactory.
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.
Date and time handling
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"]