From 06a6646acb292f05f0f625fb5c4a4ebeb26acd50 Mon Sep 17 00:00:00 2001 From: ijaron Date: Sat, 9 Nov 2024 19:45:30 -0600 Subject: [PATCH] Updated gxv3240/phonebook.xml (#7153) Creates groups based on contact type. groups contacts with more then number into one contact. Sets FirstName to contact_organization if there is no given or family name but contact_organization is set Labels work, home, and mobile numbers with all others set as other Sets Primary to line with phone_primary set (will set Primary for each if multiple lines have phone_primary set even though phone will likely only use one of the tags) --- .../grandstream/gxv3240/phonebook.xml | 243 ++++++++++++++---- 1 file changed, 194 insertions(+), 49 deletions(-) diff --git a/resources/templates/provision/grandstream/gxv3240/phonebook.xml b/resources/templates/provision/grandstream/gxv3240/phonebook.xml index 408336fb53..c59b3c5b05 100644 --- a/resources/templates/provision/grandstream/gxv3240/phonebook.xml +++ b/resources/templates/provision/grandstream/gxv3240/phonebook.xml @@ -1,54 +1,199 @@ - + + -1 + +{$contact_types = []} +{$id = 2} + {foreach $contacts as $contact} -{if $contact.contact_type == "group"} - -{$contact.id} -{$contact.group_description} - - -{/if} + {if isset($contact['contact_type'])} + {$contact_type = ucfirst($contact['contact_type'])} + {if !isset($contact_types[$contact_type])} + {$contact_types[$contact_type] = $id++} + {/if} + {/if} {/foreach} -{$i=0} -{foreach $contacts as $contact} -{if $contact.contact_name_given != "" && $contact.contact_type == "contact"} - -{$contact.contact_name_given} -{$contact.contact_name_family} -0 -0 -{if $contact.contact_title != "" } -{$contact.contact_title} -{/if} - -{$contact.contact_work} -1 - -{if $contact.contact_home != "" } - -{$contact.contact_home} -1 - -{/if} -{if $contact.contact_cell != "" } - -{$contact.contact_cell} -1 - -{/if} -{if false} -{if $contact.contact_role != "" } -{$contact.contact_role} -{/if} -{if $contact.contact_organization != "" } -{$contact.contact_organization} -{/if} -{/if} -{foreach $contact.groups as $group} -{$group} -{/foreach} - -{/if} + + + 1 + Extensions + system + + + {foreach $contact_types as $type => $id } + + {$id} + {$type} + default ringtone + + {/foreach} + +{$grouped = []} + +{foreach $contacts as $item} + {$uuid = $item['contact_uuid']} + {if (!isset($grouped[$uuid]))} + {$grouped[$uuid] = $item} + {else} + {$grouped[$uuid]['numbers'] = array_merge($grouped[$uuid]['numbers'], $item['numbers'])} + {/if} {/foreach} + +{$grouped = array_values($grouped)} + + {$start_id=0} + {foreach $grouped as $row} + {if $row.category == "users"} + + {$start_id++} + {if $row.contact_name_given != ""} + {if $row.contact_organization != ""} + {$row.contact_name_given} + {$row.contact_name_family} + {$row.contact_organization} + {else} + {$row.contact_name_given} + {$row.contact_name_family} + {/if} + {elseif $row.contact_name_family != ""} + {$row.contact_name_family} + {elseif $row.contact_organization != ""} + {$row.contact_organization} + {else} + {$row.effective_caller_id_name} + {/if} + + + 0 + {$i=0} + {foreach $row.numbers as $number} + {if $number.phone_primary == 1} + {$i} + {/if} + + {if $number.phone_number != ""} + {if $number.phone_label == "work"} + + {$number.phone_number} + 0 + + {elseif $number.phone_label == "home"} + + {$number.phone_number} + 0 + + {elseif $number.phone_label == "mobile"} + + {$number.phone_number} + 0 + + {else} + + {$number.phone_number} + 0 + + {/if} + {/if} + {/foreach} + 0 + + + + + {elseif $row.category == "groups"} + + {$start_id++} + {if $row.contact_name_given != ""} + {if $row.contact_organization != ""} + {$row.contact_name_given} + {$row.contact_name_family} + {$row.contact_organization} + {else} + {$row.contact_name_given} + {$row.contact_name_family} + {/if} + {elseif $row.contact_name_family != ""} + {$row.contact_name_family} + {elseif $row.contact_organization != ""} + {$row.contact_organization} + {else} + {$row.effective_caller_id_name} + {/if} + + + 0 + {$i=0} + {foreach $row.numbers as $number} + {if $number.phone_primary == 1} + {$i} + + {/if} + {if $number.phone_number != ""} + {if $number.phone_label == "work"} + + {$number.phone_number} + 0 + + {elseif $number.phone_label == "home"} + + {$number.phone_number} + 0 + + {elseif $number.phone_label == "mobile"} + + {$number.phone_number} + 0 + + {else} + + {$number.phone_number} + 0 + + {/if} + {/if} + {/foreach} + {if $row.contact_type != ""} + {$contact_types[ucfirst($row.contact_type)]} + {/if} + + + + + {elseif $row.category == "extensions"} + + {$start_id++} + {if $row.contact_name_given != ""} + {if $row.contact_organization != ""} + {$row.contact_name_given} {$row.contact_name_family} + {$row.contact_name_given} {$row.contact_name_family} + {$row.contact_organization} + {else} + {$row.contact_name_given} + {$row.contact_name_family} + {/if} + {else} + {$row.effective_caller_id_name} + {/if} + + 0 + {if $row.phone_number != ""} + + {$row.phone_number} + 0 + + {else} + + {$row.phone_extension} + 0 + + {/if} + 1 + 0 + + + + + {/if} + {/foreach} +