From fb6e2d87824b8a8c605585c135b3a154fbd7b684 Mon Sep 17 00:00:00 2001 From: stevenA Date: Sat, 29 Jan 2022 13:38:12 +0100 Subject: [PATCH] Enable named group functionality --- conf/sccpgeneral.xml.v433 | 64 ++++++++++++++-------------- install.php | 4 +- module.xml | 4 +- sccpManClasses/Sccp.class.php.v433 | 22 +++++++--- sccpManClasses/dbinterface.class.php | 10 ++++- 5 files changed, 60 insertions(+), 44 deletions(-) diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index 7cfe35e..b398552 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -2056,6 +2056,24 @@ and open the template in the editor. Base Version before all crash :-) Context: This is the context in which your phones will operate. It should match the context you are using for the rest of your phones (if you have any). The FreePBX default is 'from-internal' + + + namedcallgroup + + Sets the groups this line is a member of. Incoming calls to this line are given these groups as an identifier. This is a comma separated list of group names. + (It is not recommended to use numeric names) + + + + + namedpickupgroup + + This is the list of groups that this line can pickup from. This is a comma separated list of group names + @@ -2064,23 +2082,23 @@ and open the template in the editor. Base Version before all crash :-) sccp-custom - Context where direct pickup search for extensions. if not set current context will be use. + Context where direct pickup searches for extensions. if not set current context will be use. - - - namedcallgroup - - Sets the named caller groups this line is a member of + + directed_pickup + + + + + Enable/disable directed Pickup button (to do directed pickup from a specific extension). - - - namedpickupgroup - - Named PickupGroup - the list is of pickup groups used on the system + + pickup_modeanswer + + off + + + When using directed pickup, if this flag is set to Yes, the call will automatically be answered upon pickup @@ -2099,22 +2117,6 @@ and open the template in the editor. Base Version before all crash :-) Outside dialtone frequency (default 0x22) - - directed_pickup - - - - - Enable/disable Pickup button to do directed pickup from a specific extension. - - - pickup_modeanswer - - off - - - Directed Pickup Mode (Answer): If a call is sent with the "directed pickup" flag, the phone will answer when set to "Yes". - transfer diff --git a/install.php b/install.php index eee43d3..82e5a97 100644 --- a/install.php +++ b/install.php @@ -142,8 +142,8 @@ function Get_DB_config($sccp_compatible) 'directed_pickup' => array('create' => "enum('yes','no') NOT NULL default 'no'", 'modify' => "enum('yes','no')"), 'directed_pickup_context' => array('create' => "VARCHAR(100) NULL DEFAULT NULL"), 'pickup_modeanswer' => array('create' => "enum('yes','no') NOT NULL default 'yes'", 'modify' => "enum('yes','no')"), - 'namedcallgroup' => array('create' => "VARCHAR(100) NULL DEFAULT NULL AFTER `setvar`", 'modify' => "VARCHAR(100)"), - 'namedpickupgroup' => array('create' => "VARCHAR(100) NULL DEFAULT NULL AFTER `namedcallgroup`", 'modify' => "VARCHAR(100)"), + 'namedcallgroup' => array('create' => "VARCHAR(255) NULL DEFAULT NULL AFTER `setvar`", 'modify' => "VARCHAR(100)"), + 'namedpickupgroup' => array('create' => "VARCHAR(255) NULL DEFAULT NULL AFTER `namedcallgroup`", 'modify' => "VARCHAR(100)"), 'adhocNumber' => array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `namedpickupgroup`"), 'meetme' => array('create' => "VARCHAR(5) NULL DEFAULT NULL AFTER `adhocNumber`"), 'context' => array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `description`", 'def_modify' => 'from-internal'), diff --git a/module.xml b/module.xml index a25b9db..da70e33 100644 --- a/module.xml +++ b/module.xml @@ -200,8 +200,8 @@ - - + + diff --git a/sccpManClasses/Sccp.class.php.v433 b/sccpManClasses/Sccp.class.php.v433 index 5550a07..cf2c61c 100644 --- a/sccpManClasses/Sccp.class.php.v433 +++ b/sccpManClasses/Sccp.class.php.v433 @@ -413,21 +413,29 @@ class Sccp extends \FreePBX\modules\Core\Driver { unset($select); break; case 'SLG': + // namedcallgroup and namedpickupgroup. + //$extensionId = $display_info['id']; $elementID = (string)$child->name; - $named_group = \FreePbx::sccp_manager()->dbinterface->getNamedGroup($elementID); - if (!empty($named_group[$elementID])) { + $setting[$elementID] = \FreePbx::sccp_manager()->dbinterface->getLineGroups($elementID, $deviceInfo['id']); + $named_group = \FreePbx::sccp_manager()->dbinterface->getNamedGroup('namedcallgroup'); + if (!empty($named_group['namedcallgroup'])) { + /* This commented out code will display as a list foreach ($named_group[$elementID] as $val) { $select[] = array('value' => $val, 'text' => $val); } + */ + $select = ltrim(implode(',', $named_group['namedcallgroup']), " ,"); } // Disable and hide list elements if there are no valid values + $thisHelp = (string)$child->help . ".
Known sccp named groups are: " . $select; + //Need element (array)select in array below to have list. + dbug($setting[$elementID]); $tmparr[(string)$child->name] = array('prompttext' => _((string)$child->label), - 'value' => $this->line_defaults[(string)$child->name], - 'tt' => (string)$child->help, - 'select' => $select, + 'value' => $setting[$elementID], + 'tt' => $thisHelp, 'level' => 1, - 'disable' => empty($named_group[$elementID][0]), - 'hidden' => empty($named_group[$elementID][0]), + 'disable' => empty($named_group), + 'hidden' => empty($named_group), 'section' => $section, 'category' => $gn_category ); diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php index ef42b59..71a0106 100644 --- a/sccpManClasses/dbinterface.class.php +++ b/sccpManClasses/dbinterface.class.php @@ -435,9 +435,14 @@ class dbinterface return $result; } + public function getLineGroups($element, $id){ + $sth = $this->db->prepare("SELECT {$element} FROM sccpline WHERE name='{$id}'"); + $sth->execute(); + return $sth->fetchAll()[$element]; + } public function getNamedGroup($callGroup) { - $sql = "SELECT {$callGroup} FROM sccpline GROUP BY {$callGroup}"; - $sth = $this->db->prepare($sql); + //$sql = "SELECT {$callGroup} FROM sccpline GROUP BY {$callGroup}"; + $sth = $this->db->prepare("SELECT {$callGroup} FROM sccpline GROUP BY {$callGroup}"); $result = array(); $tech = array(); try { @@ -447,6 +452,7 @@ class dbinterface $tech[$callGroup][] = $val[0]; } } catch(\Exception $e) {} + dbug($tech); return $tech; } }