Mobile Phone Company Directory Search
I have just finished an implementation of the GetSearchResults function for the zimbra.php backend.
Please test, update, modify as required, and add to the the official build if you are happy with it.
Look for the GetSearchResults function
Code:
function getSearchResults($searchquery) {
return false;
}
and replace it with the following code
Code:
function GetSearchResults($searchquery, $searchrange) {
debugLog( 'START getSearchResults: [' . $searchquery . ']' );
debugLog( 'START getSearchResults: [' . $searchrange . ']' );
$type = "all"; // Can be set to "account" to not return Locations/Resources
$soap = '<SearchGalRequest xmlns="urn:zimbraAccount" type="'.$type.'">
<name>' . $searchquery . '</name>
</SearchGalRequest>';
$rows = array();
$response = $this->SoapRequest($soap);
if($response) {
$array = $this->MakeXMLTree($response);
// debugLog(print_r($array,true));
$items = $array['soap:Envelope'][0]['soap:Body'][0]['SearchGalResponse'][0]['cn'];
$total = sizeof($items);
debugLog( "Found [" . $total . "] matches" );
for ($i=0;$i<$total;$i++) {
$username = $items[$i]['fileAsStr'];
$attributes = $items[$i]['a'];
$attributeNames = $items[$i]['a_attribute_n'];
$attributeCount = sizeof( $attributes);
// debugLog( "Got [" . $attributeCount . "] attributes" );
$firstname = "";
$lastname = "";
$fullname = "";
$businessphone = "";
$emailaddress = "";
for ($j=0;$j<$attributeCount;$j++) {
switch($attributeNames[$j]) {
case 'firstName':
$firstname = $attributes[$j];
break;
case 'lastName':
$lastname = $attributes[$j];
break;
case 'fullName':
$fullname = $attributes[$j];
break;
case 'email':
$emailaddress = $attributes[$j];
break;
case 'workPhone':
$businessphone = $attributes[$j];
break;
default:
}
}
$rows[] = array( "fullname"=>$fullname,
"businessphone"=>$businessphone,
"username"=>$username,
"emailaddress"=>$emailaddress,
"firstname"=>$firstname,
"lastname"=>$lastname );
}
// debugLog(print_r($rows,true));
}
debugLog('END getSearchResults');
return $rows;
}
I have tested with a WM 6.5 phone and my Nokia E-71.
Note - I have not implemented paging for huge arrays of responses. I do not need them, as our GAL is short.