17 public static function install()
24 if(!
$ilDB->tableExists(
'chatroom_settings'))
27 'room_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
28 'object_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
false,
'default' => 0),
29 'room_type' => array(
'type' =>
'text',
'length' => 20,
'notnull' =>
true),
30 'allow_anonymous' => array(
'type' =>
'integer',
'length' => 1,
'notnull' =>
false,
'default' => 0),
31 'allow_custom_usernames' => array(
'type' =>
'integer',
'length' => 1,
'notnull' =>
false,
'default' => 0),
32 'enable_history' => array(
'type' =>
'integer',
'length' => 1,
'notnull' =>
false,
'default' => 0),
33 'restrict_history' => array(
'type' =>
'integer',
'length' => 1,
'notnull' =>
false,
'default' => 0),
34 'autogen_usernames' => array(
'type' =>
'text',
'length' => 50,
'notnull' =>
false,
'default' =>
'Anonymous #'),
35 'allow_private_rooms' => array(
'type' =>
'integer',
'length' => 1,
'notnull' =>
false,
'default' => 0),
38 $ilDB->createTable(
'chatroom_settings', $fields);
39 $ilDB->addPrimaryKey(
'chatroom_settings', array(
'room_id'));
40 $ilDB->createSequence(
'chatroom_settings');
43 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'))
58 'room_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
59 'user_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
60 'userdata' => array(
'type' =>
'text',
'length' => 4000,
'notnull' =>
true),
61 'connected' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
62 'disconnected' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
64 $ilDB->createTable(
'chatroom_sessions', $fields);
67 if(!
$ilDB->tableExists(
'chatroom_history'))
70 'room_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
71 'message' => array(
'type' =>
'text',
'length' => 4000,
'notnull' =>
true),
72 'timestamp' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
74 $ilDB->createTable(
'chatroom_history', $fields);
77 if(!
$ilDB->tableExists(
'chatroom_bans'))
80 'room_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
81 'user_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
82 'timestamp' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
83 'remark' => array(
'type' =>
'text',
'length' => 1000,
'notnull' =>
false),
85 $ilDB->createTable(
'chatroom_bans', $fields);
88 if(!
$ilDB->tableExists(
'chatroom_admconfig'))
91 'instance_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
92 'server_settings' => array(
'type' =>
'text',
'length' => 2000,
'notnull' =>
true),
93 'default_config' => array(
'type' =>
'integer',
'length' => 1,
'notnull' =>
true,
'default' => 0),
95 $ilDB->createTable(
'chatroom_admconfig', $fields);
96 $ilDB->addPrimaryKey(
'chatroom_admconfig', array(
'instance_id'));
97 $ilDB->createSequence(
'chatroom_admconfig');
100 if(!
$ilDB->tableExists(
'chatroom_prooms'))
103 'proom_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
104 'parent_id' => array(
'type' =>
'text',
'length' => 2000,
'notnull' =>
true),
105 'title' => array(
'type' =>
'text',
'length' => 200,
'notnull' =>
true,
'default' => 0),
106 'owner' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true,
'default' => 0),
107 'created' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true,
'default' => 0),
108 'closed' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
false,
'default' => 0),
110 $ilDB->createTable(
'chatroom_prooms', $fields);
111 $ilDB->addPrimaryKey(
'chatroom_prooms', array(
'proom_id'));
112 $ilDB->createSequence(
'chatroom_prooms');
115 if(!
$ilDB->tableExists(
'chatroom_psessions'))
118 'proom_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
119 'user_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
120 'connected' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
121 'disconnected' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
123 $ilDB->createTable(
'chatroom_psessions', $fields);
126 if(!
$ilDB->tableExists(
'chatroom_uploads'))
129 'upload_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
130 'room_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
131 'user_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
132 'filename' => array(
'type' =>
'text',
'length' => 200,
'notnull' =>
true),
133 'filetype' => array(
'type' =>
'text',
'length' => 200,
'notnull' =>
true),
134 'timestamp' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true)
136 $ilDB->createTable(
'chatroom_uploads', $fields);
137 $ilDB->addPrimaryKey(
'chatroom_uploads', array(
'upload_id'));
138 $ilDB->createSequence(
'chatroom_uploads');
141 if(!
$ilDB->tableColumnExists(
'chatroom_prooms',
'is_public'))
143 $ilDB->addTableColumn(
'chatroom_prooms',
'is_public', array(
'type' =>
'integer',
'default' => 1,
'length' => 1));
146 if(!
$ilDB->tableExists(
'chatroom_psessions'))
149 'proom_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
150 'user_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
151 'connected' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
152 'disconnected' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
154 $ilDB->createTable(
'chatroom_psessions', $fields);
157 if(!
$ilDB->tableExists(
'chatroom_proomaccess'))
160 'proom_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
161 'user_id' => array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
163 $ilDB->createTable(
'chatroom_proomaccess', $fields);
166 if(!
$ilDB->tableColumnExists(
'chatroom_admconfig',
'client_settings'))
168 $ilDB->addTableColumn(
169 "chatroom_admconfig",
"client_settings",
178 if(!
$ilDB->tableExists(
'chatroom_smilies'))
181 'smiley_id' => array(
185 'smiley_keywords' => array(
189 'smiley_path' => array(
195 $ilDB->createTable(
'chatroom_smilies', $fields);
196 $ilDB->addPrimaryKey(
'chatroom_smilies', array(
'smiley_id'));
197 $ilDB->createSequence(
'chatroom_smilies');
200 self::registerObject();
201 self::registerAdminObject();
202 self::removeOldChatEntries();
203 self::convertChatObjects();
205 $notificationSettings =
new ilSetting(
'notifications');
206 $notificationSettings->set(
'enable_osd',
true);
213 public static function registerObject()
222 $query =
'SELECT obj_id FROM object_data ' .
223 'WHERE type = ' .
$ilDB->quote(
'typ',
'text') .
' ' .
224 'AND title = ' .
$ilDB->quote(
'chtr',
'text');
227 $typ_id =
$ilDB->nextId(
'object_data');
231 'obj_id' => array(
'integer', $typ_id),
232 'type' => array(
'text',
'typ'),
233 'title' => array(
'text',
'chtr'),
234 'description' => array(
'text',
'Chatroom Object'),
235 'owner' => array(
'integer', -1),
236 'create_date' => array(
'timestamp',
date(
'Y-m-d H:i:s')),
237 'last_update' => array(
'timestamp',
date(
'Y-m-d H:i:s'))
243 foreach(array(1, 2, 3, 4) as $ops_id)
245 $query =
"INSERT INTO rbac_ta (typ_id, ops_id) VALUES ( " .
246 $ilDB->quote($typ_id,
'integer') .
"," .
$ilDB->quote($ops_id,
'integer') .
252 if($moderatePermissionId = self::getModeratorPermissionId())
256 $typ_id = $object_definition_row[
'obj_id'];
262 'DELETE FROM rbac_ta WHERE typ_id = %s AND ops_id = %s',
263 array(
'integer',
'integer'),
264 array($typ_id, $moderatePermissionId)
270 'typ_id' => array(
'integer', $typ_id),
271 'ops_id' => array(
'integer', $moderatePermissionId),
278 private static function getModeratorPermissionId()
285 $rset =
$ilDB->queryF(
286 'SELECT ops_id FROM rbac_operations WHERE operation = %s',
292 return $row[
'ops_id'];
301 public static function registerAdminObject()
308 $query =
'SELECT * FROM object_data WHERE type = ' .
$ilDB->quote(
'chta',
'text');
311 $obj_id =
$ilDB->nextId(
'object_data');
315 'obj_id' => array(
'integer', $obj_id),
316 'type' => array(
'text',
'chta'),
317 'title' => array(
'text',
'Chatroom Admin'),
318 'description' => array(
'text',
'Chatroom General Settings'),
319 'owner' => array(
'integer', -1),
320 'create_date' => array(
'timestamp',
date(
'Y-m-d H:i:s')),
321 'last_update' => array(
'timestamp',
date(
'Y-m-d H:i:s'))
326 $query =
"INSERT INTO object_reference (ref_id, obj_id) VALUES(" .
$ilDB->quote(
$ref_id,
'integer') .
", " .
$ilDB->quote($obj_id,
'integer') .
")";
329 $tree =
new ilTree(ROOT_FOLDER_ID);
330 $tree->insertNode(
$ref_id, SYSTEM_FOLDER_ID);
334 public static function removeOldChatEntries()
342 'SELECT object_data.obj_id, ref_id, lft, rgt
344 INNER JOIN object_reference ON object_reference.obj_id = object_data.obj_id
345 INNER JOIN tree ON child = ref_id
355 INNER JOIN object_reference ON ref_id = child
356 INNER JOIN object_data ON object_data.obj_id = object_reference.obj_id
357 WHERE lft BETWEEN %s AND %s', array(
'integer',
'integer'), array(
$data[
'lft'],
$data[
'rgt']));
363 WHERE obj_id = ' .
$ilDB->quote(
$row[
'obj_id'],
'integer')
368 FROM object_reference
369 WHERE ref_id = ' .
$ilDB->quote(
$row[
'ref_id'],
'integer')
375 WHERE child = ' .
$ilDB->quote(
$row[
'ref_id'],
'integer')
380 $ilDB->manipulateF(
'DELETE FROM object_data WHERE type = %s AND title = %s', array(
'text',
'text'), array(
'typ',
'chat'));
381 $ilDB->manipulateF(
'DELETE FROM object_data WHERE type = %s AND title = %s', array(
'text',
'text'), array(
'typ',
'chac'));
387 public static function convertChatObjects()
406 $obj_ids[] =
$row[
'obj_id'];
413 array(
'text',
'text'),
414 array(
'chtr',
'chat')
426 if(is_array($obj_ids))
428 foreach($obj_ids as $obj_id)
431 $room->saveSettings(array(
432 'object_id' => $obj_id,
433 'autogen_usernames' =>
'Autogen #',
434 'room_type' =>
'repository'
440 public static function createDefaultPublicRoom($force =
false)
449 $query =
'DELETE FROM chatroom_settings WHERE room_type = ' .
$ilDB->quote(
'default',
'text');
455 $query =
'SELECT * FROM chatroom_settings WHERE room_type = ' .
$ilDB->quote(
'default',
'text');
457 $create = !
$ilDB->fetchAssoc($rset);
462 SELECT object_data.obj_id, object_reference.ref_id
464 INNER JOIN object_reference ON object_reference.obj_id = object_data.obj_id
465 WHERE type = " .
$ilDB->quote(
'chta',
'text');
468 $chatfolder_ref_id =
$row[
'ref_id'];
470 require_once
'Modules/Chatroom/classes/class.ilObjChatroom.php';
473 $newObj->setType(
'chtr');
474 $newObj->setTitle(
'Public Chat');
475 $newObj->setDescription(
'');
477 $newObj->createReference();
478 $newObj->putInTree($chatfolder_ref_id);
479 $newObj->setPermissions($chatfolder_ref_id);
481 $obj_id = $newObj->getId();
484 $id =
$ilDB->nextId(
'chatroom_settings');
488 'room_id' => array(
'integer', $id),
489 'object_id' => array(
'integer', $obj_id),
490 'room_type' => array(
'text',
'default'),
491 'allow_anonymous' => array(
'integer', 0),
492 'allow_custom_usernames' => array(
'integer', 0),
493 'enable_history' => array(
'integer', 0),
494 'restrict_history' => array(
'integer', 0),
495 'autogen_usernames' => array(
'text',
'Anonymous #'),
496 'allow_private_rooms' => array(
'integer', 1),
501 $settings->set(
'public_room_ref',
$ref_id);
505 public static function createMissinRoomSettingsForConvertedObjects()
513 "SELECT obj_id FROM object_data
514 LEFT JOIN chatroom_settings ON object_id = obj_id
516 AND room_id IS NULL",
521 $roomsToFix = array();
524 $roomsToFix[] =
$row[
'obj_id'];
533 public static function ensureCorrectPublicChatroomTreeLocation(
$ref_id)
540 global $tree,
$ilDB, $rbacadmin;
544 SELECT object_data.obj_id, object_reference.ref_id
546 INNER JOIN object_reference ON object_reference.obj_id = object_data.obj_id
547 WHERE type = " .
$ilDB->quote(
'chta',
'text');
550 $chatfolder_ref_id =
$row[
'ref_id'];
551 $pid = $tree->getParentId(
$ref_id);
554 $chatfolder_ref_id &&
555 $pid != $chatfolder_ref_id &&
556 !$tree->isDeleted($chatfolder_ref_id)
559 $tree->moveTree(
$ref_id, $chatfolder_ref_id);
560 $rbacadmin->adjustMovedObjectPermissions(
$ref_id, $pid);
561 include_once(
'./Services/AccessControl/classes/class.ilConditionHandler.php');
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
An exception for terminatinating execution or to throw for unit testing.
Class ilChatroomInstaller.
static setChatroomSettings($obj_ids)
Sets autogen_usernames default option for chatrooms.
static _adjustMovedObjectConditions($a_ref_id)
In the moment it is not allowed to create preconditions on objects that are located outside of a cour...
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...