FYI FOP2 phonebook on Cisco and Yealink

gpuser

Member
Joined
Aug 19, 2013
Messages
37
Reaction score
12
If you are interested to get fop2 phonebook on your IP phone please read on.......

I have this working on Cisco and Yealink phones, other phones might need a little bit tweaking.

First thing is to have a working fop2 installation and entries in fop2 phonebook.

Use filezilla to access your PIAF machine using SFTP protocol and browse to /var/www/html/fop2

Download vphonebook.php to your local system.

Rename localcopy to vphonebook-mod.php and open in text editor - gedit/notepad++ etc.

Modify this line:
PHP:
echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?><Suggestions>";
To:
PHP:
echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?><CiscoIPPhoneDirectory>";
echo "<Title>Phone Directory</Title>";
echo "<Prompt>Please Select</Prompt>";
Just below after:
PHP:
if(preg_match("/\.tel$/",$texto)) {
  // query_tel($texto);
} else {
    query_phonebook($texto);
}
Add:

PHP:
echo "</CiscoIPPhoneDirectory>";
And modify the function query_phonebook to:

PHP:
function query_phonebook($texto) {
    global $db;
    global $context;
    global $extension;
    $db->consulta("SET NAMES 'UTF8'");
    $res=$db->consulta("SELECT phone1,phone2,CONCAT(firstname,' ',lastname,' (',company,')') AS name FROM visual_phonebook WHERE CONCAT(firstname,' ',lastname,' ',company) LIKE '%%%s%%' AND context='%s' AND (owner='%s' OR (owner<>'%s' AND private='no')) ORDER BY firstname",$texto,$context,$extension,$extension);
    $contador=0;
    if($db->num_rows()>0) {
        while($row=$db->fetch_assoc()) {
            $htmlname = htmlspecialchars($row['name']);
            $htmlname = preg_replace("/\(\)/","",$htmlname);
            $phone1 = preg_replace("/[^0-9]/","", $row['phone1']);
            //$phone2 = preg_replace("/[^0-9]/","", $row['phone2']);
 
            //$htmlphone2 = htmlentities($phone2);
            if($row['phone1']<>"") {
                echo "<DirectoryEntry>";
                echo "<Name>".$htmlname."</Name>";
                echo "<Telephone>".$phone1."</Telephone>";
                echo "</DirectoryEntry>";
           
                $contador++;
            }
            //if($row['phone2']<>"") {
            //    echo "<suggestion id='".$phone2."' info='".$phone2."'>".$htmlname.": $phone2</suggestion>";
            //    $contador++;
            //}
        }
    }
}
Please note that SQL query is modified by adding "ORDER BY firstname" to list entries in alphabetical order.

Now using Filezilla copy vphonebook-mod.php to /var/www/html/fop2

Open a browser and go to http://your_piaf_ip/fop2/vphonebook-mod.php and you should see all your phone entries listed in order.

Final step is to modify your phone provisioning file to point remote phonebook url to

http://your_piaf_ip/fop2/vphonebook-mod.php

This is by no means a great work, just a hack of existing code to suit. All credits go to original fop2 programmers.

Cheers!
 

gpuser

Member
Joined
Aug 19, 2013
Messages
37
Reaction score
12
I have implemented something similar on the Cisco 7900 handsets

Thanks for that lengthy post, in all my googling I somehow managed to miss it!

The handy thing about implementing it that way is it links to the Asteridex database so is easily manageable within the FreePBX gui.

We use fop2 and I've no idea what Asteridex is, I'll take a look later. Every user on the system is able to access fop2 gui which is very well laid out and has a separate page for Visual phonebook including 'click to dial' function which we many times use. Individual users are able to populate the phonebook and they have the option to make some entries private if they choose to. Only public entries are listed in the phone directory. Biggest plus for me is that I don't have to edit/manage the directory.
 

Members online

PIAF 5 - Powered by 3CX

Forum statistics

Threads
22,382
Messages
137,482
Members
14,581
Latest member
alma prado