From bc7360c6eebe0bacb5d08e765bf2886aa45463fc Mon Sep 17 00:00:00 2001 From: stevenA Date: Tue, 1 Feb 2022 10:27:52 +0100 Subject: [PATCH] Update Sccp.class.php.v433 This function can also be called via FreePbx extensions with an array of ids for deletion. Handle as such --- sccpManClasses/Sccp.class.php.v433 | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/sccpManClasses/Sccp.class.php.v433 b/sccpManClasses/Sccp.class.php.v433 index 606b1a9..63e150b 100644 --- a/sccpManClasses/Sccp.class.php.v433 +++ b/sccpManClasses/Sccp.class.php.v433 @@ -72,7 +72,7 @@ class Sccp extends \FreePBX\modules\Core\Driver { ); private $line_defaults = array(); - public $delId = ''; + public $delId = array(); public $cachedDeleteStatement; public function __construct($parent_class = null) { @@ -99,9 +99,9 @@ class Sccp extends \FreePBX\modules\Core\Driver { } public function __destruct() { - if (isset($this->delId)) { - if (isset($this->cachedDeleteStatement[$this->delId])) { - $this->cachedDeleteStatement[$this->delId]->execute(); + foreach ($this->delId as $clearId) { + if (isset($this->cachedDeleteStatement[$clearId])) { + $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 // execution is in the destructor - $this->cachedDeleteStatement[$id] = $this->database->prepare("DELETE FROM sccpbuttonconfig WHERE name LIKE '${id}%' AND buttontype = 'line'"); - $this->delId = $id; - // Delete the line as requested - if edit will add again in addDevice - $sth = $this->database->prepare("DELETE FROM sccpline WHERE name = ${id}"); - $sth->execute(); + //when called from extensions as delete, id can be a list of ids + foreach (array($id) as $clearId) { + $this->cachedDeleteStatement[$clearId] = $this->database->prepare("DELETE FROM sccpbuttonconfig WHERE name LIKE '${clearId}%' AND buttontype = 'line'"); + $this->delId[] = $clearId; + // 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; }