ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilChatroomSettingsTask.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 {
15  private $gui;
16 
25  {
26  $this->gui = $gui;
27 
28  require_once 'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
29  require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
30  require_once 'Modules/Chatroom/classes/class.ilChatroomInstaller.php';
31  }
32 
37  public function general(ilPropertyFormGUI $settingsForm = null)
38  {
44  global $lng, $tpl, $ilCtrl;
45 
47  'read',
48  'write'
49  ), $this->gui->ref_id)
50  )
51  {
52  $ilCtrl->setParameterByClass('ilrepositorygui', 'ref_id', ROOT_FOLDER_ID);
53  $ilCtrl->redirectByClass('ilrepositorygui', '');
54  }
55 
56  $chatSettings = new ilSetting('chatroom');
57  if(!$chatSettings->get('chat_enabled'))
58  {
59  ilUtil::sendInfo($lng->txt('server_disabled'), true);
60  }
61 
62  $this->gui->switchToVisibleMode();
63 
64  $formFactory = new ilChatroomFormFactory();
65 
66  $room = ilChatRoom::byObjectId($this->gui->object->getId());
67 
68  if(!$settingsForm)
69  {
70  $settingsForm = $formFactory->getSettingsForm();
71 
72  $settings = array(
73  'title' => $this->gui->object->getTitle(),
74  'desc' => $this->gui->object->getDescription(),
75  );
76 
77  if($room)
78  {
80  $settingsForm, array_merge($settings, $room->getSettings())
81  );
82  }
83  else
84  {
85  ilChatroomFormFactory::applyValues($settingsForm, $settings);
86  }
87  }
88 
89  $settingsForm->setTitle($lng->txt('settings_title'));
90  $settingsForm->addCommandButton('settings-saveGeneral', $lng->txt('save'));
91  $settingsForm->setFormAction($ilCtrl->getFormAction($this->gui, 'settings-saveGeneral'));
92 
93  $tpl->setVariable('ADM_CONTENT', $settingsForm->getHtml());
94  }
95 
99  public function saveGeneral()
100  {
105  global $ilCtrl, $lng;
106 
107  $formFactory = new ilChatroomFormFactory();
108  $settingsForm = $formFactory->getSettingsForm();
109 
110  if(!$settingsForm->checkInput())
111  {
112  $settingsForm->setValuesByPost();
113  $this->general($settingsForm);
114  }
115  else
116  {
117  $this->gui->object->setTitle($settingsForm->getInput('title'));
118  $this->gui->object->setDescription($settingsForm->getInput('desc'));
119  $this->gui->object->update();
120  // @todo: Do not rely on raw post data
121  $settings = $_POST;
122  $room = ilChatRoom::byObjectId($this->gui->object->getId());
123 
124  if(!$room)
125  {
126  $room = new ilChatRoom();
127  $settings['object_id'] = $this->gui->object->getId();
128  }
129  $room->saveSettings($settings);
130 
131  ilUtil::sendSuccess($lng->txt('saved_successfully'), true);
132  $ilCtrl->redirect($this->gui, 'settings-general');
133  }
134  }
135 
140  public function executeDefault($requestedMethod)
141  {
142  $this->general();
143  }
144 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
ILIAS Setting Class.
$_POST['username']
Definition: cron.php:12
This class represents a property form user interface.
Class ilChatroomFormFactory.
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
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.
__construct(ilChatroomObjectGUI $gui)
Constructor Requires ilChatroomFormFactory, ilChatroom and ilChatroomInstaller, sets $this->gui using...
global $lng
Definition: privfeed.php:40
Class ilChatroomSettingsTask.
static applyValues(ilPropertyFormGUI $form, array $values)
Applies given values to field in given form.
$errors general
Prepares and displays settings form.
Definition: imgupload.php:47