Hi,
First post on the forums. I am a self-thought PHP-coder and after some relatively simple websites I'm currently building a intranet-website to interconnect several of the services we're using in our 3-people-office.
This time I'm stuck connecting the asterisk-call-data-records to our ldap-addressbook. I would like to show the name of the person that has called our office. This is my code:
function TBS_tel($BlockName,&$CurrRec,$RecNum){
// 1. Extraheer ID van het toestel waarmee getelefoneerd werd
$CurrRec['src_dev_id'] = substr($CurrRec['channel'],4,3);
$CurrRec['dst_dev_id'] = substr($CurrRec['dstchannel'],4,3);
// 2. Haal de persoonsgegevens uit de LDAP-dir
// Persoonsgegevens zoeken
$notNumbers = array(".", "/", ":", " ", "-");
if ($CurrRec['dcontext'] == "internal") {
// Zoeken op dst:
$tel = str_replace($notNumbers, "", $CurrRec['dst']);
} else {
// Zoeken op src:
$tel = str_replace($notNumbers, "", $CurrRec['src']);
}
[b]$filter = "(|(mobile=$tel)(Phone=$tel)(homePhone=$tel))";[/b]
$attributes = array("sn", "givenName", "dn", "title", "o");
$result = ldap_search(CNX_LDAP, LDAP_DIR_ADR, $filter, $attributes);
$persID = ldap_get_entries(CNX_LDAP, $result);
$CurrRec['pers_id'] = $persID[0]["title"][0];
$CurrRec['pers_id'] .= " ";
$CurrRec['pers_id'] .= $persID[0]["givenname"][0];
$CurrRec['pers_id'] .= " <a href=\"link.php?dn=";
$CurrRec['pers_id'] .= urlencode($persID[0]["dn"]);
$CurrRec['pers_id'] .= "\">";
$CurrRec['pers_id'] .= $persID[0]["sn"][0];
$CurrRec['pers_id'] .= "</a>";
if ($persID[0][2])
{
$CurrRec['pers_id'] .= "<br /><a href=\"link.php?org=";
$CurrRec['pers_id'] .= urlencode($persID[0]["o"][0]);
$CurrRec['pers_id'] .= "\">";
$CurrRec['pers_id'] .= $persID[0]["o"][0]."</a>";
}
ldap_free_result($result);
}
This code is working, but not completely: everytime $tel is equal to a mobile number, then it outputs the requested data. But if we are called by someone with a number that is in 'Phone' or 'homePhone', than the result is blank.
I have tried to ditch the capitals in 'Phone', I have tried to remove the (mobile=$tel)-filter, but to no effect. My guess is that the bug is situated on the bold line of my code. Am I overlooking something silly here?
Thank you in advance...