Update provision.php

Fix the user assigned contacts for the directory.
This commit is contained in:
FusionPBX 2016-08-23 11:37:51 -06:00 committed by GitHub
parent 06ba800018
commit 76d7044b4f
1 changed files with 21 additions and 35 deletions

View File

@ -197,55 +197,41 @@ include "root.php";
$user_contacts = $prep_statement->fetchAll(PDO::FETCH_NAMED); $user_contacts = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset($prep_statement, $sql); unset($prep_statement, $sql);
$temp_contacts = array();
foreach ($user_contacts as &$row) { foreach ($user_contacts as &$row) {
$uuid = $row['contact_uuid']; $uuid = $row['contact_uuid'];
$phone_label = strtolower($row['phone_label']); $phone_label = strtolower($row['phone_label']);
$contact_category = strtolower($row['contact_category']); $contact_category = strtolower($row['contact_category']);
if(isset($contacts[$uuid])){ $contact = array();
continue; $contacts[] = &$contact;
} $contact['category'] = $is_group ? 'groups' : 'users';
$contact['contact_uuid'] = $row['contact_uuid'];
$contact['contact_type'] = $row['contact_type'];
$contact['contact_category'] = $row['contact_category'];
$contact['contact_organization'] = $row['contact_organization'];
$contact['contact_name_given'] = $row['contact_name_given'];
$contact['contact_name_family'] = $row['contact_name_family'];
$contact['numbers'] = array();
if(!isset($temp_contacts[$uuid])){
$contact = array();
$temp_contacts[$uuid] = &$contact;
$contact['category'] = $is_group ? 'groups' : 'users';
$contact['contact_uuid'] = $row['contact_uuid'];
$contact['contact_type'] = $row['contact_type'];
$contact['contact_category'] = $row['contact_category'];
$contact['contact_organization'] = $row['contact_organization'];
$contact['contact_name_given'] = $row['contact_name_given'];
$contact['contact_name_family'] = $row['contact_name_family'];
$contact['numbers'] = array();
}
$contact = &$temp_contacts[$uuid];
$numbers = &$contact['numbers']; $numbers = &$contact['numbers'];
if (($row['phone_primary'] == '1') || (!isset($contact['phone_number']))) { if (($row['phone_primary'] == '1') || (!isset($contact['phone_number']))) {
$contact['phone_label'] = $phone_label; $contact['phone_label'] = $phone_label;
$contact['phone_number'] = $row['phone_number']; $contact['phone_number'] = $row['phone_number'];
$contact['phone_extension'] = $row['phone_extension']; $contact['phone_extension'] = $row['phone_extension'];
} }
$numbers[] = array( $numbers[] = array(
line_number => $line['line_number'], line_numbe => $line['line_number'],
phone_label => $phone_label, phone_label => $phone_label,
phone_number => $row['phone_number'], phone_number => $row['phone_number'],
phone_extension => $row['phone_extension'], phone_extension => $row['phone_extension'],
phone_primary => $row['phone_primary'], phone_primar => $row['phone_primary'],
); );
$contact['phone_number_' . $phone_label] = $row['phone_number']; $contact['phone_number_' . $phone_label] = $row['phone_number'];
unset($contact, $numbers, $uuid, $phone_label); unset($contact, $numbers, $uuid, $phone_label);
} }
foreach($temp_contacts as $contact_uuid=>&$contact){
$contacts[$contact_uuid] = $contact;
}
unset($temp_contacts);
} }
public function render() { public function render() {
@ -324,7 +310,7 @@ include "root.php";
if ($_SESSION['provision']['debug']['boolean'] == 'true'){ if ($_SESSION['provision']['debug']['boolean'] == 'true'){
echo "<br/>device disabled<br/>"; echo "<br/>device disabled<br/>";
} }
echo "file not found"; echo "327 file not found";
exit; exit;
} }
@ -920,14 +906,14 @@ include "root.php";
$file = "{\$mac}.cfg"; $file = "{\$mac}.cfg";
} }
else { else {
echo "file not found"; echo "923 file not found";
exit; exit;
} }
} }
else { else {
//make sure the file exists //make sure the file exists
if (!file_exists($template_dir."/".$device_template ."/".$file)) { if (!file_exists($template_dir."/".$device_template ."/".$file)) {
echo "file not found"; echo "930 file not found ".$template_dir."/".$device_template ."/".$file;
if ($_SESSION['provision']['debug']['boolean'] == 'true'){ if ($_SESSION['provision']['debug']['boolean'] == 'true'){
echo ":$template_dir/$device_template/$file<br/>"; echo ":$template_dir/$device_template/$file<br/>";
echo "template_dir: $template_dir<br/>"; echo "template_dir: $template_dir<br/>";