gunnar: server/horde/horde-framework HK-GW-Kolab_extensions.patch, NONE, 1.1 ChangeLog, 1.10, 1.11 horde-framework-kolab.spec, 1.28, 1.29

cvs at kolab.org cvs at kolab.org
Thu Nov 22 17:24:16 CET 2007


Author: gunnar

Update of /kolabrepository/server/horde/horde-framework
In directory doto:/tmp/cvs-serv1438/horde/horde-framework

Modified Files:
	ChangeLog horde-framework-kolab.spec 
Added Files:
	HK-GW-Kolab_extensions.patch 
Log Message:
Added Horde/Kolab extensionsrequired for the new freebusy package.

--- NEW FILE: HK-GW-Kolab_extensions.patch ---
diff -r 2be0e69810d0 framework/Auth/Auth/kolab.php
--- a/framework/Auth/Auth/kolab.php	Mon Nov 19 17:20:06 2007 +0100
+++ b/framework/Auth/Auth/kolab.php	Thu Nov 22 17:17:04 2007 +0100
@@ -31,7 +31,12 @@ class Auth_kolab extends Auth_imap {
     {
         $params['hostspec'] = Kolab::getServer('imap');
         $params['port'] = $GLOBALS['conf']['kolab']['imap']['port'];
-        $params['protocol'] = 'imap/notls/novalidate-cert';
+        if (empty($GLOBALS['conf']['kolab']['imap']['protocol'])) {
+            $params['protocol'] = 'imap/notls/novalidate-cert';
+        } else {
+            $params['protocol'] = $GLOBALS['conf']['kolab']['imap']['protocol'];
+        }
+        
 
         parent::Auth_imap($params);
     }
diff -r 2be0e69810d0 framework/Date/Date/Recurrence.php
--- a/framework/Date/Date/Recurrence.php	Mon Nov 19 17:20:06 2007 +0100
+++ b/framework/Date/Date/Recurrence.php	Thu Nov 22 17:17:04 2007 +0100
@@ -1044,4 +1044,352 @@ class Horde_Date_Recurrence {
         return $rrule;
     }
 
+
+    /**
+     * Parse the recurrence data from a hash
+     *
+     * @param array   $hash  The hash to convert
+     *
+     * @return boolean True if the hash seemed valid, false otherwise
+     */
+    function fromHash($hash)
+    {
+        if (!isset($hash['interval']) || !isset($hash['interval']) ||
+            !isset($hash['range-type'])) {
+            $this->setRecurType(HORDE_DATE_RECUR_NONE);
+            return false;
+        }
+
+        $this->setRecurInterval((int) $hash['interval']);
+
+        $parse_day = false;
+        $set_daymask = false;
+
+        $update_month = false;
+        $update_daynumber = false;
+
+        $update_weekday = false;
+        $nth_weekday = -1;
+
+        switch ($hash['cycle']) {
+        case 'daily':
+            $this->setRecurType(HORDE_DATE_RECUR_DAILY);
+            break;
+
+        case 'weekly':
+            $this->setRecurType(HORDE_DATE_RECUR_WEEKLY);
+            $parse_day = true;
+            $set_daymask = true;
+            break;
+
+        case 'monthly':
+
+            if (!isset($hash['daynumber'])) {
+                $this->setRecurType(HORDE_DATE_RECUR_NONE);
+                return false;
+            }
+
+            switch ($hash['type']) {
+            case 'daynumber':
+                $this->setRecurType(HORDE_DATE_RECUR_MONTHLY_DATE);
+                $update_daynumber = true;
+                break;
+
+            case 'weekday':
+                $this->setRecurType(HORDE_DATE_RECUR_MONTHLY_WEEKDAY);
+                $nth_weekday = (int) $hash['daynumber'];
+                $hash['daynumber'] = 1;
+                $parse_day = true;
+                $update_daynumber = true;
+                $update_weekday = true;
+                break;
+            }
+            break;
+
+        case 'yearly':
+
+            if (!isset($hash['type'])) {
+                $this->setRecurType(HORDE_DATE_RECUR_NONE);
+                return false;
+            }
+
+            switch ($hash['type']) {
+            case 'monthday':
+                $this->setRecurType(HORDE_DATE_RECUR_YEARLY_DATE);
+                $update_month = true;
+                $update_daynumber = true;
+                break;
+            case 'yearday':
+
+                if (!isset($hash['month'])) {
+                    $this->setRecurType(HORDE_DATE_RECUR_NONE);
+                    return false;
+                }
+
+                $this->setRecurType(HORDE_DATE_RECUR_YEARLY_DAY);
+                // Start counting days in January
+                $hash['month'] = 'january';
+                $update_month = true;
+                $update_daynumber = true;
+                break;
+            case 'weekday':
+
+                if (!isset($hash['daynumber'])) {
+                    $this->setRecurType(HORDE_DATE_RECUR_NONE);
+                    return false;
+                }
+
+                $this->setRecurType(HORDE_DATE_RECUR_YEARLY_WEEKDAY);
+                $nth_weekday = (int) $hash['daynumber'];
+                $hash['daynumber'] = 1;
+                $parse_day = true;
+                $update_month = true;
+                $update_daynumber = true;
+                $update_weekday = true;
+                break;
+            }
+        }
+
+        switch ($hash['range-type']) {
+        case 'number':
+
+            if (!isset($hash['range'])) {
+                $this->setRecurType(HORDE_DATE_RECUR_NONE);
+                return false;
+            }
+
+            $this->setRecurCount((int) $hash['range']);
+            break;
+
+        case 'date':
+            // fix off-by-one day
+            //FIXME
+            $timestamp = Kolab_Date::decodeDate($hash['range']);
+            $this->setRecurEnd(new Horde_Date($timestamp + 86400));
+            break;
+        }
+
+        // Need to parse <day>?
+        $last_found_day = -1;
+        if ($parse_day) {
+
+            if (!isset($hash['day'])) {
+                $this->setRecurType(HORDE_DATE_RECUR_NONE);
+                return false;
+            }
+
+            $mask = 0;
+            $bits = array(
+                'monday' => HORDE_DATE_MASK_MONDAY,
+                'tuesday' => HORDE_DATE_MASK_TUESDAY,
+                'wednesday' => HORDE_DATE_MASK_WEDNESDAY,
+                'thursday' => HORDE_DATE_MASK_THURSDAY,
+                'friday' => HORDE_DATE_MASK_FRIDAY,
+                'saturday' => HORDE_DATE_MASK_SATURDAY,
+                'sunday' => HORDE_DATE_MASK_SUNDAY,
+            );
+
+            $days = array(
+                'monday' => HORDE_DATE_MONDAY,
+                'tuesday' => HORDE_DATE_TUESDAY,
+                'wednesday' => HORDE_DATE_WEDNESDAY,
+                'thursday' => HORDE_DATE_THURSDAY,
+                'friday' => HORDE_DATE_FRIDAY,
+                'saturday' => HORDE_DATE_SATURDAY,
+                'sunday' => HORDE_DATE_SUNDAY,
+            );
+
+            foreach ($hash['day'] as $day) {
+                // validity check
+                if (empty($day) || !isset($bits[$day]))
+                    continue;
+
+                $mask |= $bits[$day];
+                $last_found_day = $days[$day];
+            }
+
+            if ($set_daymask) {
+                $this->setRecurOnDay($mask);
+            }
+        }
+
+        if ($update_month || $update_daynumber || $update_weekday) {
+            if ($update_month) {
+                $month2number = array(
+                    'january'   => 1,
+                    'february'  => 2,
+                    'march'     => 3,
+                    'april'     => 4,
+                    'may'       => 5,
+                    'june'      => 6,
+                    'july'      => 7,
+                    'august'    => 8,
+                    'september' => 9,
+                    'october'   => 10,
+                    'november'  => 11,
+                    'december'  => 12,
+                );
+
+                if (isset($month2number[$hash['month']])) {
+                    $this->start->month = $month2number[$hash['month']];
+                }
+            }
+
+            if ($update_daynumber) {
+
+                if (!isset($hash['daynumber'])) {
+                    $this->setRecurType(HORDE_DATE_RECUR_NONE);
+                    return false;
+                }
+
+                $this->start->mday = $hash['daynumber'];
+            }
+
+            if ($update_weekday) {
+                $this->start->setNthWeekday($last_found_day, $nth_weekday);
+            }
+
+            $this->start->correct();
+        }
+
+        // Exclusions
+        if (isset($hash['exclusion'])) {
+            foreach($hash['exclusion'] as $exclusion) {
+                $date = new Horde_Date(Kolab_Date::decodeDate($exclusion));
+                $this->addException($date->year, $date->month, $date->mday);
+            }
+        }
+
+        return true;
+    }
+
+    /**
+     * Export this object into a hash
+     *
+     * @return array The recurrence hash
+     */
+    function toHash()
+    {
+        $hash = array();
+
+        $hash['interval'] = $this->getRecurInterval();
+
+        $day2number = array(
+            0 => 'sunday',
+            1 => 'monday',
+            2 => 'tuesday',
+            3 => 'wednesday',
+            4 => 'thursday',
+            5 => 'friday',
+            6 => 'saturday'
+        );
+
+        $month2number = array(
+            1 => 'january',
+            2 => 'february',
+            3 => 'march',
+            4 => 'april',
+            5 => 'may',
+            6 => 'june',
+            7 => 'july',
+            8 => 'august',
+            9 => 'september',
+            10 => 'october',
+            11 => 'november',
+            12 => 'december'
+        );
+
+        $start = $this->getRecurStart();
+        switch ($this->getRecurType()) {
+        case HORDE_DATE_RECUR_DAILY:
+            $hash['cycle'] = 'daily';
+            break;
+
+        case HORDE_DATE_RECUR_WEEKLY:
+            $hash['cycle'] = 'weekly';
+
+            $bits = array(
+                'monday' => HORDE_DATE_MASK_MONDAY,
+                'tuesday' => HORDE_DATE_MASK_TUESDAY,
+                'wednesday' => HORDE_DATE_MASK_WEDNESDAY,
+                'thursday' => HORDE_DATE_MASK_THURSDAY,
+                'friday' => HORDE_DATE_MASK_FRIDAY,
+                'saturday' => HORDE_DATE_MASK_SATURDAY,
+                'sunday' => HORDE_DATE_MASK_SUNDAY,
+            );
+
+            $days = array();
+            foreach($bits as $name => $bit) {
+                if ($this->recurOnDay($bit)) {
+                    $days[] = $name;
+                }
+            }
+
+            $hash['day'] = $days;
+            break;
+
+        case HORDE_DATE_RECUR_MONTHLY_DATE:
+            $hash['cycle'] = 'monthly';
+            $hash['type'] = 'daynumber';
+            $hash['daynumber'] = $start->mday;
+            break;
+
+        case HORDE_DATE_RECUR_MONTHLY_WEEKDAY:
+            $hash['cycle'] = 'monthly';
+            $hash['type'] = 'weekday';
+            $hash['daynumber'] = $start->weekOfMonth();
+            $hash['day'] = array ($day2number[$start->dayOfWeek()]);
+            break;
+
+        case HORDE_DATE_RECUR_YEARLY_DATE:
+            $hash['cycle'] = 'yearly';
+            $hash['type'] = 'monthday';
+            $hash['daynumber'] = $start->mday;
+            $hash['month'] = $month2number[$start->month];
+            break;
+
+        case HORDE_DATE_RECUR_YEARLY_DAY:
+            $hash['cycle'] = 'yearly';
+            $hash['type'] = 'yearday';
+            $hash['daynumber'] = $start->dayOfYear();
+            break;
+
+        case HORDE_DATE_RECUR_YEARLY_WEEKDAY:
+            $hash['cycle'] = 'yearly';
+            $hash['type'] = 'weekday';
+
+            $hash['daynumber'] = $start->weekOfMonth();
+            $hash['day'] = array ($day2number[$start->dayOfWeek()]);
+            $hash['month'] = $month2number[$start->month];
+        }
+
+        if ($this->hasRecurCount()) {
+            $hash['range-type'] = 'number';
+            $hash['range'] = $this->getRecurCount();
+        }else if ($this->hasRecurEnd()) {
+            // Fix of-by-one day
+            $date = $this->getRecurEnd();
+            $date->mday -= 1;
+            $date->correct();
+
+            $hash['range-type'] = 'date';
+            $hash['range'] = Kolab_Date::encodeDate($date->timestamp());
+        } else {
+            $hash['range-type'] = 'none';
+            $hash['range'] = '';
+        }
+
+        // Recurrence exclusions
+        $exclusions = array();
+        foreach ($this->getExceptions() as $exception) {
+            if (!empty($exception)) {
+                list($year, $month, $mday) = sscanf($exception, '%04d%02d%02d');
+                $exclusions[] = "$year-$month-$mday";
+            }
+        }
+        $hash['exclusion'] = $exclusions;
+
+        return $hash;
+    }
+    
 }
