-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule.php
88 lines (71 loc) · 3.05 KB
/
module.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
class TaskTrackerModule extends OBFModule {
public $name = "Task Tracker v1.0";
public $description = "Tracks tasks with assigned playlists and media items.";
public function callbacks () {
}
public function install () {
$this->db->insert('users_permissions', [
'category' => 'task tracker',
'description' => 'manage tasks',
'name' => 'task_tracker_module_manage'
]);
$this->db->query('CREATE TABLE IF NOT EXISTS `module_task_tracker` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`description` text,
`created` int(11) unsigned NOT NULL,
`due` int(11) unsigned,
`status` enum("new", "in progress", "complete") default "new" NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;');
$this->db->query('CREATE TABLE IF NOT EXISTS `module_task_tracker_media` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`task_id` int(10) unsigned NOT NULL,
`media_id` int(11) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;');
$this->db->query('CREATE TABLE IF NOT EXISTS `module_task_tracker_playlists` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`task_id` int(10) unsigned NOT NULL,
`playlist_id` int(11) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;');
$this->db->query('CREATE TABLE IF NOT EXISTS `module_task_tracker_users` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`task_id` int(10) unsigned NOT NULL,
`user_id` int(11) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;');
$this->db->query('CREATE TABLE IF NOT EXISTS
`module_task_tracker_comments` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`task_id` int(10) unsigned NOT NULL,
`user_id` int(11) unsigned NOT NULL,
`comment` text,
`created` int(11) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;');
// Add task payment info table.
$this->db->query('CREATE TABLE IF NOT EXISTS `module_task_tracker_payments` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`task_id` int(10) unsigned NOT NULL,
`amount` decimal(13, 2) NOT NULL,
`type` ENUM(\'complete\', \'media\', \'playlist\', \'mediaplaylist\', \'other\') NOT NULL,
`comment` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4');
return true;
}
public function uninstall () {
$this->db->where('name','task_tracker_module_manage');
$permission = $this->db->get_one('users_permissions');
$this->db->where('permission_id', $permission['id']);
$this->db->delete('users_permissions_to_groups');
$this->db->where('id', $permission['id']);
$this->db->delete('users_permissions');
// Keep tables for now.
// $this->db->query('DROP TABLE `module_task_tracker`');
return true;
}
}