17 public static function install()
24 $ilDB = $DIC->database();
26 if (!
$ilDB->tableExists(
'chatroom_settings')) {
28 'room_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
29 'object_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
false,
'default' => 0),
30 'room_type' => array(
'type' =>
'text',
'length' => 20,
'notnull' =>
true),
31 'allow_anonymous' => array(
'type' =>
'integer',
'length' => 1,
'notnull' =>
false,
'default' => 0),
32 'allow_custom_usernames' => array(
'type' =>
'integer',
'length' => 1,
'notnull' =>
false,
'default' => 0),
33 'enable_history' => array(
'type' =>
'integer',
'length' => 1,
'notnull' =>
false,
'default' => 0),
34 'restrict_history' => array(
'type' =>
'integer',
'length' => 1,
'notnull' =>
false,
'default' => 0),
35 'autogen_usernames' => array(
'type' =>
'text',
'length' => 50,
'notnull' =>
false,
'default' =>
'Anonymous #'),
36 'allow_private_rooms' => array(
'type' =>
'integer',
'length' => 1,
'notnull' =>
false,
'default' => 0),
39 $ilDB->createTable(
'chatroom_settings', $fields);
40 $ilDB->addPrimaryKey(
'chatroom_settings', array(
'room_id'));
41 $ilDB->createSequence(
'chatroom_settings');
44 if (!
$ilDB->tableExists(
'chatroom_users')) {
46 'room_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
47 'user_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
48 'userdata' => array(
'type' =>
'text',
'length' => 4000,
'notnull' =>
true),
49 'connected' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
51 $ilDB->createTable(
'chatroom_users', $fields);
52 $ilDB->addPrimaryKey(
'chatroom_users', array(
'room_id',
'user_id'));
55 if (!
$ilDB->tableExists(
'chatroom_sessions')) {
57 'room_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
58 'user_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
59 'userdata' => array(
'type' =>
'text',
'length' => 4000,
'notnull' =>
true),
60 'connected' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
61 'disconnected' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
63 $ilDB->createTable(
'chatroom_sessions', $fields);
66 if (!
$ilDB->tableExists(
'chatroom_history')) {
68 'room_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
69 'message' => array(
'type' =>
'text',
'length' => 4000,
'notnull' =>
true),
70 'timestamp' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
72 $ilDB->createTable(
'chatroom_history', $fields);
75 if (!
$ilDB->tableExists(
'chatroom_bans')) {
77 'room_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
78 'user_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
79 'timestamp' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
80 'remark' => array(
'type' =>
'text',
'length' => 1000,
'notnull' =>
false),
82 $ilDB->createTable(
'chatroom_bans', $fields);
85 if (!
$ilDB->tableExists(
'chatroom_admconfig')) {
87 'instance_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
88 'server_settings' => array(
'type' =>
'text',
'length' => 2000,
'notnull' =>
true),
89 'default_config' => array(
'type' =>
'integer',
'length' => 1,
'notnull' =>
true,
'default' => 0),
91 $ilDB->createTable(
'chatroom_admconfig', $fields);
92 $ilDB->addPrimaryKey(
'chatroom_admconfig', array(
'instance_id'));
93 $ilDB->createSequence(
'chatroom_admconfig');
96 if (!
$ilDB->tableExists(
'chatroom_prooms')) {
98 'proom_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
99 'parent_id' => array(
'type' =>
'text',
'length' => 2000,
'notnull' =>
true),
100 'title' => array(
'type' =>
'text',
'length' => 200,
'notnull' =>
true,
'default' => 0),
101 'owner' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true,
'default' => 0),
102 'created' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true,
'default' => 0),
103 'closed' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
false,
'default' => 0),
105 $ilDB->createTable(
'chatroom_prooms', $fields);
106 $ilDB->addPrimaryKey(
'chatroom_prooms', array(
'proom_id'));
107 $ilDB->createSequence(
'chatroom_prooms');
110 if (!
$ilDB->tableExists(
'chatroom_psessions')) {
112 'proom_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
113 'user_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
114 'connected' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
115 'disconnected' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
117 $ilDB->createTable(
'chatroom_psessions', $fields);
120 if (!
$ilDB->tableExists(
'chatroom_uploads')) {
122 'upload_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
123 'room_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
124 'user_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
125 'filename' => array(
'type' =>
'text',
'length' => 200,
'notnull' =>
true),
126 'filetype' => array(
'type' =>
'text',
'length' => 200,
'notnull' =>
true),
127 'timestamp' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true)
129 $ilDB->createTable(
'chatroom_uploads', $fields);
130 $ilDB->addPrimaryKey(
'chatroom_uploads', array(
'upload_id'));
131 $ilDB->createSequence(
'chatroom_uploads');
134 if (!
$ilDB->tableColumnExists(
'chatroom_prooms',
'is_public')) {
135 $ilDB->addTableColumn(
'chatroom_prooms',
'is_public', array(
'type' =>
'integer',
'default' => 1,
'length' => 1));
138 if (!
$ilDB->tableExists(
'chatroom_psessions')) {
140 'proom_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
141 'user_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
142 'connected' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
143 'disconnected' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
145 $ilDB->createTable(
'chatroom_psessions', $fields);
148 if (!
$ilDB->tableExists(
'chatroom_proomaccess')) {
150 'proom_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
151 'user_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
153 $ilDB->createTable(
'chatroom_proomaccess', $fields);
156 if (!
$ilDB->tableColumnExists(
'chatroom_admconfig',
'client_settings')) {
157 $ilDB->addTableColumn(
158 "chatroom_admconfig",
168 if (!
$ilDB->tableExists(
'chatroom_smilies')) {
170 'smiley_id' => array(
174 'smiley_keywords' => array(
178 'smiley_path' => array(
184 $ilDB->createTable(
'chatroom_smilies', $fields);
185 $ilDB->addPrimaryKey(
'chatroom_smilies', array(
'smiley_id'));
186 $ilDB->createSequence(
'chatroom_smilies');
189 self::registerObject();
190 self::registerAdminObject();
191 self::removeOldChatEntries();
192 self::convertChatObjects();
194 $notificationSettings =
new ilSetting(
'notifications');
195 $notificationSettings->set(
'enable_osd',
true);
202 public static function registerObject()
207 $ilDB = $DIC->database();
211 $query =
'SELECT obj_id FROM object_data ' .
212 'WHERE type = ' .
$ilDB->quote(
'typ',
'text') .
' ' .
213 'AND title = ' .
$ilDB->quote(
'chtr',
'text');
215 $typ_id =
$ilDB->nextId(
'object_data');
219 'obj_id' => array(
'integer', $typ_id),
220 'type' => array(
'text',
'typ'),
221 'title' => array(
'text',
'chtr'),
222 'description' => array(
'text',
'Chatroom Object'),
223 'owner' => array(
'integer', -1),
224 'create_date' => array(
'timestamp', date(
'Y-m-d H:i:s')),
225 'last_update' => array(
'timestamp', date(
'Y-m-d H:i:s'))
231 foreach (array(1, 2, 3, 4) as $ops_id) {
232 $query =
"INSERT INTO rbac_ta (typ_id, ops_id) VALUES ( " .
233 $ilDB->quote($typ_id,
'integer') .
"," .
$ilDB->quote($ops_id,
'integer') .
239 if ($moderatePermissionId = self::getModeratorPermissionId()) {
241 $typ_id = $object_definition_row[
'obj_id'];
246 'DELETE FROM rbac_ta WHERE typ_id = %s AND ops_id = %s',
247 array(
'integer',
'integer'),
248 array($typ_id, $moderatePermissionId)
254 'typ_id' => array(
'integer', $typ_id),
255 'ops_id' => array(
'integer', $moderatePermissionId),
262 private static function getModeratorPermissionId()
267 $ilDB = $DIC->database();
269 $rset =
$ilDB->queryF(
270 'SELECT ops_id FROM rbac_operations WHERE operation = %s',
275 return $row[
'ops_id'];
284 public static function registerAdminObject()
289 $ilDB = $DIC->database();
291 $query =
'SELECT * FROM object_data WHERE type = ' .
$ilDB->quote(
'chta',
'text');
293 $obj_id =
$ilDB->nextId(
'object_data');
297 'obj_id' => array(
'integer', $obj_id),
298 'type' => array(
'text',
'chta'),
299 'title' => array(
'text',
'Chatroom Admin'),
300 'description' => array(
'text',
'Chatroom General Settings'),
301 'owner' => array(
'integer', -1),
302 'create_date' => array(
'timestamp', date(
'Y-m-d H:i:s')),
303 'last_update' => array(
'timestamp', date(
'Y-m-d H:i:s'))
307 $ref_id =
$ilDB->nextId(
'object_reference');
308 $query =
"INSERT INTO object_reference (ref_id, obj_id) VALUES(" .
$ilDB->quote($ref_id,
'integer') .
", " .
$ilDB->quote($obj_id,
'integer') .
")";
312 $tree->insertNode($ref_id, SYSTEM_FOLDER_ID);
316 public static function removeOldChatEntries()
321 $ilDB = $DIC->database();
324 'SELECT object_data.obj_id, ref_id, lft, rgt 326 INNER JOIN object_reference ON object_reference.obj_id = object_data.obj_id 327 INNER JOIN tree ON child = ref_id 336 INNER JOIN object_reference ON ref_id = child 337 INNER JOIN object_data ON object_data.obj_id = object_reference.obj_id 338 WHERE lft BETWEEN %s AND %s', array(
'integer',
'integer'), array(
$data[
'lft'],
$data[
'rgt']));
343 WHERE obj_id = ' .
$ilDB->quote(
$row[
'obj_id'],
'integer')
348 FROM object_reference 349 WHERE ref_id = ' .
$ilDB->quote(
$row[
'ref_id'],
'integer')
355 WHERE child = ' .
$ilDB->quote(
$row[
'ref_id'],
'integer')
360 $ilDB->manipulateF(
'DELETE FROM object_data WHERE type = %s AND title = %s', array(
'text',
'text'), array(
'typ',
'chat'));
361 $ilDB->manipulateF(
'DELETE FROM object_data WHERE type = %s AND title = %s', array(
'text',
'text'), array(
'typ',
'chac'));
367 public static function convertChatObjects()
372 $ilDB = $DIC->database();
385 $obj_ids[] =
$row[
'obj_id'];
392 array(
'text',
'text'),
393 array(
'chtr',
'chat')
396 self::setChatroomSettings($obj_ids);
405 if (is_array($obj_ids)) {
406 foreach ($obj_ids as $obj_id) {
408 $room->saveSettings(array(
409 'object_id' => $obj_id,
410 'autogen_usernames' =>
'Autogen #',
411 'room_type' =>
'repository' 417 public static function createDefaultPublicRoom($force =
false)
422 $ilDB = $DIC->database();
425 $query =
'DELETE FROM chatroom_settings WHERE room_type = ' .
$ilDB->quote(
'default',
'text');
429 $query =
'SELECT * FROM chatroom_settings WHERE room_type = ' .
$ilDB->quote(
'default',
'text');
431 $create = !
$ilDB->fetchAssoc($rset);
435 SELECT object_data.obj_id, object_reference.ref_id 437 INNER JOIN object_reference ON object_reference.obj_id = object_data.obj_id 438 WHERE type = " .
$ilDB->quote(
'chta',
'text');
441 $chatfolder_ref_id =
$row[
'ref_id'];
443 require_once
'Modules/Chatroom/classes/class.ilObjChatroom.php';
446 $newObj->setType(
'chtr');
447 $newObj->setTitle(
'Public Chat');
448 $newObj->setDescription(
'');
450 $newObj->createReference();
451 $newObj->putInTree($chatfolder_ref_id);
452 $newObj->setPermissions($chatfolder_ref_id);
454 $obj_id = $newObj->getId();
455 $ref_id = $newObj->getRefId();
457 $id =
$ilDB->nextId(
'chatroom_settings');
461 'room_id' => array(
'integer',
$id),
462 'object_id' => array(
'integer', $obj_id),
463 'room_type' => array(
'text',
'default'),
464 'allow_anonymous' => array(
'integer', 0),
465 'allow_custom_usernames' => array(
'integer', 0),
466 'enable_history' => array(
'integer', 0),
467 'restrict_history' => array(
'integer', 0),
468 'autogen_usernames' => array(
'text',
'Anonymous #'),
469 'allow_private_rooms' => array(
'integer', 1),
474 $settings->set(
'public_room_ref', $ref_id);
478 public static function createMissinRoomSettingsForConvertedObjects()
483 $ilDB = $DIC->database();
486 "SELECT obj_id FROM object_data 487 LEFT JOIN chatroom_settings ON object_id = obj_id 489 AND room_id IS NULL",
494 $roomsToFix = array();
496 $roomsToFix[] =
$row[
'obj_id'];
499 self::setChatroomSettings($roomsToFix);
505 public static function ensureCorrectPublicChatroomTreeLocation($ref_id)
509 $tree = $DIC->repositoryTree();
511 $ilDB = $DIC->database();
513 $rbacadmin = $DIC->rbac()->admin();
517 SELECT object_data.obj_id, object_reference.ref_id 519 INNER JOIN object_reference ON object_reference.obj_id = object_data.obj_id 520 WHERE type = " .
$ilDB->quote(
'chta',
'text');
523 $chatfolder_ref_id =
$row[
'ref_id'];
524 $pid =
$tree->getParentId($ref_id);
527 $chatfolder_ref_id &&
528 $pid != $chatfolder_ref_id &&
529 !
$tree->isDeleted($chatfolder_ref_id)
531 $tree->moveTree($ref_id, $chatfolder_ref_id);
532 $rbacadmin->adjustMovedObjectPermissions($ref_id, $pid);
533 include_once(
'./Services/Conditions/classes/class.ilConditionHandler.php');
if(!array_key_exists('StateId', $_REQUEST)) $id
static setChatroomSettings($obj_ids)
Sets autogen_usernames default option for chatrooms.
foreach($_POST as $key=> $value) $res
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
static _adjustMovedObjectConditions($a_ref_id)
In the moment it is not allowed to create preconditions on objects that are located outside of a cour...
Class ilChatroomInstaller.