diff -r 2be0e69810d0 framework/Kolab/Kolab.php
--- a/framework/Kolab/Kolab.php	Mon Nov 19 17:20:06 2007 +0100
+++ b/framework/Kolab/Kolab.php	Thu Nov 22 17:17:04 2007 +0100
@@ -68,11 +68,14 @@ class Kolab {
      */
     var $_uid;
 
-    function Kolab()
-    {
-        global $registry;
-
-        $this->_app = $registry->getApp();
+    function Kolab($app = null)
+    {
+        if (!isset($app)) {
+            global $registry;
+            $app = $registry->getApp();
+        }
+        $this->_app = $app;
+        
         $this->_storage = &new Kolab_IMAP();
     }
 
diff -r 2be0e69810d0 framework/Kolab/Kolab/LDAP.php
--- a/framework/Kolab/Kolab/LDAP.php	Mon Nov 19 17:20:06 2007 +0100
+++ b/framework/Kolab/Kolab/LDAP.php	Thu Nov 22 17:17:04 2007 +0100
@@ -60,7 +60,7 @@ class Horde_Kolab_LDAP {
         $this->bind_dn = false;
         $this->search_result = false;
 
-        $server = Kolab::getServer('ldap');
+        $server = $GLOBALS['conf']['kolab']['ldap']['server'];
 
         $this->connection = ldap_connect($server);
         // We really neeed v3!
@@ -222,4 +222,127 @@ class Horde_Kolab_LDAP {
         }
     }
 
+    /**
+     * Return a hash of info about a user
+     *
+     * @param string $uid  The UID of the user.
+     *
+     * @return string  The hash containing the user information.
+     */
+    function userInfo($uid)
+    {
+        $result = ldap_search($this->connection,
+                              $GLOBALS['conf']['kolab']['ldap']['basedn'],
+                              '(&(objectClass=kolabInetOrgPerson)(|(uid='.
+                              Horde_LDAP::quote($uid) . ')(mail=' .
+                              Horde_LDAP::quote($uid) . ')))',
+                              array('dn','mail','uid','kolabHomeServer',
+                                    'kolabFreeBusyFuture'));
+        if ($result) {
+            $entries = ldap_get_entries($this->connection, $result);
+            if($entries['count'] > 0 && !empty($entries[0]['mail'][0])) {
+                $hash = array();
+                $hash['DN']         = $this->readLdapAttr($entries[0], 'dn');
+                $hash['UID']        = $this->readLdapAttr($entries[0], 'uid');
+                $hash['MAIL']       = $this->readLdapAttr($entries[0], 'mail',
+                                                          $uid);
+                $hash['HOMESERVER'] = $this->readLdapAttr($entries[0],
+                                                          'kolabhomeserver');
+                $hash['FBFUTURE']   = (int)($this->readLdapAttr($entries[0],
+                                                                'kolabfreebusyfuture',
+                                                                60));
+                $hash['GROUPS']     = $this->getGroups($hash['DN']);
+                ldap_free_result( $result );
+                return $hash;
+            }
+            ldap_free_result($result);
+        } else {
+            return PEAR::raiseError(sprintf(_("Error searching for user with the uid \"%s\"!"),
+                                            $uid));
+        }
+        return false;
+    }
+
+    /**
+     * Read an LDAP attribute
+     *
+     * @param string $entry    The LDAP search result
+     * @param string $attrname The attribute to read.
+     * @param mixed  $default  A possible default value.
+     *
+     * @return mixed The attribute value or the default if the
+     *               attribute was not found or the attribute 
+     *               was empty.
+     */
+    function readLdapAttr($entry, $attrname, $default = false ) {
+        $val = $default;
+        if (!array_key_exists($attrname, $entry)) {
+            return $default;
+        } else if (is_array($entry[$attrname])) {
+            $val = $entry[$attrname][0];
+        } else {
+            $val = $entry[$attrname];
+        }
+        if($val == '') {
+            return $default;
+        }
+        return $val;
+    }
+
+    function freeBusyPast() {
+        $result = ldap_read($this->connection, 
+                            $GLOBALS['conf']['kolab']['ldap']['basedn'], 
+                            '(&(objectClass=kolab)(k=kolab))',
+                            array('kolabFreeBusyPast'));
+        if ($result) {
+            $entries = ldap_get_entries($this->connection, $result);
+            if ($entries['count'] > 0 && 
+                !empty($entries[0]['kolabfreebusypast'][0])) {
+                ldap_free_result($result);
+                return $entries[0]['kolabfreebusypast'][0];
+            }
+        }
+        // Default
+        return 0;
+    }
+
+    function getGroups($dn) {
+        $result = ldap_search($this->connection,
+                              $GLOBALS['conf']['kolab']['ldap']['basedn'], 
+                              '(&(objectClass=kolabGroupOfNames)(member=' . 
+                              Horde_LDAP::quote($dn) . '))', array('mail'));
+        if ($result) {
+            $entries = ldap_get_entries($this->connection, $result);
+            $lst = array();
+            for ($i = 0; $i < $entries['count']; $i++) {
+                $lst[] = $entries[$i]['mail'][0];
+            }
+            return $lst;
+        }
+        return array();
+    }
+
+    /**
+     * Attempts to return a reference to a concrete Horde_Kolab_LDAP
+     * instance. It will only create a new instance if no
+     * Horde_Kolab_LDAP instance currently exists.
+     *
+     * This method must be invoked as:
+     *   <code>$var = &Horde_Kolab_LDAP::singleton();</code>
+     *
+     * @static
+     *
+     * @return Horde_Kolab_LDAP The concrete Horde_Kolab_LDAP
+     *                          reference, or false on an error.
+     */
+    function &singleton()
+    {
+        static $ldap = null;
+
+        if (empty($ldap)) {
+            $ldap = &new Horde_Kolab_LDAP();
+        }
+
+        return $ldap;
+    }
 }
\ No newline at end of file
diff -r 2be0e69810d0 framework/Kolab/package.xml
--- a/framework/Kolab/package.xml	Mon Nov 19 17:20:06 2007 +0100
+++ b/framework/Kolab/package.xml	Thu Nov 22 17:17:04 2007 +0100
@@ -45,6 +45,7 @@ communication between a Horde client and
    <dir name="Kolab">
     <file name="Date.php" role="php" />
     <file name="LDAP.php" role="php" />
+    <file name="Freebusy.php" role="php" />
     <file name="IMAP.php" role="php" />
     <file name="XML.php" role="php" />
     <dir name="IMAP">

Index: ChangeLog
===================================================================
RCS file: /kolabrepository/server/horde/horde-framework/ChangeLog,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- ChangeLog	19 Nov 2007 19:48:46 -0000	1.10
+++ ChangeLog	22 Nov 2007 16:24:14 -0000	1.11
@@ -1,3 +1,9 @@
+2007-11-22  Gunnar Wrobel  <p at rdus.de>
+
+	* horde-framework-kolab.spec:
+
+	New functionality required for kolab-freebusy.
+
 2007-11-19  Gunnar Wrobel  <p at rdus.de>
 
 	* horde-framework-kolab.spec:

Index: horde-framework-kolab.spec
===================================================================
RCS file: /kolabrepository/server/horde/horde-framework/horde-framework-kolab.spec,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- horde-framework-kolab.spec	19 Nov 2007 19:48:46 -0000	1.28
+++ horde-framework-kolab.spec	22 Nov 2007 16:24:14 -0000	1.29
@@ -3,7 +3,7 @@
 %define         V_package horde-%{V_horde_name}-kolab
 %define         V_year  2007
 %define         V_month 11
-%define         V_day   19
+%define         V_day   22
 %define         V_version 3.2_ALPHA
 %define         V_date %{V_year}-%{V_month}-%{V_day}
 %define         V_release %{V_year}%{V_month}%{V_day}
@@ -33,6 +33,7 @@
 Patch4:         HK-GW-Kolab_issue_2144.patch
 Patch5:         HK-GW-Kolab_issue_2138.patch
 Patch6:         HK-GW-Fix_contact_XML.patch
+Patch7:         HK-GW-Kolab_extensions.patch
 
 # Build Info
 Prefix:		%{l_prefix}
@@ -61,6 +62,7 @@
 	%patch -p2 -P 4
 	%patch -p2 -P 5
 	%patch -p2 -P 6
+	%patch -p2 -P 7
 
 %build
 





More information about the commits mailing list