Yealink directory listing for extensions, groups, users contacts (#1588)

* Fix Yealink provisioning for contacts/groups

Fix the Yealink provision templates to allow for directory_extensions,
groups and users.

* Fix group_uuid and user_uuid messup

* Yealink directory and provisioning changes

Includes the changes from PR 1582 with some fixes to the SQL.

Also merged all the directory_* options into ONE directory.xml

Will need to call the it with any of these:

http://mydomain/app/provision/?file=directory.xml&contacts=groups

http://mydomain/app/provision/?file=directory.xml&contacts=users

http://mydomain/app/provision/?file=directory.xml&contacts=extensions

http://mydomain/app/provision/?file=directory.xml&contacts=all
This commit is contained in:
Chris Black
2016-05-12 10:22:40 -07:00
committed by FusionPBX
parent 8e01682c3c
commit 7b99a14f67
14 changed files with 465 additions and 173 deletions

View File

@@ -76,13 +76,13 @@ else {
$sql .= "and ( \n"; //only contacts assigned to current user's group(s) and those not assigned to any group
$sql .= " contact_uuid in ( \n";
$sql .= " select contact_uuid from v_contact_groups ";
$sql .= " where group_uuid in ('".implode("','", $user_group_uuids)."') ";
$sql .= " where group_uuid in ('".implode("','", array_filter($user_group_uuids))."') ";
$sql .= " and domain_uuid = '".$_SESSION['domain_uuid']."' ";
$sql .= " ) \n";
$sql .= " or \n";
$sql .= " contact_uuid not in ( \n";
$sql .= " select contact_uuid from v_contact_groups ";
$sql .= " where user_uuid = '".$_SESSION['user_uuid']."' ";
$sql .= " where group_uuid = '".$_SESSION['group_uuid']."' ";
$sql .= " and domain_uuid = '".$_SESSION['domain_uuid']."' ";
$sql .= " ) \n";
$sql .= ") \n";
@@ -105,7 +105,7 @@ else {
$sql .= "and ( \n"; //only contacts assigned to current user's group(s) and those not assigned to any group
$sql .= " contact_uuid in ( \n";
$sql .= " select contact_uuid from v_contact_groups ";
$sql .= " where group_uuid in ('".implode("','", $user_group_uuids)."') ";
$sql .= " where group_uuid in ('".implode("','", array_filter($user_group_uuids))."') ";
$sql .= " and domain_uuid = '".$_SESSION['domain_uuid']."' ";
$sql .= " ) \n";
$sql .= " or contact_uuid in ( \n";

View File

@@ -164,6 +164,106 @@ include "root.php";
}
}
private function contact_append(&$contacts, &$line, $domain_uuid, $user_uuid, $is_group){
$sql = "select c.contact_uuid, c.contact_organization, c.contact_name_given, c.contact_name_family, ";
$sql .= "c.contact_type, c.contact_category, p.phone_label,";
$sql .= "p.phone_number, p.phone_extension, p.phone_primary ";
$sql .= "from v_contacts as c, v_contact_phones as p ";
$sql .= "where c.contact_uuid = p.contact_uuid ";
$sql .= "and p.phone_type_voice = '1' ";
$sql .= "and c.domain_uuid = '$domain_uuid' ";
if ($is_group) {
$sql .= "and c.contact_uuid in ( ";
$sql .= " select contact_uuid from v_contact_groups ";
$sql .= " where group_uuid in ( ";
$sql .= " select group_uuid from v_group_users ";
$sql .= " where user_uuid = '$user_uuid' ";
$sql .= " and domain_uuid = '$domain_uuid' ";
$sql .= " )) ";
}
else {
$sql .= "and c.contact_uuid in ( ";
$sql .= " select contact_uuid from v_contact_users ";
$sql .= " where user_uuid = '$user_uuid' ";
$sql .= " and domain_uuid = '$domain_uuid' ";
$sql .= ") ";
}
$prep_statement = $this->db->prepare(check_sql($sql));
$prep_statement->execute();
$user_contacts = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset($prep_statement, $sql);
$temp_contacts = array();
foreach ($user_contacts as &$row) {
$uuid = $row['contact_uuid'];
$phone_label = strtolower($row['phone_label']);
$contact_category = strtolower($row['contact_category']);
if(isset($contacts[$uuid])){
continue;
}
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'];
if (($row['phone_primary'] == '1') || (!isset($contact['phone_number']))) {
$contact['phone_label'] = $phone_label;
$contact['phone_number'] = $row['phone_number'];
$contact['phone_extension'] = $row['phone_extension'];
}
$numbers[] = array(
line_number => $line['line_number'],
phone_label => $phone_label,
phone_number => $row['phone_number'],
phone_extension => $row['phone_extension'],
phone_primary => $row['phone_primary'],
);
$contact['phone_number_' . $phone_label] = $row['phone_number'];
unset($contact, $numbers, $uuid, $phone_label);
}
foreach($temp_contacts as $contact_uuid=>&$contact){
$contacts[$contact_uuid] = $contact;
}
unset($temp_contacts);
}
private function user_uuid_for_line(&$line, $domain_uuid){
$sql = "select user_uuid from v_extension_users ";
$sql .= "where extension_uuid in ( ";
$sql .= " select extension_uuid from v_extensions ";
$sql .= " where (extension = '".$line["user_id"]."' or number_alias = '".$line["user_id"]."') ";
$sql .= " and domain_uuid = '$domain_uuid' ";
$sql .= ") ";
$sql .= "and domain_uuid = '$domain_uuid' ";
$prep_statement = $this->db->prepare(check_sql($sql));
$prep_statement->execute();
$extension_users = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset($prep_statement, $sql);
foreach ($extension_users as &$row) {
return $row["user_uuid"];
}
return false;
}
public function render() {
//debug
@@ -499,99 +599,19 @@ include "root.php";
//get the list of contact directly assigned to the user
//get the user_uuid to find the contacts assigned to the user and the groups the user is a member of.
if (strlen($device_uuid) > 0 and strlen($domain_uuid) > 0) {
foreach ($device_lines as &$line) {
//get the user_uuid assigned to the extension_uuid
if ($_SESSION['provision']['contact_users']['boolean'] == "true" || $_SESSION['provision']['contact_groups']['boolean'] == "true") {
$sql = "select user_uuid from v_extension_users ";
$sql .= "where extension_uuid in ( ";
$sql .= " select extension_uuid from v_extensions ";
$sql .= " where (extension = '".$line["user_id"]."' or number_alias = '".$line["user_id"]."') ";
$sql .= " and domain_uuid = '$domain_uuid' ";
$sql .= ") ";
$sql .= "and domain_uuid = '$domain_uuid' ";
$prep_statement = $this->db->prepare(check_sql($sql));
$prep_statement->execute();
$extension_users = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset($prep_statement);
foreach ($extension_users as &$row) {
$user_uuid = $row["user_uuid"];
}
}
if ($_SESSION['provision']['contact_users']['boolean'] == "true" || $_SESSION['provision']['contact_groups']['boolean'] == "true") {
foreach ($device_lines as &$line) {
$user_uuid = $this->user_uuid_for_line($line, $domain_uuid);
if(!$user_uuid) continue;
//get the contacts assigned to the groups and add to the contacts array
if ($_SESSION['provision']['contact_groups']['boolean'] == "true") {
$sql = "select c.contact_uuid, c.contact_organization, c.contact_name_given, c.contact_name_family, ";
$sql .= "c.contact_type, c.contact_category, p.phone_label,";
$sql .= "p.phone_number, p.phone_extension ";
$sql .= "from v_contacts as c, v_contact_phones as p ";
$sql .= "where c.contact_uuid in ( ";
$sql .= " select contact_uuid from v_contact_groups ";
$sql .= " where group_uuid in (' ";
$sql .= " select group_uuid from v_group_users ";
$sql .= " where user_uuid = '".$user_uuid."' ";
$sql .= " and domain_uuid = '$domain_uuid' ";
$sql .= " ) ";
$sql .= "and domain_uuid = '$domain_uuid' ";
$sql .= ") ";
//echo $sql."\n";
$prep_statement = $this->db->prepare(check_sql($sql));
$prep_statement->execute();
$contact_groups = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset($prep_statement);
foreach ($contact_groups as $row) {
//get the contact_uuid
$uuid = $row['contact_uuid'];
//add the contacts to the contact array
if (!$this->contact_exists($contacts, $uuid)) {
$contacts[$uuid]['category'] = 'groups';
$contacts[$uuid]['contact_uuid'] = $row['contact_uuid'];
$contacts[$uuid]['contact_type'] = $row['contact_type'];
$contacts[$uuid]['contact_category'] = $row['contact_category'];
$contacts[$uuid]['contact_organization'] = $row['contact_organization'];
$contacts[$uuid]['contact_name_given'] = $row['contact_name_given'];
$contacts[$uuid]['contact_name_family'] = $row['contact_name_family'];
$contacts[$uuid]['phone_label'] = $row['phone_label'];
$contacts[$uuid]['phone_number'] = $row['phone_number'];
$contacts[$uuid]['phone_extension'] = $row['phone_extension'];
}
//get the contacts assigned to the groups and add to the contacts array
if ($_SESSION['provision']['contact_groups']['boolean'] == "true") {
$this->contact_append($contacts, $line, $domain_uuid, $user_uuid, true);
}
}
//get the contacts assigned to the user and add to the contacts array
if ($_SESSION['provision']['contact_users']['boolean'] == "true") {
$sql = "select c.contact_uuid, c.contact_organization, c.contact_name_given, c.contact_name_family, ";
$sql .= "c.contact_type, c.contact_category, p.phone_label,";
$sql .= "p.phone_number, p.phone_extension ";
$sql .= "from v_contacts as c, v_contact_phones as p ";
$sql .= "where c.contact_uuid in ( ";
$sql .= " select contact_uuid from v_contact_users ";
$sql .= " where user_uuid = '".$user_uuid."' ";
$sql .= " and domain_uuid = '$domain_uuid' ";
$sql .= ") ";
$sql .= "and c.contact_uuid = p.contact_uuid ";
$sql .= "and p.phone_type_voice = '1' ";
$sql .= "and c.domain_uuid = '$domain_uuid' ";
//echo $sql."\n";
$prep_statement = $this->db->prepare(check_sql($sql));
$prep_statement->execute();
$user_contacts = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset($prep_statement);
foreach ($user_contacts as $row) {
//get the contact_uuid
$uuid = $row['contact_uuid'];
//add the contacts to the contact array
if (!$this->contact_exists($contacts, $uuid)) {
$contacts[$uuid]['category'] = 'users';
$contacts[$uuid]['contact_uuid'] = $row['contact_uuid'];
$contacts[$uuid]['contact_type'] = $row['contact_type'];
$contacts[$uuid]['contact_category'] = $row['contact_category'];
$contacts[$uuid]['contact_organization'] = $row['contact_organization'];
$contacts[$uuid]['contact_name_given'] = $row['contact_name_given'];
$contacts[$uuid]['contact_name_family'] = $row['contact_name_family'];
$contacts[$uuid]['phone_label'] = $row['phone_label'];
$contacts[$uuid]['phone_number'] = $row['phone_number'];
$contacts[$uuid]['phone_extension'] = $row['phone_extension'];
}
//get the contacts assigned to the user and add to the contacts array
if ($_SESSION['provision']['contact_users']['boolean'] == "true") {
$this->contact_append($contacts, $line, $domain_uuid, $user_uuid, false);
}
}
}

View File

@@ -0,0 +1,74 @@
<YealinkIPPhoneDirectory>
{foreach $contacts as $row}
{if $smarty.get.contacts == "users" && $row.category == "users"}
<DirectoryEntry>
{if $row.contact_name_given != ""}
<Name>{$row.contact_name_given} {$row.contact_name_family}</Name>
{else}
<Name>{$row.effective_caller_id_name}</Name>
{/if}
{foreach $row.numbers as $number}
{if $number.phone_number != ""}
<Telephone>{$number.phone_number}</Telephone>
{else}
<Telephone>{$number.phone_extension}</Telephone>
{/if}
{/foreach}
</DirectoryEntry>
{elseif $smarty.get.contacts == "groups" && $row.category == "groups"}
<DirectoryEntry>
{if $row.contact_name_given != ""}
<Name>{$row.contact_name_given} {$row.contact_name_family}</Name>
{else}
<Name>{$row.effective_caller_id_name}</Name>
{/if}
{foreach $row.numbers as $number}
{if $number.phone_number != ""}
<Telephone>{$number.phone_number}</Telephone>
{else}
<Telephone>{$number.phone_extension}</Telephone>
{/if}
{/foreach}
</DirectoryEntry>
{elseif $smarty.get.contacts == "extensions" && $row.category == "extensions"}
<DirectoryEntry>
{if $row.contact_name_given != ""}
<Name>{$row.contact_name_given} {$row.contact_name_family}</Name>
{else}
<Name>{$row.effective_caller_id_name}</Name>
{/if}
{if $row.phone_number != ""}
<Telephone>{$row.phone_number}</Telephone>
{else}
<Telephone>{$row.phone_extension}</Telephone>
{/if}
</DirectoryEntry>
{elseif $smarty.get.contacts == "all"}
<DirectoryEntry>
{if $row.contact_name_given != ""}
<Name>{$row.contact_name_given} {$row.contact_name_family}</Name>
{else}
<Name>{$row.effective_caller_id_name}</Name>
{/if}
{if $row.category == "extensions"}
{if $row.phone_number != ""}
<Telephone>{$row.phone_number}</Telephone>
{else}
<Telephone>{$row.phone_extension}</Telephone>
{/if}
{else}
{foreach $row.numbers as $number}
{if $number.phone_number != ""}
<Telephone>{$number.phone_number}</Telephone>
{else}
<Telephone>{$number.phone_extension}</Telephone>
{/if}
{/foreach}
{/if}
</DirectoryEntry>
{/if}
{/foreach}
</YealinkIPPhoneDirectory>

View File

@@ -1,18 +0,0 @@
<YealinkIPPhoneDirectory>
{assign var=x value=1}
{foreach $contacts as $row}
<DirectoryEntry>
{if $row.contact_name_given != ""}
<Name>{$row.contact_name_given} {$row.contact_name_family}</Name>
{else}
<Name>{$row.effective_caller_id_name}</Name>
{/if}
{if $row.number_alias != ""}
<Telephone>{$row.number_alias}</Telephone>
{else}
<Telephone>{$row.phone_extension}</Telephone>
{/if}
</DirectoryEntry>
{assign var=x value=$x+1}
{/foreach}
</YealinkIPPhoneDirectory>

View File

@@ -557,8 +557,20 @@ dialplan.item.1 =
#remote_phonebook.data.X.url =
#remote_phonebook.data.X.name =
remote_phonebook.data.1.url = {$yealink_remote_phone_book_url}
remote_phonebook.data.1.name = Local Extensions
remote_phonebook.data.1.url = {$yealink_remote_phone_book_url_1}
remote_phonebook.data.1.name = {$yealink_remote_phone_book_name_1}
remote_phonebook.data.2.url = {$yealink_remote_phone_book_url_2}
remote_phonebook.data.2.name = {$yealink_remote_phone_book_name_2}
remote_phonebook.data.3.url = {$yealink_remote_phone_book_url_3}
remote_phonebook.data.3.name = {$yealink_remote_phone_book_name_3}
remote_phonebook.data.4.url = {$yealink_remote_phone_book_url_4}
remote_phonebook.data.4.name = {$yealink_remote_phone_book_name_4}
remote_phonebook.data.5.url = {$yealink_remote_phone_book_url_5}
remote_phonebook.data.5.name = {$yealink_remote_phone_book_name_5}
#######################################################################################
## Network Directory ##

View File

@@ -0,0 +1,74 @@
<YealinkIPPhoneDirectory>
{foreach $contacts as $row}
{if $smarty.get.contacts == "users" && $row.category == "users"}
<DirectoryEntry>
{if $row.contact_name_given != ""}
<Name>{$row.contact_name_given} {$row.contact_name_family}</Name>
{else}
<Name>{$row.effective_caller_id_name}</Name>
{/if}
{foreach $row.numbers as $number}
{if $number.phone_number != ""}
<Telephone>{$number.phone_number}</Telephone>
{else}
<Telephone>{$number.phone_extension}</Telephone>
{/if}
{/foreach}
</DirectoryEntry>
{elseif $smarty.get.contacts == "groups" && $row.category == "groups"}
<DirectoryEntry>
{if $row.contact_name_given != ""}
<Name>{$row.contact_name_given} {$row.contact_name_family}</Name>
{else}
<Name>{$row.effective_caller_id_name}</Name>
{/if}
{foreach $row.numbers as $number}
{if $number.phone_number != ""}
<Telephone>{$number.phone_number}</Telephone>
{else}
<Telephone>{$number.phone_extension}</Telephone>
{/if}
{/foreach}
</DirectoryEntry>
{elseif $smarty.get.contacts == "extensions" && $row.category == "extensions"}
<DirectoryEntry>
{if $row.contact_name_given != ""}
<Name>{$row.contact_name_given} {$row.contact_name_family}</Name>
{else}
<Name>{$row.effective_caller_id_name}</Name>
{/if}
{if $row.phone_number != ""}
<Telephone>{$row.phone_number}</Telephone>
{else}
<Telephone>{$row.phone_extension}</Telephone>
{/if}
</DirectoryEntry>
{elseif $smarty.get.contacts == "all"}
<DirectoryEntry>
{if $row.contact_name_given != ""}
<Name>{$row.contact_name_given} {$row.contact_name_family}</Name>
{else}
<Name>{$row.effective_caller_id_name}</Name>
{/if}
{if $row.category == "extensions"}
{if $row.phone_number != ""}
<Telephone>{$row.phone_number}</Telephone>
{else}
<Telephone>{$row.phone_extension}</Telephone>
{/if}
{else}
{foreach $row.numbers as $number}
{if $number.phone_number != ""}
<Telephone>{$number.phone_number}</Telephone>
{else}
<Telephone>{$number.phone_extension}</Telephone>
{/if}
{/foreach}
{/if}
</DirectoryEntry>
{/if}
{/foreach}
</YealinkIPPhoneDirectory>

View File

@@ -1,18 +0,0 @@
<YealinkIPPhoneDirectory>
{assign var=x value=1}
{foreach $contacts as $row}
<DirectoryEntry>
{if $row.contact_name_given != ""}
<Name>{$row.contact_name_given} {$row.contact_name_family}</Name>
{else}
<Name>{$row.effective_caller_id_name}</Name>
{/if}
{if $row.number_alias != ""}
<Telephone>{$row.number_alias}</Telephone>
{else}
<Telephone>{$row.phone_extension}</Telephone>
{/if}
</DirectoryEntry>
{assign var=x value=$x+1}
{/foreach}
</YealinkIPPhoneDirectory>

View File

@@ -547,8 +547,20 @@ dialplan.item.1 =
#remote_phonebook.data.X.url =
#remote_phonebook.data.X.name =
remote_phonebook.data.1.url = {$yealink_remote_phone_book_url}
remote_phonebook.data.1.name = Local Extensions
remote_phonebook.data.1.url = {$yealink_remote_phone_book_url_1}
remote_phonebook.data.1.name = {$yealink_remote_phone_book_name_1}
remote_phonebook.data.2.url = {$yealink_remote_phone_book_url_2}
remote_phonebook.data.2.name = {$yealink_remote_phone_book_name_2}
remote_phonebook.data.3.url = {$yealink_remote_phone_book_url_3}
remote_phonebook.data.3.name = {$yealink_remote_phone_book_name_3}
remote_phonebook.data.4.url = {$yealink_remote_phone_book_url_4}
remote_phonebook.data.4.name = {$yealink_remote_phone_book_name_4}
remote_phonebook.data.5.url = {$yealink_remote_phone_book_url_5}
remote_phonebook.data.5.name = {$yealink_remote_phone_book_name_5}
#######################################################################################
## Network Directory ##

View File

@@ -0,0 +1,74 @@
<YealinkIPPhoneDirectory>
{foreach $contacts as $row}
{if $smarty.get.contacts == "users" && $row.category == "users"}
<DirectoryEntry>
{if $row.contact_name_given != ""}
<Name>{$row.contact_name_given} {$row.contact_name_family}</Name>
{else}
<Name>{$row.effective_caller_id_name}</Name>
{/if}
{foreach $row.numbers as $number}
{if $number.phone_number != ""}
<Telephone>{$number.phone_number}</Telephone>
{else}
<Telephone>{$number.phone_extension}</Telephone>
{/if}
{/foreach}
</DirectoryEntry>
{elseif $smarty.get.contacts == "groups" && $row.category == "groups"}
<DirectoryEntry>
{if $row.contact_name_given != ""}
<Name>{$row.contact_name_given} {$row.contact_name_family}</Name>
{else}
<Name>{$row.effective_caller_id_name}</Name>
{/if}
{foreach $row.numbers as $number}
{if $number.phone_number != ""}
<Telephone>{$number.phone_number}</Telephone>
{else}
<Telephone>{$number.phone_extension}</Telephone>
{/if}
{/foreach}
</DirectoryEntry>
{elseif $smarty.get.contacts == "extensions" && $row.category == "extensions"}
<DirectoryEntry>
{if $row.contact_name_given != ""}
<Name>{$row.contact_name_given} {$row.contact_name_family}</Name>
{else}
<Name>{$row.effective_caller_id_name}</Name>
{/if}
{if $row.phone_number != ""}
<Telephone>{$row.phone_number}</Telephone>
{else}
<Telephone>{$row.phone_extension}</Telephone>
{/if}
</DirectoryEntry>
{elseif $smarty.get.contacts == "all"}
<DirectoryEntry>
{if $row.contact_name_given != ""}
<Name>{$row.contact_name_given} {$row.contact_name_family}</Name>
{else}
<Name>{$row.effective_caller_id_name}</Name>
{/if}
{if $row.category == "extensions"}
{if $row.phone_number != ""}
<Telephone>{$row.phone_number}</Telephone>
{else}
<Telephone>{$row.phone_extension}</Telephone>
{/if}
{else}
{foreach $row.numbers as $number}
{if $number.phone_number != ""}
<Telephone>{$number.phone_number}</Telephone>
{else}
<Telephone>{$number.phone_extension}</Telephone>
{/if}
{/foreach}
{/if}
</DirectoryEntry>
{/if}
{/foreach}
</YealinkIPPhoneDirectory>

View File

@@ -1,18 +0,0 @@
<YealinkIPPhoneDirectory>
{assign var=x value=1}
{foreach $contacts as $row}
<DirectoryEntry>
{if $row.contact_name_given != ""}
<Name>{$row.contact_name_given} {$row.contact_name_family}</Name>
{else}
<Name>{$row.effective_caller_id_name}</Name>
{/if}
{if $row.number_alias != ""}
<Telephone>{$row.number_alias}</Telephone>
{else}
<Telephone>{$row.phone_extension}</Telephone>
{/if}
</DirectoryEntry>
{assign var=x value=$x+1}
{/foreach}
</YealinkIPPhoneDirectory>

View File

@@ -548,8 +548,20 @@ dialplan.item.1 =
#remote_phonebook.data.X.url =
#remote_phonebook.data.X.name =
remote_phonebook.data.1.url = {$yealink_remote_phone_book_url}
remote_phonebook.data.1.name = Local Extensions
remote_phonebook.data.1.url = {$yealink_remote_phone_book_url_1}
remote_phonebook.data.1.name = {$yealink_remote_phone_book_name_1}
remote_phonebook.data.2.url = {$yealink_remote_phone_book_url_2}
remote_phonebook.data.2.name = {$yealink_remote_phone_book_name_2}
remote_phonebook.data.3.url = {$yealink_remote_phone_book_url_3}
remote_phonebook.data.3.name = {$yealink_remote_phone_book_name_3}
remote_phonebook.data.4.url = {$yealink_remote_phone_book_url_4}
remote_phonebook.data.4.name = {$yealink_remote_phone_book_name_4}
remote_phonebook.data.5.url = {$yealink_remote_phone_book_url_5}
remote_phonebook.data.5.name = {$yealink_remote_phone_book_name_5}
#######################################################################################
## Network Directory ##

View File

@@ -0,0 +1,74 @@
<YealinkIPPhoneDirectory>
{foreach $contacts as $row}
{if $smarty.get.contacts == "users" && $row.category == "users"}
<DirectoryEntry>
{if $row.contact_name_given != ""}
<Name>{$row.contact_name_given} {$row.contact_name_family}</Name>
{else}
<Name>{$row.effective_caller_id_name}</Name>
{/if}
{foreach $row.numbers as $number}
{if $number.phone_number != ""}
<Telephone>{$number.phone_number}</Telephone>
{else}
<Telephone>{$number.phone_extension}</Telephone>
{/if}
{/foreach}
</DirectoryEntry>
{elseif $smarty.get.contacts == "groups" && $row.category == "groups"}
<DirectoryEntry>
{if $row.contact_name_given != ""}
<Name>{$row.contact_name_given} {$row.contact_name_family}</Name>
{else}
<Name>{$row.effective_caller_id_name}</Name>
{/if}
{foreach $row.numbers as $number}
{if $number.phone_number != ""}
<Telephone>{$number.phone_number}</Telephone>
{else}
<Telephone>{$number.phone_extension}</Telephone>
{/if}
{/foreach}
</DirectoryEntry>
{elseif $smarty.get.contacts == "extensions" && $row.category == "extensions"}
<DirectoryEntry>
{if $row.contact_name_given != ""}
<Name>{$row.contact_name_given} {$row.contact_name_family}</Name>
{else}
<Name>{$row.effective_caller_id_name}</Name>
{/if}
{if $row.phone_number != ""}
<Telephone>{$row.phone_number}</Telephone>
{else}
<Telephone>{$row.phone_extension}</Telephone>
{/if}
</DirectoryEntry>
{elseif $smarty.get.contacts == "all"}
<DirectoryEntry>
{if $row.contact_name_given != ""}
<Name>{$row.contact_name_given} {$row.contact_name_family}</Name>
{else}
<Name>{$row.effective_caller_id_name}</Name>
{/if}
{if $row.category == "extensions"}
{if $row.phone_number != ""}
<Telephone>{$row.phone_number}</Telephone>
{else}
<Telephone>{$row.phone_extension}</Telephone>
{/if}
{else}
{foreach $row.numbers as $number}
{if $number.phone_number != ""}
<Telephone>{$number.phone_number}</Telephone>
{else}
<Telephone>{$number.phone_extension}</Telephone>
{/if}
{/foreach}
{/if}
</DirectoryEntry>
{/if}
{/foreach}
</YealinkIPPhoneDirectory>

View File

@@ -1,18 +0,0 @@
<YealinkIPPhoneDirectory>
{assign var=x value=1}
{foreach $contacts as $row}
<DirectoryEntry>
{if $row.contact_name_given != ""}
<Name>{$row.contact_name_given} {$row.contact_name_family}</Name>
{else}
<Name>{$row.effective_caller_id_name}</Name>
{/if}
{if $row.number_alias != ""}
<Telephone>{$row.number_alias}</Telephone>
{else}
<Telephone>{$row.phone_extension}</Telephone>
{/if}
</DirectoryEntry>
{assign var=x value=$x+1}
{/foreach}
</YealinkIPPhoneDirectory>

View File

@@ -557,8 +557,20 @@ dialplan.item.1 =
#remote_phonebook.data.X.url =
#remote_phonebook.data.X.name =
remote_phonebook.data.1.url = {$yealink_remote_phone_book_url}
remote_phonebook.data.1.name = Local Extensions
remote_phonebook.data.1.url = {$yealink_remote_phone_book_url_1}
remote_phonebook.data.1.name = {$yealink_remote_phone_book_name_1}
remote_phonebook.data.2.url = {$yealink_remote_phone_book_url_2}
remote_phonebook.data.2.name = {$yealink_remote_phone_book_name_2}
remote_phonebook.data.3.url = {$yealink_remote_phone_book_url_3}
remote_phonebook.data.3.name = {$yealink_remote_phone_book_name_3}
remote_phonebook.data.4.url = {$yealink_remote_phone_book_url_4}
remote_phonebook.data.4.name = {$yealink_remote_phone_book_name_4}
remote_phonebook.data.5.url = {$yealink_remote_phone_book_url_5}
remote_phonebook.data.5.name = {$yealink_remote_phone_book_name_5}
#######################################################################################
## Network Directory ##