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)
This commit is contained in:
ijaron
2024-11-09 19:45:30 -06:00
committed by GitHub
parent 8f8caaede7
commit 06a6646acb

View File

@@ -1,54 +1,199 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="UTF-8"?>
<AddressBook> <AddressBook>
<version>1</version>
{$contact_types = []}
{$id = 2}
{foreach $contacts as $contact} {foreach $contacts as $contact}
{if $contact.contact_type == "group"} {if isset($contact['contact_type'])}
<pbgroup> {$contact_type = ucfirst($contact['contact_type'])}
<id>{$contact.id}</id> {if !isset($contact_types[$contact_type])}
<name>{$contact.group_description}</name> {$contact_types[$contact_type] = $id++}
<ringtones/> {/if}
</pbgroup> {/if}
{/if}
{/foreach} {/foreach}
{$i=0}
{foreach $contacts as $contact} <pbgroup>
{if $contact.contact_name_given != "" && $contact.contact_type == "contact"} <id>1</id>
<Contact> <name>Extensions</name>
<FirstName>{$contact.contact_name_given}</FirstName> <ringtones>system</ringtones>
<LastName>{$contact.contact_name_family}</LastName> </pbgroup>
<Primary>0</Primary>
<Frequent>0</Frequent> {foreach $contact_types as $type => $id }
{if $contact.contact_title != "" } <pbgroup>
<JobTitle>{$contact.contact_title}</JobTitle> <id>{$id}</id>
{/if} <name>{$type}</name>
<Phone type="Work"> <ringtones>default ringtone</ringtones>
<phonenumber>{$contact.contact_work}</phonenumber> </pbgroup>
<accountindex>1</accountindex> {/foreach}
</Phone>
{if $contact.contact_home != "" } {$grouped = []}
<Phone type="Home">
<phonenumber>{$contact.contact_home}</phonenumber> {foreach $contacts as $item}
<accountindex>1</accountindex> {$uuid = $item['contact_uuid']}
</Phone> {if (!isset($grouped[$uuid]))}
{/if} {$grouped[$uuid] = $item}
{if $contact.contact_cell != "" } {else}
<Phone type="Cell"> {$grouped[$uuid]['numbers'] = array_merge($grouped[$uuid]['numbers'], $item['numbers'])}
<phonenumber>{$contact.contact_cell}</phonenumber> {/if}
<accountindex>1</accountindex>
</Phone>
{/if}
{if false}
{if $contact.contact_role != "" }
<Department>{$contact.contact_role}</Department>
{/if}
{if $contact.contact_organization != "" }
<Company>{$contact.contact_organization}</Company>
{/if}
{/if}
{foreach $contact.groups as $group}
<Group>{$group}</Group>
{/foreach}
</Contact>
{/if}
{/foreach} {/foreach}
{$grouped = array_values($grouped)}
{$start_id=0}
{foreach $grouped as $row}
{if $row.category == "users"}
<Contact>
<id>{$start_id++}</id>
{if $row.contact_name_given != ""}
{if $row.contact_organization != ""}
<FirstName>{$row.contact_name_given}</FirstName>
<LastName>{$row.contact_name_family}</LastName>
<Company>{$row.contact_organization}</Company>
{else}
<FirstName>{$row.contact_name_given}</FirstName>
<LastName>{$row.contact_name_family}</LastName>
{/if}
{elseif $row.contact_name_family != ""}
<LastName>{$row.contact_name_family}</LastName>
{elseif $row.contact_organization != ""}
<FirstName>{$row.contact_organization}</FirstName>
{else}
<FirstName>{$row.effective_caller_id_name}</FirstName>
{/if}
<JobTitle></JobTitle>
<Frequent>0</Frequent>
{$i=0}
{foreach $row.numbers as $number}
{if $number.phone_primary == 1}
<Primary>{$i}</Primary>
{/if}
<!--{$i++}-->
{if $number.phone_number != ""}
{if $number.phone_label == "work"}
<Phone type="Work">
<phonenumber>{$number.phone_number}</phonenumber>
<accountindex>0</accountindex>
</Phone>
{elseif $number.phone_label == "home"}
<Phone type="Home">
<phonenumber>{$number.phone_number}</phonenumber>
<accountindex>0</accountindex>
</Phone>
{elseif $number.phone_label == "mobile"}
<Phone type="Cell">
<phonenumber>{$number.phone_number}</phonenumber>
<accountindex>0</accountindex>
</Phone>
{else}
<Phone type="Other">
<phonenumber>{$number.phone_number}</phonenumber>
<accountindex>0</accountindex>
</Phone>
{/if}
{/if}
{/foreach}
<Group>0</Group>
<Department></Department>
<Job></Job>
<Company></Company>
</Contact>
{elseif $row.category == "groups"}
<Contact>
<id>{$start_id++}</id>
{if $row.contact_name_given != ""}
{if $row.contact_organization != ""}
<FirstName>{$row.contact_name_given}</FirstName>
<LastName>{$row.contact_name_family}</LastName>
<Company>{$row.contact_organization}</Company>
{else}
<FirstName>{$row.contact_name_given}</FirstName>
<LastName>{$row.contact_name_family}</LastName>
{/if}
{elseif $row.contact_name_family != ""}
<LastName>{$row.contact_name_family}</LastName>
{elseif $row.contact_organization != ""}
<FirstName>{$row.contact_organization}</FirstName>
{else}
<FirstName>{$row.effective_caller_id_name}</FirstName>
{/if}
<JobTitle></JobTitle>
<Frequent>0</Frequent>
{$i=0}
{foreach $row.numbers as $number}
{if $number.phone_primary == 1}
<Primary>{$i}</Primary>
<!--{$i++}-->
{/if}
{if $number.phone_number != ""}
{if $number.phone_label == "work"}
<Phone type="Work">
<phonenumber>{$number.phone_number}</phonenumber>
<accountindex>0</accountindex>
</Phone>
{elseif $number.phone_label == "home"}
<Phone type="Home">
<phonenumber>{$number.phone_number}</phonenumber>
<accountindex>0</accountindex>
</Phone>
{elseif $number.phone_label == "mobile"}
<Phone type="Cell">
<phonenumber>{$number.phone_number}</phonenumber>
<accountindex>0</accountindex>
</Phone>
{else}
<Phone type="Other">
<phonenumber>{$number.phone_number}</phonenumber>
<accountindex>0</accountindex>
</Phone>
{/if}
{/if}
{/foreach}
{if $row.contact_type != ""}
<Group>{$contact_types[ucfirst($row.contact_type)]}</Group>
{/if}
<Department></Department>
<Job></Job>
<Company></Company>
</Contact>
{elseif $row.category == "extensions"}
<Contact>
<id>{$start_id++}</id>
{if $row.contact_name_given != ""}
{if $row.contact_organization != ""}
<FirstName>{$row.contact_name_given} {$row.contact_name_family}</FirstName>
<FirstName>{$row.contact_name_given} {$row.contact_name_family}</FirstName>
<Company>{$row.contact_organization}</Company>
{else}
<FirstName>{$row.contact_name_given}</FirstName>
<LastName>{$row.contact_name_family}</LastName>
{/if}
{else}
<FirstName>{$row.effective_caller_id_name}</FirstName>
{/if}
<JobTitle></JobTitle>
<Frequent>0</Frequent>
{if $row.phone_number != ""}
<Phone type="Work">
<phonenumber>{$row.phone_number}</phonenumber>
<accountindex>0</accountindex>
</Phone>
{else}
<Phone type="Work">
<phonenumber>{$row.phone_extension}</phonenumber>
<accountindex>0</accountindex>
</Phone>
{/if}
<Group>1</Group>
<Primary>0</Primary>
<Department></Department>
<Job></Job>
<Company></Company>
</Contact>
{/if}
{/foreach}
</AddressBook> </AddressBook>