Fix Issue #65
Do not delete immediately from sccpbuttonconfig when requested by FreePbx, but cache and execute in destructor if no add follows in same instance
This commit is contained in:
parent
824c861775
commit
35c1b7c708
|
@ -1,7 +1,7 @@
|
||||||
<module>
|
<module>
|
||||||
<rawname>sccp_manager</rawname>
|
<rawname>sccp_manager</rawname>
|
||||||
<name>SCCP Manager</name>
|
<name>SCCP Manager</name>
|
||||||
<version>16.0.0.1</version>
|
<version>16.0.0.2</version>
|
||||||
<type>setup</type>
|
<type>setup</type>
|
||||||
<category>SCCP Connectivity</category>
|
<category>SCCP Connectivity</category>
|
||||||
<publisher>Steve Lad, Alex GP</publisher>
|
<publisher>Steve Lad, Alex GP</publisher>
|
||||||
|
|
|
@ -72,9 +72,10 @@ class Sccp extends \FreePBX\modules\Core\Driver {
|
||||||
);
|
);
|
||||||
|
|
||||||
private $line_defaults = array();
|
private $line_defaults = array();
|
||||||
|
public $delId = '';
|
||||||
|
public $cachedDeleteStatement;
|
||||||
|
|
||||||
public function __construct($parent_class = null) {
|
public function __construct($parent_class = null) {
|
||||||
|
|
||||||
$this->freepbx = $parent_class;
|
$this->freepbx = $parent_class;
|
||||||
$this->database = $parent_class->Database();
|
$this->database = $parent_class->Database();
|
||||||
// Get system defaults [systemdefault] and sitedefaults [data] from sccpsettings.
|
// Get system defaults [systemdefault] and sitedefaults [data] from sccpsettings.
|
||||||
|
@ -97,6 +98,14 @@ class Sccp extends \FreePBX\modules\Core\Driver {
|
||||||
unset($raw_settings, $siteDefaults, $sccpDefaults);
|
unset($raw_settings, $siteDefaults, $sccpDefaults);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function __destruct() {
|
||||||
|
if (isset($this->delId)) {
|
||||||
|
if (isset($this->cachedDeleteStatement[$this->delId])) {
|
||||||
|
$this->cachedDeleteStatement[$this->delId]->execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function getInfo() {
|
public function getInfo() {
|
||||||
return array(
|
return array(
|
||||||
"rawName" => "sccp",
|
"rawName" => "sccp",
|
||||||
|
@ -110,6 +119,12 @@ class Sccp extends \FreePBX\modules\Core\Driver {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addDevice($id, $settings) {
|
public function addDevice($id, $settings) {
|
||||||
|
// If editing, have first passed by delDevice, so have cached PDO statement
|
||||||
|
// to remove this device from sccpbuttonconfig. As this is an edit, clear that statement.
|
||||||
|
if (isset($this->cachedDeleteStatement[$id])) {
|
||||||
|
unset($this->cachedDeleteStatement[$id]);
|
||||||
|
}
|
||||||
|
|
||||||
// This is actually save line and is used by add and edit.
|
// This is actually save line and is used by add and edit.
|
||||||
$add_fld = array ("name"=>'label',"outboundcid"=>'cid_num',"langcode"=>'language',"extdisplay"=>'description','devinfo_mailbox'=>'mailbox');
|
$add_fld = array ("name"=>'label',"outboundcid"=>'cid_num',"langcode"=>'language',"extdisplay"=>'description','devinfo_mailbox'=>'mailbox');
|
||||||
$settings['cid_num']['value'] = '';
|
$settings['cid_num']['value'] = '';
|
||||||
|
@ -184,17 +199,18 @@ class Sccp extends \FreePBX\modules\Core\Driver {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delDevice($id) {
|
public function delDevice($id) {
|
||||||
//Required by FreePBX.
|
/*Required by FreePBX.
|
||||||
// Delete associated default line buttons or will leave orphans
|
FreePbx edit is a delete followed by an add. Do not want to delete the
|
||||||
foreach (array($id) as $openId) {
|
sccpbuttonconfig if we are editing, so store the statement, and execute via the destructor
|
||||||
$sth = $this->database->prepare("DELETE FROM sccpbuttonconfig WHERE name LIKE :openID AND buttontype = 'line'");
|
if no add has followed
|
||||||
$openId = "{$openId}%";
|
*/
|
||||||
$sth->bindParam(':openID', $openId);
|
// Delete associated default line buttons or will leave orphans. Cache this statement
|
||||||
$sth->execute();
|
// execution is in the destructor
|
||||||
}
|
$this->cachedDeleteStatement[$id] = $this->database->prepare("DELETE FROM sccpbuttonconfig WHERE name LIKE '${id}%' AND buttontype = 'line'");
|
||||||
|
$this->delId = $id;
|
||||||
$sth = $this->database->prepare("DELETE FROM sccpline WHERE name = ?");
|
// Delete the line as requested - if edit will add again in addDevice
|
||||||
$sth->execute(array($id));
|
$sth = $this->database->prepare("DELETE FROM sccpline WHERE name = ${id}");
|
||||||
|
$sth->execute();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -429,7 +445,6 @@ class Sccp extends \FreePBX\modules\Core\Driver {
|
||||||
// Disable and hide list elements if there are no valid values
|
// Disable and hide list elements if there are no valid values
|
||||||
$thisHelp = (string)$child->help . ". <br>Known sccp named groups are: " . $select;
|
$thisHelp = (string)$child->help . ". <br>Known sccp named groups are: " . $select;
|
||||||
//Need element (array)select in array below to have list.
|
//Need element (array)select in array below to have list.
|
||||||
dbug($setting[$elementID]);
|
|
||||||
$tmparr[(string)$child->name] = array('prompttext' => _((string)$child->label),
|
$tmparr[(string)$child->name] = array('prompttext' => _((string)$child->label),
|
||||||
'value' => $setting[$elementID],
|
'value' => $setting[$elementID],
|
||||||
'tt' => $thisHelp,
|
'tt' => $thisHelp,
|
||||||
|
|
Loading…
Reference in a new issue