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>
<version>1</version>
{$contact_types = []}
{$id = 2}
{foreach $contacts as $contact}
{if $contact.contact_type == "group"}
<pbgroup>
<id>{$contact.id}</id>
<name>{$contact.group_description}</name>
<ringtones/>
</pbgroup>
{/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>
<FirstName>{$contact.contact_name_given}</FirstName>
<LastName>{$contact.contact_name_family}</LastName>
<Primary>0</Primary>
<Frequent>0</Frequent>
{if $contact.contact_title != "" }
<JobTitle>{$contact.contact_title}</JobTitle>
{/if}
<Phone type="Work">
<phonenumber>{$contact.contact_work}</phonenumber>
<accountindex>1</accountindex>
</Phone>
{if $contact.contact_home != "" }
<Phone type="Home">
<phonenumber>{$contact.contact_home}</phonenumber>
<accountindex>1</accountindex>
</Phone>
{/if}
{if $contact.contact_cell != "" }
<Phone type="Cell">
<phonenumber>{$contact.contact_cell}</phonenumber>
<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}
<pbgroup>
<id>1</id>
<name>Extensions</name>
<ringtones>system</ringtones>
</pbgroup>
{foreach $contact_types as $type => $id }
<pbgroup>
<id>{$id}</id>
<name>{$type}</name>
<ringtones>default ringtone</ringtones>
</pbgroup>
{/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"}
<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>