ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilNotificationSetupHelper.php
Go to the documentation of this file.
1<?php
2
3require_once 'Services/Notifications/classes/class.ilNotificationDatabaseHelper.php';
4
9{
10 public static $tbl_userconfig = 'notification_usercfg';
11 public static $tbl_userlistener = 'notification_listener';
12 public static $tbl_notification_data = 'notification_data';
13 public static $tbl_notification_queue = 'notification_queue';
14 public static $tbl_notification_osd_handler = 'notification_osd';
15 public static $tbl_notification_channels = 'notification_channels';
16 public static $tbl_notification_types = 'notification_types';
17
18 public static function setupTables()
19 {
20 global $DIC;
21
22 $ilDB = $DIC->database();
23
24 if (!$ilDB->tableExists(self::$tbl_userconfig)) {
25 $fields = array(
26 'usr_id' => array('type' => 'integer', 'notnull' => true, 'length' => 4),
27 'module' => array('type' => 'text' , 'notnull' => true, 'length' => 100),
28 'channel' => array('type' => 'text' , 'notnull' => true, 'length' => 100),
29 );
30 $ilDB->createTable(self::$tbl_userconfig, $fields);
31 $ilDB->addPrimaryKey(self::$tbl_userconfig, array('usr_id', 'module', 'channel'));
32 }
33
34 if (!$ilDB->tableExists(self::$tbl_userlistener)) {
35 $fields = array(
36 'usr_id' => array('type' => 'integer', 'notnull' => true, 'length' => 4),
37 'module' => array('type' => 'text' , 'notnull' => true, 'length' => 100),
38 'sender_id' => array('type' => 'integer', 'notnull' => true, 'length' => 4),
39 'disabled' => array('type' => 'integer', 'notnull' => true, 'length' => 1),
40 );
41 $ilDB->createTable(self::$tbl_userlistener, $fields);
42 $ilDB->addPrimaryKey(self::$tbl_userlistener, array('usr_id', 'module', 'sender_id'));
43 }
44
45 if (!$ilDB->tableExists(self::$tbl_notification_data)) {
46 $fields = array(
47 'notification_id' => array('type' => 'integer', 'notnull' => true, 'length' => 4),
48 'serialized' => array('type' => 'text' , 'notnull' => true, 'length' => 4000),
49 );
50 $ilDB->createTable(self::$tbl_notification_data, $fields);
51 $ilDB->addPrimaryKey(self::$tbl_notification_data, array('notification_id'));
52
53 $ilDB->createSequence(self::$tbl_notification_data);
54 }
55
56 if (!$ilDB->tableExists(self::$tbl_notification_queue)) {
57 $fields = array(
58 'notification_id' => array('type' => 'integer' , 'notnull' => true, 'length' => 4),
59 'usr_id' => array('type' => 'integer' , 'notnull' => true, 'length' => 4),
60 #'notification_channel' => array('type' => 'text' , 'notnull' => true, 'length' => 100),
61 'valid_until' => array('type' => 'integer' , 'notnull' => true, 'length' => 4),
62 );
63 $ilDB->createTable(self::$tbl_notification_queue, $fields);
64 #$ilDB->addPrimaryKey(self::$tbl_notification_queue, array('notification_id', 'usr_id', 'notification_channel'));
65 $ilDB->addPrimaryKey(self::$tbl_notification_queue, array('notification_id', 'usr_id'));
66 }
67
68 if (!$ilDB->tableExists(self::$tbl_notification_osd_handler)) {
69 $fields = array(
70 'notification_osd_id' => array('type' => 'integer' , 'notnull' => true, 'length' => 4),
71 'usr_id' => array('type' => 'integer' , 'notnull' => true, 'length' => 4),
72 'serialized' => array('type' => 'text' , 'notnull' => true, 'length' => 4000),
73 'valid_until' => array('type' => 'integer' , 'notnull' => true, 'length' => 4),
74 'time_added' => array('type' => 'integer' , 'notnull' => true, 'length' => 4),
75 'type' => array('type' => 'text' , 'notnull' => true, 'length' => 100),
76 );
77 $ilDB->createTable(self::$tbl_notification_osd_handler, $fields);
78
79 $ilDB->addPrimaryKey(self::$tbl_notification_osd_handler, array('notification_osd_id'));
83 #$ilDB->addIndex(self::$tbl_notification_osd_handler, array('usr_id', 'valid_until', 'time_added'));
84
85 $ilDB->createSequence(self::$tbl_notification_osd_handler);
86 }
87
88 if (!$ilDB->tableExists(self::$tbl_notification_channels)) {
89 $fields = array(
90 'channel_name' => array('type' => 'text', 'notnull' => true, 'length' => 100),
91 'title' => array('type' => 'text', 'notnull' => true, 'length' => 100),
92 'description' => array('type' => 'text', 'notnull' => true, 'length' => 4000),
93 'class' => array('type' => 'text', 'notnull' => true, 'length' => 100),
94 'include' => array('type' => 'text', 'notnull' => true, 'length' => 100),
95 'config_type' => array('type' => 'text', 'notnull' => true, 'length' => 30),
96 );
97 $ilDB->createTable(self::$tbl_notification_channels, $fields);
98
99 $ilDB->addPrimaryKey(self::$tbl_notification_channels, array('channel_name'));
100
101 ilNotificationSetupHelper::registerChannel('mail', 'mail', 'mail_desc', 'ilNotificationMailHandler', 'Services/Notifications/classes/class.ilNotificationMailHandler.php');
102 ilNotificationSetupHelper::registerChannel('osd', 'osd', 'osd_desc', 'ilNotificationOSDHandler', 'Services/Notifications/classes/class.ilNotificationOSDHandler.php');
103 }
104
105 if (!$ilDB->tableExists(self::$tbl_notification_types)) {
106 $fields = array(
107 'type_name' => array('type' => 'text', 'notnull' => true, 'length' => 100),
108 'title' => array('type' => 'text', 'notnull' => true, 'length' => 100),
109 'description' => array('type' => 'text', 'notnull' => true, 'length' => 100),
110 'notification_group' => array('type' => 'text', 'notnull' => true, 'length' => 100),
111 'config_type' => array('type' => 'text', 'notnull' => true, 'length' => 30),
112 );
113 $ilDB->createTable(self::$tbl_notification_types, $fields);
114 $ilDB->addPrimaryKey(self::$tbl_notification_types, array('type_name'));
115
116 ilNotificationSetupHelper::registerType('chat_invitation', 'chat_invitation', 'chat_invitation_description', 'chat');
117 //ilNotificationSetupHelper::registerType('adobe_connect_invitation', 'adobe_connect_invitation', 'adobe_connect_invitation_description', 'adobe_connect');
118 ilNotificationSetupHelper::registerType('osd_maint', 'osd_maint', 'osd_maint_description', 'osd_notification');
119 }
120 }
121
122
123 public static function registerChannel($name, $title, $description, $class, $classfile, $config_type = 'set_by_user')
124 {
125 ilNotificationDatabaseHandler::registerChannel($name, $title, $description, $class, $classfile, $config_type);
126 }
127
128 public static function registerType($name, $title, $description, $notification_group, $config_type = 'set_by_user')
129 {
130 ilNotificationDatabaseHandler::registerType($name, $title, $description, $notification_group, $config_type);
131 }
132}
An exception for terminatinating execution or to throw for unit testing.
static registerChannel($name, $title, $description, $class, $classfile, $config_type)
Registers a new notification channel for distributing notifications.
static registerType($name, $title, $description, $notification_group, $config_type)
Registers a new notification type.
Helper class for initial database setup and registration of notification.
static registerChannel($name, $title, $description, $class, $classfile, $config_type='set_by_user')
static registerType($name, $title, $description, $notification_group, $config_type='set_by_user')
global $DIC
Definition: goto.php:24
if($format !==null) $name
Definition: metadata.php:230
global $ilDB