{
/** Define attributes specific to this object type */
+
+ /** The global ID of this object on the server */
const ATTRIBUTE_UID = 'dn';
+
+ /** The ID part of the UID */
const ATTRIBUTE_ID = 'id';
- const ATTRIBUTE_SID = 'uid';
- const ATTRIBUTE_CN = 'cn';
- const ATTRIBUTE_SN = 'sn';
- const ATTRIBUTE_GIVENNAME = 'givenName';
- const ATTRIBUTE_FN = 'fn';
- const ATTRIBUTE_MAIL = 'mail';
- const ATTRIBUTE_DELEGATE = 'kolabDelegate';
- const ATTRIBUTE_MEMBER = 'member';
- const ATTRIBUTE_VISIBILITY = 'visible';
- const ATTRIBUTE_LNFN = 'lnfn';
- const ATTRIBUTE_FNLN = 'fnln';
- const ATTRIBUTE_DOMAIN = 'domain';
- const ATTRIBUTE_DELETED = 'kolabDeleteFlag';
- const ATTRIBUTE_FBPAST = 'kolabFreeBusyPast';
- const ATTRIBUTE_FBFUTURE = 'kolabFreeBusyFuture';
- const ATTRIBUTE_FOLDERTYPE = 'kolabFolderType';
- const ATTRIBUTE_HOMESERVER = 'kolabHomeServer';
- const ATTRIBUTE_FREEBUSYHOST = 'kolabFreeBusyServer';
- const ATTRIBUTE_IMAPHOST = 'kolabImapServer';
- const ATTRIBUTE_IPOLICY = 'kolabInvitationPolicy';
+
+ /** The attribute holding the object classes */
+ const ATTRIBUTE_OC = 'objectClass';
/** Define the possible Kolab object classes */
- const OBJECTCLASS_TOP = 'top';
- const OBJECTCLASS_INETORGPERSON = 'inetOrgPerson';
- const OBJECTCLASS_KOLABINETORGPERSON = 'kolabInetOrgPerson';
- const OBJECTCLASS_HORDEPERSON = 'hordePerson';
- const OBJECTCLASS_KOLABGROUPOFNAMES = 'kolabGroupOfNames';
- const OBJECTCLASS_KOLABSHAREDFOLDER = 'kolabSharedFolder';
+ const OBJECTCLASS_TOP = 'top';
/**
* Link into the Kolab server.
/** FIXME: Add an attribute cache for the get() function */
/**
- * The LDAP filter to retrieve this object type.
- *
- * @var string
- */
- public static $filter = '';
-
- /**
- * The group the UID must be member of so that this object really
- * matches this class type. This may not include the root UID.
- *
- * @var string
- */
- protected $required_group;
-
- /**
* The LDAP attributes supported by this class.
*
* @var array
public $supported_attributes = false;
/**
- * Attributes derived from the LDAP values.
+ * Attributes derived from other object attributes.
*
* @var array
*/
*
* @var array
*/
- protected $object_classes = array();
+ protected $object_classes = array(
+ self::OBJECTCLASS_TOP
+ );
/**
* Sort by this attributes (must be a LDAP attribute).
*
* @var string
*/
- var $sort_by = self::ATTRIBUTE_SN;
+ var $sort_by = self::ATTRIBUTE_UID;
/**
* Initialize the Kolab Object. Provide either the UID or a
}
/**
+ * 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()
+ {
+ return '(&(' . self::ATTRIBUTE_OC . '=' . self::OBJECTCLASS_TOP . '))';
+ }
+
+ /**
* Does the object exist?
*
* @return NULL
protected function read()
{
$this->_cache = $this->db->read($this->uid,
- $this->supported_attributes);
+ $this->supported_attributes);
}
/**
public function get($attr, $single = true)
{
if ($attr != self::ATTRIBUTE_UID) {
+ // FIXME: This wont work this way.
if ($this->supported_attributes !== false
&& !in_array($attr, $this->supported_attributes)
&& !in_array($attr, $this->derived_attributes)) {
switch ($attr) {
case self::ATTRIBUTE_UID:
return $this->uid;
- case self::ATTRIBUTE_FN:
- return $this->getFn();
default:
return $this->_get($attr, $single);
}
{
switch ($attr) {
case self::ATTRIBUTE_ID:
- $result = split(',', $this->uid);
- if (substr($result[0], 0, 3) == 'cn=') {
- return substr($result[0], 3);
- } else {
- return $result[0];
- }
- case self::ATTRIBUTE_LNFN:
- $gn = $this->_get(self::ATTRIBUTE_GIVENNAME, true);
- $sn = $this->_get(self::ATTRIBUTE_SN, true);
- return sprintf('%s, %s', $sn, $gn);
- case self::ATTRIBUTE_FNLN:
- $gn = $this->_get(self::ATTRIBUTE_GIVENNAME, true);
- $sn = $this->_get(self::ATTRIBUTE_SN, true);
- return sprintf('%s %s', $gn, $sn);
- default:
- return false;
+ return substr($this->uid, 0,
+ strlen($this->uid) - strlen($this->db->getBaseUid()) - 1);
}
}
}
/**
- * Get the "first name" attribute of this object
- *
- * FIXME: This should get refactored to be combined with the Id value.
- *
- * @return string the "first name" of this object
- */
- protected function getFn()
- {
- $sn = $this->_get(self::ATTRIBUTE_SN, true);
- $cn = $this->_get(self::ATTRIBUTE_CN, true);
- return trim(substr($cn, 0, strlen($cn) - strlen($sn)));
- }
-
- /**
- * Get the groups for this object
- *
- * @return mixed An array of group ids or a PEAR Error in case of
- * an error.
- */
- public function getGroups()
- {
- return array();
- }
-
- /**
- * Returns the server url of the given type for this user.
- *
- * This method can be used to encapsulate multidomain support.
- *
- * @param string $server_type The type of server URL that should be returned.
- *
- * @return string|PEAR_Error The server url or empty.
- */
- public function getServer($server_type)
- {
- throw new Horde_Kolab_Server_Exception('Not implemented!');
- }
-
- /**
* Generates an ID for the given information.
*
* @param array $info The data of the object.
*
* @static
*
- * @return string|PEAR_Error The ID.
+ * @return string The ID.
*/
public static function generateId($info)
{
- $id_mapfields = array('givenName', 'sn');
- $id_format = '%s %s';
-
- $fieldarray = array();
- foreach ($id_mapfields as $mapfield) {
- if (isset($info[$mapfield])) {
- $fieldarray[] = $info[$mapfield];
- } else {
- $fieldarray[] = '';
- }
- }
-
- return trim(vsprintf($id_format, $fieldarray), " \t\n\r\0\x0B,");
+ return hash('sha256', uniqid(mt_rand(), true));
}
/**
}
}
- $info['objectClass'] = $this->object_classes;
+ $info[self::ATTRIBUTE_OC] = $this->object_classes;
$result = $this->db->save($this->uid, $info);
if ($result === false || is_a($result, 'PEAR_Error')) {
* @license http://www.fsf.org/copyleft/lgpl.html LGPL
* @link http://pear.horde.org/index.php?package=Kolab_Server
*/
-class Horde_Kolab_Server_Object_address extends Horde_Kolab_Server_Object
+class Horde_Kolab_Server_Object_address extends Horde_Kolab_Server_Object_base
{
/**
- * The LDAP filter to retrieve this object type
- *
- * @var string
- */
- public static $filter = '(&(objectclass=inetOrgPerson)(!(uid=*))(sn=*))';
-
- /**
* Attributes derived from the LDAP values.
*
* @var array
*/
public $derived_attributes = array(
- Horde_Kolab_Server_Object::ATTRIBUTE_LNFN,
- Horde_Kolab_Server_Object::ATTRIBUTE_FNLN,
+ self::ATTRIBUTE_LNFN,
+ self::ATTRIBUTE_FNLN,
);
/**
* @var array
*/
protected $object_classes = array(
- Horde_Kolab_Server_Object::OBJECTCLASS_TOP,
- Horde_Kolab_Server_Object::OBJECTCLASS_INETORGPERSON,
- Horde_Kolab_Server_Object::OBJECTCLASS_KOLABINETORGPERSON,
+ self::OBJECTCLASS_TOP,
+ self::OBJECTCLASS_INETORGPERSON,
+ self::OBJECTCLASS_KOLABINETORGPERSON,
);
/**
+ * 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()
+ {
+ return '(&(objectclass=inetOrgPerson)(!(uid=*))(sn=*))';
+ }
+
+ /**
* Convert the object attributes to a hash.
*
* @param string $attrs The attributes to return.
{
if (!isset($attrs)) {
$attrs = array(
- Horde_Kolab_Server_Object::ATTRIBUTE_LNFN,
+ self::ATTRIBUTE_LNFN,
);
}
return parent::toHash($attrs);
* @license http://www.fsf.org/copyleft/lgpl.html LGPL
* @link http://pear.horde.org/index.php?package=Kolab_Server
*/
-class Horde_Kolab_Server_Object_adminrole extends Horde_Kolab_Server_Object
+class Horde_Kolab_Server_Object_adminrole extends Horde_Kolab_Server_Object_base
{
/**
- * The LDAP filter to retrieve this object type
- *
- * @var string
- */
- public static $filter = '(&(cn=*)(objectClass=inetOrgPerson)(!(uid=manager))(sn=*))';
-
- /**
* Attributes derived from the LDAP values.
*
* @var array
*/
public $derived_attributes = array(
- Horde_Kolab_Server_Object::ATTRIBUTE_ID,
- Horde_Kolab_Server_Object::ATTRIBUTE_LNFN,
+ self::ATTRIBUTE_ID,
+ self::ATTRIBUTE_LNFN,
);
/**
* @var array
*/
protected $object_classes = array(
- Horde_Kolab_Server_Object::OBJECTCLASS_TOP,
- Horde_Kolab_Server_Object::OBJECTCLASS_INETORGPERSON,
- Horde_Kolab_Server_Object::OBJECTCLASS_KOLABINETORGPERSON,
+ self::OBJECTCLASS_TOP,
+ self::OBJECTCLASS_INETORGPERSON,
+ self::OBJECTCLASS_KOLABINETORGPERSON,
);
/**
protected $required_group;
/**
+ * 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()
+ {
+ return '(&(cn=*)(objectClass=inetOrgPerson)(!(uid=manager))(sn=*))';
+ }
+
+ /**
* Convert the object attributes to a hash.
*
* @param string $attrs The attributes to return.
{
if (!isset($attrs)) {
$attrs = array(
- Horde_Kolab_Server_Object::ATTRIBUTE_SID,
- Horde_Kolab_Server_Object::ATTRIBUTE_LNFN,
+ self::ATTRIBUTE_SID,
+ self::ATTRIBUTE_LNFN,
);
}
return parent::toHash($attrs);
$parts = split(',', $this->required_group);
list($groupname) = sscanf($parts[0], 'cn=%s');
- $result = $this->db->add(array(Horde_Kolab_Server_Object::ATTRIBUTE_CN => $groupname,
+ $result = $this->db->add(array(self::ATTRIBUTE_CN => $groupname,
'type' => 'Horde_Kolab_Server_Object_group',
- Horde_Kolab_Server_Object::ATTRIBUTE_MEMBER => $members,
- Horde_Kolab_Server_Object::ATTRIBUTE_VISIBILITY => false));
+ self::ATTRIBUTE_MEMBER => $members,
+ self::ATTRIBUTE_VISIBILITY => false));
if (is_a($result, 'PEAR_Error')) {
return $result;
}
if ($result === false) {
$members = $admin_group->getMembers();
$members[] = $this->uid;
- $admin_group->save(array(Horde_Kolab_Server_Object::ATTRIBUTE_MEMBER => $members));
+ $admin_group->save(array(self::ATTRIBUTE_MEMBER => $members));
}
}
return parent::save($info);
--- /dev/null
+<?php
+/**
+ * A bsaic object representation.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package Kolab_Server
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * This class provides basic methods common to all Kolab server objects.
+ *
+ * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package Kolab_Server
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Server
+ */
+class Horde_Kolab_Server_Object_base extends Horde_Kolab_Server_Object
+{
+
+ const ATTRIBUTE_SID = 'uid';
+ const ATTRIBUTE_CN = 'cn';
+ const ATTRIBUTE_SN = 'sn';
+ const ATTRIBUTE_GIVENNAME = 'givenName';
+ const ATTRIBUTE_FN = 'fn';
+ const ATTRIBUTE_MAIL = 'mail';
+ const ATTRIBUTE_DELEGATE = 'kolabDelegate';
+ const ATTRIBUTE_MEMBER = 'member';
+ const ATTRIBUTE_VISIBILITY = 'visible';
+ const ATTRIBUTE_LNFN = 'lnfn';
+ const ATTRIBUTE_FNLN = 'fnln';
+ const ATTRIBUTE_DOMAIN = 'domain';
+ const ATTRIBUTE_DELETED = 'kolabDeleteFlag';
+ const ATTRIBUTE_FBPAST = 'kolabFreeBusyPast';
+ const ATTRIBUTE_FBFUTURE = 'kolabFreeBusyFuture';
+ const ATTRIBUTE_FOLDERTYPE = 'kolabFolderType';
+ const ATTRIBUTE_HOMESERVER = 'kolabHomeServer';
+ const ATTRIBUTE_FREEBUSYHOST = 'kolabFreeBusyServer';
+ const ATTRIBUTE_IMAPHOST = 'kolabImapServer';
+ const ATTRIBUTE_IPOLICY = 'kolabInvitationPolicy';
+
+ const OBJECTCLASS_INETORGPERSON = 'inetOrgPerson';
+ const OBJECTCLASS_KOLABINETORGPERSON = 'kolabInetOrgPerson';
+ const OBJECTCLASS_HORDEPERSON = 'hordePerson';
+ const OBJECTCLASS_KOLABGROUPOFNAMES = 'kolabGroupOfNames';
+ const OBJECTCLASS_KOLABSHAREDFOLDER = 'kolabSharedFolder';
+
+ /**
+ * The group the UID must be member of so that this object really
+ * matches this class type. This may not include the root UID.
+ *
+ * @var string
+ */
+ protected $required_group;
+
+ /**
+ * The attributes supported by this class
+ *
+ * @var array
+ */
+/* public $supported_attributes = array( */
+/* self::ATTRIBUTE_FBPAST, */
+/* ); */
+
+
+ /**
+ * Derive an attribute value.
+ *
+ * @param string $attr The attribute to derive.
+ *
+ * @return mixed The value of the attribute.
+ */
+ protected function derive($attr)
+ {
+ switch ($attr) {
+ case self::ATTRIBUTE_ID:
+ $result = split(',', $this->uid);
+ if (substr($result[0], 0, 3) == 'cn=') {
+ return substr($result[0], 3);
+ } else {
+ return $result[0];
+ }
+ default:
+ return parent::derive($attr);
+ }
+ }
+
+ /**
+ * Generates an ID for the given information.
+ *
+ * @param array $info The data of the object.
+ *
+ * @static
+ *
+ * @return string|PEAR_Error The ID.
+ */
+ public static function generateId($info)
+ {
+ $id_mapfields = array('givenName', 'sn');
+ $id_format = '%s %s';
+
+ $fieldarray = array();
+ foreach ($id_mapfields as $mapfield) {
+ if (isset($info[$mapfield])) {
+ $fieldarray[] = $info[$mapfield];
+ } else {
+ $fieldarray[] = '';
+ }
+ }
+
+ return trim(vsprintf($id_format, $fieldarray), " \t\n\r\0\x0B,");
+ }
+
+}
\ No newline at end of file
*/
class Horde_Kolab_Server_Object_distlist extends Horde_Kolab_Server_Object_group
{
-
/**
- * The LDAP filter to retrieve this object type
+ * Return the filter string to retrieve this object type.
+ *
+ * @static
*
- * @var string
+ * @return string The filter to retrieve this object type from the server
+ * database.
*/
- public static $filter = '(&(objectClass=kolabGroupOfNames)(mail=*))';
+ public static function getFilter()
+ {
+ return '(&(objectClass=kolabGroupOfNames)(mail=*))';
+ }
};
* @var array
*/
public $derived_attributes = array(
- Horde_Kolab_Server_Object::ATTRIBUTE_ID,
- Horde_Kolab_Server_Object::ATTRIBUTE_LNFN,
- Horde_Kolab_Server_Object::ATTRIBUTE_DOMAIN,
+ self::ATTRIBUTE_ID,
+ self::ATTRIBUTE_LNFN,
+ self::ATTRIBUTE_DOMAIN,
);
/**
{
if (!isset($attrs)) {
$attrs = array(
- Horde_Kolab_Server_Object::ATTRIBUTE_SID,
- Horde_Kolab_Server_Object::ATTRIBUTE_LNFN,
- Horde_Kolab_Server_Object::ATTRIBUTE_DOMAIN,
+ self::ATTRIBUTE_SID,
+ self::ATTRIBUTE_LNFN,
+ self::ATTRIBUTE_DOMAIN,
);
}
return parent::toHash($attrs);
*/
public function save($info)
{
- foreach ($info[Horde_Kolab_Server_Object::ATTRIBUTE_DOMAIN] as $domain) {
+ foreach ($info[self::ATTRIBUTE_DOMAIN] as $domain) {
$domain_uid = sprintf('cn=%s,cn=domain,cn=internal,%s',
$domain, $this->db->getBaseUid());
}
if (!$domain_group->exists()) {
$members = array($this->uid);
- $domain_group->save(array(Horde_Kolab_Server_Object::ATTRIBUTE_CN => $domain,
- Horde_Kolab_Server_Object::ATTRIBUTE_MEMBER => $members));
+ $domain_group->save(array(self::ATTRIBUTE_CN => $domain,
+ self::ATTRIBUTE_MEMBER => $members));
} else {
$result = $domain_group->isMember($this->uid);
if (is_a($result, 'PEAR_Error')) {
if ($result === false) {
$members = $domain_group->getMembers();
$members[] = $this->uid;
- $domain_group->save(array(Horde_Kolab_Server_Object::ATTRIBUTE_MEMBER => $members));
+ $domain_group->save(array(self::ATTRIBUTE_MEMBER => $members));
}
}
}
* @license http://www.fsf.org/copyleft/lgpl.html LGPL
* @link http://pear.horde.org/index.php?package=Kolab_Server
*/
-class Horde_Kolab_Server_Object_group extends Horde_Kolab_Server_Object
+class Horde_Kolab_Server_Object_group extends Horde_Kolab_Server_Object_base
{
/**
- * The LDAP filter to retrieve this object type
- *
- * @var string
- */
- public static $filter = '(objectClass=kolabGroupOfNames)';
-
- /**
* Attributes derived from the LDAP values.
*
* @var array
*/
public $derived_attributes = array(
- Horde_Kolab_Server_Object::ATTRIBUTE_ID,
- Horde_Kolab_Server_Object::ATTRIBUTE_VISIBILITY,
+ self::ATTRIBUTE_ID,
+ self::ATTRIBUTE_VISIBILITY,
);
/**
* @var array
*/
protected $object_classes = array(
- Horde_Kolab_Server_Object::OBJECTCLASS_TOP,
- Horde_Kolab_Server_Object::OBJECTCLASS_INETORGPERSON,
- Horde_Kolab_Server_Object::OBJECTCLASS_KOLABGROUPOFNAMES,
+ self::OBJECTCLASS_TOP,
+ self::OBJECTCLASS_INETORGPERSON,
+ self::OBJECTCLASS_KOLABGROUPOFNAMES,
);
/**
*
* @var string
*/
- public $sort_by = Horde_Kolab_Server_Object::ATTRIBUTE_MAIL;
+ public $sort_by = self::ATTRIBUTE_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()
+ {
+ return '(objectClass=kolabGroupOfNames)';
+ }
/**
* Derive an attribute value.
{
if (!isset($attrs)) {
$attrs = array(
- Horde_Kolab_Server_Object::ATTRIBUTE_ID,
- Horde_Kolab_Server_Object::ATTRIBUTE_MAIL,
- Horde_Kolab_Server_Object::ATTRIBUTE_VISIBILITY,
+ self::ATTRIBUTE_ID,
+ self::ATTRIBUTE_MAIL,
+ self::ATTRIBUTE_VISIBILITY,
);
}
return parent::toHash($attrs);
*/
public function getMembers()
{
- return $this->_get(Horde_Kolab_Server_Object::ATTRIBUTE_MEMBER, false);
+ return $this->_get(self::ATTRIBUTE_MEMBER, false);
}
/**
return $members;
}
if (!in_array($member, $members)) {
- $this->_cache[Horde_Kolab_Server_Object::ATTRIBUTE_MEMBER][] = $member;
+ $this->_cache[self::ATTRIBUTE_MEMBER][] = $member;
} else {
return PEAR::raiseError(_("The UID %s is already a member of the group %s!"),
$member, $this->_uid);
return $members;
}
if (in_array($member, $members)) {
- $this->_cache[Horde_Kolab_Server_Object::ATTRIBUTE_MEMBER] =
- array_diff($this->_cache[Horde_Kolab_Server_Object::ATTRIBUTE_MEMBER],
+ $this->_cache[self::ATTRIBUTE_MEMBER] =
+ array_diff($this->_cache[self::ATTRIBUTE_MEMBER],
array($member));
} else {
return PEAR::raiseError(_("The UID %s is no member of the group %s!"),
* @license http://www.fsf.org/copyleft/lgpl.html LGPL
* @link http://pear.horde.org/index.php?package=Kolab_Server
*/
-class Horde_Kolab_Server_Object_server extends Horde_Kolab_Server_Object
+class Horde_Kolab_Server_Object_server extends Horde_Kolab_Server_Object_base
{
/**
- * The LDAP filter to retrieve this object type
- *
- * @var string
- */
- public static $filter = '(&((k=kolab))(objectclass=kolab))';
-
- /**
* The attributes supported by this class
*
* @var array
*/
public $supported_attributes = array(
- Horde_Kolab_Server_Object::ATTRIBUTE_FBPAST,
+ self::ATTRIBUTE_FBPAST,
);
+ /**
+ * 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()
+ {
+ return '(&((k=kolab))(objectclass=kolab))';
+ }
}
\ No newline at end of file
* @license http://www.fsf.org/copyleft/lgpl.html LGPL
* @link http://pear.horde.org/index.php?package=Kolab_Server
*/
-class Horde_Kolab_Server_Object_sharedfolder extends Horde_Kolab_Server_Object
+class Horde_Kolab_Server_Object_sharedfolder extends Horde_Kolab_Server_Object_base
{
/**
- * The LDAP filter to retrieve this object type
- *
- * @var string
- */
- public static $filter = '(objectClass=kolabSharedFolder)';
-
- /**
* The ldap classes for this type of object.
*
* @var array
*/
protected $object_classes = array(
- Horde_Kolab_Server_Object::OBJECTCLASS_TOP,
- Horde_Kolab_Server_Object::OBJECTCLASS_KOLABSHAREDFOLDER,
+ self::OBJECTCLASS_TOP,
+ self::OBJECTCLASS_KOLABSHAREDFOLDER,
);
/**
+ * 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()
+ {
+ return '(objectClass=kolabSharedFolder)';
+ }
+
+ /**
* Generates an ID for the given information.
*
* @param array $info The data of the object.
{
if (!isset($attrs)) {
$attrs = array(
- Horde_Kolab_Server_Object::ATTRIBUTE_CN,
- Horde_Kolab_Server_Object::ATTRIBUTE_HOMESERVER,
- Horde_Kolab_Server_Object::ATTRIBUTE_FOLDERTYPE,
+ self::ATTRIBUTE_CN,
+ self::ATTRIBUTE_HOMESERVER,
+ self::ATTRIBUTE_FOLDERTYPE,
);
}
return parent::toHash($attrs);
* @license http://www.fsf.org/copyleft/lgpl.html LGPL
* @link http://pear.horde.org/index.php?package=Kolab_Server
*/
-class Horde_Kolab_Server_Object_user extends Horde_Kolab_Server_Object
+class Horde_Kolab_Server_Object_user extends Horde_Kolab_Server_Object_base
{
/** Define attributes specific to this object type */
const USERTYPE_RESOURCE = 3;
/**
- * The LDAP filter to retrieve this object type
- *
- * @var string
- */
- public static $filter = '(&(objectClass=kolabInetOrgPerson)(uid=*)(mail=*)(sn=*))';
-
- /**
* The attributes supported by this class
*
* @var array
* @var array
*/
public $derived_attributes = array(
+ self::ATTRIBUTE_FN,
'id',
'usertype',
//FIXME: Do we really want to have this type of functionality within this library?
}
/**
+ * 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()
+ {
+ return '(&(objectClass=kolabInetOrgPerson)(uid=*)(mail=*)(sn=*))';
+ }
+
+ /**
* Derive an attribute value.
*
* @param string $attr The attribute to derive.
} else {
return self::USERTYPE_STANDARD;
}
+ case self::ATTRIBUTE_LNFN:
+ $gn = $this->_get(self::ATTRIBUTE_GIVENNAME, true);
+ $sn = $this->_get(self::ATTRIBUTE_SN, true);
+ return sprintf('%s, %s', $sn, $gn);
+ case self::ATTRIBUTE_FNLN:
+ $gn = $this->_get(self::ATTRIBUTE_GIVENNAME, true);
+ $sn = $this->_get(self::ATTRIBUTE_SN, true);
+ return sprintf('%s %s', $gn, $sn);
+ case self::ATTRIBUTE_FN:
+ return $this->getFn();
default:
return parent::derive($attr);
}
}
/**
+ * Get the "first name" attribute of this object
+ *
+ * FIXME: This should get refactored to be combined with the Id value.
+ *
+ * @return string the "first name" of this object
+ */
+ protected function getFn()
+ {
+ $sn = $this->_get(self::ATTRIBUTE_SN, true);
+ $cn = $this->_get(self::ATTRIBUTE_CN, true);
+ return trim(substr($cn, 0, strlen($cn) - strlen($sn)));
+ }
+
+ /**
* Get the groups for this object
*
* @return mixed|PEAR_Error An array of group ids, false if no groups were