[Kolab-devel] wilde: server/patches/horde-webmail/1.2.0/tg t_Kolab__Server_HK_GW_MappableAttributes.diff, NONE, 1.1.4.1 series, 1.5.2.7, 1.5.2.8

Gunnar Wrobel wrobel at pardus.de
Mon Feb 22 06:06:25 CET 2010


Merged ohne commit, da auch der Webclient mittlerweile das  
installierte Kolab_Server-Paket verwendet.

Quoting cvs at kolab.org:

> Author: wilde
>
> Update of /kolabrepository/server/patches/horde-webmail/1.2.0/tg
> In directory doto:/tmp/cvs-serv14888/patches/horde-webmail/1.2.0/tg
>
> Modified Files:
>       Tag: kolab_2_2_branch
> 	series
> Added Files:
>       Tag: kolab_2_2_branch
> 	t_Kolab__Server_HK_GW_MappableAttributes.diff
> Log Message:
> Added ability to map arbitrary ldap attributes to those expected by kolab.
> (Merged from suc branch)
>
>
> --- NEW FILE: t_Kolab__Server_HK_GW_MappableAttributes.diff ---
> From: Gunnar Wrobel <p at rdus.de>
> Subject: [PATCH] t/Kolab_Server/HK/GW/MappableAttributes
>
> Allow to configure mapped LDAP attributes.
>
> Signed-off-by: Gunnar Wrobel <p at rdus.de>
>
> ---
>  horde-webmail/lib/Horde/Kolab/Server.php           |   15 +-
>  horde-webmail/lib/Horde/Kolab/Server/Object.php    |    2 +
>  .../lib/Horde/Kolab/Server/Object/address.php      |   33 ++-
>  .../lib/Horde/Kolab/Server/Object/adminrole.php    |   35 ++-
>  .../lib/Horde/Kolab/Server/Object/distlist.php     |   30 ++-
>  .../lib/Horde/Kolab/Server/Object/group.php        |   23 +-
>  .../lib/Horde/Kolab/Server/Object/server.php       |   21 ++-
>  .../lib/Horde/Kolab/Server/Object/sharedfolder.php |   23 +-
>  .../lib/Horde/Kolab/Server/Object/user.php         |   32 ++-
>  horde-webmail/lib/Horde/Kolab/Server/ldap.php      |  308  
> ++++++++++++++++++--
>  horde-webmail/lib/Horde/Kolab/Server/test.php      |   20 ++-
>  11 files changed, 467 insertions(+), 75 deletions(-)
>
> diff --git a/horde-webmail/lib/Horde/Kolab/Server.php  
> b/horde-webmail/lib/Horde/Kolab/Server.php
> index bf251f5..fd0bda7 100644
> --- a/horde-webmail/lib/Horde/Kolab/Server.php
> +++ b/horde-webmail/lib/Horde/Kolab/Server.php
> @@ -159,9 +159,12 @@ class Horde_Kolab_Server {
>              $driver = 'ldap';
>
>              $server_params = array('server'  =>  
> $conf['kolab']['ldap']['server'],
> -                                  'base_dn' =>  
> $conf['kolab']['ldap']['basedn'],
> -                                  'uid'     =>  
> $conf['kolab']['ldap']['phpdn'],
> -                                  'pass'    =>  
> $conf['kolab']['ldap']['phppw']);
> +                                   'base_dn' =>  
> $conf['kolab']['ldap']['basedn'],
> +                                   'uid'     =>  
> $conf['kolab']['ldap']['phpdn'],
> +                                   'pass'    =>  
> $conf['kolab']['ldap']['phppw']);
> +            if (isset($conf['kolab']['ldap']['map'])) {
> +                $server_params['map'] = $conf['kolab']['ldap']['map'];
> +            }
>          } else {
>              $driver        = null;
>              $server_params = array();
> @@ -473,7 +476,7 @@ class Horde_Kolab_Server {
>      function uidForId($id,
>                        $restrict = KOLAB_SERVER_RESULT_SINGLE)
>      {
> -        return $this->uidForAttr('uid', $id);
> +        return $this->uidForAttr(KOLAB_ATTR_SID, $id);
>      }
>
>      /**
> @@ -513,7 +516,7 @@ class Horde_Kolab_Server {
>       */
>      function uidForIdOrMail($id)
>      {
> -        $uid = $this->uidForAttr('uid', $id);
> +        $uid = $this->uidForAttr(KOLAB_ATTR_SID, $id);
>          if (!$uid) {
>              $uid = $this->uidForAttr('mail', $id);
>          }
> @@ -562,7 +565,7 @@ class Horde_Kolab_Server {
>       */
>      function uidForMailOrIdOrAlias($id)
>      {
> -        $uid = $this->uidForAttr('uid', $id);
> +        $uid = $this->uidForAttr(KOLAB_ATTR_SID, $id);
>          if (!$uid) {
>              $uid = $this->uidForAttr('mail', $id);
>              if (!$uid) {
> diff --git a/horde-webmail/lib/Horde/Kolab/Server/Object.php  
> b/horde-webmail/lib/Horde/Kolab/Server/Object.php
> index 2e5ada2..be9eca9 100644
> --- a/horde-webmail/lib/Horde/Kolab/Server/Object.php
> +++ b/horde-webmail/lib/Horde/Kolab/Server/Object.php
> @@ -26,6 +26,7 @@ define('KOLAB_OBJECT_USER',              
> 'Horde_Kolab_Server_Object_user');
>  define('KOLAB_OBJECT_SERVER',           'Horde_Kolab_Server_Object_server');
>
>  /** Define the possible Kolab object attributes */
> +define('KOLAB_ATTR_OC',           'objectClass');
>  define('KOLAB_ATTR_UID',          'dn');
>  define('KOLAB_ATTR_ID',           'id');
>  define('KOLAB_ATTR_SN',           'sn');
> @@ -35,6 +36,7 @@ define('KOLAB_ATTR_FN',           'fn');
>  define('KOLAB_ATTR_LNFN',         'lnfn');
>  define('KOLAB_ATTR_FNLN',         'fnln');
>  define('KOLAB_ATTR_MAIL',         'mail');
> +define('KOLAB_ATTR_ALIAS',        'alias');
>  define('KOLAB_ATTR_SID',          'uid');
>  define('KOLAB_ATTR_ACL',          'acl');
>  define('KOLAB_ATTR_MEMBER',       'member');
> diff --git a/horde-webmail/lib/Horde/Kolab/Server/Object/address.php  
> b/horde-webmail/lib/Horde/Kolab/Server/Object/address.php
> index 98ed518..bd6128f 100644
> --- a/horde-webmail/lib/Horde/Kolab/Server/Object/address.php
> +++ b/horde-webmail/lib/Horde/Kolab/Server/Object/address.php
> @@ -33,13 +33,6 @@
>  class Horde_Kolab_Server_Object_address extends Horde_Kolab_Server_Object {
>
>      /**
> -     * The LDAP filter to retrieve this object type
> -     *
> -     * @var string
> -     */
> -    var $filter = '(&(objectclass=inetOrgPerson)(!(uid=*))(sn=*))';
> -
> -    /**
>       * The attributes supported by this class
>       *
>       * @var array
> @@ -86,6 +79,32 @@ class Horde_Kolab_Server_Object_address extends  
> Horde_Kolab_Server_Object {
>      );
>
>      /**
> +     * The LDAP filter to retrieve this object type
> +     *
> +     * @return string
> +     */
> +    function getFilter()
> +    {
> +        $criteria = array('AND' => array(
> +                              array('field' => KOLAB_ATTR_SN,
> +                                    'op'    => '=',
> +                                    'test'  => '*'),
> +                              array('field' => KOLAB_ATTR_OC,
> +                                    'op'    => '=',
> +                                    'test'  => KOLAB_OC_INETORGPERSON),
> +                              array('NOT' => array(
> +                                        array('field' => KOLAB_ATTR_SID,
> +                                              'op'    => '=',
> +                                              'test'  => '*'),
> +                                    ),
> +                              ),
> +                          ),
> +        );
> +        return $criteria;
> +    }
> +
> +
> +    /**
>       * Convert the object attributes to a hash.
>       *
>       * @param string $attrs The attributes to return.
> diff --git  
> a/horde-webmail/lib/Horde/Kolab/Server/Object/adminrole.php  
> b/horde-webmail/lib/Horde/Kolab/Server/Object/adminrole.php
> index aea4410..b2571ff 100644
> --- a/horde-webmail/lib/Horde/Kolab/Server/Object/adminrole.php
> +++ b/horde-webmail/lib/Horde/Kolab/Server/Object/adminrole.php
> @@ -32,13 +32,6 @@
>  class Horde_Kolab_Server_Object_adminrole extends  
> Horde_Kolab_Server_Object {
>
>      /**
> -     * The LDAP filter to retrieve this object type
> -     *
> -     * @var string
> -     */
> -    var $filter =  
> '(&(cn=*)(objectClass=inetOrgPerson)(!(uid=manager))(sn=*))';
> -
> -    /**
>       * The attributes supported by this class
>       *
>       * @var array
> @@ -87,6 +80,34 @@ class Horde_Kolab_Server_Object_adminrole extends  
> Horde_Kolab_Server_Object {
>      );
>
>      /**
> +     * The LDAP filter to retrieve this object type
> +     *
> +     * @return string
> +     */
> +    function getFilter()
> +    {
> +        $criteria = array('AND' => array(
> +                              array('field' => KOLAB_ATTR_CN,
> +                                    'op'    => '=',
> +                                    'test'  => '*'),
> +                              array('field' => KOLAB_ATTR_SN,
> +                                    'op'    => '=',
> +                                    'test'  => '*'),
> +                              array('field' => KOLAB_ATTR_OC,
> +                                    'op'    => '=',
> +                                    'test'  => KOLAB_OC_INETORGPERSON),
> +                              array('NOT' => array(
> +                                        array('field' => KOLAB_ATTR_SID,
> +                                              'op'    => '=',
> +                                              'test'  => 'manager'),
> +                                    ),
> +                              ),
> +                          ),
> +        );
> +        return $criteria;
> +    }
> +
> +    /**
>       * Convert the object attributes to a hash.
>       *
>       * @param string $attrs The attributes to return.
> diff --git  
> a/horde-webmail/lib/Horde/Kolab/Server/Object/distlist.php  
> b/horde-webmail/lib/Horde/Kolab/Server/Object/distlist.php
> index 7965e0d..22e096e 100644
> --- a/horde-webmail/lib/Horde/Kolab/Server/Object/distlist.php
> +++ b/horde-webmail/lib/Horde/Kolab/Server/Object/distlist.php
> @@ -34,14 +34,6 @@ require_once 'Horde/Kolab/Server/Object/group.php';
>  class Horde_Kolab_Server_Object_distlist extends  
> Horde_Kolab_Server_Object_group {
>
>      /**
> -     * The LDAP filter to retrieve this object type
> -     *
> -     * @var string
> -     */
> -    var $filter = '(&(objectClass=kolabGroupOfNames)(mail=*))';
> -
> -
> -    /**
>       * The attributes required when creating an object of this class.
>       *
>       * @var array
> @@ -49,4 +41,26 @@ class Horde_Kolab_Server_Object_distlist extends  
> Horde_Kolab_Server_Object_group
>      var $_required_attributes = array(
>          KOLAB_ATTR_MAIL,
>      );
> +
> +    /**
> +     * Return the filter string to retrieve this object type.
> +     *
> +     * @static
> +     *
> +     * @return string The filter to retrieve this object type from  
> the server
> +     *                database.
> +     */
> +    public static function getFilter()
> +    {
> +        $criteria = array('AND' => array(
> +                              array('field' => KOLAB_ATTR_MAIL,
> +                                    'op'    => '=',
> +                                    'test'  => '*'),
> +                              array('field' => KOLAB_ATTR_OC,
> +                                    'op'    => '=',
> +                                    'test'  => KOLAB_OC_KOLABGROUPOFNAMES),
> +                          ),
> +        );
> +        return $criteria;
> +    }
>  };
> diff --git a/horde-webmail/lib/Horde/Kolab/Server/Object/group.php  
> b/horde-webmail/lib/Horde/Kolab/Server/Object/group.php
> index 91c1bd2..f58c905 100644
> --- a/horde-webmail/lib/Horde/Kolab/Server/Object/group.php
> +++ b/horde-webmail/lib/Horde/Kolab/Server/Object/group.php
> @@ -32,13 +32,6 @@
>  class Horde_Kolab_Server_Object_group extends Horde_Kolab_Server_Object {
>
>      /**
> -     * The LDAP filter to retrieve this object type
> -     *
> -     * @var string
> -     */
> -    var $filter = '(objectClass=kolabGroupOfNames)';
> -
> -    /**
>       * The attributes supported by this class
>       *
>       * @var array
> @@ -104,6 +97,22 @@ class Horde_Kolab_Server_Object_group extends  
> Horde_Kolab_Server_Object {
>      }
>
>      /**
> +     * Return the filter string to retrieve this object type.
> +     *
> +     * @return string The filter to retrieve this object type from  
> the server
> +     *                database.
> +     */
> +    public static function getFilter()
> +    {
> +        $criteria = array('AND' => array(array('field' => KOLAB_ATTR_OC,
> +                                               'op'    => '=',
> +                                               'test'  =>  
> KOLAB_OC_KOLABGROUPOFNAMES),
> +                          ),
> +        );
> +        return $criteria;
> +    }
> +
> +    /**
>       * Convert the object attributes to a hash.
>       *
>       * @param string $attrs The attributes to return.
> diff --git a/horde-webmail/lib/Horde/Kolab/Server/Object/server.php  
> b/horde-webmail/lib/Horde/Kolab/Server/Object/server.php
> index 965eb84..740417c 100644
> --- a/horde-webmail/lib/Horde/Kolab/Server/Object/server.php
> +++ b/horde-webmail/lib/Horde/Kolab/Server/Object/server.php
> @@ -32,11 +32,26 @@
>  class Horde_Kolab_Server_Object_server extends Horde_Kolab_Server_Object {
>
>      /**
> -     * The LDAP filter to retrieve this object type
> +     * Return the filter string to retrieve this object type.
>       *
> -     * @var string
> +     * @static
> +     *
> +     * @return string The filter to retrieve this object type from  
> the server
> +     *                database.
>       */
> -    var $filter = '(&((k=kolab))(objectclass=kolab))';
> +    public static function getFilter()
> +    {
> +        $criteria = array('AND' => array(
> +                              array('field' => 'k',
> +                                    'op'    => '=',
> +                                    'test'  => 'kolab'),
> +                              array('field' => KOLAB_ATTR_OC,
> +                                    'op'    => '=',
> +                                    'test'  => KOLAB_OC_KOLAB),
> +                          ),
> +        );
> +        return $criteria;
> +    }
>
>      /**
>       * The attributes supported by this class
> diff --git  
> a/horde-webmail/lib/Horde/Kolab/Server/Object/sharedfolder.php  
> b/horde-webmail/lib/Horde/Kolab/Server/Object/sharedfolder.php
> index 3b68862..b92f07b 100644
> --- a/horde-webmail/lib/Horde/Kolab/Server/Object/sharedfolder.php
> +++ b/horde-webmail/lib/Horde/Kolab/Server/Object/sharedfolder.php
> @@ -33,13 +33,6 @@
>  class Horde_Kolab_Server_Object_sharedfolder extends  
> Horde_Kolab_Server_Object {
>
>      /**
> -     * The LDAP filter to retrieve this object type
> -     *
> -     * @var string
> -     */
> -    var $filter = '(objectClass=kolabSharedFolder)';
> -
> -    /**
>       * The attributes supported by this class
>       *
>       * @var array
> @@ -89,6 +82,22 @@ class Horde_Kolab_Server_Object_sharedfolder  
> extends Horde_Kolab_Server_Object {
>      }
>
>      /**
> +     * Return the filter string to retrieve this object type.
> +     *
> +     * @return string The filter to retrieve this object type from  
> the server
> +     *                database.
> +     */
> +    public static function getFilter()
> +    {
> +        $criteria = array('AND' => array(array('field' => KOLAB_ATTR_OC,
> +                                               'op'    => '=',
> +                                               'test'  =>  
> KOLAB_OC_KOLABSHAREDFOLDER),
> +                          ),
> +        );
> +        return $criteria;
> +    }
> +
> +    /**
>       * Convert the object attributes to a hash.
>       *
>       * @param string $attrs The attributes to return.
> diff --git a/horde-webmail/lib/Horde/Kolab/Server/Object/user.php  
> b/horde-webmail/lib/Horde/Kolab/Server/Object/user.php
> index d4e57a0..b702a4f 100644
> --- a/horde-webmail/lib/Horde/Kolab/Server/Object/user.php
> +++ b/horde-webmail/lib/Horde/Kolab/Server/Object/user.php
> @@ -33,13 +33,6 @@
>  class Horde_Kolab_Server_Object_user extends Horde_Kolab_Server_Object {
>
>      /**
> -     * The LDAP filter to retrieve this object type
> -     *
> -     * @var string
> -     */
> -    var $filter =  
> '(&(objectClass=kolabInetOrgPerson)(uid=*)(mail=*)(sn=*))';
> -
> -    /**
>       * The attributes supported by this class
>       *
>       * @var array
> @@ -154,6 +147,31 @@ class Horde_Kolab_Server_Object_user extends  
> Horde_Kolab_Server_Object {
>      }
>
>      /**
> +     * The LDAP filter to retrieve this object type
> +     *
> +     * @return string
> +     */
> +    function getFilter()
> +    {
> +        $criteria = array('AND' => array(
> +                              array('field' => KOLAB_ATTR_SN,
> +                                    'op'    => '=',
> +                                    'test'  => '*'),
> +                              array('field' => KOLAB_ATTR_MAIL,
> +                                    'op'    => '=',
> +                                    'test'  => '*'),
> +                              array('field' => KOLAB_ATTR_SID,
> +                                    'op'    => '=',
> +                                    'test'  => '*'),
> +                              array('field' => KOLAB_ATTR_OC,
> +                                    'op'    => '=',
> +                                    'test'  => KOLAB_OC_KOLABINETORGPERSON),
> +                          ),
> +        );
> +        return $criteria;
> +    }
> +
> +    /**
>       * Convert the object attributes to a hash.
>       *
>       * @param string $attrs The attributes to return.
> diff --git a/horde-webmail/lib/Horde/Kolab/Server/ldap.php  
> b/horde-webmail/lib/Horde/Kolab/Server/ldap.php
> index a50ba2c..ea73b4f 100644
> --- a/horde-webmail/lib/Horde/Kolab/Server/ldap.php
> +++ b/horde-webmail/lib/Horde/Kolab/Server/ldap.php
> @@ -2,7 +2,7 @@
>  /**
>   * The driver for accessing the Kolab user database stored in LDAP.
>   *
> - * $Horde: framework/Kolab_Server/lib/Horde/Kolab/Server/ldap.php,v  
> 1.2.2.2 2008/08/01 07:56:19 wrobel Exp $
> + * $Horde: framework/Kolab_Server/lib/Horde/Kolab/Server/ldap.php,v  
> 1.2.2.10 2009/02/24 07:39:47 wrobel Exp $
>   *
>   * PHP version 4
>   *
> @@ -210,6 +210,7 @@ class Horde_Kolab_Server_ldap extends  
> Horde_Kolab_Server {
>          }
>
>          if (isset($attrs)) {
> +            $this->mapKeys($attrs);
>              $result = @ldap_read($this->_connection, $dn,  
> '(objectclass=*)', $attrs);
>          } else {
>              $result = @ldap_read($this->_connection, $dn,  
> '(objectclass=*)');
> @@ -220,7 +221,7 @@ class Horde_Kolab_Server_ldap extends  
> Horde_Kolab_Server {
>          }
>          $entry = $this->_firstEntry($result);
>          if (!$entry) {
> -            ldap_free_result($result);
> +            @ldap_free_result($result);
>              return PEAR::raiseError(sprintf(_("LDAP Error: Empty  
> result for: %s."),
>                                              $dn));
>          }
> @@ -229,7 +230,10 @@ class Horde_Kolab_Server_ldap extends  
> Horde_Kolab_Server {
>              return PEAR::raiseError(sprintf(_("LDAP Error: No such  
> dn: %s: %s"),
>                                              $dn, $this->_error()));
>          }
> -        ldap_free_result($result);
> +        @ldap_free_result($result);
> +
> +        $this->unmapAttributes($object);
> +
>          return $object;
>      }
>
> @@ -250,6 +254,8 @@ class Horde_Kolab_Server_ldap extends  
> Horde_Kolab_Server {
>              }
>          }
>
> +        $this->mapAttributes($data);
> +
>          return @ldap_add($this->_connection, $dn, $data);
>      }
>
> @@ -681,9 +687,25 @@ class Horde_Kolab_Server_ldap extends  
> Horde_Kolab_Server {
>       */
>      function mailForIdOrMail($id)
>      {
> -        $filter = '(&(objectClass=kolabInetOrgPerson)(|(uid='.
> -            Horde_LDAP::quote($id) . ')(mail=' .
> -            Horde_LDAP::quote($id) . ')))';
> +        $criteria = array('AND' =>
> +                         array(
> +                             array('field' => KOLAB_ATTR_OC,
> +                                   'op'    => '=',
> +                                   'test'  => KOLAB_OC_KOLABINETORGPERSON),
> +                             array('OR' =>
> +                                   array(
> +                                       array('field' => KOLAB_ATTR_SID,
> +                                             'op'    => '=',
> +                                             'test'  => $id),
> +                                       array('field' => KOLAB_ATTR_MAIL,
> +                                             'op'    => '=',
> +                                             'test'  => $id),
> +                                   ),
> +                             ),
> +                         ),
> +        );
> +        $filter   = $this->searchQuery($criteria);
> +
>          $result = $this->_attrsForFilter($filter, array('mail'),
>                                           KOLAB_SERVER_RESULT_STRICT);
>          if (is_a($result, 'PEAR_Error')) {
> @@ -702,9 +724,24 @@ class Horde_Kolab_Server_ldap extends  
> Horde_Kolab_Server {
>       */
>      function uidForIdOrMail($id)
>      {
> -        $filter = '(&(objectClass=kolabInetOrgPerson)(|(uid='.
> -            Horde_LDAP::quote($id) . ')(mail=' .
> -            Horde_LDAP::quote($id) . ')))';
> +        $criteria = array('AND' =>
> +                         array(
> +                             array('field' => KOLAB_ATTR_OC,
> +                                   'op'    => '=',
> +                                   'test'  => KOLAB_OC_KOLABINETORGPERSON),
> +                             array('OR' =>
> +                                   array(
> +                                       array('field' => KOLAB_ATTR_SID,
> +                                             'op'    => '=',
> +                                             'test'  => $id),
> +                                       array('field' => KOLAB_ATTR_MAIL,
> +                                             'op'    => '=',
> +                                             'test'  => $id),
> +                                   ),
> +                             ),
> +                         ),
> +        );
> +        $filter   = $this->searchQuery($criteria);
>          return $this->_dnForFilter($filter, KOLAB_SERVER_RESULT_STRICT);
>      }
>
> @@ -717,9 +754,25 @@ class Horde_Kolab_Server_ldap extends  
> Horde_Kolab_Server {
>       */
>      function addrsForIdOrMail($id)
>      {
> -        $filter = '(&(objectClass=kolabInetOrgPerson)(|(mail='
> -            . Horde_LDAP::quote($id) . ')(uid='
> -            . Horde_LDAP::quote($id) . ')))';
> +        $criteria = array('AND' =>
> +                         array(
> +                             array('field' => KOLAB_ATTR_OC,
> +                                   'op'    => '=',
> +                                   'test'  => KOLAB_OC_KOLABINETORGPERSON),
> +                             array('OR' =>
> +                                   array(
> +                                       array('field' => KOLAB_ATTR_SID,
> +                                             'op'    => '=',
> +                                             'test'  => $id),
> +                                       array('field' => KOLAB_ATTR_MAIL,
> +                                             'op'    => '=',
> +                                             'test'  => $id),
> +                                   ),
> +                             ),
> +                         ),
> +        );
> +        $filter   = $this->searchQuery($criteria);
> +
>          $result = $this->_attrsForFilter($filter, array('mail', 'alias'),
>




More information about the devel mailing list