Branch 'kolab-webadmin-2.4' - 9 commits - lib/api lib/Auth lib/Conf.php lib/functions.php lib/kolab_client_api.php lib/kolab_client_task.php lib/kolab_recipient_policy.php

Jeroen van Meeuwen vanmeeuwen at kolabsys.com
Fri May 11 12:54:59 CEST 2012


 lib/Auth/LDAP.php                        |   59 ++++++++++++---------
 lib/Conf.php                             |   84 ++++++++++++++++++++-----------
 lib/api/kolab_api_service_form_value.php |   15 ++++-
 lib/functions.php                        |   11 ++--
 lib/kolab_client_api.php                 |   22 ++++++++
 lib/kolab_client_task.php                |    5 -
 lib/kolab_recipient_policy.php           |   10 +++
 7 files changed, 143 insertions(+), 63 deletions(-)

New commits:
commit 8fc386d9898456d546475730bc07542c8331baa1
Merge: 4ef9546 6b031f8
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Fri May 11 11:54:16 2012 +0100

    Merge branch 'kolab-webadmin-2.4' of ssh://git.kolab.org/git/kolab-wap into kolab-webadmin-2.4



commit 4ef95461d4cb3c4bdf045ab01d9820c039e19060
Author: Aleksander Machniak <machniak at kolabsys.com>
Date:   Fri May 11 11:35:28 2012 +0200

    Support boolean values in config file

