-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathinstall.php
134 lines (105 loc) · 3.18 KB
/
install.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
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
<?php
$fcc = new featurecode('bosssecretary', 'bsc_toggle');
$fcc->setDescription('Bosssecretary Toggle');
$fcc->setDefault('*152');
$fcc->update();
unset($fcc);
$fcc = new featurecode('bosssecretary', 'bsc_on');
$fcc->setDescription('Bosssecretary On');
$fcc->setDefault('*153');
$fcc->update();
unset($fcc);
$fcc = new featurecode('bosssecretary', 'bsc_off');
$fcc->setDescription('Bosssecretary Off');
$fcc->setDefault('*154');
$fcc->update();
unset($fcc);
$sql = " DROP TABLE IF EXISTS `bosssecretary_config`";
$check = $db->query($sql);
if(DB::IsError($check)) {
die_freepbx("Can not drop bosssecretary_config table");
}
$sql = "
CREATE TABLE IF NOT EXISTS `bosssecretary_chief` (
`id_group` int(10) unsigned NOT NULL,
`chief_extension` varchar(20) NOT NULL,
PRIMARY KEY (`id_group`,`chief_extension`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
";
$check = $db->query($sql);
if(DB::IsError($check)) {
die_freepbx("Can not create bosssecretary_chief table");
}
$sql = "
CREATE TABLE IF NOT EXISTS `bosssecretary_boss` (
`id_group` int(10) unsigned NOT NULL,
`boss_extension` varchar(20) NOT NULL,
PRIMARY KEY (`id_group`,`boss_extension`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
";
$check = $db->query($sql);
if(DB::IsError($check)) {
die_freepbx("Can not create bosssecretary_boss table");
}
$sql = "
CREATE TABLE IF NOT EXISTS `bosssecretary_group` (
`id_group` int(10) unsigned NOT NULL AUTO_INCREMENT,
`label` varchar(20) NOT NULL,
PRIMARY KEY (`id_group`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
";
$check = $db->query($sql);
if(DB::IsError($check)) {
die_freepbx("Can not create bosssecretary_group table");
}
$sql = "SHOW COLUMNS FROM `bosssecretary_group`";
$results = $db->getAll($sql);
if(DB::IsError($results)) {
die_freepbx("Can not check bosssecretary_group table");
}
foreach ($results as $column)
{
if (trim(strtolower($column["Field"])) == "dring")
{
$sql = "ALTER TABLE `bosssecretary_group` DROP `".$column["Field"]."` ";
$check = $db->query($sql);
if(DB::IsError($check)) {
die_freepbx("Can not alter bosssecretary_group table");
}
}
if (trim(strtolower($column["Field"])) == "ringtime")
{
$sql = "ALTER TABLE `bosssecretary_group` DROP `".$column["Field"]."` ";
$check = $db->query($sql);
if(DB::IsError($check)) {
die_freepbx("Can not alter bosssecretary_group table");
}
}
}
$sql = "ALTER TABLE bosssecretary_group MODIFY id_group INT(10) NOT NULL";
$results = $db->query($sql);
if(DB::IsError($results)) {
die_freepbx("Can not modify bosssecretary_group.id_group column");
}
$sql = "
CREATE TABLE IF NOT EXISTS `bosssecretary_secretary` (
`id_group` int(11) NOT NULL,
`secretary_extension` varchar(20) NOT NULL,
PRIMARY KEY (`id_group`,`secretary_extension`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
";
$check = $db->query($sql);
if(DB::IsError($check)) {
die_freepbx("Can not create bosssecretary_secretary table");
}
$sql = "
CREATE TABLE IF NOT EXISTS `bosssecretary_group_numbers_free` (
`group_number` int(10) unsigned NOT NULL,
PRIMARY KEY (`group_number`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
";
$check = $db->query($sql);
if(DB::IsError($check)) {
die_freepbx("Can not create bosssecretary_group_numbers_free");
}
?>