ILIAS  release_8 Revision v8.24
ilNotificationSetupHelper.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
21namespace ILIAS\Notifications;
22
24
29{
30 public static string $tbl_userconfig = 'notification_usercfg';
31 public static string $tbl_userlistener = 'notification_listener';
32 public static string $tbl_notification_data = 'notification_data';
33 public static string $tbl_notification_queue = 'notification_queue';
34 public static string $tbl_notification_osd_handler = 'notification_osd';
35 public static string $tbl_notification_channels = 'notification_channels';
36 public static string $tbl_notification_types = 'notification_types';
37
38 public static function setupTables(): void
39 {
40 global $DIC;
41
42 $ilDB = $DIC->database();
43
44 if (!$ilDB->tableExists(self::$tbl_userconfig)) {
45 $fields = array(
46 'usr_id' => array('type' => 'integer', 'notnull' => true, 'length' => 4),
47 'module' => array('type' => 'text' , 'notnull' => true, 'length' => 100),
48 'channel' => array('type' => 'text' , 'notnull' => true, 'length' => 100),
49 );
50 $ilDB->createTable(self::$tbl_userconfig, $fields);
51 $ilDB->addPrimaryKey(self::$tbl_userconfig, array('usr_id', 'module', 'channel'));
52 }
53
54 if (!$ilDB->tableExists(self::$tbl_userlistener)) {
55 $fields = array(
56 'usr_id' => array('type' => 'integer', 'notnull' => true, 'length' => 4),
57 'module' => array('type' => 'text' , 'notnull' => true, 'length' => 100),
58 'sender_id' => array('type' => 'integer', 'notnull' => true, 'length' => 4),
59 'disabled' => array('type' => 'integer', 'notnull' => true, 'length' => 1),
60 );
61 $ilDB->createTable(self::$tbl_userlistener, $fields);
62 $ilDB->addPrimaryKey(self::$tbl_userlistener, array('usr_id', 'module', 'sender_id'));
63 }
64
65 if (!$ilDB->tableExists(self::$tbl_notification_data)) {
66 $fields = array(
67 'notification_id' => array('type' => 'integer', 'notnull' => true, 'length' => 4),
68 'serialized' => array('type' => 'text' , 'notnull' => true, 'length' => 4000),
69 );
70 $ilDB->createTable(self::$tbl_notification_data, $fields);
71 $ilDB->addPrimaryKey(self::$tbl_notification_data, array('notification_id'));
72
73 $ilDB->createSequence(self::$tbl_notification_data);
74 }
75
76 if (!$ilDB->tableExists(self::$tbl_notification_queue)) {
77 $fields = array(
78 'notification_id' => array('type' => 'integer' , 'notnull' => true, 'length' => 4),
79 'usr_id' => array('type' => 'integer' , 'notnull' => true, 'length' => 4),
80 'valid_until' => array('type' => 'integer' , 'notnull' => true, 'length' => 4),
81 );
82 $ilDB->createTable(self::$tbl_notification_queue, $fields);
83 $ilDB->addPrimaryKey(self::$tbl_notification_queue, array('notification_id', 'usr_id'));
84 }
85
86 if (!$ilDB->tableExists(self::$tbl_notification_osd_handler)) {
87 $fields = array(
88 'notification_osd_id' => array('type' => 'integer' , 'notnull' => true, 'length' => 4),
89 'usr_id' => array('type' => 'integer' , 'notnull' => true, 'length' => 4),
90 'serialized' => array('type' => 'text' , 'notnull' => true, 'length' => 4000),
91 'valid_until' => array('type' => 'integer' , 'notnull' => true, 'length' => 4),
92 'time_added' => array('type' => 'integer' , 'notnull' => true, 'length' => 4),
93 'type' => array('type' => 'text' , 'notnull' => true, 'length' => 100),
94 );
95 $ilDB->createTable(self::$tbl_notification_osd_handler, $fields);
96
97 $ilDB->addPrimaryKey(self::$tbl_notification_osd_handler, array('notification_osd_id'));
98
99 $ilDB->createSequence(self::$tbl_notification_osd_handler);
100 }
101
102 if (!$ilDB->tableExists(self::$tbl_notification_channels)) {
103 $fields = array(
104 'channel_name' => array('type' => 'text', 'notnull' => true, 'length' => 100),
105 'title' => array('type' => 'text', 'notnull' => true, 'length' => 100),
106 'description' => array('type' => 'text', 'notnull' => true, 'length' => 4000),
107 'class' => array('type' => 'text', 'notnull' => true, 'length' => 100),
108 'include' => array('type' => 'text', 'notnull' => true, 'length' => 100),
109 'config_type' => array('type' => 'text', 'notnull' => true, 'length' => 30),
110 );
111 $ilDB->createTable(self::$tbl_notification_channels, $fields);
112
113 $ilDB->addPrimaryKey(self::$tbl_notification_channels, array('channel_name'));
114
115 self::registerChannel($ilDB, 'mail', 'mail', 'mail_desc', 'ilNotificationMailHandler', 'Services/Notifications/classes/class.ilNotificationMailHandler.php');
116 self::registerChannel($ilDB, 'osd', 'osd', 'osd_desc', 'ilNotificationOSDHandler', 'Services/Notifications/classes/class.ilNotificationOSDHandler.php');
117 }
118
119 if (!$ilDB->tableExists(self::$tbl_notification_types)) {
120 $fields = array(
121 'type_name' => array('type' => 'text', 'notnull' => true, 'length' => 100),
122 'title' => array('type' => 'text', 'notnull' => true, 'length' => 100),
123 'description' => array('type' => 'text', 'notnull' => true, 'length' => 100),
124 'notification_group' => array('type' => 'text', 'notnull' => true, 'length' => 100),
125 'config_type' => array('type' => 'text', 'notnull' => true, 'length' => 30),
126 );
127 $ilDB->createTable(self::$tbl_notification_types, $fields);
128 $ilDB->addPrimaryKey(self::$tbl_notification_types, array('type_name'));
129
130 self::registerType($ilDB, 'chat_invitation', 'chat_invitation', 'chat_invitation_description', 'chat');
131 self::registerType($ilDB, 'osd_maint', 'osd_maint', 'osd_maint_description', 'osd_notification');
132 }
133 }
134
135 public static function registerChannel(ilDBInterface $db, string $name, string $title, string $description, string $class, string $classfile, string $config_type = 'set_by_user'): void
136 {
137 ilNotificationDatabaseHandler::registerChannel($db, $name, $title, $description, $class, $classfile, $config_type);
138 }
139
140 public static function registerType(ilDBInterface $db, string $name, string $title, string $description, string $notification_group, string $config_type = 'set_by_user'): void
141 {
142 ilNotificationDatabaseHandler::registerType($db, $name, $title, $description, $notification_group, $config_type);
143 }
144}
static registerChannel(ilDBInterface $db, string $name, string $title, string $description, string $class, string $classfile, string $config_type)
static registerType(ilDBInterface $db, string $name, string $title, string $description, string $notification_group, string $config_type)
static registerChannel(ilDBInterface $db, string $name, string $title, string $description, string $class, string $classfile, string $config_type='set_by_user')
static registerType(ilDBInterface $db, string $name, string $title, string $description, string $notification_group, string $config_type='set_by_user')
global $DIC
Definition: feed.php:28
Interface ilDBInterface.
if($format !==null) $name
Definition: metadata.php:247
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...