ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjChatroom.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/Object/classes/class.ilObject.php';
5require_once 'Services/Object/classes/class.ilObjectActivation.php';
6
14{
18 protected $access_type;
19
23 protected $access_begin;
24
28 protected $access_end;
29
34
38 public function __construct($a_id = 0, $a_call_by_reference = true)
39 {
41
42 $this->type = 'chtr';
43 parent::__construct($a_id, $a_call_by_reference);
44 }
45
49 public function setAccessVisibility($a_value)
50 {
51 $this->access_visibility = (bool) $a_value;
52 }
53
57 public function getAccessVisibility()
58 {
60 }
61
65 public function getAccessType()
66 {
67 return $this->access_type;
68 }
69
73 public function setAccessType($access_type)
74 {
75 $this->access_type = $access_type;
76 }
77
81 public function getAccessBegin()
82 {
84 }
85
90 {
91 $this->access_begin = $access_begin;
92 }
93
97 public function getAccessEnd()
98 {
99 return $this->access_end;
100 }
101
105 public function setAccessEnd($access_end)
106 {
107 $this->access_end = $access_end;
108 }
109
113 public function update()
114 {
115 if ($this->ref_id) {
116 $activation = new ilObjectActivation();
117 $activation->setTimingType($this->getAccessType());
118 $activation->setTimingStart($this->getAccessBegin());
119 $activation->setTimingEnd($this->getAccessEnd());
120 $activation->toggleVisible($this->getAccessVisibility());
121 $activation->update($this->ref_id);
122 }
123
124 return parent::update();
125 }
126
130 public function read()
131 {
132 if ($this->ref_id) {
133 $activation = ilObjectActivation::getItem($this->ref_id);
134 $this->setAccessType($activation['timing_type']);
136 $this->setAccessBegin($activation['timing_start']);
137 $this->setAccessEnd($activation['timing_end']);
138 $this->setAccessVisibility($activation['visible']);
139 }
140 }
141
142 parent::read();
143 }
144
145 public static function _getPublicRefId()
146 {
147 $settings = new ilSetting('chatroom');
148 return $settings->get('public_room_ref', 0);
149 }
150
151 public static function _getPublicObjId()
152 {
153 global $DIC;
154
155 $rset = $DIC->database()->query('SELECT object_id FROM chatroom_settings WHERE room_type=' . $DIC->database()->quote('default', 'text'));
156 if ($row = $DIC->database()->fetchAssoc($rset)) {
157 return $row['object_id'];
158 }
159 return 0;
160 }
161
168 {
169 $userInfo = new stdClass();
170 $userInfo->username = $user->getUsername();
171 $userInfo->id = $user->getUserId();
172
173 return $userInfo;
174 }
175
179 public function initDefaultRoles()
180 {
181 include_once './Services/AccessControl/classes/class.ilObjRole.php';
182
183 $role = $this->createDefaultRole();
184
185 return array();
186 }
187
191 protected function createDefaultRole()
192 {
194 'il_chat_moderator_' . $this->getRefId(),
195 "Moderator of chat obj_no." . $this->getId(),
196 'il_chat_moderator',
197 $this->getRefId()
198 );
199 }
200
204 public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree = false)
205 {
206 global $DIC;
207
208 require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
209 $original_room = ilChatroom::byObjectId($this->getId());
210
211 $newObj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
212
213 $objId = $newObj->getId();
214
215 $original_settings = $original_room->getSettings();
216 $room = new ilChatroom();
217
218 $original_settings['object_id'] = $objId;
219
220 $room->saveSettings($original_settings);
221
222 include_once "Services/AccessControl/classes/class.ilRbacLog.php";
223 $rbac_log_roles = $DIC->rbac()->review()->getParentRoleIds($newObj->getRefId(), false);
224 $rbac_log = ilRbacLog::gatherFaPa($newObj->getRefId(), array_keys($rbac_log_roles), true);
225 ilRbacLog::add(ilRbacLog::CREATE_OBJECT, $newObj->getRefId(), $rbac_log);
226
227 require_once 'Modules/Chatroom/classes/class.ilChatroomServerConnector.php';
228 require_once 'Modules/Chatroom/classes/class.ilChatroomServerSettings.php';
229 require_once 'Modules/Chatroom/classes/class.ilChatroomAdmin.php';
230
231 $settings = ilChatroomAdmin::getDefaultConfiguration()->getServerSettings();
232 $connector = new ilChatroomServerConnector($settings);
233
234 $connector->sendCreatePrivateRoom($room->getRoomId(), 0, $newObj->getOwner(), $newObj->getTitle());
235
236 return $newObj;
237 }
238
242 public function delete()
243 {
244 global $DIC;
245
246 $DIC->database()->manipulateF(
247 'DELETE FROM chatroom_users WHERE chatroom_users.room_id IN (SELECT chatroom_settings.room_id FROM chatroom_settings WHERE chatroom_settings.object_id = %s)',
248 array('integer'),
249 array($this->getId())
250 );
251
252 $DIC->database()->manipulateF(
253 'DELETE FROM chatroom_history WHERE chatroom_history.room_id IN (SELECT chatroom_settings.room_id FROM chatroom_settings WHERE chatroom_settings.object_id = %s)',
254 array('integer'),
255 array($this->getId())
256 );
257
258 $DIC->database()->manipulateF(
259 'DELETE FROM chatroom_bans WHERE chatroom_bans.room_id IN (SELECT chatroom_settings.room_id FROM chatroom_settings WHERE chatroom_settings.object_id = %s)',
260 array('integer'),
261 array($this->getId())
262 );
263
264 $DIC->database()->manipulateF(
265 'DELETE FROM chatroom_sessions WHERE chatroom_sessions.room_id IN (SELECT chatroom_settings.room_id FROM chatroom_settings WHERE chatroom_settings.object_id = %s)',
266 array('integer'),
267 array($this->getId())
268 );
269
270 $DIC->database()->manipulateF(
271 '
272 DELETE FROM chatroom_proomaccess
273 WHERE chatroom_proomaccess.proom_id IN (
274 SELECT chatroom_prooms.proom_id
275 FROM chatroom_prooms WHERE chatroom_prooms.parent_id IN (
276 SELECT chatroom_settings.room_id
277 FROM chatroom_settings
278 WHERE chatroom_settings.object_id = %s
279 )
280 )',
281 array('integer'),
282 array($this->getId())
283 );
284
285 $DIC->database()->manipulateF(
286 '
287 DELETE FROM chatroom_psessions
288 WHERE chatroom_psessions.proom_id IN (
289 SELECT chatroom_prooms.proom_id
290 FROM chatroom_prooms WHERE chatroom_prooms.parent_id IN (
291 SELECT chatroom_settings.room_id
292 FROM chatroom_settings
293 WHERE chatroom_settings.object_id = %s
294 )
295 )',
296 array('integer'),
297 array($this->getId())
298 );
299
300 $DIC->database()->manipulateF(
301 'DELETE FROM chatroom_prooms WHERE chatroom_prooms.parent_id IN (SELECT chatroom_settings.room_id FROM chatroom_settings WHERE chatroom_settings.object_id = %s)',
302 array('integer'),
303 array($this->getId())
304 );
305
306 // Finally delete rooms
307 $DIC->database()->manipulateF(
308 'DELETE FROM chatroom_settings WHERE object_id = %s',
309 array('integer'),
310 array($this->getId())
311 );
312
313 if ($this->getId()) {
314 if ($this->ref_id) {
316 }
317 }
318
319 return parent::delete();
320 }
321}
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 ilChatroomServerConnector.
Class ilChatroomUser.
Class ilChatroom.
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
Class ilObjChatroom.
setAccessVisibility($a_value)
getPersonalInformation(ilChatroomUser $user)
Prepares and returns $userInfo using given $user object.
setAccessBegin($access_begin)
setAccessEnd($access_end)
__construct($a_id=0, $a_call_by_reference=true)
{Constructor @access public.}
read()
read object data from db into object
cloneObject($a_target_id, $a_copy_id=0, $a_omit_tree=false)
{}
initDefaultRoles()
{init default roles settings Purpose of this function is to create a local role folder and local role...
update()
update object in db@access public boolean true on success
setAccessType($access_type)
static createDefaultRole($a_title, $a_description, $a_tpl_name, $a_ref_id)
Class ilObjectActivation.
static deleteAllEntries($a_ref_id)
Delete all db entries for ref id.
static getItem($a_ref_id)
Get item data.
Class ilObject Basic functions for all objects.
getRefId()
get reference id @access public
getId()
get object id @access public
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
ILIAS Setting Class.
$user
Definition: migrateto20.php:57
$row
update($pash, $contents, Config $config)
global $DIC
Definition: saml.php:7