Overview

Packages

  • Kolab
    • Server

Classes

  • Horde_Kolab_Server_Composite
  • Horde_Kolab_Server_Connection_File
  • Horde_Kolab_Server_Connection_Mock
  • Horde_Kolab_Server_Connection_Mock_Ldap
  • Horde_Kolab_Server_Connection_Mock_Search
  • Horde_Kolab_Server_Connection_Simpleldap
  • Horde_Kolab_Server_Connection_Splittedldap
  • Horde_Kolab_Server_Decorator_Clean
  • Horde_Kolab_Server_Decorator_Count
  • Horde_Kolab_Server_Decorator_Log
  • Horde_Kolab_Server_Decorator_Map
  • Horde_Kolab_Server_Exception
  • Horde_Kolab_Server_Exception_Bindfailed
  • Horde_Kolab_Server_Exception_Novalue
  • Horde_Kolab_Server_Factory
  • Horde_Kolab_Server_Ldap
  • Horde_Kolab_Server_Ldap_Changes
  • Horde_Kolab_Server_Ldap_Filtered
  • Horde_Kolab_Server_Ldap_Standard
  • Horde_Kolab_Server_List_Base
  • Horde_Kolab_Server_Object_Attribute_Base
  • Horde_Kolab_Server_Object_Attribute_Createtimestamp
  • Horde_Kolab_Server_Object_Attribute_Createtimestampdate
  • Horde_Kolab_Server_Object_Attribute_Decorator
  • Horde_Kolab_Server_Object_Attribute_Default
  • Horde_Kolab_Server_Object_Attribute_Empty
  • Horde_Kolab_Server_Object_Attribute_External
  • Horde_Kolab_Server_Object_Attribute_Field
  • Horde_Kolab_Server_Object_Attribute_Firstnamelastname
  • Horde_Kolab_Server_Object_Attribute_Guid
  • Horde_Kolab_Server_Object_Attribute_Id
  • Horde_Kolab_Server_Object_Attribute_Internal
  • Horde_Kolab_Server_Object_Attribute_Locked
  • Horde_Kolab_Server_Object_Attribute_Modifytimestamp
  • Horde_Kolab_Server_Object_Attribute_Modifytimestampdate
  • Horde_Kolab_Server_Object_Attribute_Objectclass
  • Horde_Kolab_Server_Object_Attribute_Openldapaci
  • Horde_Kolab_Server_Object_Attribute_Required
  • Horde_Kolab_Server_Object_Attribute_Single
  • Horde_Kolab_Server_Object_Attribute_Value
  • Horde_Kolab_Server_Object_Attribute_Writelock
  • Horde_Kolab_Server_Object_Base
  • Horde_Kolab_Server_Object_Factory
  • Horde_Kolab_Server_Object_Groupofnames
  • Horde_Kolab_Server_Object_Hash
  • Horde_Kolab_Server_Object_Inetorgperson
  • Horde_Kolab_Server_Object_Kolab
  • Horde_Kolab_Server_Object_Kolab_Address
  • Horde_Kolab_Server_Object_Kolab_Administrator
  • Horde_Kolab_Server_Object_Kolab_Adminrole
  • Horde_Kolab_Server_Object_Kolab_Distlist
  • Horde_Kolab_Server_Object_Kolab_Domainmaintainer
  • Horde_Kolab_Server_Object_Kolab_Maintainer
  • Horde_Kolab_Server_Object_Kolab_User
  • Horde_Kolab_Server_Object_Kolabgermanbankarrangement
  • Horde_Kolab_Server_Object_Kolabgroupofnames
  • Horde_Kolab_Server_Object_Kolabinetorgperson
  • Horde_Kolab_Server_Object_Kolabpop3account
  • Horde_Kolab_Server_Object_Kolabsharedfolder
  • Horde_Kolab_Server_Object_Mcached
  • Horde_Kolab_Server_Object_Organizationalperson
  • Horde_Kolab_Server_Object_Person
  • Horde_Kolab_Server_Object_Top
  • Horde_Kolab_Server_Objects_Base
  • Horde_Kolab_Server_Query_Element_And
  • Horde_Kolab_Server_Query_Element_Approx
  • Horde_Kolab_Server_Query_Element_Begins
  • Horde_Kolab_Server_Query_Element_Contains
  • Horde_Kolab_Server_Query_Element_Ends
  • Horde_Kolab_Server_Query_Element_Equals
  • Horde_Kolab_Server_Query_Element_Greater
  • Horde_Kolab_Server_Query_Element_Group
  • Horde_Kolab_Server_Query_Element_Less
  • Horde_Kolab_Server_Query_Element_Mapped
  • Horde_Kolab_Server_Query_Element_Not
  • Horde_Kolab_Server_Query_Element_Or
  • Horde_Kolab_Server_Query_Element_Single
  • Horde_Kolab_Server_Query_Ldap
  • Horde_Kolab_Server_Result_Ldap
  • Horde_Kolab_Server_Schema_Base
  • Horde_Kolab_Server_Schema_Decorator_Cache
  • Horde_Kolab_Server_Search_Base
  • Horde_Kolab_Server_Search_Operation_Addressesforuidormail
  • Horde_Kolab_Server_Search_Operation_Attributes
  • Horde_Kolab_Server_Search_Operation_Base
  • Horde_Kolab_Server_Search_Operation_Children
  • Horde_Kolab_Server_Search_Operation_Constraint_Single
  • Horde_Kolab_Server_Search_Operation_Constraint_Strict
  • Horde_Kolab_Server_Search_Operation_Groupsformember
  • Horde_Kolab_Server_Search_Operation_Guid
  • Horde_Kolab_Server_Search_Operation_Guidforalias
  • Horde_Kolab_Server_Search_Operation_Guidforcn
  • Horde_Kolab_Server_Search_Operation_Guidforkolabusers
  • Horde_Kolab_Server_Search_Operation_Guidformail
  • Horde_Kolab_Server_Search_Operation_Guidformailoralias
  • Horde_Kolab_Server_Search_Operation_Guidforuid
  • Horde_Kolab_Server_Search_Operation_Guidforuidormail
  • Horde_Kolab_Server_Search_Operation_Guidforuidormailoralias
  • Horde_Kolab_Server_Search_Operation_Mailforuidormail
  • Horde_Kolab_Server_Search_Operation_Restrictgroups
  • Horde_Kolab_Server_Search_Operation_Restrictkolab
  • Horde_Kolab_Server_Structure_Attribute_Double
  • Horde_Kolab_Server_Structure_Attribute_Value
  • Horde_Kolab_Server_Structure_Base
  • Horde_Kolab_Server_Structure_Kolab
  • Horde_Kolab_Server_Structure_Ldap

