PHP-Push-2
PHP-Push-2 copied to clipboard
FIX: More categories for synchronisation
Below I include the patch to update ldap.php to sync all (iOS) relevant fields from the LDAP schemata
- Person
- organizationalPerson
- inetOrgPerson
Adding this to ldap.php fills up almost all available iOS fields from a corresponding LDAP entry.
--- ldap.php 2012-06-02 02:09:07.017471276 +0200 +++ ldap.php.ORIG 2012-06-02 01:47:24.981471693 +0200 @@ -212,7 +212,7 @@ case "pager": $contact->pagernumber = $value; break;
-
case "assistantName":
-
@@ -229,8 +229,7 @@ $contact->businesspostalcode = $value; break; case "st":case "secretary": $contact->assistantname = $value; break; //organizationalPerson
-
$contact->businessstate = $value;
-
break;
-
@@ -244,48 +243,11 @@ case "title": $contact->title = $value; break;$contact->businessstate = $value; case "street": $contact->businessstreet = $value; break;
-
case "note":
-
case "description": $contact->body = $value; $contact->bodysize = strlen($value); $contact->bodytruncated = "0"; break;
-
//other
-
case "anniversary":
-
$contact->anniversary = $value;
-
break;
-
case "assistantPhone":
-
$contact->assistnamephonenumber = $value;
-
break;
-
case "birthDate":
-
$contact->birthday = $value;
-
break;
-
case "businessRole":
-
$contact->jobtitle = $value;
-
break;
-
case "carPhone":
-
$contact->carphonenumber = $value;
-
break;
-
case "facsimileTelephoneNumber":
-
$contact->businessfaxnumber = $value;
-
break;
-
case "homeFacsimileTelephoneNumber":
-
$contact->homefaxnumber = $value;
-
break;
-
case "initials":
-
$contact->middlename = $value;
-
break;
-
case "internationaliSDNNumber":
-
$contact->business2phonenumber = $value;
-
break;
-
case "managerName":
-
$contact->managername = $value;
-
break;
-
case "otherPhone":
-
$contact->home2phonenumber = $value;
-
break;
-
case "spouseName":
-
$contact->spouse = $value;
-
break; } } return $contact;
Those fiels are not in one of the following OpenLDAP scheme's Person organizationalPerson inetOrgPerson
They seem to be MS LDAP values, and those are not supported (yet) in our LDAP backend.
You are right, this is based on adding "evolutionPerson" to OpenLDAP and works just fine. Please consider including it in "head", even only optionally. It would be of great value for all iOS users, as this really makes Contacts so much more complete. Thanks for considering.
Will check to implement those mappings (or eventually configurable mappings) when LDAP is working perfectly :)
I have now perfected the mapping: any possible field (photo, 3 emails, 12 phone numbers, phonetic first & last names, birthday, anniversay, assistant, manager, spouse, ...) available on iOS now can be mapped successfully. Since iOS implements a subset of ActiveSync, I suppose that such a more complete mapping is useful for any other client out there. Its a simple fix for ldap.php and the LDAP schema needs to use the object classes top, person, inetOrgPerson, organizationalPerson, and evolutionPerson.
diff --git a/backend/ldap.php b/backend/ldap.php
index 9bdb878..d3253b3 100644
--- a/backend/ldap.php
+++ b/backend/ldap.php
@@ -117,7 +117,8 @@ class BackendLDAP extends BackendDiff {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendLDAP->GetMessageList('%s','%s')", $folderid, $cutoffdate));
$cutoff = date("YmdHis\Z", $cutoffdate);
- $filter = sprintf('(modifyTimestamp>=%s)', $cutoff);
+ // also filter only for persons, so that we don't transmit groups
+ $filter = sprintf('(&(!(objectClass=groupOfNames))(modifyTimestamp>=%s))', $cutoff);
$attributes = array("entryUUID", "modifyTimestamp");
$messages = array();
@@ -195,6 +196,10 @@ class BackendLDAP extends BackendDiff {
break;
case "homePhone":
$contact->homephonenumber = $value;
+ if ($values[$name]["count"] >= 2)
+ {
+ $contact->home2phonenumber = $values[$name][1];
+ }
break;
case "jpegPhoto":
$contact->picture = base64_encode($value);
@@ -222,7 +227,7 @@ class BackendLDAP extends BackendDiff {
case "pager":
$contact->pagernumber = $value;
break;
- case "secretary":
+ case "assistantName":
$contact->assistantname = $value;
break;
//organizationalPerson
@@ -232,9 +237,12 @@ class BackendLDAP extends BackendDiff {
case "ou":
$contact->department = $value;
break;
+/*
+ // does not exist on iPhone, and we use the field for othercountry
case "physicalDeliveryOfficeName":
$contact->officelocation = $value;
break;
+*/
case "postalCode":
$contact->businesspostalcode = $value;
break;
@@ -254,11 +262,113 @@ class BackendLDAP extends BackendDiff {
case "title":
$contact->title = $value;
break;
- case "description":
+ case "note":
$contact->body = $value;
$contact->bodysize = strlen($value);
$contact->bodytruncated = "0";
break;
+ //others added by AJL
+ case "telex":
+ $contact->suffix = $value;
+ break;
+ case "tty":
+ $contact->nickname = $value;
+ break;
+ case "fileAs":
+ $contact->yomifirstname = $value;
+ break;
+ case "category":
+ $contact->yomilastname = $value;
+ break;
+ case "anniversary":
+ $contact->anniversary = $value;
+ break;
+ case "assistantPhone":
+ $contact->assistnamephonenumber = $value;
+ break;
+ case "birthDate":
+ $contact->birthday = $value;
+ break;
+ case "businessRole":
+ $contact->jobtitle = $value;
+ break;
+ case "carPhone":
+ $contact->carphonenumber = $value;
+ break;
+ case "facsimileTelephoneNumber":
+ $contact->businessfaxnumber = $value;
+ break;
+ case "homeFacsimileTelephoneNumber":
+ $contact->homefaxnumber = $value;
+ break;
+ case "initials":
+ $contact->middlename = $value;
+ break;
+/*
+ // already covered above by multifield
+ case "internationaliSDNNumber":
+ $contact->business2phonenumber = $value;
+ break;
+*/
+ case "managerName":
+ $contact->managername = $value;
+ break;
+ case "otherPhone":
+ $contact->home2phonenumber = $value;
+ break;
+ case "spouseName":
+ $contact->spouse = $value;
+ break;
+ case "companyPhone":
+ $contact->companymainphone = $value;
+ break;
+ case "radio":
+ $contact->radiophonenumber = $value;
+ break;
+ case "mailer":
+ $contact->businesscountry = $value;
+ break;
+ case "categories":
+ $contact->imaddress = $value;
+ if ($values[$name]["count"] >= 2)
+ {
+ $contact->imaddress2 = $values[$name][1];
+ }
+ if ($values[$name]["count"] >= 3)
+ {
+ $contact->imaddress3 = $values[$name][2];
+ }
+ break;
+ case "homePostalAddress":
+ $contact->homecity = $value;
+ break;
+ case "postalAddress":
+ $contact->homecountry = $value;
+ break;
+ case "postOfficeBox":
+ $contact->homepostalcode = $value;
+ break;
+ case "roomNumber":
+ $contact->homestate = $value;
+ break;
+ case "registeredAddress":
+ $contact->homestreet = $value;
+ break;
+ case "otherPostalAddress":
+ $contact->othercity = $value;
+ break;
+ case "physicalDeliveryOfficeName":
+ $contact->othercountry = $value;
+ break;
+ case "description":
+ $contact->otherpostalcode = $value;
+ break;
+ case "preferredLanguage":
+ $contact->otherstate = $value;
+ break;
+ case "carLicense":
+ case "carLicense":
+ $contact->otherstreet = $value;
+ break;
}
}
return $contact;
@@ -342,7 +452,13 @@ class BackendLDAP extends BackendDiff {
{
$ldap = array();
//Set the Object Class
- $ldap["objectClass"] = "inetOrgPerson";
+ // for existing records, this causes "ldap_modify(): Modify: Cannot modify object class (2)"
+ //$ldap["objectClass"] = "inetOrgPerson";
+ $ldap['objectclass'][0] = "top";
+ $ldap['objectclass'][1] = "person";
+ $ldap['objectclass'][2] = "inetOrgPerson";
+ $ldap['objectclass'][3] = "organizationalPerson";
+ $ldap['objectclass'][4] = "evolutionPerson";
//Parse Data
if ($message->fileas)
{
@@ -362,8 +478,12 @@ class BackendLDAP extends BackendDiff {
}
if ($message->homephonenumber)
{
- $ldap["homePhone"] = $message->homephonenumber;
+ $ldap["homePhone"][] = $message->homephonenumber;
}
+ if ($message->home2phonenumber)
+ {
+ $ldap["homePhone"][] = $message->home2phonenumber;
+ }
if ($message->picture)
{
$ldap["jpegPhoto"] = base64_decode($message->picture);
@@ -398,7 +518,7 @@ class BackendLDAP extends BackendDiff {
}
if ($message->assistantname)
{
- $ldap["secretary"] = $message->assistantname;
+ $ldap["assistantName"] = $message->assistantname;
}
if ($message->businesscity)
{
@@ -408,10 +528,13 @@ class BackendLDAP extends BackendDiff {
{
$ldap["ou"] = $message->department;
}
+/*
+ // does not exist on iPhone, and we use that field for othercountry
if ($message->officelocation)
{
$ldap["physicalDeliveryOfficeName"] = $message->officelocation;
}
+*/
if ($message->businesspostalcode)
{
$ldap["postalCode"] = $message->businesspostalcode;
@@ -438,8 +561,137 @@ class BackendLDAP extends BackendDiff {
}
if ($message->body)
{
- $ldap["description"] = $message->body;
+ $ldap["note"] = $message->body;
}
+
+ // others added by AJL
+ if ($message->suffix)
+ {
+// ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendLDAP->suffix is set '%s'", $message->suffix));
+ $ldap["telex"] = $message->suffix;
+ }
+ if ($message->nickname)
+ {
+ $ldap["tty"] = $message->nickname;
+ }
+ if ($message->yomifirstname)
+ {
+ $ldap["fileAs"] = $message->yomifirstname;
+ }
+ if ($message->yomilastname)
+ {
+ $ldap["category"] = $message->yomilastname;
+ }
+ if ($message->anniversary)
+ {
+ $ldap["anniversary"] = $message->anniversary;
+ }
+ if ($message->assistnamephonenumber)
+ {
+ $ldap["assistantPhone"] = $message->assistnamephonenumber;
+ }
+ if ($message->birthday)
+ {
+ $ldap["birthDate"] = $message->birthday;
+ }
+ if ($message->jobtitle)
+ {
+ $ldap["businessRole"] = $message->jobtitle;
+ }
+ if ($message->carphonenumber)
+ {
+ $ldap["carPhone"] = $message->carphonenumber;
+ }
+ if ($message->businessfaxnumber)
+ {
+ $ldap["facsimileTelephoneNumber"] = $message->businessfaxnumber;
+ }
+ if ($message->homefaxnumber)
+ {
+ $ldap["homeFacsimileTelephoneNumber"] = $message->homefaxnumber;
+ }
+ if ($message->middlename)
+ {
+ $ldap["initials"] = $message->middlename;
+ }
+ if ($message->managername)
+ {
+ $ldap["managerName"] = $message->managername;
+ }
+ if ($message->home2phonenumber)
+ {
+ $ldap["otherPhone"] = $message->home2phonenumber;
+ }
+ if ($message->spouse)
+ {
+ $ldap["spouseName"] = $message->spouse;
+ }
+ if ($message->imaddress)
+ {
+ $ldap["categories"][] = $message->imaddress;
+ }
+ if ($message->imaddress2)
+ {
+ $ldap["categories"][] = $message->imaddress2;
+ }
+ if ($message->imaddress3)
+ {
+ $ldap["categories"][] = $message->imaddress3;
+ }
+ if ($message->companymainphone)
+ {
+ $ldap["companyPhone"] = $message->companymainphone;
+ }
+ if ($message->radiophonenumber)
+ {
+ $ldap["radio"] = $message->radiophonenumber;
+ }
+ if ($message->businesscountry)
+ {
+ $ldap["mailer"] = $message->businesscountry;
+ }
+ if ($message->homecity)
+ {
+ $ldap["homePostalAddress"] = $message->homecity;
+ }
+ if ($message->homecountry)
+ {
+ $ldap["postalAddress"] = $message->homecountry;
+ }
+ if ($message->homepostalcode)
+ {
+ $ldap["postOfficeBox"] = $message->homepostalcode;
+ }
+ if ($message->homestate)
+ {
+ $ldap["roomNumber"] = $message->homestate;
+ }
+ if ($message->homestreet)
+ {
+ $ldap["registeredAddress"] = $message->homestreet;
+ }
+ if ($message->othercity)
+ {
+ $ldap["otherPostalAddress"] = $message->othercity;
+ }
+ if ($message->othercountry)
+ {
+ $ldap["physicalDeliveryOfficeName"] = $message->othercountry;
+ }
+ if ($message->otherpostalcode)
+ {
+ $ldap["description"] = $message->otherpostalcode;
+ }
+ if ($message->otherstate)
+ {
+ $ldap["preferredLanguage"] = $message->otherstate;
+ }
+ if ($message->otherstreet)
+ {
+ $ldap["carLicense"] = $message->otherstreet;
+ }
+ // end others
+
return $ldap;
}