From f2d15ebd5e3269f62ba3a418325b64f202aebb06 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Thu, 29 Jul 2021 16:28:05 +0200 Subject: [PATCH] Correct del extension to remove all associated buttons --- assets/js/sccp_manager.js | 2 +- sccpManClasses/Sccp.class.php.v433 | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js index 1fffeb4..264bc9c 100644 --- a/assets/js/sccp_manager.js +++ b/assets/js/sccp_manager.js @@ -213,7 +213,7 @@ $(document).ready(function () { } e.preventDefault(); }); - + // Set focus on the mac entry field. It will not stay but ensures that focusout brings it back $('#sccp_hw_mac').focus(); $('#sccp_hw_mac').focusout(function() { diff --git a/sccpManClasses/Sccp.class.php.v433 b/sccpManClasses/Sccp.class.php.v433 index e31c62e..5e135b7 100644 --- a/sccpManClasses/Sccp.class.php.v433 +++ b/sccpManClasses/Sccp.class.php.v433 @@ -187,8 +187,12 @@ class Sccp extends \FreePBX\modules\Core\Driver { public function delDevice($id) { //Required by FreePBX. // Delete associated default line buttons or will leave orphans - $sth = $this->database->prepare("DELETE FROM sccpbuttonconfig WHERE ref = ? AND instance = 1 AND buttontype = 'line'"); - $sth->execute(array($id)); + foreach (array($id) as $openId) { + $sth = $this->database->prepare("DELETE FROM sccpbuttonconfig WHERE name LIKE :openID AND buttontype = 'line'"); + $openId = "{$openId}%"; + $sth->bindParam(':openID', $openId); + $sth->execute(); + } $sth = $this->database->prepare("DELETE FROM sccpline WHERE name = ?"); $sth->execute(array($id));