ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilObjChatroomGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/Object/classes/class.ilObjectGUI.php';
5require_once 'Modules/Chatroom/classes/class.ilObjChatroom.php';
6require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
7require_once 'Modules/Chatroom/classes/class.ilObjChatroomAccess.php';
8require_once 'Modules/Chatroom/classes/class.ilChatroomObjectGUI.php';
9
20{
24 public function __construct($a_data = null, $a_id = null, $a_call_by_reference = true)
25 {
26 if(in_array($_REQUEST['cmd'], array('getOSDNotifications', 'removeOSDNotifications')))
27 {
28 require_once 'Services/Notifications/classes/class.ilNotificationGUI.php';
29 $notifications = new ilNotificationGUI();
30 $notifications->{$_REQUEST['cmd'] . 'Object'}();
31 exit;
32 }
33
34 if($a_data == null)
35 {
36 if($_GET['serverInquiry'])
37 {
38 require_once dirname(__FILE__) . '/class.ilChatroomServerHandler.php';
40 return;
41 }
42 }
43
44 $this->type = 'chtr';
45 parent::__construct($a_data, $a_id, $a_call_by_reference, false);
46 $this->lng->loadLanguageModule('chatroom');
47 $this->lng->loadLanguageModule('chatroom_adm');
48 }
49
54 public static function _goto($params)
55 {
61 global $rbacsystem, $ilErr, $lng;
62
63 $parts = explode('_', $params);
64 $ref_id = $parts[0];
65 $sub = $parts[1];
66
67 if($rbacsystem->checkAccess('read', $ref_id))
68 {
69 if($sub)
70 {
71 $_REQUEST['sub'] = $_GET['sub'] = (int)$sub;
72 }
73 include_once 'Services/Object/classes/class.ilObjectGUI.php';
75 }
76 else if($rbacsystem->checkAccess('read', ROOT_FOLDER_ID))
77 {
79 include_once 'Services/Object/classes/class.ilObjectGUI.php';
80 ilObjectGUI::_gotoRepositoryNode(ROOT_FOLDER_ID, '');
81 }
82
83 $ilErr->raiseError(sprintf($lng->txt('msg_no_perm_read_item'), ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id))), $ilErr->FATAL);
84 }
85
91 protected function getObjectDefinition()
92 {
94 }
95
99 protected function initCreationForms($a_new_type)
100 {
101 $forms = parent::initCreationForms($a_new_type);
102
103 unset($forms[self::CFORM_IMPORT]);
104 $forms[self::CFORM_NEW]->clearCommandButtons();
105 $forms[self::CFORM_NEW]->addCommandButton('create-save', $this->lng->txt($a_new_type . '_add'));
106 $forms[self::CFORM_NEW]->addCommandButton('cancel', $this->lng->txt('cancel'));
107 return $forms;
108 }
109
110 protected function addLocatorItems()
111 {
115 global $ilLocator;
116
117 if(is_object($this->object))
118 {
119 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, 'view'), '', $this->getRefId());
120 }
121 }
122
127 public function getRefId()
128 {
129 return $this->object->getRefId();
130 }
131
136 public function _forwards()
137 {
138 return array();
139 }
140
144 public function executeCommand()
145 {
152 global $ilNavigationHistory, $ilCtrl, $ilHelp, $ilAccess;
153
154 if('cancel' == $ilCtrl->getCmd() && $this->getCreationMode())
155 {
156 parent::cancelCreation();
157 return;
158 }
159
160 // add entry to navigation history
161 if(!$this->getCreationMode() && $ilAccess->checkAccess('read', '', (int)$_GET['ref_id']))
162 {
163 $ilNavigationHistory->addItem($_GET['ref_id'], './goto.php?target=' . $this->type . '_' . $_GET['ref_id'], $this->type);
164 }
165
166 $next_class = $ilCtrl->getNextClass();
167
168 require_once 'Modules/Chatroom/classes/class.ilChatroomTabGUIFactory.php';
169 if(!$this->getCreationMode())
170 {
171 $tabFactory = new ilChatroomTabGUIFactory($this);
172
173 if(strtolower($_GET['baseClass']) == 'iladministrationgui')
174 {
175 $tabFactory->getAdminTabsForCommand($ilCtrl->getCmd());
176 }
177 else
178 {
179 $ilHelp->setScreenIdComponent("chtr");
180 $tabFactory->getTabsForCommand($ilCtrl->getCmd());
181 }
182 }
183
184 // #8701 - infoscreen actions
185 if($next_class == 'ilinfoscreengui' && $ilCtrl->getCmd() != 'info')
186 {
187 $ilCtrl->setCmd('info-' . $ilCtrl->getCmd());
188 }
189 // repository info call
190 if($ilCtrl->getCmd() == 'infoScreen')
191 {
192 $ilCtrl->setCmdClass('ilinfoscreengui');
193 $ilCtrl->setCmd('info');
194 }
195
196 switch($next_class)
197 {
198 case "ilpropertyformgui":
199 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
200
201 require_once 'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
202 $factory = new ilChatroomFormFactory();
203 $form = $factory->getClientSettingsForm();
204
205 $ilCtrl->forwardCommand($form);
206 break;
207 case 'ilpermissiongui':
208 include_once 'Services/AccessControl/classes/class.ilPermissionGUI.php';
209 $this->prepareOutput();
210 $perm_gui = new ilPermissionGUI($this);
211 $ilCtrl->forwardCommand($perm_gui);
212 break;
213 case 'ilobjectcopygui':
214 $this->prepareOutput();
215 include_once 'Services/Object/classes/class.ilObjectCopyGUI.php';
216 $cp = new ilObjectCopyGUI($this);
217 $cp->setType('chtr');
218 $ilCtrl->forwardCommand($cp);
219 break;
220
221 case "ilcommonactiondispatchergui":
222 include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
224 $this->ctrl->forwardCommand($gui);
225 break;
226
227 default:
228 try
229 {
230 $res = explode('-', $ilCtrl->getCmd(), 2);
231 $this->dispatchCall($res[0], $res[1] ? $res[1] : '');
232 }
233 catch(Exception $e)
234 {
235 $error = array(
236 'success' => false,
237 'reason' => $e->getMessage()
238 );
239 echo json_encode($error);
240 exit;
241 }
242 }
243 }
244
248 public function getConnector()
249 {
250 require_once 'Modules/Chatroom/classes/class.ilChatroomServerConnector.php';
251 require_once 'Modules/Chatroom/classes/class.ilChatroomServerSettings.php';
252 require_once 'Modules/Chatroom/classes/class.ilChatroomAdmin.php';
253
254 $settings = ilChatroomAdmin::getDefaultConfiguration()->getServerSettings();
255 $connector = new ilChatroomServerConnector($settings);
256
257 return $connector;
258 }
259
263 public function fallback()
264 {
265 $this->prepareOutput();
266 $this->tpl->setVariable('ADM_CONTENT', $this->lng->txt('invalid_operation'));
267 }
268
272 public function settings()
273 {
274 $this->prepareOutput();
275 }
276
284 public function insertObject()
285 {
291 global $rbacsystem, $objDefinition, $rbacreview;
292
293 $new_type = $this->type;
294
295 // create permission is already checked in createObject.
296 // This check here is done to prevent hacking attempts
297 if(!$rbacsystem->checkAccess('create', $_GET['ref_id'], $new_type))
298 {
299 $this->ilias->raiseError(
300 $this->lng->txt('no_create_permission'),
301 $this->ilias->error_obj->MESSAGE
302 );
303 }
304
305 $location = $objDefinition->getLocation($new_type);
306
307 // create and insert object in objecttree
308 $class_name = 'ilObj' . $objDefinition->getClassName($new_type);
309 include_once $location . '/class.' . $class_name . '.php';
310
314 $newObj = new $class_name();
315 $newObj->setType($new_type);
316 $newObj->setTitle(ilUtil::stripSlashes($_POST['title']));
317 $newObj->setDescription(ilUtil::stripSlashes($_POST['desc']));
318 $newObj->create();
319 $newObj->createReference();
320 $newObj->putInTree($_GET['ref_id']);
321 $newObj->setPermissions($_GET['ref_id']);
322
323 $objId = $newObj->getId();
324
325 $room = new ilChatroom();
326
327 $room->saveSettings(
328 array(
329 'object_id' => $objId,
330 'autogen_usernames' => 'Autogen #',
331 'display_past_msgs' => 20,
332 'private_rooms_enabled' => 0
333 ));
334
335 // rbac log
336 include_once 'Services/AccessControl/classes/class.ilRbacLog.php';
337 $rbac_log_roles = $rbacreview->getParentRoleIds($newObj->getRefId(), false);
338 $rbac_log = ilRbacLog::gatherFaPa($newObj->getRefId(), array_keys($rbac_log_roles), true);
339 ilRbacLog::add(ilRbacLog::CREATE_OBJECT, $newObj->getRefId(), $rbac_log);
340
341 $this->object = $newObj;
342
343 return $newObj;
344 }
345}
sprintf('%.4f', $callTime)
$error
Definition: Error.php:17
$location
Definition: buildRTE.php:44
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
Class ilChatroomFormFactory.
static getDefaultDefinition($moduleName)
Returns an Instance of ilChatroomObjectDefinition, using given $moduleName as parameter.
Class ilChatroomServerConnector.
Class ilChatroomServerHandler.
Class ilChatroomTabGUIFactory.
Class ilChatroom.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
Class ilObjChatroomGUI GUI class for chatroom objects.
_forwards()
Returns an empty array.
__construct($a_data=null, $a_id=null, $a_call_by_reference=true)
{}
initCreationForms($a_new_type)
{Init creation froms.this will create the default creation forms: new, import, clonearray}
fallback()
Calls $this->prepareOutput method and sets template variable.
getObjectDefinition()
Returns object definition by calling getDefaultDefinition method in ilChatroomObjectDefinition.
settings()
Calls prepareOutput method.
GUI class for the workflow of copying objects.
static _gotoRepositoryNode($a_ref_id, $a_cmd="frameset")
Goto repository root.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
static add($a_action, $a_ref_id, array $a_diff, $a_source_ref_id=false)
static gatherFaPa($a_ref_id, array $a_role_ids, $a_add_action=false)
const CREATE_OBJECT
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$params
Definition: example_049.php:96
global $ilCtrl
Definition: ilias.php:18
redirection script todo: (a better solution should control the processing via a xml file)
global $lng
Definition: privfeed.php:17
global $ilErr
Definition: raiseError.php:16
$ref_id
Definition: sahs_server.php:39