ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
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  if(!$settingsForm)
67  {
68  $settingsForm = $formFactory->getSettingsForm();
69  }
70 
71  $room = ilChatRoom::byObjectId($this->gui->object->getId());
72 
73  $settings = array(
74  'title' => $this->gui->object->getTitle(),
75  'desc' => $this->gui->object->getDescription(),
76  );
77 
78  if($room)
79  {
81  $settingsForm, array_merge($settings, $room->getSettings())
82  );
83  }
84  else
85  {
86  ilChatroomFormFactory::applyValues($settingsForm, $settings);
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  $this->general($settingsForm);
113  }
114  else
115  {
116  $this->gui->object->setTitle($settingsForm->getInput('title'));
117  $this->gui->object->setDescription($settingsForm->getInput('desc'));
118  $this->gui->object->update();
119  // @todo: Do not rely on raw post data
120  $settings = $_POST;
121  $room = ilChatRoom::byObjectId($this->gui->object->getId());
122 
123  if(!$room)
124  {
125  $room = new ilChatRoom();
126  $settings['object_id'] = $this->gui->object->getId();
127  }
128  $room->saveSettings($settings);
129 
130  ilUtil::sendSuccess($lng->txt('saved_successfully'), true);
131  $ilCtrl->redirect($this->gui, 'settings-general');
132  }
133  }
134 
139  public function executeDefault($requestedMethod)
140  {
141  $this->general();
142  }
143 }
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.
$errors general
Prepares and displays settings form.
Definition: imgupload.php:46
Class ilChatroomFormFactory.
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...
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
global $lng
Definition: privfeed.php:40
Class ilChatroomSettingsTask.
static applyValues(ilPropertyFormGUI $form, array $values)
Applies given values to field in given form.