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