Update Sccp.class.php.v433
This function can also be called via FreePbx extensions with an array of ids for deletion. Handle as such
This commit is contained in:
parent
35c1b7c708
commit
bc7360c6ee
|
@ -72,7 +72,7 @@ class Sccp extends \FreePBX\modules\Core\Driver {
|
||||||
);
|
);
|
||||||
|
|
||||||
private $line_defaults = array();
|
private $line_defaults = array();
|
||||||
public $delId = '';
|
public $delId = array();
|
||||||
public $cachedDeleteStatement;
|
public $cachedDeleteStatement;
|
||||||
|
|
||||||
public function __construct($parent_class = null) {
|
public function __construct($parent_class = null) {
|
||||||
|
@ -99,9 +99,9 @@ class Sccp extends \FreePBX\modules\Core\Driver {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __destruct() {
|
public function __destruct() {
|
||||||
if (isset($this->delId)) {
|
foreach ($this->delId as $clearId) {
|
||||||
if (isset($this->cachedDeleteStatement[$this->delId])) {
|
if (isset($this->cachedDeleteStatement[$clearId])) {
|
||||||
$this->cachedDeleteStatement[$this->delId]->execute();
|
$this->cachedDeleteStatement[$clearId]->execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,11 +206,14 @@ class Sccp extends \FreePBX\modules\Core\Driver {
|
||||||
*/
|
*/
|
||||||
// Delete associated default line buttons or will leave orphans. Cache this statement
|
// Delete associated default line buttons or will leave orphans. Cache this statement
|
||||||
// execution is in the destructor
|
// execution is in the destructor
|
||||||
$this->cachedDeleteStatement[$id] = $this->database->prepare("DELETE FROM sccpbuttonconfig WHERE name LIKE '${id}%' AND buttontype = 'line'");
|
//when called from extensions as delete, id can be a list of ids
|
||||||
$this->delId = $id;
|
foreach (array($id) as $clearId) {
|
||||||
// Delete the line as requested - if edit will add again in addDevice
|
$this->cachedDeleteStatement[$clearId] = $this->database->prepare("DELETE FROM sccpbuttonconfig WHERE name LIKE '${clearId}%' AND buttontype = 'line'");
|
||||||
$sth = $this->database->prepare("DELETE FROM sccpline WHERE name = ${id}");
|
$this->delId[] = $clearId;
|
||||||
$sth->execute();
|
// Delete the line as requested - if edit will add again in addDevice
|
||||||
|
$sth = $this->database->prepare("DELETE FROM sccpline WHERE name = ${clearId}");
|
||||||
|
$sth->execute();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue