Clean Installer
Remove unused functions Remove unused cases Remove duplicate code
This commit is contained in:
parent
5e7bdbe40b
commit
218e1c66ee
124
install.php
124
install.php
|
@ -56,11 +56,6 @@ if ($result[0]['IsEmpty']) {
|
||||||
outn("Populating sccpdevmodel...");
|
outn("Populating sccpdevmodel...");
|
||||||
InstallDB_fillsccpdevmodel();
|
InstallDB_fillsccpdevmodel();
|
||||||
}
|
}
|
||||||
if (!$sccp_db_ver) {
|
|
||||||
InstallDB_updateSccpDevice();
|
|
||||||
} else {
|
|
||||||
outn("Skip update Device model");
|
|
||||||
}
|
|
||||||
|
|
||||||
InstallDB_createButtonConfigTrigger();
|
InstallDB_createButtonConfigTrigger();
|
||||||
InstallDB_CreateSccpDeviceConfigView($sccp_compatible);
|
InstallDB_CreateSccpDeviceConfigView($sccp_compatible);
|
||||||
|
@ -94,17 +89,14 @@ function Get_DB_config($sccp_compatible)
|
||||||
'directed_pickup_modeanswer' => array('drop' => "yes"),
|
'directed_pickup_modeanswer' => array('drop' => "yes"),
|
||||||
'pickupmodeanswer' => array('drop' => "yes"),
|
'pickupmodeanswer' => array('drop' => "yes"),
|
||||||
'disallow' => array('drop' => "yes"),
|
'disallow' => array('drop' => "yes"),
|
||||||
'disallow' => array('drop' => "yes"),
|
|
||||||
'callhistory_answered_elsewhere' => array('create' => "enum('Ignore','Missed Calls','Received Calls', 'Placed Calls') NOT NULL default 'Ignore'",
|
'callhistory_answered_elsewhere' => array('create' => "enum('Ignore','Missed Calls','Received Calls', 'Placed Calls') NOT NULL default 'Ignore'",
|
||||||
'modify' => "enum('Ignore','Missed Calls','Received Calls','Placed Calls')"),
|
'modify' => "enum('Ignore','Missed Calls','Received Calls','Placed Calls')"),
|
||||||
|
|
||||||
'description' => array('rename' => "_description"),
|
'description' => array('rename' => "_description"),
|
||||||
'hwlang' => array('rename' => "_hwlang"),
|
'hwlang' => array('rename' => "_hwlang"),
|
||||||
'_hwlang' => array('create' => 'varchar(12) NULL DEFAULT NULL'),
|
'_hwlang' => array('create' => 'varchar(12) NULL DEFAULT NULL'),
|
||||||
'_loginname' => array('create' => 'varchar(20) NULL DEFAULT NULL AFTER `_hwlang`'),
|
'_loginname' => array('create' => 'varchar(20) NULL DEFAULT NULL AFTER `_hwlang`'),
|
||||||
'_profileid' => array('create' => "INT(11) NOT NULL DEFAULT '0' AFTER `_loginname`"),
|
'_profileid' => array('create' => "INT(11) NOT NULL DEFAULT '0' AFTER `_loginname`"),
|
||||||
'_dialrules' => array('create' => "VARCHAR(255) NULL DEFAULT NULL AFTER `_profileid`"),
|
'_dialrules' => array('create' => "VARCHAR(255) NULL DEFAULT NULL AFTER `_profileid`"),
|
||||||
|
|
||||||
'useRedialMenu' => array('create' => "VARCHAR(5) NULL DEFAULT 'no' AFTER `_dialrules`"),
|
'useRedialMenu' => array('create' => "VARCHAR(5) NULL DEFAULT 'no' AFTER `_dialrules`"),
|
||||||
'dtmfmode' => array('drop' => "yes"),
|
'dtmfmode' => array('drop' => "yes"),
|
||||||
'force_dtmfmode' => array('create' => "ENUM('auto','rfc2833','skinny') NOT NULL default 'auto'",
|
'force_dtmfmode' => array('create' => "ENUM('auto','rfc2833','skinny') NOT NULL default 'auto'",
|
||||||
|
@ -553,17 +545,6 @@ function InstallDB_fillsccpdevmodel()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function InstallDB_updateSccpDevice()
|
|
||||||
{
|
|
||||||
global $db;
|
|
||||||
outn("<li>" . _("Update sccpdevice") . "</li>");
|
|
||||||
$sql = "UPDATE `sccpdevice` set audio_tos='0xB8',audio_cos='6',video_tos='0x88',video_cos='5' where audio_tos=NULL or audio_tos='';";
|
|
||||||
$check = $db->query($sql);
|
|
||||||
if (DB::IsError($check)) {
|
|
||||||
die_freepbx("Can not REPLACE defaults into sccpdevice table\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function InstallDB_createButtonConfigTrigger()
|
function InstallDB_createButtonConfigTrigger()
|
||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
|
@ -615,93 +596,42 @@ function InstallDB_CreateSccpDeviceConfigView($sccp_compatible)
|
||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
outn("<li>" . _("(Re)Create sccpdeviceconfig view") . "</li>");
|
outn("<li>" . _("(Re)Create sccpdeviceconfig view") . "</li>");
|
||||||
$sql = "";
|
$sql = "DROP VIEW IF EXISTS sccpdeviceconfig;
|
||||||
if ($sccp_compatible < 431) {
|
DROP VIEW IF EXISTS sccpuserconfig;";
|
||||||
$sql = "CREATE OR REPLACE
|
|
||||||
|
global $mobile_hw;
|
||||||
|
if ($mobile_hw == '1') {
|
||||||
|
$sql .= "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( ',', sccpbuttonconfig.buttontype, sccpbuttonconfig.name, sccpbuttonconfig.options )
|
||||||
ORDER BY instance ASC
|
ORDER BY instance ASC SEPARATOR ';' ) AS sccpbutton, sccpdevice.*
|
||||||
SEPARATOR ';' ) AS button,
|
|
||||||
sccpdevice.type AS type,
|
|
||||||
sccpdevice.addon AS addon,
|
|
||||||
sccpdevice.description AS description,
|
|
||||||
sccpdevice.tzoffset AS tzoffset,
|
|
||||||
sccpdevice.transfer AS transfer,
|
|
||||||
sccpdevice.cfwdall AS cfwdall,
|
|
||||||
sccpdevice.cfwdbusy AS cfwdbusy,
|
|
||||||
sccpdevice.imageversion AS imageversion,
|
|
||||||
sccpdevice.deny AS deny,
|
|
||||||
sccpdevice.permit AS permit,
|
|
||||||
sccpdevice.dndFeature AS dndFeature,
|
|
||||||
sccpdevice.directrtp AS directrtp,
|
|
||||||
sccpdevice.earlyrtp AS earlyrtp,
|
|
||||||
sccpdevice.mwilamp AS mwilamp,
|
|
||||||
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
|
FROM sccpdevice
|
||||||
LEFT JOIN sccpbuttonconfig buttonconfig ON ( buttonconfig.device = sccpdevice.name )
|
LEFT JOIN sccpbuttonconfig ON (sccpbuttonconfig.reftype = 'sccpdevice' AND sccpbuttonconfig.ref = sccpdevice.name )
|
||||||
GROUP BY sccpdevice.name;";
|
GROUP BY sccpdevice.name; ";
|
||||||
|
$sql .= "CREATE OR REPLACE ALGORITHM = MERGE VIEW sccpuserconfig AS
|
||||||
|
SELECT GROUP_CONCAT( CONCAT_WS( ',', sccpbuttonconfig.buttontype, sccpbuttonconfig.name, sccpbuttonconfig.options )
|
||||||
|
ORDER BY instance ASC SEPARATOR ';' ) AS button, sccpuser.*
|
||||||
|
FROM sccpuser
|
||||||
|
LEFT JOIN sccpbuttonconfig ON ( sccpbuttonconfig.reftype = 'sccpuser' AND sccpbuttonconfig.ref = sccpuser.id)
|
||||||
|
GROUP BY sccpuser.name; ";
|
||||||
} else {
|
} else {
|
||||||
$sql = "DROP VIEW IF EXISTS sccpdeviceconfig;
|
$sql .= "CREATE OR REPLACE
|
||||||
DROP VIEW IF EXISTS sccpuserconfig;";
|
ALGORITHM = MERGE
|
||||||
/// global $hw_mobil;
|
VIEW sccpdeviceconfig AS
|
||||||
|
|
||||||
global $mobile_hw;
|
|
||||||
if ($mobile_hw == '1') {
|
|
||||||
$sql .= "CREATE OR REPLACE
|
|
||||||
ALGORITHM = MERGE
|
|
||||||
VIEW sccpdeviceconfig AS
|
|
||||||
SELECT GROUP_CONCAT( CONCAT_WS( ',', sccpbuttonconfig.buttontype, sccpbuttonconfig.name, sccpbuttonconfig.options )
|
|
||||||
ORDER BY instance ASC SEPARATOR ';' ) AS sccpbutton, sccpdevice.*
|
|
||||||
FROM sccpdevice
|
|
||||||
LEFT JOIN sccpbuttonconfig ON (sccpbuttonconfig.reftype = 'sccpdevice' AND sccpbuttonconfig.ref = sccpdevice.name )
|
|
||||||
GROUP BY sccpdevice.name; ";
|
|
||||||
$sql .= "CREATE OR REPLACE ALGORITHM = MERGE VIEW sccpuserconfig AS
|
|
||||||
SELECT GROUP_CONCAT( CONCAT_WS( ',', sccpbuttonconfig.buttontype, sccpbuttonconfig.name, sccpbuttonconfig.options )
|
|
||||||
ORDER BY instance ASC SEPARATOR ';' ) AS button, sccpuser.*
|
|
||||||
FROM sccpuser
|
|
||||||
LEFT JOIN sccpbuttonconfig ON ( sccpbuttonconfig.reftype = 'sccpuser' AND sccpbuttonconfig.ref = sccpuser.id)
|
|
||||||
GROUP BY sccpuser.name; ";
|
|
||||||
} else {
|
|
||||||
$sql .= "CREATE OR REPLACE
|
|
||||||
ALGORITHM = MERGE
|
|
||||||
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 )
|
||||||
GROUP BY sccpdevice.name;";
|
GROUP BY sccpdevice.name;";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$results = $db->query($sql);
|
$results = $db->query($sql);
|
||||||
if (DB::IsError($results)) {
|
if (DB::IsError($results)) {
|
||||||
die_freepbx(sprintf(_("Error updating sccpdeviceconfig view. Command was: %s; error was: %s "), $sql, $results->getMessage()));
|
die_freepbx(sprintf(_("Error updating sccpdeviceconfig view. Command was: %s; error was: %s "), $sql, $results->getMessage()));
|
||||||
|
|
Loading…
Reference in a new issue