jbryanffcu
(jbryanffcu)
February 1, 2022, 6:58pm
1
Hello,
I hope you all are doing well! I am currently utilizing a PHP script to dynamically build the phonebook that is used on our phones/endpoints. The link to the script is below. This works very well without issue, but one thing I’m unsure of is the best option to add static entries to this list. For instance, queues and feature codes.
<?php
require_once("/etc/freepbx.conf");
$mysqli = new mysqli($amp_conf['AMPDBHOST'], $amp_conf['AMPDBUSER'], $amp_conf['AMPDBPASS'], $amp_conf['AMPDBNAME']);
function DBQuery($query){
global $mysqli;
if (!$sqlResult = mysqli_query($mysqli, $query)) {
trigger_error('DB query failed: ' . $mysqli->error . "\nquery: " . $query);
return false;
} else {
$all_rows = array();
while ($row = mysqli_fetch_assoc($sqlResult)) {
$all_rows[] = $row;
}
return $all_rows;
}
}
function formatXML($xml){
$dom = new DOMDocument;
This file has been truncated. show original
Thanks!
jbryanffcu
(jbryanffcu)
February 1, 2022, 8:30pm
3
You are correct, this is not an exposed system. So, something like an array_push near line 15? Also, I just thought it would probably be better if we could programmatically pull in queues and just skip the feature codes? Those aren’t entirely necessary.
Thanks!
jbryanffcu
(jbryanffcu)
February 1, 2022, 8:36pm
4
Also, what exactly is it using for the ID parameter in the XML?
jfinstrom
(James Finstrom)
February 1, 2022, 8:42pm
5
function getQueues()
{
$queues = queues_list();
return array_map(function ($q) {
return ['name' => $q[1], 'number' => $q[0]];
}, $queues);
}
will return
Array
(
[0] => Array
(
[name] => Test
[number] => 9100
)
)
jbryanffcu
(jbryanffcu)
February 2, 2022, 3:15pm
6
So, in trying to call queues_list(), I am getting a call to an undefined function.
jfinstrom
(James Finstrom)
February 2, 2022, 6:24pm
7
Assuming you have queues installed and enabled that should be added with
include /etc/freepbx.conf
jbryanffcu
(jbryanffcu)
February 2, 2022, 6:26pm
8
I am currently utilizing the queues module, so I’m assuming it would load the dependencies from that, correct?
Thanks!
jfinstrom
(James Finstrom)
February 2, 2022, 6:32pm
9
Yes, that function is built in
//remove dynamic memebers from astDB
if ($astman) {
$astman->database_deltree('QPENALTY/'.$account);
} else {
fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]);
}
}
//get the existing queue extensions
//
function queues_list($listall=false) {
global $db;
$sql = "SELECT extension, descr,callback_id,use_queue_context FROM queues_config ORDER BY extension";
$results = $db->getAll($sql);
if($db->IsError($results)) {
$results = array();
}
foreach($results as $result){
if ($listall || checkRange($result[0])){
$extens[] = array($result[0],$result[1],$result[2],$result[3]);
You can try adding
FreePBX::Modules()->loadAllFunctionsInc();
Under the include
system
(system)
Closed
March 5, 2022, 6:33pm
10
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.