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