-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.php
More file actions
155 lines (141 loc) · 5.02 KB
/
setup.php
File metadata and controls
155 lines (141 loc) · 5.02 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?php
if (!defined('DP_BASE_DIR')) {
die('You should not access this file directly.');
}
/*
* Name: Audit
* Directory: audit
* Version 0.1
* Type: user
* UI Name: Audit
*/
$config['mod_name'] = "Audit";
$config['mod_version'] = "0.1";
$config['mod_directory'] = "audit";
$config['mod_setup_class'] = "CSetupAudit";
$config['mod_type'] = "user";
$config['mod_ui_name'] = "Audit";
$config['mod_ui_icon'] = "";
$config['mod_description'] = "A module for auditions";
$config['mod_config'] = true;
$config['permissions_item_table'] = "audit";
$config['permissions_item_field'] = "audit_id";
$config['permissions_item_label'] = "audit_name";
class CSetupAudit{
function configure() { return true; }
function remove() {
if($this->removeArtefact() && $this->removeAudit() && $this->removeAuditors() && $this->removeChecklist()) {
return NULL;
}
}
function upgrade($old_version) {
return true;
}
function install() {
if($this->installArtefact() && $this->installAudit() && $this->installAuditors() && $this->installChecklist()) {
return NULL;
}
}
function installArtefact() {
$q = new DBQuery();
$q->createTable('artefacts');
$q->createDefinition("(artefact_id integer auto_increment,".
" project_id integer not null,".
" artefact_name varchar(255) not null,".
" artefact_phase varchar(255) not null,".
" artefact_short_description varchar(255) not null,".
" artefact_description varchar(255) not null,".
" artefact_status varchar(255) not null,".
" primary key(artefact_id),".
" foreign key(project_id) references ".dPgetConfig('dbprefix', '')."projects (project_id))");
if (!$q->exec()) {
return db_error();
}
$q->clear();
return true;
}
function removeArtefact(){
$q = new DBQuery();
$q->dropTable('artefacts');
if (!$q->exec()) {
return db_error();
}else{
return true;
}
}
function installAuditors(){
$q = new DBQuery();
$q->createTable('auditors');
$q->createDefinition("(auditor_id integer auto_increment,".
" project_id integer not null,".
" contact_id integer not null,".
" primary key(auditor_id),".
" foreign key(project_id) references ".dPgetConfig('dbprefix', '')."projects (project_id),".
" foreign key(contact_id) references ".dPgetConfig('dbprefix', '')."contacts (contact_id))");
if (!$q->exec()) {
return db_error();
}
$q->clear();
return true;
}
function removeAuditors(){
$q = new DBQuery();
$q->dropTable('auditors');
if (!$q->exec()) {
return db_error();
}else{
return true;
}
}
function installAudit() {
$q = new DBQuery();
$q->createTable('audits');
$q->createDefinition("(audit_id integer auto_increment,".
" artefact_id integer not null,".
" auditor_id integer not null,".
" audit_name varchar(255) not null,".
" primary key(audit_id),".
" foreign key(artefact_id) references ".dPgetConfig('dbprefix', '')."artefacts (artefact_id),".
" foreign key(auditor_id) references ".dPgetConfig('dbprefix', '')."auditors (user_id))");
if (!$q->exec()) {
return db_error();
}
$q->clear();
return true;
}
function removeAudit(){
$q = new DBQuery();
$q->dropTable('audits');
if (!$q->exec()) {
return db_error();
}else{
return true;
}
}
function installChecklist() {
$q = new DBQuery();
$q->createTable('checklists');
$q->createDefinition("(checklist_id integer auto_increment,".
" checklist_name varchar(255) not null,".
" checklist_description varchar(255),".
" checklist_criteria varchar(255),".
" audit_id integer not null,".
" primary key(checklist_id),".
" foreign key(audit_id) references ".dPgetConfig('dbprefix', '')."audits (audit_id))");
if (!$q->exec()) {
return db_error();
}
$q->clear();
return true;
}
function removeChecklist(){
$q = new DBQuery();
$q->dropTable('checklists');
if (!$q->exec()) {
return db_error();
}else{
return true;
}
}
}
?>