Interfaces

  • Horde_Kolab_Server_Connection_Interface
  • Horde_Kolab_Server_Interface
  • Horde_Kolab_Server_List_Interface
  • Horde_Kolab_Server_Object_Attribute_Interface
  • Horde_Kolab_Server_Object_Interface
  • Horde_Kolab_Server_Object_Searches
  • Horde_Kolab_Server_Objects_Interface
  • Horde_Kolab_Server_Query_Element_Interface
  • Horde_Kolab_Server_Query_Interface
  • Horde_Kolab_Server_Result_Interface
  • Horde_Kolab_Server_Schema_Interface
  • Horde_Kolab_Server_Search_Interface
  • Horde_Kolab_Server_Search_Operation_Interface
  • Horde_Kolab_Server_Structure_Attribute_Interface
  • Horde_Kolab_Server_Structure_Interface
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * A standard Kolab user.
  4:  *
  5:  * PHP version 5
  6:  *
  7:  * @category Kolab
  8:  * @package  Kolab_Server
  9:  * @author   Gunnar Wrobel <wrobel@pardus.de>
 10:  * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
 11:  * @link     http://pear.horde.org/index.php?package=Kolab_Server
 12:  */
 13: 
 14: /**
 15:  * This class provides methods to deal with Kolab users stored in
 16:  * the Kolab db.
 17:  *
 18:  * Copyright 2008-2012 Horde LLC (http://www.horde.org/)
 19:  *
 20:  * See the enclosed file COPYING for license information (LGPL). If you
 21:  * did not receive this file, see http://www.horde.org/licenses/lgpl21.
 22:  *
 23:  * @category Kolab
 24:  * @package  Kolab_Server
 25:  * @author   Gunnar Wrobel <wrobel@pardus.de>
 26:  * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
 27:  * @link     http://pear.horde.org/index.php?package=Kolab_Server
 28:  */
 29: class Horde_Kolab_Server_Object_Kolab_User extends Horde_Kolab_Server_Object_Kolabinetorgperson
 30: {
 31: 
 32:     /** Define attributes specific to this object type */
 33: 
 34:     /** The user type */
 35:     const ATTRIBUTE_USERTYPE = 'usertype';
 36: 
 37:     /** The first name */
 38:     const ATTRIBUTE_FN = 'fn';
 39: 
 40:     /** Define the possible Kolab user types */
 41:     const USERTYPE_STANDARD = 0;
 42:     const USERTYPE_INTERNAL = 1;
 43:     const USERTYPE_GROUP    = 2;
 44:     const USERTYPE_RESOURCE = 3;
 45: 
 46:     /**
 47:      * A structure to initialize the attribute structure for this class.
 48:      *
 49:      * @var array
 50:      */
 51: /*     static public $init_attributes = array( */
 52: /*         'derived' => array( */
 53: /*             self::ATTRIBUTE_USERTYPE => array(), */
 54: /*             self::ATTRIBUTE_FN => array(), */
 55: /*         ), */
 56: /*         'required' => array( */
 57: /*             self::ATTRIBUTE_USERPASSWORD, */
 58: /*         ), */
 59: /*     ); */
 60: 
 61:     /**
 62:      * Return the filter string to retrieve this object type.
 63:      *
 64:      * @return string The filter to retrieve this object type from the server
 65:      *                database.
 66:      */
 67:     public static function getFilter()
 68:     {
 69:         $criteria = array('AND' => array(
 70:                               array('field' => self::ATTRIBUTE_SN,
 71:                                     'op'    => 'any'),
 72:                               array('field' => self::ATTRIBUTE_MAIL,
 73:                                     'op'    => 'any'),
 74:                               array('field' => self::ATTRIBUTE_SID,
 75:                                     'op'    => 'any'),
 76:                               array('field' => self::ATTRIBUTE_OC,
 77:                                     'op'    => '=',
 78:                                     'test'  => self::OBJECTCLASS_KOLABINETORGPERSON),
 79:                           ),
 80:         );
 81:         return $criteria;
 82:     }
 83: 
 84:     /**
 85:      * Derive an attribute value.
 86:      *
 87:      * @param string $attr The attribute to derive.
 88:      *
 89:      * @return mixed The value of the attribute.
 90:      */
 91:     protected function derive($attr)
 92:     {
 93:         switch ($attr) {
 94:         case self::ATTRIBUTE_USERTYPE:
 95:             if (strpos($this->_uid, 'cn=internal')) {
 96:                 return self::USERTYPE_INTERNAL;
 97:             } else if (strpos($this->_uid, 'cn=group')) {
 98:                 return self::USERTYPE_GROUP;
 99:             } else if (strpos($this->_uid, 'cn=resource')) {
100:                 return self::USERTYPE_RESOURCE;
101:             } else {
102:                 return self::USERTYPE_STANDARD;
103:             }
104:         case self::ATTRIBUTE_FN:
105:             return $this->getFn();
106:         default:
107:             return parent::derive($attr);
108:         }
109:     }
110: 
111:     /**
112:      * Convert the object attributes to a hash.
113:      *
114:      * @param string $attrs The attributes to return.
115:      *
116:      * @return array|PEAR_Error The hash representing this object.
117:      */
118:     public function toHash($attrs = null)
119:     {
120:         if (!isset($attrs)) {
121:             $attrs = array(
122:                 self::ATTRIBUTE_SID,
123:                 self::ATTRIBUTE_FN,
124:                 self::ATTRIBUTE_MAIL,
125:                 self::ATTRIBUTE_USERTYPE,
126:             );
127:         }
128:         return parent::toHash($attrs);
129:     }
130: 
131:     /**
132:      * Get the "first name" attribute of this object
133:      *
134:      * @todo: This should get refactored to be combined with the Id value.
135:      *
136:      * @return string the "first name" of this object
137:      */
138:     protected function getFn()
139:     {
140:         $sn = $this->_get(self::ATTRIBUTE_SN, true);
141:         $cn = $this->_get(self::ATTRIBUTE_CN, true);
142:         return trim(substr($cn, 0, strlen($cn) - strlen($sn)));
143:     }
144: 
145:     /**
146:      * Get the groups for this object
147:      *
148:      * @return mixed|PEAR_Error An array of group ids, false if no groups were
149:      *                          found.
150:      */
151:     public function getGroups()
152:     {
153:         return $this->server->getGroups($this->uid);
154:     }
155: 
156:     /**
157:      * Get the group mail addresses for this object
158:      *
159:      * @return mixed|PEAR_Error An array of group addresses, false if no groups were
160:      *                          found.
161:      */
162:     function getGroupAddresses()
163:     {
164:         return $this->server->getGroupAddresses($this->uid);
165:     }
166: };
167: 
API documentation generated by ApiGen