Update install.php

Clean up formatting and remove unnecessary quotations
This commit is contained in:
steve-lad 2021-05-31 10:00:06 +02:00
parent d846af6913
commit ac71164055

View file

@ -461,8 +461,8 @@ function InstallDB_Buttons()
outn("<li>" . _("Creating buttons table...") . "</li>"); outn("<li>" . _("Creating buttons table...") . "</li>");
// $check = $db->getRow("SELECT 1 FROM buttonconfig LIMIT 0", DB_FETCHMODE_ASSOC); // $check = $db->getRow("SELECT 1 FROM buttonconfig LIMIT 0", DB_FETCHMODE_ASSOC);
// if (DB::IsError($check)) { // if (DB::IsError($check)) {
$sql = "DROP TABLE IF EXISTS `buttonconfig`; $sql = "DROP TABLE IF EXISTS buttonconfig;
CREATE TABLE IF NOT EXISTS `sccpbuttonconfig` ( CREATE TABLE IF NOT EXISTS sccpbuttonconfig (
`ref` varchar(15) NOT NULL default '', `ref` varchar(15) NOT NULL default '',
`reftype` enum('sccpdevice', 'sipdevice', 'sccpuser') NOT NULL default 'sccpdevice', `reftype` enum('sccpdevice', 'sipdevice', 'sccpuser') NOT NULL default 'sccpdevice',
`instance` tinyint(4) NOT NULL default 0, `instance` tinyint(4) NOT NULL default 0,
@ -501,18 +501,18 @@ function InstallDB_sccpdevmodel()
{ {
global $db; global $db;
outn("<li>" . _("Creating sccpdevmodel table...") . "</li>"); outn("<li>" . _("Creating sccpdevmodel table...") . "</li>");
$sql = "CREATE TABLE IF NOT EXISTS `sccpdevmodel` ( $sql = "CREATE TABLE IF NOT EXISTS sccpdevmodel (
`model` varchar(20) NOT NULL DEFAULT '', `model` varchar(20) NOT NULL DEFAULT '',
`vendor` varchar(40) DEFAULT '', `vendor` varchar(40) DEFAULT '',
`dns` int(2) DEFAULT '1', `dns` int(2) DEFAULT '1',
`buttons` int(2) DEFAULT '0', `buttons` int(2) DEFAULT '0',
`loadimage` varchar(40) DEFAULT '', `loadimage` varchar(40) DEFAULT '',
`loadinformationid` VARCHAR(30) NULL DEFAULT NULL, `loadinformationid` VARCHAR(30) NULL DEFAULT NULL,
`enabled` INT(2) NULL DEFAULT '0', `enabled` INT(2) NULL DEFAULT '0',
`nametemplate` VARCHAR(50) NULL DEFAULT NULL, `nametemplate` VARCHAR(50) NULL DEFAULT NULL,
PRIMARY KEY (`model`), PRIMARY KEY (`model`),
KEY `model` (`model`) KEY `model` (`model`)
) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;"; ) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;";
$check = $db->query($sql); $check = $db->query($sql);
if (DB::IsError($check)) { if (DB::IsError($check)) {
die_freepbx("Can not create sccpdevmodel table, error:$check\n"); die_freepbx("Can not create sccpdevmodel table, error:$check\n");
@ -525,17 +525,17 @@ function InstallDB_sccpuser()
global $db; global $db;
outn("<li>" . _("Creating sccpuser table...") . "</li>"); outn("<li>" . _("Creating sccpuser table...") . "</li>");
$sql = "CREATE TABLE IF NOT EXISTS `sccpuser` ( $sql = "CREATE TABLE IF NOT EXISTS `sccpuser` (
`name` VARCHAR(20) NULL DEFAULT NULL, `name` VARCHAR(20) NULL DEFAULT NULL,
`pin` VARCHAR(7) NULL DEFAULT NULL, `pin` VARCHAR(7) NULL DEFAULT NULL,
`password` VARCHAR(7) NULL DEFAULT NULL, `password` VARCHAR(7) NULL DEFAULT NULL,
`description` VARCHAR(45) NULL DEFAULT NULL, `description` VARCHAR(45) NULL DEFAULT NULL,
`roaminglogin` ENUM('on','off','multi') NULL DEFAULT 'off', `roaminglogin` ENUM('on','off','multi') NULL DEFAULT 'off',
`devicegroup` VARCHAR(20) NULL DEFAULT 'all', `devicegroup` VARCHAR(20) NULL DEFAULT 'all',
`auto_logout` ENUM('on','off') NULL DEFAULT 'off', `auto_logout` ENUM('on','off') NULL DEFAULT 'off',
`homedevice` VARCHAR(20) NULL DEFAULT NULL, `homedevice` VARCHAR(20) NULL DEFAULT NULL,
UNIQUE INDEX (`name`), UNIQUE INDEX (`name`),
PRIMARY KEY (`name`) PRIMARY KEY (`name`)
) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;"; ) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;";
$check = $db->query($sql); $check = $db->query($sql);
if (DB::IsError($check)) { if (DB::IsError($check)) {
die_freepbx("Can not create sccpdevmodel table, error:$check\n"); die_freepbx("Can not create sccpdevmodel table, error:$check\n");
@ -871,28 +871,53 @@ function InstallDB_CreateSccpDeviceConfigView($sccp_compatible)
outn("<li>" . _("(Re)Create sccpdeviceconfig view") . "</li>"); outn("<li>" . _("(Re)Create sccpdeviceconfig view") . "</li>");
$sql = ""; $sql = "";
if ($sccp_compatible < 431) { if ($sccp_compatible < 431) {
$sql = " $sql = "CREATE OR REPLACE
CREATE OR REPLACE
ALGORITHM = MERGE ALGORITHM = MERGE
VIEW sccpdeviceconfig AS VIEW sccpdeviceconfig AS
SELECT GROUP_CONCAT( CONCAT_WS( ',', buttonconfig.type, buttonconfig.name, buttonconfig.options )
SELECT GROUP_CONCAT( CONCAT_WS( ',', buttonconfig.type, buttonconfig.name, buttonconfig.options ) ORDER BY instance ASC
ORDER BY instance ASC SEPARATOR ';' ) AS button,
SEPARATOR ';' ) AS button, sccpdevice.type AS type,
`sccpdevice`.`type` AS `type`,`sccpdevice`.`addon` AS `addon`,`sccpdevice`.`description` AS `description`,`sccpdevice`.`tzoffset` AS `tzoffset`, sccpdevice.addon AS addon,
`sccpdevice`.`transfer` AS `transfer`,`sccpdevice`.`cfwdall` AS `cfwdall`,`sccpdevice`.`cfwdbusy` AS `cfwdbusy`,`sccpdevice`.`imageversion` AS `imageversion`, sccpdevice.description AS description,
`sccpdevice`.`deny` AS `deny`,`sccpdevice`.`permit` AS `permit`,`sccpdevice`.`dndFeature` AS `dndFeature`,`sccpdevice`.`directrtp` AS `directrtp`, sccpdevice.tzoffset AS tzoffset,
`sccpdevice`.`earlyrtp` AS `earlyrtp`,`sccpdevice`.`mwilamp` AS `mwilamp`,`sccpdevice`.`mwioncall` AS `mwioncall`,`sccpdevice`.`pickupexten` AS `pickupexten`, sccpdevice.transfer AS transfer,
`sccpdevice`.`pickupcontext` AS `pickupcontext`,`sccpdevice`.`pickupmodeanswer` AS `pickupmodeanswer`,`sccpdevice`.`private` AS `private`, sccpdevice.cfwdall AS cfwdall,
`sccpdevice`.`privacy` AS `privacy`,`sccpdevice`.`nat` AS `nat`,`sccpdevice`.`softkeyset` AS `softkeyset`,`sccpdevice`.`audio_tos` AS `audio_tos`, sccpdevice.cfwdbusy AS cfwdbusy,
`sccpdevice`.`audio_cos` AS `audio_cos`,`sccpdevice`.`video_tos` AS `video_tos`,`sccpdevice`.`video_cos` AS `video_cos`,`sccpdevice`.`conf_allow` AS `conf_allow`, sccpdevice.imageversion AS imageversion,
`sccpdevice`.`conf_play_general_announce` AS `conf_play_general_announce`,`sccpdevice`.`conf_play_part_announce` AS `conf_play_part_announce`, sccpdevice.deny AS deny,
`sccpdevice`.`conf_mute_on_entry` AS `conf_mute_on_entry`,`sccpdevice`.`conf_music_on_hold_class` AS `conf_music_on_hold_class`, sccpdevice.permit AS permit,
`sccpdevice`.`conf_show_conflist` AS `conf_show_conflist`,`sccpdevice`.`setvar` AS `setvar`,`sccpdevice`.`disallow` AS `disallow`, sccpdevice.dndFeature AS dndFeature,
`sccpdevice`.`allow` AS `allow`,`sccpdevice`.`backgroundImage` AS `backgroundImage`,`sccpdevice`.`ringtone` AS `ringtone`,`sccpdevice`.`name` AS `name` sccpdevice.directrtp AS directrtp,
FROM sccpdevice sccpdevice.earlyrtp AS earlyrtp,
LEFT JOIN sccpbuttonconfig buttonconfig ON ( buttonconfig.device = sccpdevice.name ) sccpdevice.mwilamp AS mwilamp,
GROUP BY sccpdevice.name;"; sccpdevice.mwioncall AS mwioncall,
sccpdevice.pickupexten AS pickupexten,
sccpdevice.pickupcontext AS pickupcontext,
sccpdevice.pickupmodeanswer AS pickupmodeanswer,
sccpdevice.private AS private,
sccpdevice.privacy AS privacy,
sccpdevice.nat AS nat,
sccpdevice.softkeyset AS softkeyset,
sccpdevice.audio_tos AS audio_tos,
sccpdevice.audio_cos AS audio_cos,
sccpdevice.video_tos AS video_tos,
sccpdevice.video_cos AS video_cos,
sccpdevice.conf_allow AS conf_allow,
sccpdevice.conf_play_general_announce AS conf_play_general_announce,
sccpdevice.conf_play_part_announce AS conf_play_part_announce,
sccpdevice.conf_mute_on_entry AS conf_mute_on_entry,
sccpdevice.conf_music_on_hold_class AS conf_music_on_hold_class,
sccpdevice.conf_show_conflist AS conf_show_conflist,
sccpdevice.setvar AS setvar,
sccpdevice.disallow AS disallow,
sccpdevice.allow AS allow,
sccpdevice.backgroundImage AS backgroundImage,
sccpdevice.ringtone AS ringtone,
sccpdevice.name AS name
FROM sccpdevice
LEFT JOIN sccpbuttonconfig buttonconfig ON ( buttonconfig.device = sccpdevice.name )
GROUP BY sccpdevice.name;";
} else { } else {
/* $sql = " /* $sql = "
CREATE OR REPLACE CREATE OR REPLACE
@ -909,35 +934,37 @@ function InstallDB_CreateSccpDeviceConfigView($sccp_compatible)
LEFT JOIN sccpline ON ( sccpline.name = sccpdevice._loginname) LEFT JOIN sccpline ON ( sccpline.name = sccpdevice._loginname)
GROUP BY sccpdevice.name;"; GROUP BY sccpdevice.name;";
*/ */
$sql = "DROP VIEW IF EXISTS `sccpdeviceconfig`; $sql = "DROP VIEW IF EXISTS sccpdeviceconfig;
DROP VIEW IF EXISTS `sccpuserconfig`;"; DROP VIEW IF EXISTS sccpuserconfig;";
/// global $hw_mobil; /// global $hw_mobil;
global $mobile_hw; global $mobile_hw;
if ($mobile_hw == '1') { if ($mobile_hw == '1') {
$sql .= "CREATE OR REPLACE ALGORITHM = MERGE VIEW sccpdeviceconfig AS $sql .= "CREATE OR REPLACE
SELECT GROUP_CONCAT( CONCAT_WS( ',', sccpbuttonconfig.buttontype, sccpbuttonconfig.name, sccpbuttonconfig.options ) ALGORITHM = MERGE
ORDER BY instance ASC SEPARATOR ';' ) AS sccpbutton, sccpdevice.* VIEW sccpdeviceconfig AS
FROM sccpdevice SELECT GROUP_CONCAT( CONCAT_WS( ',', sccpbuttonconfig.buttontype, sccpbuttonconfig.name, sccpbuttonconfig.options )
LEFT JOIN sccpbuttonconfig ON (sccpbuttonconfig.reftype = 'sccpdevice' AND sccpbuttonconfig.ref = sccpdevice.name ) ORDER BY instance ASC SEPARATOR ';' ) AS sccpbutton, sccpdevice.*
GROUP BY sccpdevice.name; "; FROM sccpdevice
$sql .= "CREATE OR REPLACE ALGORITHM = MERGE VIEW sccpuserconfig AS LEFT JOIN sccpbuttonconfig ON (sccpbuttonconfig.reftype = 'sccpdevice' AND sccpbuttonconfig.ref = sccpdevice.name )
SELECT GROUP_CONCAT( CONCAT_WS( ',', sccpbuttonconfig.buttontype, sccpbuttonconfig.name, sccpbuttonconfig.options ) GROUP BY sccpdevice.name; ";
ORDER BY instance ASC SEPARATOR ';' ) AS button, sccpuser.* $sql .= "CREATE OR REPLACE ALGORITHM = MERGE VIEW sccpuserconfig AS
FROM sccpuser SELECT GROUP_CONCAT( CONCAT_WS( ',', sccpbuttonconfig.buttontype, sccpbuttonconfig.name, sccpbuttonconfig.options )
LEFT JOIN sccpbuttonconfig ON ( sccpbuttonconfig.reftype = 'sccpuser' AND sccpbuttonconfig.ref = sccpuser.id) ORDER BY instance ASC SEPARATOR ';' ) AS button, sccpuser.*
GROUP BY sccpuser.name; "; FROM sccpuser
LEFT JOIN sccpbuttonconfig ON ( sccpbuttonconfig.reftype = 'sccpuser' AND sccpbuttonconfig.ref = sccpuser.id)
GROUP BY sccpuser.name; ";
} else { } else {
$sql .= "CREATE OR REPLACE $sql .= "CREATE OR REPLACE
ALGORITHM = MERGE ALGORITHM = MERGE
VIEW sccpdeviceconfig AS VIEW sccpdeviceconfig AS
SELECT case sccpdevice._profileid SELECT case sccpdevice._profileid
when 0 then when 0 then
(select GROUP_CONCAT(CONCAT_WS( ',', defbutton.buttontype, defbutton.name, defbutton.options ) SEPARATOR ';') from `sccpbuttonconfig` as defbutton where defbutton.ref = sccpdevice.name ORDER BY defbutton.instance ) (select GROUP_CONCAT(CONCAT_WS( ',', defbutton.buttontype, defbutton.name, defbutton.options ) SEPARATOR ';') from sccpbuttonconfig as defbutton where defbutton.ref = sccpdevice.name ORDER BY defbutton.instance )
when 1 then when 1 then
(select GROUP_CONCAT(CONCAT_WS( ',', userbutton.buttontype, userbutton.name, userbutton.options ) SEPARATOR ';') from `sccpbuttonconfig` as userbutton where userbutton.ref = sccpdevice._loginname ORDER BY userbutton.instance ) (select GROUP_CONCAT(CONCAT_WS( ',', userbutton.buttontype, userbutton.name, userbutton.options ) SEPARATOR ';') from sccpbuttonconfig as userbutton where userbutton.ref = sccpdevice._loginname ORDER BY userbutton.instance )
when 2 then when 2 then
(select GROUP_CONCAT(CONCAT_WS( ',', homebutton.buttontype, homebutton.name, homebutton.options ) SEPARATOR ';') from `sccpbuttonconfig` as homebutton where homebutton.ref = sccpuser.homedevice ORDER BY homebutton.instance ) (select GROUP_CONCAT(CONCAT_WS( ',', homebutton.buttontype, homebutton.name, homebutton.options ) SEPARATOR ';') from sccpbuttonconfig as homebutton where homebutton.ref = sccpuser.homedevice ORDER BY homebutton.instance )
end as button, if(sccpdevice._profileid = 0, sccpdevice._description, sccpuser.description) as description, sccpdevice.* end as button, if(sccpdevice._profileid = 0, sccpdevice._description, sccpuser.description) as description, sccpdevice.*
FROM sccpdevice FROM sccpdevice
LEFT JOIN sccpuser sccpuser ON ( sccpuser.name = sccpdevice._loginname ) LEFT JOIN sccpuser sccpuser ON ( sccpuser.name = sccpdevice._loginname )