ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 include_once 'Services/Object/classes/class.ilObjectGUI.php';
64 ilObjectGUI::_gotoRepositoryNode($ref_id, 'view');
65 } elseif ($DIC->rbac()->system()->checkAccess('read', ROOT_FOLDER_ID)) {
66 ilUtil::sendInfo(sprintf($DIC->language()->txt('msg_no_perm_read_item'), ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id))), true);
67 include_once 'Services/Object/classes/class.ilObjectGUI.php';
68 ilObjectGUI::_gotoRepositoryNode(ROOT_FOLDER_ID, '');
69 }
70
71 $DIC['ilErr']->raiseError(sprintf($DIC->language()->txt('msg_no_perm_read_item'), ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id))), $DIC['ilErr']->FATAL);
72 }
73
79 protected function getObjectDefinition()
80 {
82 }
83
87 protected function initCreationForms($a_new_type)
88 {
89 $forms = parent::initCreationForms($a_new_type);
90
91 $forms[self::CFORM_NEW]->clearCommandButtons();
92 $forms[self::CFORM_NEW]->addCommandButton('create-save', $this->lng->txt($a_new_type . '_add'));
93 $forms[self::CFORM_NEW]->addCommandButton('cancel', $this->lng->txt('cancel'));
94 return $forms;
95 }
96
97 protected function addLocatorItems()
98 {
99 global $DIC;
100
101 if (is_object($this->object)) {
102 $DIC['ilLocator']->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, 'view'), '', $this->getRefId());
103 }
104 }
105
110 public function getRefId()
111 {
112 return $this->object->getRefId();
113 }
114
119 public function _forwards()
120 {
121 return array();
122 }
123
127 public function executeCommand()
128 {
129 global $DIC;
130
131 if ('cancel' == $this->ctrl->getCmd() && $this->getCreationMode()) {
132 parent::cancelCreation();
133 return;
134 }
135
136 // add entry to navigation history
137 if (!$this->getCreationMode() && $DIC->access()->checkAccess('read', '', (int) $_GET['ref_id'])) {
138 $DIC['ilNavigationHistory']->addItem($_GET['ref_id'], './goto.php?target=' . $this->type . '_' . $_GET['ref_id'], $this->type);
139 }
140
141 $next_class = $this->ctrl->getNextClass();
142
143 require_once 'Modules/Chatroom/classes/class.ilChatroomTabGUIFactory.php';
144 if (!$this->getCreationMode()) {
145 $tabFactory = new ilChatroomTabGUIFactory($this);
146
147 if (strtolower($_GET['baseClass']) == 'iladministrationgui') {
148 $tabFactory->getAdminTabsForCommand($this->ctrl->getCmd());
149 } else {
150 $DIC['ilHelp']->setScreenIdComponent("chtr");
151 $tabFactory->getTabsForCommand($this->ctrl->getCmd());
152 }
153 }
154
155 // #8701 - infoscreen actions
156 if ($next_class == 'ilinfoscreengui' && $this->ctrl->getCmd() != 'info') {
157 $this->ctrl->setCmd('info-' . $this->ctrl->getCmd());
158 }
159 // repository info call
160 if ($this->ctrl->getCmd() == 'infoScreen') {
161 $this->ctrl->setCmdClass('ilinfoscreengui');
162 $this->ctrl->setCmd('info');
163 }
164
165 switch ($next_class) {
166 case "ilpropertyformgui":
167 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
168
169 require_once 'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
171 $form = $factory->getClientSettingsForm();
172
173 $this->ctrl->forwardCommand($form);
174 break;
175 case 'ilpermissiongui':
176 include_once 'Services/AccessControl/classes/class.ilPermissionGUI.php';
177 $this->prepareOutput();
178 $perm_gui = new ilPermissionGUI($this);
179 $this->ctrl->forwardCommand($perm_gui);
180 break;
181
182 case 'ilexportgui':
183 $this->prepareOutput();
184
185 $GLOBALS['DIC']->tabs()->setTabActive('export');
186
187 require_once 'Services/Export/classes/class.ilExportGUI.php';
188 $exp = new ilExportGUI($this);
189 $exp->addFormat('xml');
190 $this->ctrl->forwardCommand($exp);
191 break;
192
193 case 'ilobjectcopygui':
194 $this->prepareOutput();
195 include_once 'Services/Object/classes/class.ilObjectCopyGUI.php';
196 $cp = new ilObjectCopyGUI($this);
197 $cp->setType('chtr');
198 $this->ctrl->forwardCommand($cp);
199 break;
200
201 case "ilcommonactiondispatchergui":
202 include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
204 $this->ctrl->forwardCommand($gui);
205 break;
206
207 default:
208 try {
209 $res = explode('-', $this->ctrl->getCmd(), 2);
210 $result = $this->dispatchCall($res[0], isset($res[1]) ? $res[1] : '');
211 if (!$result && method_exists($this, $this->ctrl->getCmd() . 'Object')) {
212 $this->prepareOutput();
213 $this->{$this->ctrl->getCmd() . 'Object'}();
214 }
215 } catch (Exception $e) {
216 $error = array(
217 'success' => false,
218 'reason' => $e->getMessage()
219 );
220 echo json_encode($error);
221 exit;
222 }
223 break;
224 }
225 }
226
230 public function getConnector()
231 {
232 require_once 'Modules/Chatroom/classes/class.ilChatroomServerConnector.php';
233 require_once 'Modules/Chatroom/classes/class.ilChatroomServerSettings.php';
234 require_once 'Modules/Chatroom/classes/class.ilChatroomAdmin.php';
235
236 $settings = ilChatroomAdmin::getDefaultConfiguration()->getServerSettings();
237 $connector = new ilChatroomServerConnector($settings);
238
239 return $connector;
240 }
241
245 public function fallback()
246 {
247 $this->prepareOutput();
248 $this->tpl->setVariable('ADM_CONTENT', $this->lng->txt('invalid_operation'));
249 }
250
254 public function settings()
255 {
256 $this->prepareOutput();
257 }
258
266 public function insertObject()
267 {
268 global $DIC;
269
270 $new_type = $this->type;
271
272 // create permission is already checked in createObject.
273 // This check here is done to prevent hacking attempts
274 if (!$DIC->rbac()->system()->checkAccess('create', $_GET['ref_id'], $new_type)) {
275 $this->ilias->raiseError(
276 $this->lng->txt('no_create_permission'),
277 $this->ilias->error_obj->MESSAGE
278 );
279 }
280
281 $location = $DIC['objDefinition']->getLocation($new_type);
282
283 // create and insert object in objecttree
284 $class_name = 'ilObj' . $DIC['objDefinition']->getClassName($new_type);
285 include_once $location . '/class.' . $class_name . '.php';
286
290 $newObj = new $class_name();
291 $newObj->setType($new_type);
292 $newObj->setTitle(ilUtil::stripSlashes($_POST['title']));
293 $newObj->setDescription(ilUtil::stripSlashes($_POST['desc']));
294 $newObj->create();
295 $newObj->createReference();
296 $newObj->putInTree($_GET['ref_id']);
297 $newObj->setPermissions($_GET['ref_id']);
298
299 $objId = $newObj->getId();
300
301 $room = new ilChatroom();
302
303 $room->saveSettings(
304 array(
305 'object_id' => $objId,
306 'autogen_usernames' => 'Autogen #',
307 'display_past_msgs' => 20,
308 'private_rooms_enabled' => 0
309 )
310 );
311
312 include_once 'Services/AccessControl/classes/class.ilRbacLog.php';
313 $rbac_log_roles = $DIC->rbac()->review()->getParentRoleIds($newObj->getRefId(), false);
314 $rbac_log = ilRbacLog::gatherFaPa($newObj->getRefId(), array_keys($rbac_log_roles), true);
315 ilRbacLog::add(ilRbacLog::CREATE_OBJECT, $newObj->getRefId(), $rbac_log);
316
317 $this->object = $newObj;
318
319 return $newObj;
320 }
321}
sprintf('%.4f', $callTime)
$result
$factory
Definition: metadata.php:47
$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.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$error
Definition: Error.php:17
redirection script todo: (a better solution should control the processing via a xml file)
$type
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$params
Definition: disable.php:11