ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $ilDB;
21
22 if (!$ilDB->tableExists(self::$tbl_userconfig)) {
23 $fields = array(
24 'usr_id' => array('type' => 'integer', 'notnull' => true, 'length' => 4),
25 'module' => array('type' => 'text' , 'notnull' => true, 'length' => 100),
26 'channel' => array('type' => 'text' , 'notnull' => true, 'length' => 100),
27 );
28 $ilDB->createTable(self::$tbl_userconfig, $fields);
29 $ilDB->addPrimaryKey(self::$tbl_userconfig, array('usr_id', 'module', 'channel'));
30 }
31
32 if (!$ilDB->tableExists(self::$tbl_userlistener)) {
33 $fields = array(
34 'usr_id' => array('type' => 'integer', 'notnull' => true, 'length' => 4),
35 'module' => array('type' => 'text' , 'notnull' => true, 'length' => 100),
36 'sender_id' => array('type' => 'integer', 'notnull' => true, 'length' => 4),
37 'disabled' => array('type' => 'integer', 'notnull' => true, 'length' => 1),
38 );
39 $ilDB->createTable(self::$tbl_userlistener, $fields);
40 $ilDB->addPrimaryKey(self::$tbl_userlistener, array('usr_id', 'module', 'sender_id'));
41 }
42
43 if (!$ilDB->tableExists(self::$tbl_notification_data)) {
44 $fields = array(
45 'notification_id' => array('type' => 'integer', 'notnull' => true, 'length' => 4),
46 'serialized' => array('type' => 'text' , 'notnull' => true, 'length' => 4000),
47 );
48 $ilDB->createTable(self::$tbl_notification_data, $fields);
49 $ilDB->addPrimaryKey(self::$tbl_notification_data, array('notification_id'));
50
51 $ilDB->createSequence(self::$tbl_notification_data);
52 }
53
54 if (!$ilDB->tableExists(self::$tbl_notification_queue)) {
55 $fields = array(
56 'notification_id' => array('type' => 'integer' , 'notnull' => true, 'length' => 4),
57 'usr_id' => array('type' => 'integer' , 'notnull' => true, 'length' => 4),
58 #'notification_channel' => array('type' => 'text' , 'notnull' => true, 'length' => 100),
59 'valid_until' => array('type' => 'integer' , 'notnull' => true, 'length' => 4),
60 );
61 $ilDB->createTable(self::$tbl_notification_queue, $fields);
62 #$ilDB->addPrimaryKey(self::$tbl_notification_queue, array('notification_id', 'usr_id', 'notification_channel'));
63 $ilDB->addPrimaryKey(self::$tbl_notification_queue, array('notification_id', 'usr_id'));
64 }
65
66 if (!$ilDB->tableExists(self::$tbl_notification_osd_handler)) {
67 $fields = array(
68 'notification_osd_id' => array('type' => 'integer' , 'notnull' => true, 'length' => 4),
69 'usr_id' => array('type' => 'integer' , 'notnull' => true, 'length' => 4),
70 'serialized' => array('type' => 'text' , 'notnull' => true, 'length' => 4000),
71 'valid_until' => array('type' => 'integer' , 'notnull' => true, 'length' => 4),
72 'time_added' => array('type' => 'integer' , 'notnull' => true, 'length' => 4),
73 'type' => array('type' => 'text' , 'notnull' => true, 'length' => 100),
74 );
75 $ilDB->createTable(self::$tbl_notification_osd_handler, $fields);
76
77 $ilDB->addPrimaryKey(self::$tbl_notification_osd_handler, array('notification_osd_id'));
81 #$ilDB->addIndex(self::$tbl_notification_osd_handler, array('usr_id', 'valid_until', 'time_added'));
82
83 $ilDB->createSequence(self::$tbl_notification_osd_handler);
84 }
85
86 if (!$ilDB->tableExists(self::$tbl_notification_channels)) {
87 $fields = array(
88 'channel_name'=> array('type' => 'text', 'notnull' => true, 'length' => 100),
89 'title' => array('type' => 'text', 'notnull' => true, 'length' => 100),
90 'description'=> array('type' => 'text', 'notnull' => true, 'length' => 4000),
91 'class' => array('type' => 'text', 'notnull' => true, 'length' => 100),
92 'include' => array('type' => 'text', 'notnull' => true, 'length' => 100),
93 'config_type' => array('type' => 'text', 'notnull' => true, 'length' => 30),
94 );
95 $ilDB->createTable(self::$tbl_notification_channels, $fields);
96
97 $ilDB->addPrimaryKey(self::$tbl_notification_channels, array('channel_name'));
98
99 ilNotificationSetupHelper::registerChannel('mail', 'mail', 'mail_desc', 'ilNotificationMailHandler', 'Services/Notifications/classes/class.ilNotificationMailHandler.php');
100 ilNotificationSetupHelper::registerChannel('osd', 'osd', 'osd_desc', 'ilNotificationOSDHandler', 'Services/Notifications/classes/class.ilNotificationOSDHandler.php');
101 }
102
103 if (!$ilDB->tableExists(self::$tbl_notification_types)) {
104 $fields = array(
105 'type_name'=> array('type' => 'text', 'notnull' => true, 'length' => 100),
106 'title' => array('type' => 'text', 'notnull' => true, 'length' => 100),
107 'description' => array('type' => 'text', 'notnull' => true, 'length' => 100),
108 'notification_group' => array('type' => 'text', 'notnull' => true, 'length' => 100),
109 'config_type' => array('type' => 'text', 'notnull' => true, 'length' => 30),
110 );
111 $ilDB->createTable(self::$tbl_notification_types, $fields);
112 $ilDB->addPrimaryKey(self::$tbl_notification_types, array('type_name'));
113
114 ilNotificationSetupHelper::registerType('chat_invitation', 'chat_invitation', 'chat_invitation_description', 'chat');
115 //ilNotificationSetupHelper::registerType('adobe_connect_invitation', 'adobe_connect_invitation', 'adobe_connect_invitation_description', 'adobe_connect');
116 ilNotificationSetupHelper::registerType('osd_maint', 'osd_maint', 'osd_maint_description', 'osd_notification');
117 }
118 }
119
120
121 public static function registerChannel($name, $title, $description, $class, $classfile, $config_type = 'set_by_user')
122 {
123 ilNotificationDatabaseHandler::registerChannel($name, $title, $description, $class, $classfile, $config_type);
124 }
125
126 public static function registerType($name, $title, $description, $notification_group, $config_type = 'set_by_user')
127 {
128 ilNotificationDatabaseHandler::registerType($name, $title, $description, $notification_group, $config_type);
129 }
130}
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')
if($format !==null) $name
Definition: metadata.php:146
global $ilDB