]> git.sur5r.net Git - contagged/commitdiff
Store tags in Thunderbird custom fields
authorAndreas Gohr <gohr@cosmocode.de>
Wed, 5 Sep 2007 11:02:24 +0000 (13:02 +0200)
committerAndreas Gohr <gohr@cosmocode.de>
Wed, 5 Sep 2007 11:02:24 +0000 (13:02 +0200)
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
doc/slapd.example
entry.php
inc/config.php
inc/functions.php

index 99280449ab57785b01efb439f63050590acff427..416d0c9fc404f9083419f0f95d2f53e9a79e0508 100644 (file)
@@ -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 )
             )
+
+
index cd7643ab92abf5307fa24101f8d29f2c294b412e..6545fffe4593a42ca7c225c56d346b7116466e4e 100644 (file)
@@ -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 *
index 19b1777367433b3cb25ae927e0d504f6235b90dd..b79bc69680ae49bc1ed2ad62b4e66b856eac25e5 100644 (file)
--- a/entry.php
+++ b/entry.php
@@ -173,6 +173,27 @@ print '</pre>';
         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;
   }
 }
index 5f8aaf4bf8546594bf7b9cb4549ddc08f9223fb3..fa8ff428f7b96f206538daa404b3821272ff836b 100644 (file)
   // 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';
index f3b2ac05fac2660d67762f46e44793d5ea92059c..bb24f23691114a22b7e5ff30d0729e96cb508ef1 100644 (file)
@@ -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;