17 public static function install()
24 if (!$ilDB->tableExists(
'chatroom_settings')) {
26 'room_id' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
27 'object_id' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
false,
'default' => 0),
28 'room_type' =>
array(
'type' =>
'text',
'length' => 20,
'notnull' =>
true),
29 'allow_anonymous' =>
array(
'type' =>
'integer',
'length' => 1,
'notnull' =>
false,
'default' => 0),
30 'allow_custom_usernames' =>
array(
'type' =>
'integer',
'length' => 1,
'notnull' =>
false,
'default' => 0),
31 'enable_history' =>
array(
'type' =>
'integer',
'length' => 1,
'notnull' =>
false,
'default' => 0),
32 'restrict_history' =>
array(
'type' =>
'integer',
'length' => 1,
'notnull' =>
false,
'default' => 0),
33 'autogen_usernames' =>
array(
'type' =>
'text',
'length' => 50,
'notnull' =>
false,
'default' =>
'Anonymous #'),
34 'allow_private_rooms' =>
array(
'type' =>
'integer',
'length' => 1,
'notnull' =>
false,
'default' => 0),
37 $ilDB->createTable(
'chatroom_settings', $fields);
38 $ilDB->addPrimaryKey(
'chatroom_settings',
array(
'room_id'));
39 $ilDB->createSequence(
'chatroom_settings');
42 if (!$ilDB->tableExists(
'chatroom_users')) {
44 'room_id' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
45 'user_id' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
46 'userdata' =>
array(
'type' =>
'text',
'length' => 4000,
'notnull' =>
true),
47 'connected' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
49 $ilDB->createTable(
'chatroom_users', $fields);
50 $ilDB->addPrimaryKey(
'chatroom_users',
array(
'room_id',
'user_id'));
53 if (!$ilDB->tableExists(
'chatroom_sessions')) {
55 'room_id' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
56 'user_id' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
57 'userdata' =>
array(
'type' =>
'text',
'length' => 4000,
'notnull' =>
true),
58 'connected' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
59 'disconnected' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
61 $ilDB->createTable(
'chatroom_sessions', $fields);
64 if (!$ilDB->tableExists(
'chatroom_history')) {
66 'room_id' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
67 'message' =>
array(
'type' =>
'text',
'length' => 4000,
'notnull' =>
true),
68 'timestamp' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
70 $ilDB->createTable(
'chatroom_history', $fields);
73 if (!$ilDB->tableExists(
'chatroom_bans')) {
75 'room_id' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
76 'user_id' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
77 'timestamp' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
78 'remark' =>
array(
'type' =>
'text',
'length' => 1000,
'notnull' =>
false),
80 $ilDB->createTable(
'chatroom_bans', $fields);
83 if (!$ilDB->tableExists(
'chatroom_admconfig')) {
85 'instance_id' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
86 'server_settings' =>
array(
'type' =>
'text',
'length' => 2000,
'notnull' =>
true),
87 'default_config' =>
array(
'type' =>
'integer',
'length' => 1,
'notnull' =>
true,
'default' => 0),
89 $ilDB->createTable(
'chatroom_admconfig', $fields);
90 $ilDB->addPrimaryKey(
'chatroom_admconfig',
array(
'instance_id'));
91 $ilDB->createSequence(
'chatroom_admconfig');
94 if (!$ilDB->tableExists(
'chatroom_prooms')) {
96 'proom_id' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
97 'parent_id' =>
array(
'type' =>
'text',
'length' => 2000,
'notnull' =>
true),
98 'title' =>
array(
'type' =>
'text',
'length' => 200,
'notnull' =>
true,
'default' => 0),
99 'owner' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true,
'default' => 0),
100 'created' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true,
'default' => 0),
101 'closed' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
false,
'default' => 0),
103 $ilDB->createTable(
'chatroom_prooms', $fields);
104 $ilDB->addPrimaryKey(
'chatroom_prooms',
array(
'proom_id'));
105 $ilDB->createSequence(
'chatroom_prooms');
108 if (!$ilDB->tableExists(
'chatroom_psessions')) {
110 'proom_id' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
111 'user_id' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
112 'connected' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
113 'disconnected' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
115 $ilDB->createTable(
'chatroom_psessions', $fields);
118 if (!$ilDB->tableExists(
'chatroom_uploads')) {
120 'upload_id' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
121 'room_id' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
122 'user_id' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
123 'filename' =>
array(
'type' =>
'text',
'length' => 200,
'notnull' =>
true),
124 'filetype' =>
array(
'type' =>
'text',
'length' => 200,
'notnull' =>
true),
125 'timestamp' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true)
127 $ilDB->createTable(
'chatroom_uploads', $fields);
128 $ilDB->addPrimaryKey(
'chatroom_uploads',
array(
'upload_id'));
129 $ilDB->createSequence(
'chatroom_uploads');
132 if (!$ilDB->tableColumnExists(
'chatroom_prooms',
'is_public')) {
133 $ilDB->addTableColumn(
'chatroom_prooms',
'is_public',
array(
'type' =>
'integer',
'default' => 1,
'length' => 1));
136 if (!$ilDB->tableExists(
'chatroom_psessions')) {
138 'proom_id' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
139 'user_id' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
140 'connected' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
141 'disconnected' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
143 $ilDB->createTable(
'chatroom_psessions', $fields);
146 if (!$ilDB->tableExists(
'chatroom_proomaccess')) {
148 'proom_id' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
149 'user_id' =>
array(
'type' =>
'integer',
'length' => 4,
'notnull' =>
true),
151 $ilDB->createTable(
'chatroom_proomaccess', $fields);
154 if (!$ilDB->tableColumnExists(
'chatroom_admconfig',
'client_settings')) {
155 $ilDB->addTableColumn(
156 "chatroom_admconfig",
166 if (!$ilDB->tableExists(
'chatroom_smilies')) {
168 'smiley_id' =>
array(
172 'smiley_keywords' =>
array(
176 'smiley_path' =>
array(
182 $ilDB->createTable(
'chatroom_smilies', $fields);
183 $ilDB->addPrimaryKey(
'chatroom_smilies',
array(
'smiley_id'));
184 $ilDB->createSequence(
'chatroom_smilies');
187 self::registerObject();
188 self::registerAdminObject();
189 self::removeOldChatEntries();
190 self::convertChatObjects();
192 $notificationSettings =
new ilSetting(
'notifications');
193 $notificationSettings->set(
'enable_osd',
true);
200 public static function registerObject()
209 $query =
'SELECT obj_id FROM object_data ' .
210 'WHERE type = ' . $ilDB->quote(
'typ',
'text') .
' ' .
211 'AND title = ' . $ilDB->quote(
'chtr',
'text');
212 if (!($object_definition_row = $ilDB->fetchAssoc($ilDB->query(
$query)))) {
213 $typ_id = $ilDB->nextId(
'object_data');
217 'obj_id' =>
array(
'integer', $typ_id),
218 'type' =>
array(
'text',
'typ'),
219 'title' =>
array(
'text',
'chtr'),
220 'description' =>
array(
'text',
'Chatroom Object'),
221 'owner' =>
array(
'integer', -1),
222 'create_date' =>
array(
'timestamp',
date(
'Y-m-d H:i:s')),
223 'last_update' =>
array(
'timestamp',
date(
'Y-m-d H:i:s'))
229 foreach (
array(1, 2, 3, 4) as $ops_id) {
230 $query =
"INSERT INTO rbac_ta (typ_id, ops_id) VALUES ( " .
231 $ilDB->quote($typ_id,
'integer') .
"," . $ilDB->quote($ops_id,
'integer') .
233 $ilDB->manipulate(
$query);
237 if ($moderatePermissionId = self::getModeratorPermissionId()) {
239 $typ_id = $object_definition_row[
'obj_id'];
244 'DELETE FROM rbac_ta WHERE typ_id = %s AND ops_id = %s',
245 array(
'integer',
'integer'),
246 array($typ_id, $moderatePermissionId)
252 'typ_id' =>
array(
'integer', $typ_id),
253 'ops_id' =>
array(
'integer', $moderatePermissionId),
260 private static function getModeratorPermissionId()
267 $rset = $ilDB->queryF(
268 'SELECT ops_id FROM rbac_operations WHERE operation = %s',
272 if (
$row = $ilDB->fetchAssoc($rset)) {
273 return $row[
'ops_id'];
282 public static function registerAdminObject()
289 $query =
'SELECT * FROM object_data WHERE type = ' . $ilDB->quote(
'chta',
'text');
290 if (!$ilDB->fetchAssoc($ilDB->query(
$query))) {
291 $obj_id = $ilDB->nextId(
'object_data');
295 'obj_id' =>
array(
'integer', $obj_id),
296 'type' =>
array(
'text',
'chta'),
297 'title' =>
array(
'text',
'Chatroom Admin'),
298 'description' =>
array(
'text',
'Chatroom General Settings'),
299 'owner' =>
array(
'integer', -1),
300 'create_date' =>
array(
'timestamp',
date(
'Y-m-d H:i:s')),
301 'last_update' =>
array(
'timestamp',
date(
'Y-m-d H:i:s'))
305 $ref_id = $ilDB->nextId(
'object_reference');
306 $query =
"INSERT INTO object_reference (ref_id, obj_id) VALUES(" . $ilDB->quote($ref_id,
'integer') .
", " . $ilDB->quote($obj_id,
'integer') .
")";
307 $ilDB->manipulate(
$query);
309 $tree =
new ilTree(ROOT_FOLDER_ID);
310 $tree->insertNode($ref_id, SYSTEM_FOLDER_ID);
314 public static function removeOldChatEntries()
321 $res = $ilDB->queryF(
322 'SELECT object_data.obj_id, ref_id, lft, rgt 324 INNER JOIN object_reference ON object_reference.obj_id = object_data.obj_id 325 INNER JOIN tree ON child = ref_id 333 $res = $ilDB->queryF(
'SELECT * FROM tree 334 INNER JOIN object_reference ON ref_id = child 335 INNER JOIN object_data ON object_data.obj_id = object_reference.obj_id 337 while (
$row = $ilDB->fetchAssoc(
$res)) {
341 WHERE obj_id = ' . $ilDB->quote(
$row[
'obj_id'],
'integer')
346 FROM object_reference 347 WHERE ref_id = ' . $ilDB->quote(
$row[
'ref_id'],
'integer')
353 WHERE child = ' . $ilDB->quote(
$row[
'ref_id'],
'integer')
358 $ilDB->manipulateF(
'DELETE FROM object_data WHERE type = %s AND title = %s',
array(
'text',
'text'),
array(
'typ',
'chat'));
359 $ilDB->manipulateF(
'DELETE FROM object_data WHERE type = %s AND title = %s',
array(
'text',
'text'),
array(
'typ',
'chac'));
365 public static function convertChatObjects()
372 $res = $ilDB->queryF(
382 while (
$row = $ilDB->fetchAssoc(
$res)) {
383 $obj_ids[] =
$row[
'obj_id'];
390 array(
'text',
'text'),
391 array(
'chtr',
'chat')
394 self::setChatroomSettings($obj_ids);
403 if (is_array($obj_ids)) {
404 foreach ($obj_ids as $obj_id) {
406 $room->saveSettings(
array(
407 'object_id' => $obj_id,
408 'autogen_usernames' =>
'Autogen #',
409 'room_type' =>
'repository' 415 public static function createDefaultPublicRoom($force =
false)
423 $query =
'DELETE FROM chatroom_settings WHERE room_type = ' . $ilDB->quote(
'default',
'text');
424 $ilDB->manipulate(
$query);
427 $query =
'SELECT * FROM chatroom_settings WHERE room_type = ' . $ilDB->quote(
'default',
'text');
428 $rset = $ilDB->query(
$query);
429 $create = !$ilDB->fetchAssoc($rset);
433 SELECT object_data.obj_id, object_reference.ref_id 435 INNER JOIN object_reference ON object_reference.obj_id = object_data.obj_id 436 WHERE type = " . $ilDB->quote(
'chta',
'text');
437 $rset = $ilDB->query(
$query);
438 $row = $ilDB->fetchAssoc($rset);
439 $chatfolder_ref_id =
$row[
'ref_id'];
441 require_once
'Modules/Chatroom/classes/class.ilObjChatroom.php';
444 $newObj->setType(
'chtr');
445 $newObj->setTitle(
'Public Chat');
446 $newObj->setDescription(
'');
448 $newObj->createReference();
449 $newObj->putInTree($chatfolder_ref_id);
450 $newObj->setPermissions($chatfolder_ref_id);
452 $obj_id = $newObj->getId();
453 $ref_id = $newObj->getRefId();
455 $id = $ilDB->nextId(
'chatroom_settings');
460 'object_id' =>
array(
'integer', $obj_id),
461 'room_type' =>
array(
'text',
'default'),
462 'allow_anonymous' =>
array(
'integer', 0),
463 'allow_custom_usernames' =>
array(
'integer', 0),
464 'enable_history' =>
array(
'integer', 0),
465 'restrict_history' =>
array(
'integer', 0),
466 'autogen_usernames' =>
array(
'text',
'Anonymous #'),
467 'allow_private_rooms' =>
array(
'integer', 1),
472 $settings->set(
'public_room_ref', $ref_id);
476 public static function createMissinRoomSettingsForConvertedObjects()
483 $res = $ilDB->queryF(
484 "SELECT obj_id FROM object_data 485 LEFT JOIN chatroom_settings ON object_id = obj_id 487 AND room_id IS NULL",
492 $roomsToFix =
array();
493 while (
$row = $ilDB->fetchAssoc(
$res)) {
494 $roomsToFix[] =
$row[
'obj_id'];
497 self::setChatroomSettings($roomsToFix);
503 public static function ensureCorrectPublicChatroomTreeLocation($ref_id)
510 global $tree,
$ilDB, $rbacadmin;
514 SELECT object_data.obj_id, object_reference.ref_id 516 INNER JOIN object_reference ON object_reference.obj_id = object_data.obj_id 517 WHERE type = " . $ilDB->quote(
'chta',
'text');
518 $rset = $ilDB->query(
$query);
519 $row = $ilDB->fetchAssoc($rset);
520 $chatfolder_ref_id =
$row[
'ref_id'];
521 $pid = $tree->getParentId($ref_id);
524 $chatfolder_ref_id &&
525 $pid != $chatfolder_ref_id &&
526 !$tree->isDeleted($chatfolder_ref_id)
528 $tree->moveTree($ref_id, $chatfolder_ref_id);
529 $rbacadmin->adjustMovedObjectPermissions($ref_id, $pid);
530 include_once(
'./Services/AccessControl/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
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
Create styles array
The data for the language used.
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.