ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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";
5
13{
17 public function __construct($a_id = 0, $a_call_by_reference = true)
18 {
19 $this->type = 'chtr';
20 parent::__construct($a_id, $a_call_by_reference);
21 }
22
23 public static function _getPublicRefId()
24 {
25 $settings = new ilSetting('chatroom');
26 return $settings->get('public_room_ref', 0);
27 }
28
29 public static function _getPublicObjId()
30 {
31 global $ilDB;
32
33 $rset = $ilDB->query('SELECT object_id FROM chatroom_settings WHERE room_type=' . $ilDB->quote('default', 'text'));
34 if($row = $ilDB->fetchAssoc($rset))
35 {
36 return $row['object_id'];
37 }
38 return 0;
39 }
40
47 {
48 $userInfo = new stdClass();
49 $userInfo->username = $user->getUsername();
50 $userInfo->id = $user->getUserId();
51
52 return $userInfo;
53 }
54
59 {
60 include_once './Services/AccessControl/classes/class.ilObjRole.php';
61
62 $role = $this->createDefaultRole();
63
64 return array();
65 }
66
70 protected function createDefaultRole()
71 {
73 'il_chat_moderator_' . $this->getRefId(),
74 "Moderator of chat obj_no." . $this->getId(),
75 'il_chat_moderator',
76 $this->getRefId()
77 );
78 }
79
83 public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree = false)
84 {
88 global $rbacreview;
89
90 require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
91 $original_room = ilChatroom::byObjectId($this->getId());
92
93 $newObj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
94
95 $objId = $newObj->getId();
96
97 $original_settings = $original_room->getSettings();
98 $room = new ilChatroom();
99
100 $original_settings['object_id'] = $objId;
101
102 $room->saveSettings($original_settings);
103
104 include_once "Services/AccessControl/classes/class.ilRbacLog.php";
105 $rbac_log_roles = $rbacreview->getParentRoleIds($newObj->getRefId(), false);
106 $rbac_log = ilRbacLog::gatherFaPa($newObj->getRefId(), array_keys($rbac_log_roles), true);
107 ilRbacLog::add(ilRbacLog::CREATE_OBJECT, $newObj->getRefId(), $rbac_log);
108
109 require_once 'Modules/Chatroom/classes/class.ilChatroomServerConnector.php';
110 require_once 'Modules/Chatroom/classes/class.ilChatroomServerSettings.php';
111 require_once 'Modules/Chatroom/classes/class.ilChatroomAdmin.php';
112
113 $settings = ilChatroomAdmin::getDefaultConfiguration()->getServerSettings();
114 $connector = new ilChatroomServerConnector($settings);
115
116 $connector->sendCreatePrivateRoom($room->getRoomId(), 0, $newObj->getOwner(), $newObj->getTitle());
117
118 return $newObj;
119 }
120
124 public function delete()
125 {
129 global $ilDB;
130
131 $ilDB->manipulateF(
132 'DELETE FROM chatroom_users WHERE chatroom_users.room_id IN (SELECT chatroom_settings.room_id FROM chatroom_settings WHERE chatroom_settings.object_id = %s)',
133 array('integer'),
134 array($this->getId())
135 );
136
137 $ilDB->manipulateF(
138 'DELETE FROM chatroom_history WHERE chatroom_history.room_id IN (SELECT chatroom_settings.room_id FROM chatroom_settings WHERE chatroom_settings.object_id = %s)',
139 array('integer'),
140 array($this->getId())
141 );
142
143 $ilDB->manipulateF(
144 'DELETE FROM chatroom_bans WHERE chatroom_bans.room_id IN (SELECT chatroom_settings.room_id FROM chatroom_settings WHERE chatroom_settings.object_id = %s)',
145 array('integer'),
146 array($this->getId())
147 );
148
149 $ilDB->manipulateF(
150 'DELETE FROM chatroom_sessions WHERE chatroom_sessions.room_id IN (SELECT chatroom_settings.room_id FROM chatroom_settings WHERE chatroom_settings.object_id = %s)',
151 array('integer'),
152 array($this->getId())
153 );
154
155 $ilDB->manipulateF('
156 DELETE FROM chatroom_proomaccess
157 WHERE chatroom_proomaccess.proom_id IN (
158 SELECT chatroom_prooms.proom_id
159 FROM chatroom_prooms WHERE chatroom_prooms.parent_id IN (
160 SELECT chatroom_settings.room_id
161 FROM chatroom_settings
162 WHERE chatroom_settings.object_id = %s
163 )
164 )',
165 array('integer'),
166 array($this->getId())
167 );
168
169 $ilDB->manipulateF('
170 DELETE FROM chatroom_psessions
171 WHERE chatroom_psessions.proom_id IN (
172 SELECT chatroom_prooms.proom_id
173 FROM chatroom_prooms WHERE chatroom_prooms.parent_id IN (
174 SELECT chatroom_settings.room_id
175 FROM chatroom_settings
176 WHERE chatroom_settings.object_id = %s
177 )
178 )',
179 array('integer'),
180 array($this->getId())
181 );
182
183 $ilDB->manipulateF(
184 'DELETE FROM chatroom_prooms WHERE chatroom_prooms.parent_id IN (SELECT chatroom_settings.room_id FROM chatroom_settings WHERE chatroom_settings.object_id = %s)',
185 array('integer'),
186 array($this->getId())
187 );
188
189 // Finally delete rooms
190 $ilDB->manipulateF(
191 'DELETE FROM chatroom_settings WHERE object_id = %s',
192 array('integer'),
193 array($this->getId())
194 );
195
196 return parent::delete();
197 }
198}
An exception for terminatinating execution or to throw for unit testing.
Class ilChatroomServerConnector.
Class ilChatroomUser.
getUserId()
Returns Ilias User ID.
getUsername()
Returns username from Object or SESSION.
Class ilChatroom.
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
Class ilObjChatroom.
getPersonalInformation(ilChatroomUser $user)
Prepares and returns $userInfo using given $user object.
__construct($a_id=0, $a_call_by_reference=true)
{Constructor @access public.}
initDefaultRoles()
{init default roles settings Purpose of this function is to create a local role folder and local role...
static createDefaultRole($a_title, $a_description, $a_tpl_name, $a_ref_id)
Class ilObject Basic functions for all objects.
cloneObject($a_target_id, $a_copy_id=0, $a_omit_tree=false)
Clone object permissions, put in tree ...
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.
global $ilDB