Contact Manager conversion script for Sangoma D80 phone

(R. Stindl) #1

I don’t know, if EPM already supports the contact manager for Sangoma D-series phones (e.g. D80). If not, here is my updated script for the D80 (should support the D65 too, but I don’t have it here right now for testing).
The script creates a phonebook.xml file the D-series phones can understand.
A detailed description you’ll find here:

updated script:

$mysql_conn = mysql_connect('localhost','freepbxuser','password');
mysql_select_db('asterisk', $mysql_conn);
$query = "SELECT number AS id, title AS prefix, fname AS first_name, \"\" AS second_name, lname AS last_name, \"\" AS suffix, company AS organizaton, \"\" AS job_title, concat_ws('  ', company, address) AS location, concat_ws('  ', type, email, website) AS notes, \"sip\" AS contact_type, number AS account_id
FROM contactmanager_group_entries LEFT JOIN contactmanager_entry_numbers ON = contactmanager_entry_numbers.entryid LEFT JOIN contactmanager_entry_emails ON = contactmanager_entry_emails.entryid LEFT JOIN contactmanager_entry_websites ON = contactmanager_entry_websites.entryid
WHERE type != \"internal\"

$result = mysql_query($query, $mysql_conn);
if (! $result){
echo mysql_error();

$Output = "<?xml version=\"1.0\"?>\n<contacts group_name=\"phonebook-1\" editable=\"0\" id=\"0\">";
while($data = mysql_fetch_assoc($result)){
    $results[] = $data;
    $Output .= "\n <contact\n";
    foreach($data as $key => $value){
    $value = mb_convert_encoding($value, 'UTF-8', 'HTML');
    $Output .= "  $key=\"$value\"\n";
    $Output .= " >\n";
    $Output .= "<actions>\n";
    $Output .= " <action id=\"primary\" dial=\"$value\" label=\"CL_ACTN_SIP\" name=\"CN_ACTN_DIAL\" transfer_name=\"CN_ACTN_TRANSFER\"/>";
    $Output .= "\n";
    $Output .= "</actions>\n";
    $Output .= " </contact>\n";
$Output .= "</contacts>\n";
// echo $Output;