ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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{
27 public function __construct($a_data = null, $a_id = null, $a_call_by_reference = true)
28 {
29 if(in_array($_REQUEST['cmd'], array('getOSDNotifications', 'removeOSDNotifications')))
30 {
31 require_once 'Services/Notifications/classes/class.ilNotificationGUI.php';
32 $notifications = new ilNotificationGUI();
33 $notifications->{$_REQUEST['cmd'] . 'Object'}();
34 exit;
35 }
36
37 if($a_data == null)
38 {
39 if($_GET['serverInquiry'])
40 {
41 require_once dirname(__FILE__) . '/class.ilChatroomServerHandler.php';
43 return;
44 }
45 }
46
47 $this->type = 'chtr';
48 parent::__construct($a_data, $a_id, $a_call_by_reference, false);
49 $this->lng->loadLanguageModule('chatroom');
50 $this->lng->loadLanguageModule('chatroom_adm');
51 }
52
58 protected function getObjectDefinition()
59 {
61 }
62
67 public function _forwards()
68 {
69 return array();
70 }
71
75 public function executeCommand()
76 {
83 global $ilNavigationHistory, $ilCtrl, $ilHelp, $ilAccess;
84
85 if('cancel' == $ilCtrl->getCmd() && $this->getCreationMode())
86 {
87 parent::cancelCreation();
88 return;
89 }
90
91 // add entry to navigation history
92 if(!$this->getCreationMode() && $ilAccess->checkAccess('read', '', (int)$_GET['ref_id']))
93 {
94 $ilNavigationHistory->addItem($_GET['ref_id'], './goto.php?target=' . $this->type . '_' . $_GET['ref_id'], $this->type);
95 }
96
97 $next_class = $ilCtrl->getNextClass();
98
99 require_once 'Modules/Chatroom/classes/class.ilChatroomTabGUIFactory.php';
100 if(!$this->getCreationMode())
101 {
102 $tabFactory = new ilChatroomTabGUIFactory($this);
103
104 if(strtolower($_GET['baseClass']) == 'iladministrationgui')
105 {
106 $tabFactory->getAdminTabsForCommand($ilCtrl->getCmd());
107 }
108 else
109 {
110 $ilHelp->setScreenIdComponent("chtr");
111 $tabFactory->getTabsForCommand($ilCtrl->getCmd());
112 }
113 }
114
115 // #8701 - infoscreen actions
116 if($next_class == 'ilinfoscreengui' && $ilCtrl->getCmd() != 'info')
117 {
118 $ilCtrl->setCmd('info-' . $ilCtrl->getCmd());
119 }
120 // repository info call
121 if($ilCtrl->getCmd() == 'infoScreen')
122 {
123 $ilCtrl->setCmdClass('ilinfoscreengui');
124 $ilCtrl->setCmd('info');
125 }
126
127 switch($next_class)
128 {
129 case 'ilpermissiongui':
130 include_once 'Services/AccessControl/classes/class.ilPermissionGUI.php';
131 $this->prepareOutput();
132 $perm_gui = new ilPermissionGUI($this);
133 $ilCtrl->forwardCommand($perm_gui);
134 break;
135 case 'ilobjectcopygui':
136 $this->prepareOutput();
137 include_once 'Services/Object/classes/class.ilObjectCopyGUI.php';
138 $cp = new ilObjectCopyGUI($this);
139 $cp->setType('chtr');
140 $ilCtrl->forwardCommand($cp);
141 break;
142
143 case "ilcommonactiondispatchergui":
144 include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
146 $this->ctrl->forwardCommand($gui);
147 break;
148
149 default:
150 try
151 {
152 $res = explode('-', $ilCtrl->getCmd(), 2);
153 $this->dispatchCall($res[0], $res[1] ? $res[1] : '');
154 }
155 catch(Exception $e)
156 {
157 $error = array(
158 'success' => false,
159 'reason' => $e->getMessage()
160 );
161 echo json_encode($error);
162 exit;
163 }
164 }
165 }
166
170 public function getConnector()
171 {
172 require_once 'Modules/Chatroom/classes/class.ilChatroomServerConnector.php';
173 require_once 'Modules/Chatroom/classes/class.ilChatroomServerSettings.php';
174 require_once 'Modules/Chatroom/classes/class.ilChatroomAdmin.php';
175
176 $settings = ilChatroomAdmin::getDefaultConfiguration()->getServerSettings();
177 $connector = new ilChatroomServerConnector($settings);
178
179 return $connector;
180 }
181
185 public function fallback()
186 {
187 $this->prepareOutput();
188 $this->tpl->setVariable('ADM_CONTENT', $this->lng->txt('invalid_operation'));
189 }
190
194 public function settings()
195 {
196 $this->prepareOutput();
197 }
198
206 public function insertObject()
207 {
213 global $rbacsystem, $objDefinition, $rbacreview;
214
215 $new_type = $this->type;
216
217 // create permission is already checked in createObject.
218 // This check here is done to prevent hacking attempts
219 if(!$rbacsystem->checkAccess('create', $_GET['ref_id'], $new_type))
220 {
221 $this->ilias->raiseError(
222 $this->lng->txt('no_create_permission'),
223 $this->ilias->error_obj->MESSAGE
224 );
225 }
226
227 $location = $objDefinition->getLocation($new_type);
228
229 // create and insert object in objecttree
230 $class_name = 'ilObj' . $objDefinition->getClassName($new_type);
231 include_once $location . '/class.' . $class_name . '.php';
232
236 $newObj = new $class_name();
237 $newObj->setType($new_type);
238 $newObj->setTitle(ilUtil::stripSlashes($_POST['title']));
239 $newObj->setDescription(ilUtil::stripSlashes($_POST['desc']));
240 $newObj->create();
241 $newObj->createReference();
242 $newObj->putInTree($_GET['ref_id']);
243 $newObj->setPermissions($_GET['ref_id']);
244
245 $objId = $newObj->getId();
246
247 $room = new ilChatroom();
248
249 $room->saveSettings(
250 array(
251 'object_id' => $objId,
252 'autogen_usernames' => 'Autogen #',
253 'display_past_msgs' => 20,
254 'private_rooms_enabled' => 0
255 ));
256
257 // rbac log
258 include_once 'Services/AccessControl/classes/class.ilRbacLog.php';
259 $rbac_log_roles = $rbacreview->getParentRoleIds($newObj->getRefId(), false);
260 $rbac_log = ilRbacLog::gatherFaPa($newObj->getRefId(), array_keys($rbac_log_roles), true);
261 ilRbacLog::add(ilRbacLog::CREATE_OBJECT, $newObj->getRefId(), $rbac_log);
262
263 $this->object = $newObj;
264
265 return $newObj;
266 }
267
272 public function getRefId()
273 {
274 return $this->object->getRefId();
275 }
276
281 public static function _goto($params)
282 {
288 global $rbacsystem, $ilErr, $lng;
289
290 $parts = explode('_', $params);
291 $ref_id = $parts[0];
292 $sub = $parts[1];
293
294 if($rbacsystem->checkAccess('read', $ref_id))
295 {
296 if($sub)
297 {
298 $_REQUEST['sub'] = $_GET['sub'] = (int)$sub;
299 }
300 include_once 'Services/Object/classes/class.ilObjectGUI.php';
302 }
303 else if($rbacsystem->checkAccess('read', ROOT_FOLDER_ID))
304 {
305 ilUtil::sendInfo(sprintf($lng->txt('msg_no_perm_read_item'), ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id))), true);
306 include_once 'Services/Object/classes/class.ilObjectGUI.php';
307 ilObjectGUI::_gotoRepositoryNode(ROOT_FOLDER_ID, '');
308 }
309
310 $ilErr->raiseError(sprintf($lng->txt('msg_no_perm_read_item'), ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id))), $ilErr->FATAL);
311 }
312
317 protected function initCreationForms($a_new_type)
318 {
319 $forms = parent::initCreationForms($a_new_type);
320
321 unset($forms[self::CFORM_IMPORT]);
322 $forms[self::CFORM_NEW]->clearCommandButtons();
323 $forms[self::CFORM_NEW]->addCommandButton('create-save', $this->lng->txt($a_new_type . '_add'));
324 $forms[self::CFORM_NEW]->addCommandButton('cancel', $this->lng->txt('cancel'));
325 return $forms;
326 }
327
328 function addLocatorItems()
329 {
333 global $ilLocator;
334
335 if(is_object($this->object))
336 {
337 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, 'view'), '', $this->getRefId());
338 }
339 }
340}
$location
Definition: buildRTE.php:44
$_GET["client_id"]
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)
Constructor.
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.
$_POST['username']
Definition: cron.php:12
$params
Definition: example_049.php:96
global $ilCtrl
Definition: ilias.php:18
exit
Definition: login.php:54
redirection script todo: (a better solution should control the processing via a xml file)
global $lng
Definition: privfeed.php:40
$ref_id
Definition: sahs_server.php:39
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7