From c1792e8f272b2fbd5dee54e36b17fb1125031ac0 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 5 Sep 2007 13:02:24 +0200 Subject: [PATCH] Store tags in Thunderbird custom fields This adds a new config option called tbtaghack. When enabled the first four assigned tags will be put into the fields custom1 to custom4 which are read Thunderbird's addressbook. Note those tags are writeonly, if you change a custom filed through other applications, ConTagged will not know about it. Tags are stored in the marker attribute additionally - only those are used inside ConTagged. darcs-hash:20070905110224-6e07b-db9a92cf4e1c32e375b940bee797d127aa0c62a7.gz --- doc/ldapab.schema | 51 ++++++++++++++++++++++++++++++++++++++++++++--- doc/slapd.example | 16 ++++++--------- entry.php | 21 +++++++++++++++++++ inc/config.php | 13 ++++-------- inc/functions.php | 9 +++++++++ 5 files changed, 88 insertions(+), 22 deletions(-) diff --git a/doc/ldapab.schema b/doc/ldapab.schema index 9928044..416d0c9 100644 --- a/doc/ldapab.schema +++ b/doc/ldapab.schema @@ -29,7 +29,7 @@ objectIdentifier LDAPab cosmocodeOID:2.2 attributetype ( 1.3.6.1.4.1.16331.2.2.1.1 NAME 'anniversary' - DESC 'Holds Birthdays etc.' + DESC 'Holds Marriage dates etc.' EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch SUBSTR caseIgnoreSubstringsMatch @@ -37,15 +37,60 @@ attributetype ( 1.3.6.1.4.1.16331.2.2.1.1 NAME 'anniversary' SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.16331.2.2.1.2 NAME 'marker' - DESC 'marking flag' + DESC 'For tagging support' EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} ) +attributetype ( 1.3.6.1.4.1.16331.2.2.1.3 NAME 'birthday' + DESC 'Date of birth' + EQUALITY caseIgnoreMatch + ORDERING caseIgnoreOrderingMatch + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 + SINGLE-VALUE ) + +attributetype ( 1.3.6.1.4.1.16331.2.2.1.51 NAME 'custom1' + DESC 'Thunderbird compatible custom field 1' + EQUALITY caseIgnoreMatch + ORDERING caseIgnoreOrderingMatch + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} + ) + +attributetype ( 1.3.6.1.4.1.16331.2.2.1.52 NAME 'custom2' + DESC 'Thunderbird compatible custom field 2' + EQUALITY caseIgnoreMatch + ORDERING caseIgnoreOrderingMatch + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} + ) + +attributetype ( 1.3.6.1.4.1.16331.2.2.1.53 NAME 'custom3' + DESC 'Thunderbird compatible custom field 3' + EQUALITY caseIgnoreMatch + ORDERING caseIgnoreOrderingMatch + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} + ) + +attributetype ( 1.3.6.1.4.1.16331.2.2.1.54 NAME 'custom4' + DESC 'Thunderbird compatible custom field 4' + EQUALITY caseIgnoreMatch + ORDERING caseIgnoreOrderingMatch + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} + ) + + + + objectclass ( 1.3.6.1.4.1.16331.2.2.2.1 NAME 'contactPerson' DESC 'Contact - Addressbook entry' AUXILIARY - MAY ( anniversary $ marker ) + MAY ( anniversary $ marker $ birthday $ custom1 $ custom2 $ custom3 $ custom4 ) ) + + diff --git a/doc/slapd.example b/doc/slapd.example index cd7643a..6545fff 100644 --- a/doc/slapd.example +++ b/doc/slapd.example @@ -6,11 +6,7 @@ include /etc/ldap/schema/core.schema include /etc/ldap/schema/cosine.schema include /etc/ldap/schema/nis.schema include /etc/ldap/schema/inetorgperson.schema -include /etc/ldap/schema/samba.schema -include /etc/ldap/schema/courierimap.schema -include /etc/ldap/schema/phpgwaccount.schema -include /etc/ldap/schema/phpgwcontact.schema -include /etc/ldap/schema/ldapab.schema +include /etc/ldap/schema/ldapab.schema # Schema check allows for forcing entries to @@ -25,11 +21,11 @@ pidfile /var/run/slapd.pid argsfile /var/run/slapd.args # Where to store the replica logs -replogfile /var/lib/ldap/replog +replogfile /var/lib/ldap/replog # Read slapd.conf(5) for possible values #loglevel 256 -loglevel 0 +loglevel 0 ####################################################################### # ldbm database definitions @@ -87,7 +83,7 @@ access to attribute=ntPassword by * none # private LDAP Addressbook is readable and writable for the owner only -access to dn="(.*,)?ou=contacts,cn=([^,]+),ou=people,(.*)$" +access to dn="(.*,)?ou=contacts,cn=([^,]+),ou=people,(.*)$" by dn="cn=$2,ou=people,$3" write by * none @@ -95,8 +91,8 @@ access to dn="(.*,)?ou=contacts,cn=([^,]+),ou=people,(.*)$" # This entry has to be _before_ any other entry that matches the contact # tree eg. the * entry access to dn.subtree="ou=contacts,o=cosmocode,c=de" - by users write - by * read + by users write + by * read # The admin dn has full write access access to * diff --git a/entry.php b/entry.php index 19b1777..b79bc69 100644 --- a/entry.php +++ b/entry.php @@ -173,6 +173,27 @@ print ''; tpl_ldaperror("mod $key"); } } + + // special tag handling for Thunderbird + if($conf['tbtaghack'] && in_array('contactPerson',$OCLASSES)){ + for($i=1;$i<5;$i++){ + if(empty($entry["custom$i"])){ + // deletion + unset($del); + $del["custom$i"]=array(); + $r = @ldap_mod_replace($LDAP_CON,$dn,$del); + tpl_ldaperror("del custom$i"); + }else{ + // modification + unset($add); + $add["custom$i"]=$entry["custom$i"]; + $r = @ldap_mod_replace($LDAP_CON,$dn,$add); + tpl_ldaperror("mod custom$i"); + } + } + } + + return $dn; } } diff --git a/inc/config.php b/inc/config.php index 5f8aaf4..fa8ff42 100644 --- a/inc/config.php +++ b/inc/config.php @@ -37,18 +37,13 @@ // Should the public address book be viewable by logged in users only? (0|1) $conf['userlogreq'] = 0; - // Should the additional schema ldapab.schema be used? (0|1) - // Note: openxchange and extended are currently exclusive, do not use both at the same time! - $conf['extended'] = 1; - - // Should we use some parts of the openxchange.schema? (0|1) - // Note: openxchange and extended are currently exclusive, do not use both at the same time! - $conf['openxchange'] = 0; - // Should we try to login using the username and password provided by httpd? (0|1) $conf['httpd_auth'] = 0; - // Dateformat for birthdays when using extended schema + // Store the first 4 tags in Thunderbird's custom fields when using ldapab.schema + $conf['tbtaghack'] = 1; + + // Dateformat for birthdays and anniversary // see http://www.php.net/manual/en/function.strftime.php $conf['dateformat'] = '%Y/%m/%d'; #$conf['dateformat'] = '%d.%m.%Y'; diff --git a/inc/functions.php b/inc/functions.php index f3b2ac0..bb24f23 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -234,6 +234,15 @@ function prepare_ldap_entry($in){ } } + // special tag handling for Thunderbird + if($conf['tbtaghack'] && in_array('contactPerson',$OCLASSES)){ + if($in['marker'][0]) $out['custom1'][] = $in['marker'][0]; + if($in['marker'][1]) $out['custom2'][] = $in['marker'][1]; + if($in['marker'][2]) $out['custom3'][] = $in['marker'][2]; + if($in['marker'][3]) $out['custom4'][] = $in['marker'][3]; + } + + // add the Objectclasses $out['objectclass'] = $OCLASSES; -- 2.39.5