ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 require_once 'Services/Notifications/classes/class.ilNotificationGUI.php';
28 $notifications = new ilNotificationGUI();
29 $notifications->{$_REQUEST['cmd'] . 'Object'}();
30 exit;
31 }
32
33 if ($a_data == null) {
34 if ($_GET['serverInquiry']) {
35 require_once dirname(__FILE__) . '/class.ilChatroomServerHandler.php';
37 return;
38 }
39 }
40
41 $this->type = 'chtr';
42 parent::__construct($a_data, $a_id, $a_call_by_reference, false);
43 $this->lng->loadLanguageModule('chatroom');
44 $this->lng->loadLanguageModule('chatroom_adm');
45 }
46
51 public static function _goto($params)
52 {
53 global $DIC;
54
55 $parts = explode('_', $params);
56 $ref_id = $parts[0];
57 $sub = $parts[1];
58
59 if (ilChatroom::checkUserPermissions('read', $ref_id, false)) {
60 if ($sub) {
61 $_REQUEST['sub'] = $_GET['sub'] = (int) $sub;
62 }
63 ilObjectGUI::_gotoRepositoryNode($ref_id, 'view');
64 } elseif (ilChatroom::checkUserPermissions('visible', $ref_id, false)) {
65 $DIC->ctrl()->setParameterByClass(ilInfoScreenGUI::class, 'ref_id', $ref_id);
66 $DIC->ctrl()->redirectByClass(
67 [
68 ilRepositoryGUI::class,
69 ilObjChatroomGUI::class,
70 ilInfoScreenGUI::class
71 ],
72 'info'
73 );
74 } elseif ($DIC->rbac()->system()->checkAccess('read', ROOT_FOLDER_ID)) {
75 ilUtil::sendInfo(sprintf($DIC->language()->txt('msg_no_perm_read_item'), ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id))), true);
76 ilObjectGUI::_gotoRepositoryNode(ROOT_FOLDER_ID, '');
77 }
78
79 $DIC['ilErr']->raiseError(sprintf($DIC->language()->txt('msg_no_perm_read_item'), ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id))), $DIC['ilErr']->FATAL);
80 }
81
87 protected function getObjectDefinition()
88 {
90 }
91
95 protected function initCreationForms($a_new_type)
96 {
97 $forms = parent::initCreationForms($a_new_type);
98
99 $forms[self::CFORM_NEW]->clearCommandButtons();
100 $forms[self::CFORM_NEW]->addCommandButton('create-save', $this->lng->txt($a_new_type . '_add'));
101 $forms[self::CFORM_NEW]->addCommandButton('cancel', $this->lng->txt('cancel'));
102 return $forms;
103 }
104
105 protected function addLocatorItems()
106 {
107 global $DIC;
108
109 if (is_object($this->object)) {
110 $DIC['ilLocator']->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, 'view'), '', $this->getRefId());
111 }
112 }
113
118 public function getRefId()
119 {
120 return $this->object->getRefId();
121 }
122
127 public function _forwards()
128 {
129 return array();
130 }
131
135 public function executeCommand()
136 {
137 global $DIC;
138
139 if ('cancel' == $this->ctrl->getCmd() && $this->getCreationMode()) {
140 parent::cancelCreation();
141 return;
142 }
143
144 // add entry to navigation history
145 if (!$this->getCreationMode() && $DIC->access()->checkAccess('read', '', (int) $_GET['ref_id'])) {
146 $DIC['ilNavigationHistory']->addItem($_GET['ref_id'], './goto.php?target=' . $this->type . '_' . $_GET['ref_id'], $this->type);
147 }
148
149 $next_class = $this->ctrl->getNextClass();
150
151 require_once 'Modules/Chatroom/classes/class.ilChatroomTabGUIFactory.php';
152 if (!$this->getCreationMode()) {
153 $tabFactory = new ilChatroomTabGUIFactory($this);
154
155 if (strtolower($_GET['baseClass']) == 'iladministrationgui') {
156 $tabFactory->getAdminTabsForCommand($this->ctrl->getCmd());
157 } else {
158 $DIC['ilHelp']->setScreenIdComponent("chtr");
159 $tabFactory->getTabsForCommand($this->ctrl->getCmd());
160 }
161 }
162
163 // #8701 - infoscreen actions
164 if ($next_class == 'ilinfoscreengui' && $this->ctrl->getCmd() != 'info') {
165 $this->ctrl->setCmd('info-' . $this->ctrl->getCmd());
166 }
167 // repository info call
168 if ($this->ctrl->getCmd() == 'infoScreen') {
169 $this->ctrl->setCmdClass('ilinfoscreengui');
170 $this->ctrl->setCmd('info');
171 }
172
173 switch ($next_class) {
174 case "ilpropertyformgui":
175 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
176
177 require_once 'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
179 $form = $factory->getClientSettingsForm();
180
181 $this->ctrl->forwardCommand($form);
182 break;
183 case 'ilpermissiongui':
184 include_once 'Services/AccessControl/classes/class.ilPermissionGUI.php';
185 $this->prepareOutput();
186 $perm_gui = new ilPermissionGUI($this);
187 $this->ctrl->forwardCommand($perm_gui);
188 break;
189
190 case 'ilexportgui':
191 $this->prepareOutput();
192
193 $GLOBALS['DIC']->tabs()->setTabActive('export');
194
195 require_once 'Services/Export/classes/class.ilExportGUI.php';
196 $exp = new ilExportGUI($this);
197 $exp->addFormat('xml');
198 $this->ctrl->forwardCommand($exp);
199 break;
200
201 case 'ilobjectcopygui':
202 $this->prepareOutput();
203 include_once 'Services/Object/classes/class.ilObjectCopyGUI.php';
204 $cp = new ilObjectCopyGUI($this);
205 $cp->setType('chtr');
206 $this->ctrl->forwardCommand($cp);
207 break;
208
209 case "ilcommonactiondispatchergui":
210 include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
212 $this->ctrl->forwardCommand($gui);
213 break;
214
215 default:
216 try {
217 $res = explode('-', $this->ctrl->getCmd(), 2);
218 $result = $this->dispatchCall($res[0], isset($res[1]) ? $res[1] : '');
219 if (!$result && method_exists($this, $this->ctrl->getCmd() . 'Object')) {
220 $this->prepareOutput();
221 $this->{$this->ctrl->getCmd() . 'Object'}();
222 }
223 } catch (Exception $e) {
224 $error = array(
225 'success' => false,
226 'reason' => $e->getMessage()
227 );
228 echo json_encode($error);
229 exit;
230 }
231 break;
232 }
233 }
234
238 public function getConnector()
239 {
240 require_once 'Modules/Chatroom/classes/class.ilChatroomServerConnector.php';
241 require_once 'Modules/Chatroom/classes/class.ilChatroomServerSettings.php';
242 require_once 'Modules/Chatroom/classes/class.ilChatroomAdmin.php';
243
244 $settings = ilChatroomAdmin::getDefaultConfiguration()->getServerSettings();
245 $connector = new ilChatroomServerConnector($settings);
246
247 return $connector;
248 }
249
253 public function fallback()
254 {
255 $this->prepareOutput();
256 $this->tpl->setVariable('ADM_CONTENT', $this->lng->txt('invalid_operation'));
257 }
258
262 public function settings()
263 {
264 $this->prepareOutput();
265 }
266
274 public function insertObject()
275 {
276 global $DIC;
277
278 $new_type = $this->type;
279
280 // create permission is already checked in createObject.
281 // This check here is done to prevent hacking attempts
282 if (!$DIC->rbac()->system()->checkAccess('create', $_GET['ref_id'], $new_type)) {
283 $this->ilias->raiseError(
284 $this->lng->txt('no_create_permission'),
285 $this->ilias->error_obj->MESSAGE
286 );
287 }
288
289 $location = $DIC['objDefinition']->getLocation($new_type);
290
291 // create and insert object in objecttree
292 $class_name = 'ilObj' . $DIC['objDefinition']->getClassName($new_type);
293 include_once $location . '/class.' . $class_name . '.php';
294
298 $newObj = new $class_name();
299 $newObj->setType($new_type);
300 $newObj->setTitle(ilUtil::stripSlashes($_POST['title']));
301 $newObj->setDescription(ilUtil::stripSlashes($_POST['desc']));
302 $newObj->create();
303 $newObj->createReference();
304 $newObj->putInTree($_GET['ref_id']);
305 $newObj->setPermissions($_GET['ref_id']);
306
307 $objId = $newObj->getId();
308
309 $room = new ilChatroom();
310
311 $room->saveSettings(
312 array(
313 'object_id' => $objId,
314 'autogen_usernames' => 'Autogen #',
315 'display_past_msgs' => 20,
316 'private_rooms_enabled' => 0
317 )
318 );
319
320 include_once 'Services/AccessControl/classes/class.ilRbacLog.php';
321 $rbac_log_roles = $DIC->rbac()->review()->getParentRoleIds($newObj->getRefId(), false);
322 $rbac_log = ilRbacLog::gatherFaPa($newObj->getRefId(), array_keys($rbac_log_roles), true);
323 ilRbacLog::add(ilRbacLog::CREATE_OBJECT, $newObj->getRefId(), $rbac_log);
324
325 $this->object = $newObj;
326
327 return $newObj;
328 }
329}
$result
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$location
Definition: buildRTE.php:44
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
static getDefaultConfiguration()
Instantiates and returns ilChatroomAdmin object using instance_id and settings from settingsTable.
Class ilChatroomFormFactory.
static getDefaultDefinition($moduleName)
Returns an Instance of ilChatroomObjectDefinition, using given $moduleName as parameter.
Class ilChatroomServerConnector.
Class ilChatroomServerHandler.
Class ilChatroomTabGUIFactory.
Class ilChatroom.
static checkUserPermissions($permissions, $ref_id, $send_info=true)
Checks user permissions by given array and ref_id.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
Export User Interface Class.
Class ilObjChatroomGUI GUI class for chatroom objects.
executeCommand()
{execute command}
_forwards()
Returns an empty array.
__construct($a_data=null, $a_id=null, $a_call_by_reference=true)
{}
addLocatorItems()
should be overwritten to add object specific items (repository items are preloaded)
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.
static _goto($params)
Overwrites $_GET['ref_id'] with given $ref_id.
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.
exit
Definition: login.php:29
$factory
Definition: metadata.php:58
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
redirection script todo: (a better solution should control the processing via a xml file)
$type
foreach($_POST as $key=> $value) $res
$DIC
Definition: xapitoken.php:46
$objId
Definition: xapitoken.php:41