| 1 |
<?php |
|---|
| 2 |
if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } |
|---|
| 3 |
|
|---|
| 4 |
if (false) { |
|---|
| 5 |
_("Intercom prefix"); |
|---|
| 6 |
_("User Intercom Allow"); |
|---|
| 7 |
_("User Intercom Disallow"); |
|---|
| 8 |
} |
|---|
| 9 |
|
|---|
| 10 |
global $amp_conf; |
|---|
| 11 |
|
|---|
| 12 |
$fcc = new featurecode('paging', 'intercom-prefix'); |
|---|
| 13 |
$fcc->setDescription('Intercom prefix'); |
|---|
| 14 |
$fcc->setDefault('*80'); |
|---|
| 15 |
$fcc->update(); |
|---|
| 16 |
unset($fcc); |
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
$fcc = new featurecode('paging', 'intercom-on'); |
|---|
| 20 |
$fcc->setDescription('User Intercom Allow'); |
|---|
| 21 |
$fcc->setDefault('*54'); |
|---|
| 22 |
$fcc->update(); |
|---|
| 23 |
unset($fcc); |
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
$fcc = new featurecode('paging', 'intercom-off'); |
|---|
| 27 |
$fcc->setDescription('User Intercom Disallow'); |
|---|
| 28 |
$fcc->setDefault('*55'); |
|---|
| 29 |
$fcc->update(); |
|---|
| 30 |
unset($fcc); |
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
$sql = "DROP TABLE IF EXISTS paging_phones"; |
|---|
| 35 |
$result = $db->query($sql); |
|---|
| 36 |
if(DB::IsError($result)) { |
|---|
| 37 |
die_freepbx($result->getDebugInfo()); |
|---|
| 38 |
} |
|---|
| 39 |
$sql = "DROP TABLE IF EXISTS paging_overview"; |
|---|
| 40 |
$result = $db->query($sql); |
|---|
| 41 |
if(DB::IsError($result)) { |
|---|
| 42 |
die_freepbx($result->getDebugInfo()); |
|---|
| 43 |
} |
|---|
| 44 |
|
|---|
| 45 |
$sql = "CREATE TABLE IF NOT EXISTS paging_groups |
|---|
| 46 |
( page_number VARCHAR(50), |
|---|
| 47 |
ext VARCHAR(25), |
|---|
| 48 |
PRIMARY KEY (page_number, ext) |
|---|
| 49 |
)"; |
|---|
| 50 |
$result = $db->query($sql); |
|---|
| 51 |
if(DB::IsError($result)) { |
|---|
| 52 |
die_freepbx($result->getDebugInfo()); |
|---|
| 53 |
} |
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
$sql = " |
|---|
| 59 |
CREATE TABLE IF NOT EXISTS `paging_autoanswer` ( |
|---|
| 60 |
`useragent` VARCHAR( 255 ) NOT NULL , |
|---|
| 61 |
`var` VARCHAR( 20 ) NOT NULL , |
|---|
| 62 |
`setting` VARCHAR( 255 ) NOT NULL , |
|---|
| 63 |
PRIMARY KEY ( `useragent` , `var` ) |
|---|
| 64 |
);"; |
|---|
| 65 |
$result = $db->query($sql); |
|---|
| 66 |
if(DB::IsError($result)) { |
|---|
| 67 |
die_freepbx($result->getDebugInfo()); |
|---|
| 68 |
} |
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
$sql = "SELECT page_group FROM paging_config"; |
|---|
| 72 |
$check = $db->getRow($sql, DB_FETCHMODE_ASSOC); |
|---|
| 73 |
if(DB::IsError($check)) { |
|---|
| 74 |
|
|---|
| 75 |
$sql = "DROP TABLE IF EXISTS paging_config;"; |
|---|
| 76 |
$result = $db->query($sql); |
|---|
| 77 |
if(DB::IsError($result)) { |
|---|
| 78 |
die_freepbx($result->getDebugInfo()); |
|---|
| 79 |
} |
|---|
| 80 |
|
|---|
| 81 |
$sql = "CREATE TABLE IF NOT EXISTS paging_config |
|---|
| 82 |
( page_group VARCHAR(255), |
|---|
| 83 |
force_page INTEGER(1) NOT NULL, |
|---|
| 84 |
duplex INTEGER(1) NOT NULL default '0', |
|---|
| 85 |
description VARCHAR(255) NOT NULL default '', |
|---|
| 86 |
PRIMARY KEY (page_group) |
|---|
| 87 |
)"; |
|---|
| 88 |
$result = $db->query($sql); |
|---|
| 89 |
if(DB::IsError($result)) { |
|---|
| 90 |
die_freepbx($result->getDebugInfo()); |
|---|
| 91 |
} |
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
$sql = "INSERT INTO paging_config (page_group, force_page, duplex, description) SELECT DISTINCT page_number, 0, 0, '' FROM paging_groups"; |
|---|
| 95 |
$result = $db->query($sql); |
|---|
| 96 |
if(DB::IsError($result)) { |
|---|
| 97 |
die_freepbx($result->getDebugInfo()); |
|---|
| 98 |
} |
|---|
| 99 |
} |
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
$sql = "INSERT INTO paging_autoanswer (useragent, var, setting) VALUES ('default', 'CALLINFO', 'Call-Info: <uri>\\\\;answer-after=0')"; |
|---|
| 107 |
$result = $db->query($sql); |
|---|
| 108 |
$sql = "INSERT INTO paging_autoanswer (useragent, var, setting) VALUES ('default', 'ALERTINFO', 'Alert-Info: Ring Answer')"; |
|---|
| 109 |
$result = $db->query($sql); |
|---|
| 110 |
$sql = "INSERT INTO paging_autoanswer (useragent, var, setting) VALUES ('default', 'SIPURI', 'intercom=true')"; |
|---|
| 111 |
$result = $db->query($sql); |
|---|
| 112 |
$sql = "INSERT INTO paging_autoanswer (useragent, var, setting) VALUES ('Mitel', 'CALLINFO', 'Call-Info: <sip:broadworks.net>\\\\;answer-after=0')"; |
|---|
| 113 |
$result = $db->query($sql); |
|---|
| 114 |
$sql = "INSERT INTO paging_autoanswer (useragent, var, setting) VALUES ('Panasonic', 'ALERTINFO', 'Alert-Info: Intercom')"; |
|---|
| 115 |
$result = $db->query($sql); |
|---|
| 116 |
$sql = "INSERT INTO paging_autoanswer (useragent, var, setting) VALUES ('Polycom', 'ALERTINFO', 'Alert-Info: info-Auto Answer')"; |
|---|
| 117 |
$result = $db->query($sql); |
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 |
|
|---|
| 121 |
$sql = "SELECT duplex FROM paging_config"; |
|---|
| 122 |
$result = $db->getRow($sql, DB_FETCHMODE_ASSOC); |
|---|
| 123 |
if (DB::IsError($result)) { |
|---|
| 124 |
$sql = "ALTER TABLE paging_config ADD duplex INTEGER(1) NOT NULL default '0'"; |
|---|
| 125 |
$results = $db->query($sql); |
|---|
| 126 |
if(DB::IsError($results)) { |
|---|
| 127 |
die_freepbx($results->getMessage()); |
|---|
| 128 |
} |
|---|
| 129 |
} |
|---|
| 130 |
|
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 |
$sql = "SELECT description FROM paging_config"; |
|---|
| 134 |
$result = $db->getRow($sql, DB_FETCHMODE_ASSOC); |
|---|
| 135 |
if (DB::IsError($result)) { |
|---|
| 136 |
$sql = "ALTER TABLE paging_config ADD description VARCHAR(255) NOT NULL default ''"; |
|---|
| 137 |
$results = $db->query($sql); |
|---|
| 138 |
if(DB::IsError($results)) { |
|---|
| 139 |
die_freepbx($results->getMessage()); |
|---|
| 140 |
} |
|---|
| 141 |
} |
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 |
|
|---|
| 147 |
if($amp_conf["AMPDBENGINE"] != "sqlite3") { |
|---|
| 148 |
$sql = "ALTER TABLE `paging_groups` ADD PRIMARY KEY ( `page_number` , `ext` )"; |
|---|
| 149 |
$result = $db->query($sql); |
|---|
| 150 |
|
|---|
| 151 |
$sql = "ALTER TABLE `paging_config` ADD PRIMARY KEY ( `page_group` )"; |
|---|
| 152 |
$result = $db->query($sql); |
|---|
| 153 |
} |
|---|
| 154 |
?> |
|---|
| 155 |
|
|---|