diff --git a/lib/Conf.php b/lib/Conf.php
index e8a9a02..e91110c 100644
--- a/lib/Conf.php
+++ b/lib/Conf.php
@@ -30,6 +30,11 @@ class Conf {
 
     const CONFIG_FILE = '/etc/kolab/kolab.conf';
 
+    const STRING = 0;
+    const BOOL   = 1;
+    const INT    = 2;
+    const FLOAT  = 3;
+
     /**
      * This implements the 'singleton' design pattern
      *
@@ -55,9 +60,24 @@ class Conf {
 
     }
 
-    public function get($key1, $key2 = NULL)
+    public function get($key1, $key2 = null, $type = null)
     {
-        return $this->expand($this->get_raw($key1, $key2));
+        $value = $this->expand($this->get_raw($key1, $key2));
+
+        if ($value === null) {
+            return $value;
+        }
+
+        switch ($type) {
+            case self::INT:
+                return intval($value);
+            case self::FLOAT:
+                return floatval($value);
+            case self::BOOL:
+                return (bool) preg_match('/^(true|1|on|enabled|yes)$/i', $value);
+        }
+
+        return (string) $value;
     }
 
     public function get_list($key1, $key2 = NULL)
@@ -131,7 +151,7 @@ class Conf {
 //        error_log("Could not find setting for \$key1: " . $key1 .
 //                " with \$key2: " . $key2);
 
-        return false;
+        return null;
     }
 
     public function expand($str, $custom = FALSE)
diff --git a/lib/kolab_client_api.php b/lib/kolab_client_api.php
index 4159a84..622842a 100644
--- a/lib/kolab_client_api.php
+++ b/lib/kolab_client_api.php
@@ -64,16 +64,16 @@ class kolab_client_api
         // Configure connection options
         $config  = Conf::get_instance();
         $options = array(
-            'ssl_verify_peer',
-            'ssl_verify_host',
-            'ssl_cafile',
-            'ssl_capath',
-            'ssl_local_cert',
-            'ssl_passphrase',
+            'ssl_verify_peer' => Conf::BOOL,
+            'ssl_verify_host' => Conf::BOOL,
+            'ssl_cafile'      => Conf::STRING,
+            'ssl_capath'      => Conf::STRING,
+            'ssl_local_cert'  => Conf::STRING,
+            'ssl_passphrase'  => Conf::STRING,
         );
 
-        foreach ($options as $optname) {
-            if (($optvalue = $config->get('kolab_wap', $optname)) !== null) {
+        foreach ($options as $optname => $opttype) {
+            if (($optvalue = $config->get('kolab_wap', $optname, $opttype)) !== null) {
                 try {
                     $this->request->setConfig($optname, $optvalue);
                 }


commit 92aeb73fb6e7788a0c9219e9a3aa28e0c294163c
Author: Aleksander Machniak <machniak at kolabsys.com>
Date:   Fri May 11 10:05:06 2012 +0200

    Small improvement in errors logging

diff --git a/lib/functions.php b/lib/functions.php
index 441752f..4183454 100644
--- a/lib/functions.php
+++ b/lib/functions.php
@@ -108,16 +108,19 @@ function write_log($name, $line)
     $logfile = $log_dir . '/' . $name;
     $date    = date('d-M-Y H:i:s O');
     $sess_id = session_id();
-    $line    = sprintf("[%s]%s: %s\n", $date, $sess_id ? "($sess_id)" : '', $line);
+    $logline = sprintf("[%s]%s: %s\n", $date, $sess_id ? "($sess_id)" : '', $line);
 
     if ($fp = @fopen($logfile, 'a')) {
-        fwrite($fp, $line);
+        fwrite($fp, $logline);
         fflush($fp);
         fclose($fp);
-        return true;
+        return;
     }
 
-    return false;
+    if ($name == 'errors') {
+        // send error to PHPs error handler if write to file didn't succeed
+        trigger_error($line, E_USER_ERROR);
+    }
 }
 
 function timer($time = null, $label = '')
diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php
index 380e590..4bcc56b 100644
--- a/lib/kolab_client_task.php
+++ b/lib/kolab_client_task.php
@@ -328,10 +328,7 @@ class kolab_client_task
             $msg . (isset($args['file']) ? sprintf(' in %s on line %d', $args['file'], $args['line']) : ''),
             $_SERVER['REQUEST_METHOD']);
 
-        if (!write_log('errors', $log_line)) {
-            // send error to PHPs error handler if write_log() didn't succeed
-            trigger_error($msg, E_USER_ERROR);
-        }
+        write_log('errors', $log_line);
 
         if (!$output) {
             return;


commit 6beb449f9b160725f3b7c2b36c54c331bc73bb3f
Author: Aleksander Machniak <machniak at kolabsys.com>
Date:   Fri May 11 09:58:47 2012 +0200

    Support SSL connection configuration of HTTP_Request2 via kolab.conf (#751)

diff --git a/lib/kolab_client_api.php b/lib/kolab_client_api.php
index b8d101a..4159a84 100644
--- a/lib/kolab_client_api.php
+++ b/lib/kolab_client_api.php
@@ -60,6 +60,28 @@ class kolab_client_api
     public function init()
     {
         $this->request = new HTTP_Request2();
+
+        // Configure connection options
+        $config  = Conf::get_instance();
+        $options = array(
+            'ssl_verify_peer',
+            'ssl_verify_host',
+            'ssl_cafile',
+            'ssl_capath',
+            'ssl_local_cert',
+            'ssl_passphrase',
+        );
+
+        foreach ($options as $optname) {
+            if (($optvalue = $config->get('kolab_wap', $optname)) !== null) {
+                try {
+                    $this->request->setConfig($optname, $optvalue);
+                }
+                catch (Exception $e) {
+                    write_log('errors', $e->getMessage());
+                }
+            }
+        }
     }
 
     /**


commit 8eb656d4e0e534bfc71a2613c18f5b4d8d4d5612
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Tue Apr 24 14:26:07 2012 +0200

    Add more complex but more suitable default SQL file with many more attributes set as optional

diff --git a/doc/kolab_wap-3.0.0.sql b/doc/kolab_wap-3.0.0.sql
index b94eb00..1807032 100644
--- a/doc/kolab_wap-3.0.0.sql
+++ b/doc/kolab_wap-3.0.0.sql
@@ -1,11 +1,11 @@
 -- phpMyAdmin SQL Dump
--- version 3.4.8
+-- version 3.4.9
 -- http://www.phpmyadmin.net
 --
 -- Host: localhost
--- Generation Time: Mar 29, 2012 at 04:24 PM
+-- Generation Time: Apr 24, 2012 at 02:25 PM
 -- Server version: 5.5.13
--- PHP Version: 5.3.8
+-- PHP Version: 5.3.10
 
 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
 SET time_zone = "+00:00";
@@ -34,15 +34,16 @@ CREATE TABLE IF NOT EXISTS `group_types` (
   `attributes` longtext NOT NULL,
   PRIMARY KEY (`id`),
   UNIQUE KEY `name` (`name`)
-) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
+) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
 
 --
 -- Dumping data for table `group_types`
 --
 
 INSERT INTO `group_types` (`id`, `key`, `name`, `description`, `attributes`) VALUES
-(1, 'kolab', 'Kolab Distribution Group', 'A Kolab Distribution Group (with mail address)', 's:187:"{"auto_form_fields":{"mail":{"data":["cn"]}},"fields":{"objectclass":["top","groupofuniquenames","kolabgroupofuniquenames"]},"form_fields":{"cn":[],"uniquemember":{"type":"multiselect"}}}";'),
-(2, 'posix', 'POSIX Group', 'A UNIX POSIX Group', 's:166:"{"auto_form_fields":{"gidnumber":[]},"fields":{"objectclass":["top","groupofuniquenames","posixgroup"]},"form_fields":{"cn":[],"uniquemember":{"type":"multiselect"}}}";');
+(1, 'kolab', 'Kolab Distribution Group', 'A Kolab Distribution Group (with mail address)', '{"auto_form_fields":{"mail":{"data":["cn"]}},"fields":{"objectclass":["top","groupofuniquenames","kolabgroupofuniquenames"]},"form_fields":{"cn":[],"uniquemember":{"type":"list","autocomplete":true,"optional":true}}}'),
+(2, 'posix', '(Pure) POSIX Group', 'A pure UNIX POSIX Group', '{"auto_form_fields":{"gidnumber":[]},"fields":{"objectclass":["top","groupofuniquenames","posixgroup"]},"form_fields":{"cn":[],"uniquemember":{"type":"list","autocomplete":true,"optional":true}}}'),
+(3, 'posix_mail', 'Mail-enabled POSIX Group', 'A Kolab and also UNIX POSIX Group', '{"auto_form_fields":{"gidnumber":[],"mail":{"data":["cn"]}},"fields":{"objectclass":["top","groupofuniquenames","kolabgroupofuniquenames","posixgroup"]},"form_fields":{"cn":[],"mail":{"optional":true},"uniquemember":{"type":"list","autocomplete":true,"optional":true}}}');
 
 -- --------------------------------------------------------
 
@@ -60,7 +61,8 @@ CREATE TABLE IF NOT EXISTS `options` (
 --
 
 INSERT INTO `options` (`attribute`, `option_values`) VALUES
-('preferredlanguage', '["aa_DJ","aa_ER","aa_ET","af_ZA","am_ET","an_ES","ar_AE","ar_BH","ar_DZ","ar_EG","ar_IN","ar_IQ","ar_JO","ar_KW","ar_LB","ar_LY","ar_MA","ar_OM","ar_QA","ar_SA","ar_SD","ar_SY","ar_TN","ar_YE","as_IN","az_AZ","be_BY","bg_BG","bn_BD","bn_IN","bokmal","br_FR","bs_BA","byn_ER","C","ca_AD","ca_ES","ca_FR","ca_IT","catalan","croatian","csb_PL","cs_CZ","cy_GB","czech","da_DK","danish","dansk","de_AT","de_BE","de_CH","de_DE","de_LU","deutsch","dutch","dz_BT","eesti","el_CY","el_GR","en_AU","en_BW","en_CA","en_DK","en_GB","en_HK","en_IE","en_IN","en_NZ","en_PH","en_SG","en_US","en_ZA","en_ZW","es_AR","es_BO","es_CL","es_CO","es_CR","es_DO","es_EC","es_ES","es_GT","es_HN","es_MX","es_NI","es_PA","es_PE","es_PR","es_PY","es_SV","estonian","es_US","es_UY","es_VE","et_EE","eu_ES","fa_IR","fi_FI","finnish","fo_FO","fr_BE","fr_CA","fr_CH","french","fr_FR","fr_LU","fy_NL","ga_IE","galego","galician","gd_GB","german","gez_ER","gez_ET","gl_ES","greek","gu_IN","gv_GB","
 hebrew","he_IL","hi_IN","hr_HR","hrvatski","hsb_DE","hu_HU","hungarian","hy_AM","icelandic","id_ID","is_IS","italian","it_CH","it_IT","iw_IL","ja_JP","japanese","ka_GE","kk_KZ","kl_GL","km_KH","kn_IN","ko_KR","korean","ku_TR","kw_GB","ky_KG","lg_UG","lithuanian","lo_LA","lt_LT","lv_LV","mai_IN","mg_MG","mi_NZ","mk_MK","ml_IN","mn_MN","mr_IN","ms_MY","mt_MT","nb_NO","ne_NP","nl_BE","nl_NL","nn_NO","no_NO","norwegian","nr_ZA","nso_ZA","nynorsk","oc_FR","om_ET","om_KE","or_IN","pa_IN","pa_PK","pl_PL","polish","portuguese","POSIX","pt_BR","pt_PT","romanian","ro_RO","ru_RU","russian","ru_UA","rw_RW","se_NO","sid_ET","si_LK","sk_SK","slovak","slovene","slovenian","sl_SI","so_DJ","so_ET","so_KE","so_SO","spanish","sq_AL","sr_CS","sr_ME","sr_RS","ss_ZA","st_ZA","sv_FI","sv_SE","swedish","ta_IN","te_IN","tg_TJ","thai","th_TH","ti_ER","ti_ET","tig_ER","tl_PH","tn_ZA","tr_CY","tr_TR","ts_ZA","tt_RU","turkish","uk_UA","ur_PK","uz_UZ","ve_ZA","vi_VN","wa_BE","xh_ZA","yi_US","zh_CN","zh_H
 K","zh_SG","zh_TW","zu_ZA"]');
+('preferredlanguage', '["aa_DJ","aa_ER","aa_ET","af_ZA","am_ET","an_ES","ar_AE","ar_BH","ar_DZ","ar_EG","ar_IN","ar_IQ","ar_JO","ar_KW","ar_LB","ar_LY","ar_MA","ar_OM","ar_QA","ar_SA","ar_SD","ar_SY","ar_TN","ar_YE","as_IN","az_AZ","be_BY","bg_BG","bn_BD","bn_IN","bokmal","br_FR","bs_BA","byn_ER","C","ca_AD","ca_ES","ca_FR","ca_IT","catalan","croatian","csb_PL","cs_CZ","cy_GB","czech","da_DK","danish","dansk","de_AT","de_BE","de_CH","de_DE","de_LU","deutsch","dutch","dz_BT","eesti","el_CY","el_GR","en_AU","en_BW","en_CA","en_DK","en_GB","en_HK","en_IE","en_IN","en_NZ","en_PH","en_SG","en_US","en_ZA","en_ZW","es_AR","es_BO","es_CL","es_CO","es_CR","es_DO","es_EC","es_ES","es_GT","es_HN","es_MX","es_NI","es_PA","es_PE","es_PR","es_PY","es_SV","estonian","es_US","es_UY","es_VE","et_EE","eu_ES","fa_IR","fi_FI","finnish","fo_FO","fr_BE","fr_CA","fr_CH","french","fr_FR","fr_LU","fy_NL","ga_IE","galego","galician","gd_GB","german","gez_ER","gez_ET","gl_ES","greek","gu_IN","gv_GB","
 hebrew","he_IL","hi_IN","hr_HR","hrvatski","hsb_DE","hu_HU","hungarian","hy_AM","icelandic","id_ID","is_IS","italian","it_CH","it_IT","iw_IL","ja_JP","japanese","ka_GE","kk_KZ","kl_GL","km_KH","kn_IN","ko_KR","korean","ku_TR","kw_GB","ky_KG","lg_UG","lithuanian","lo_LA","lt_LT","lv_LV","mai_IN","mg_MG","mi_NZ","mk_MK","ml_IN","mn_MN","mr_IN","ms_MY","mt_MT","nb_NO","ne_NP","nl_BE","nl_NL","nn_NO","no_NO","norwegian","nr_ZA","nso_ZA","nynorsk","oc_FR","om_ET","om_KE","or_IN","pa_IN","pa_PK","pl_PL","polish","portuguese","POSIX","pt_BR","pt_PT","romanian","ro_RO","ru_RU","russian","ru_UA","rw_RW","se_NO","sid_ET","si_LK","sk_SK","slovak","slovene","slovenian","sl_SI","so_DJ","so_ET","so_KE","so_SO","spanish","sq_AL","sr_CS","sr_ME","sr_RS","ss_ZA","st_ZA","sv_FI","sv_SE","swedish","ta_IN","te_IN","tg_TJ","thai","th_TH","ti_ER","ti_ET","tig_ER","tl_PH","tn_ZA","tr_CY","tr_TR","ts_ZA","tt_RU","turkish","uk_UA","ur_PK","uz_UZ","ve_ZA","vi_VN","wa_BE","xh_ZA","yi_US","zh_CN","zh_H
 K","zh_SG","zh_TW","zu_ZA"]'),
+('c', '["AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AS","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CW","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IR","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","
 SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","UM","US","UY","UZ","VA","VA","VC","VE","VG","VI","VN","VU","WF","WS","YE","YT","YU","ZA","ZM","ZW"]');
 
 -- --------------------------------------------------------
 
@@ -76,15 +78,16 @@ CREATE TABLE IF NOT EXISTS `user_types` (
   `attributes` longtext NOT NULL,
   PRIMARY KEY (`id`),
   UNIQUE KEY `name` (`name`)
-) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
+) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
 
 --
 -- Dumping data for table `user_types`
 --
 
 INSERT INTO `user_types` (`id`, `key`, `name`, `description`, `attributes`) VALUES
-(1, 'kolab', 'Kolab User', 'A Kolab User', '{"auto_form_fields":{"cn":{"data":["givenname","sn"]},"displayname":{"data":["givenname","sn"]},"mail":{"data":["givenname","preferredlanguage","sn"]},"mailalternateaddress":{"data":["givenname","preferredlanguage","sn"]},"mailhost":[],"uid":{"data":["givenname","preferredlanguage","sn"]},"userpassword":[]},"form_fields":{"initials":[],"givenname":[],"mailalternateaddress":{"type":"list"},"nsrole":{"type":"list","autocomplete":true},"preferredlanguage":{"type":"select","values":["en_US","de_DE","de_CH","en_GB","fr_FR"]},"sn":[],"title":[]},"fields":{"objectclass":["top","inetorgperson","organizationalperson","person","kolabinetorgperson"]}}'),
-(2, 'posix', 'POSIX User', 'A POSIX user (with a home directory and shell access)', '{"auto_form_fields":{"cn":{"data":["givenname","sn"]},"displayname":{"data":["givenname","sn"]},"gidnumber":[],"homedirectory":{"data":["givenname","sn"]},"uid":{"data":["givenname","sn"]},"uidnumber":[],"userpassword":[]},"form_fields":{"givenname":[],"initials":[],"preferredlanguage":{"type":"select","values_source":"<uri>"},"shell":{"type":"select","values":["/bin/bash","/usr/bin/git-shell","/sbin/nologin"]},"sn":[],"title":[]},"fields":{"objectclass":["top","inetorgperson","organizationalperson","person","posixaccount"]}}');
+(1, 'kolab', 'Kolab User', 'A Kolab User', '{"auto_form_fields":{"cn":{"data":["givenname","sn"]},"displayname":{"data":["givenname","sn"]},"mail":{"data":["givenname","preferredlanguage","sn"]},"mailalternateaddress":{"data":["givenname","preferredlanguage","sn"],"optional":true},"mailhost":{"optional":true},"uid":{"data":["givenname","preferredlanguage","sn"]},"userpassword":{"optional":true}},"form_fields":{"givenname":[],"initials":{"optional":true},"kolabdelegate":{"type":"list","autocomplete":true,"optional":true},"kolabinvitationpolicy":{"type":"select","values":["","ACT_MANUAL","ACT_REJECT"],"optional":true},"kolaballowsmtprecipient":{"type":"list","optional":true},"kolaballowsmtpsender":{"type":"list","optional":true},"l":{"optional":true},"mailalternateaddress":{"type":"list","optional":true},"mailquota":{"optional":true},"mobile":{"optional":true},"nsroledn":{"type":"list","autocomplete":true,"optional":true},"o":{"optional":true},"ou":{"type":"select"},"pager":{"
 optional":true},"postalcode":{"optional":true},"preferredlanguage":{"type":"select"},"sn":[],"street":{"optional":true},"telephonenumber":{"optional":true},"title":{"optional":true},"userpassword":{"optional":true}},"fields":{"objectclass":["top","inetorgperson","kolabinetorgperson","mailrecipient","organizationalperson","person"]}}'),
+(2, 'posix', 'POSIX User', 'A POSIX user (with a home directory and shell access)', '{"auto_form_fields":{"cn":{"data":["givenname","sn"]},"displayname":{"data":["givenname","sn"]},"gidnumber":[],"homedirectory":{"data":["givenname","sn"]},"uid":{"data":["givenname","sn"]},"uidnumber":[],"userpassword":{"optional":true}},"form_fields":{"givenname":[],"initials":{"optional":true},"preferredlanguage":{"type":"select","values":["en_US","de_DE","de_CH","en_GB","fi_FI","fr_FR","hu_HU"]},"loginshell":{"type":"select","values":["/bin/bash","/usr/bin/git-shell","/sbin/nologin"]},"ou":{"type":"select"},"sn":[],"title":{"optional":true},"userpassword":{"optional":true}},"fields":{"objectclass":["top","inetorgperson","organizationalperson","person","posixaccount"]}}'),
+(3, 'kolab_posix', 'Mail-enabled POSIX User', 'A mail-enabled POSIX User', '{"auto_form_fields":{"cn":{"data":["givenname","preferredlanguage","sn"]},"displayname":{"data":["givenname","preferredlanguage","sn"]},"gidnumber":[],"homedirectory":{"data":["givenname","preferredlanguage","sn"]},"mail":{"data":["givenname","preferredlanguage","sn"]},"mailalternateaddress":{"data":["givenname","preferredlanguage","sn"],"optional":true},"mailhost":{"optional":true},"uid":{"data":["givenname","preferredlanguage","sn"]},"uidnumber":[],"userpassword":{"optional":true}},"form_fields":{"givenname":[],"initials":{"optional":true},"kolabdelegate":{"type":"list","autocomplete":true,"optional":true},"kolabinvitationpolicy":{"type":"select","values":["","ACT_MANUAL","ACT_REJECT"],"optional":true},"kolaballowsmtprecipient":{"type":"list","optional":true},"kolaballowsmtpsender":{"type":"list","optional":true},"l":{"optional":true},"loginshell":{"type":"select","values":["/bin/bash","/usr/bin/gi
 t-shell","/sbin/nologin"]},"mailalternateaddress":{"type":"list","optional":true},"mailquota":{"optional":true},"mobile":{"optional":true},"nsroledn":{"type":"list","autocomplete":true,"optional":true},"o":{"optional":true},"ou":{"type":"select"},"pager":{"optional":true},"postalcode":{"optional":true},"preferredlanguage":{"type":"select"},"sn":[],"street":{"optional":true},"telephonenumber":{"optional":true},"title":{"optional":true},"userpassword":{"optional":true}},"fields":{"objectclass":["top","inetorgperson","kolabinetorgperson","mailrecipient","organizationalperson","person","posixaccount"]}}');
 
 /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
 /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;


commit 8eb7357b248952f16c50da9a2483e56d9f449c89
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Fri Apr 20 11:04:55 2012 +0200

    Bug #704: Cannot override auto_form_field values

diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index bcd3491..52ea985 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -568,7 +568,7 @@ class LDAP
         $_user_dn = key($_user);
         $_user = $this->user_info($_user_dn, array_keys($attributes));
 
-        //console("user_edit \$_user", $_user);
+        //console("Auth::LDAP::user_edit() existing \$_user info", $_user);
 
         // We should start throwing stuff over the fence here.
         return $this->modify_entry($_user_dn, $_user[$_user_dn], $attributes);
@@ -999,7 +999,7 @@ class LDAP
 
         $rdn_attr = $rdn_components[0];
 
-        //console($rdn_attr);
+        //console("Auth::LDAP::modify_entry() using rdn attribute: " . $rdn_attr);
 
         $mod_array = Array(
                 "add"       => Array(), // For use with ldap_mod_add()
@@ -1019,15 +1019,14 @@ class LDAP
         foreach ($old_attrs as $attr => $old_attr_value) {
 
             if (array_key_exists($attr, $new_attrs)) {
-                $_sort1 = false;
-                $_sort2 = false;
-                if (is_array($new_attrs[$attr])) {
+                if (is_array($old_attrs[$attr]) && is_array($new_attrs[$attr])) {
                     $_sort1 = $new_attrs[$attr];
                     sort($_sort1);
-                }
-                if (is_array($old_attr_value)) {
                     $_sort2 = $old_attr_value;
                     sort($_sort2);
+                } else {
+                    $_sort1 = true;
+                    $_sort2 = false;
                 }
 
                 if (!($new_attrs[$attr] === $old_attr_value) && !($_sort1 === $_sort2)) {
@@ -1120,12 +1119,38 @@ class LDAP
         // Opportunities to set false include failed ldap commands.
         $result = true;
 
+        if (is_array($attributes['rename']) && !empty($attributes['rename'])) {
+            $olddn = $attributes['rename']['dn'];
+            $newrdn = $attributes['rename']['new_rdn'];
+            if (!empty($attributes['rename']['new_parent'])) {
+                $new_parent = $attributes['rename']['new_parent'];
+            } else {
+                $new_parent = null;
+            }
+
+            //console("Attempt to rename $olddn to $newrdn,$new_parent");
+
+            $result = ldap_rename($this->conn, $olddn, $newrdn, $new_parent, true);
+            if ($result) {
+                if ($new_parent) {
+                    $subject_dn = $newrdn . ',' . $new_parent;
+                } else {
+                    $old_parent_dn_components = ldap_explode_dn($olddn, 0);
+                    unset($old_parent_dn_components["count"]);
+                    $old_rdn = array_shift($old_parent_dn_components);
+                    $old_parent_dn = implode(",", $old_parent_dn_components);
+                    $subject_dn = $newrdn . ',' . $old_parent_dn;
+                }
+            }
+
+        }
+
         if (is_array($attributes['replace']) && !empty($attributes['replace'])) {
             $result = ldap_mod_replace($this->conn, $subject_dn, $attributes['replace']);
         }
 
         if (!$result) {
-            //console("Failed to replace the following attributes", $attributes['replace']);
+            console("Failed to replace the following attributes on subject " . $subject_dn, $attributes['replace']);
             return false;
         }
 
@@ -1134,7 +1159,7 @@ class LDAP
         }
 
         if (!$result) {
-            //console("Failed to delete the following attributes", $attributes['del']);
+            console("Failed to delete the following attributes", $attributes['del']);
             return false;
         }
 
@@ -1144,24 +1169,10 @@ class LDAP
         }
 
         if (!$result) {
-            //console("Failed to add the following attributes", $attributes['add']);
+            console("Failed to add the following attributes", $attributes['add']);
             return false;
         }
 
-        if (is_array($attributes['rename']) && !empty($attributes['rename'])) {
-            $olddn = $attributes['rename']['dn'];
-            $newrdn = $attributes['rename']['new_rdn'];
-            if (!empty($attributes['rename']['new_parent'])) {
-                $new_parent = $attributes['rename']['new_parent'];
-            } else {
-                $new_parent = null;
-            }
-
-            //console("Attempt to rename $olddn to $newrdn,$new_parent");
-
-            $result = ldap_rename($this->conn, $olddn, $newrdn, $new_parent, true);
-        }
-
         if (!$result) {
             error_log("LDAP Error: " . $this->_errstr());
             return false;


commit 9c9a7b3e782386e50933006221a26de54748c170
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Fri Apr 20 11:03:35 2012 +0200

    Ensure any primary email addresses are not included in the result for secondary email addresses

diff --git a/lib/kolab_recipient_policy.php b/lib/kolab_recipient_policy.php
index 492df0b..6667631 100644
--- a/lib/kolab_recipient_policy.php
+++ b/lib/kolab_recipient_policy.php
@@ -175,6 +175,9 @@ class kolab_recipient_policy {
             );
 
         $userdata = self::normalize_userdata($userdata);
+        if (!array_key_exists('mail', $userdata)) {
+            $userdata['mail'] = self::primary_mail($userdata);
+        }
 
         $conf = Conf::get_instance();
 
@@ -234,6 +237,13 @@ class kolab_recipient_policy {
                 eval("\$result = sprintf('" . $format . "', '" . implode("', '", array_values($result)) . "');");
 
                 if ($result = self::parse_email($result)) {
+                    // See if the equivalent is already in the 'mail' attribute value(s)
+                    if (!empty($userdata['mail'])) {
+                        if (strtolower($userdata['mail']) == strtolower($result)) {
+                            continue;
+                        }
+                    }
+
                     $secondary_mail_addresses[] = $result;
                 }
             }


commit 2cf72fefc2d987f4b97b376cdc13d96998e730db
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Fri Apr 20 11:01:56 2012 +0200

    Extract reading configuration file to a different function, make sure configuration is read in time

diff --git a/lib/Conf.php b/lib/Conf.php
index 4f1f883..e8a9a02 100644
--- a/lib/Conf.php
+++ b/lib/Conf.php
@@ -26,6 +26,8 @@
 class Conf {
     static private $instance;
 
+    private $_conf = array();
+
     const CONFIG_FILE = '/etc/kolab/kolab.conf';
 
     /**
@@ -49,33 +51,8 @@ class Conf {
             return;
         }
 
-        $_ini_raw = file(self::CONFIG_FILE);
-
-        $this->_conf = array();
+        $this->read_config();
 
-        foreach ($_ini_raw as $_line) {
-            if (preg_match('/^\[([a-z0-9-_\.]+)\]/', $_line, $matches)) {
-                $_cur_section = $matches[1];
-                $this->_conf[$_cur_section] = array();
-                unset($_cur_key);
-            }
-
-            if (preg_match('/^;/', $_line, $matches)) {
-            }
-
-            if (preg_match('/^([a-z0-9\.-_]+)\s*=\s*(.*)/', $_line, $matches)) {
-                if (isset($_cur_section) && !empty($_cur_section)) {
-                    $_cur_key = $matches[1];
-                    $this->_conf[$_cur_section][$matches[1]] = isset($matches[2]) ? $matches[2] : '';
-                }
-            }
-
-            if (preg_match('/^\s+(.*)$/', $_line, $matches)) {
-                if (isset($_cur_key) && !empty($_cur_key)) {
-                    $this->_conf[$_cur_section][$_cur_key] .= $matches[1];
-                }
-            }
-        }
     }
 
     public function get($key1, $key2 = NULL)
@@ -130,7 +107,7 @@ class Conf {
                     return $this->_conf[$domain_section_name][$key1];
                 }
             } catch (Exception $e) {
-                $domain_section_name = $this->get('kolab', 'primary_domain');
+                $domain_section_name = $this->get_raw('kolab', 'primary_domain');
                 if (isset($this->_conf[$domain_section_name][$key1])) {
                     return $this->_conf[$domain_section_name][$key1];
                 }
@@ -183,4 +160,35 @@ class Conf {
             return $str;
         }
     }
+
+    private function read_config()
+    {
+        $_ini_raw = file(self::CONFIG_FILE);
+
+        $this->_conf = array();
+
+        foreach ($_ini_raw as $_line) {
+            if (preg_match('/^\[([a-z0-9-_\.]+)\]/', $_line, $matches)) {
+                $_cur_section = $matches[1];
+                $this->_conf[$_cur_section] = array();
+                unset($_cur_key);
+            }
+
+            if (preg_match('/^;/', $_line, $matches)) {
+            }
+
+            if (preg_match('/^([a-z0-9\.-_]+)\s*=\s*(.*)/', $_line, $matches)) {
+                if (isset($_cur_section) && !empty($_cur_section)) {
+                    $_cur_key = $matches[1];
+                    $this->_conf[$_cur_section][$matches[1]] = isset($matches[2]) ? $matches[2] : '';
+                }
+            }
+
+            if (preg_match('/^\s+(.*)$/', $_line, $matches)) {
+                if (isset($_cur_key) && !empty($_cur_key)) {
+                    $this->_conf[$_cur_section][$_cur_key] .= $matches[1];
+                }
+            }
+        }
+    }
 }


commit f9da7438d93d12de64cfd08e02d4c8d2949ffdaa
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Fri Apr 20 11:00:30 2012 +0200

    Make sure the secondary mail addresses are unique, too

diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index 614bd18..8af2f8f 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -389,7 +389,7 @@ class kolab_api_service_form_value extends kolab_api_service
 
     private function generate_secondary_mail($postdata, $attribs = array())
     {
-        $secondary_mail_address = Array();
+        $secondary_mail_addresses = Array();
 
         if (isset($attribs['auto_form_fields'])) {
             if (isset($attribs['auto_form_fields']['alias'])) {
@@ -412,9 +412,17 @@ class kolab_api_service_form_value extends kolab_api_service
                 }
             }
 
-            $secondary_mail = kolab_recipient_policy::secondary_mail($postdata);
+            if (array_key_exists('mail', $attribs['auto_form_fields'])) {
+                if (!array_key_exists('mail', $postdata)) {
+                    $postdata['mail'] = $this->generate_primary_mail($postdata, $attribs);
+                }
+            }
+
+            $secondary_mail_addresses = kolab_recipient_policy::secondary_mail($postdata);
+
+            // TODO: Check for uniqueness. Not sure what to do if not unique.
 
-            return $secondary_mail;
+            return $secondary_mail_addresses;
         }
     }
 
@@ -459,6 +467,7 @@ class kolab_api_service_form_value extends kolab_api_service
                     $user_found_unique_attr = $auth->get_attribute($user_found_dn, $unique_attr);
                     //console("user with uid $uid found", $user_found_unique_attr);
                     if ($user_found_unique_attr == $postdata['id']) {
+                        //console("that's us.");
                         break;
                     }
                 }





More information about the commits mailing list