*
* @var Kolab_Server
*/
- var $_db;
+ protected $db;
/**
* UID of this object on the Kolab server.
*
* @var string
*/
- var $_uid;
+ protected $uid;
/**
* The cached LDAP result
*
* @var mixed
*/
- var $_cache = false;
+ private $_cache = false;
/** FIXME: Add an attribute cache for the get() function */
*
* @var string
*/
- var $filter = '';
+ public static $filter = '';
/**
* The group the UID must be member of so that this object really
*
* @var string
*/
- var $required_group;
+ protected $required_group;
/**
* The LDAP attributes supported by this class.
*
* @var array
*/
- var $_supported_attributes = array();
+ public $supported_attributes = array();
/**
* Attributes derived from the LDAP values.
*
* @var array
*/
- var $_derived_attributes = array(
+ public $derived_attributes = array(
KOLAB_ATTR_ID,
);
*
* @var array
*/
- var $_required_attributes = array();
+ public $required_attributes = array();
/**
* The ldap classes for this type of object.
*
* @var array
*/
- var $_object_classes = array();
+ protected $object_classes = array();
/**
* Sort by this attributes (must be a LDAP attribute).
* @param string $uid UID of the object.
* @param array $data A possible array of data for the object
*/
- function Horde_Kolab_Server_Object(&$db, $uid = null, $data = null)
+ public function __construct(&$db, $uid = null, $data = null)
{
- $this->_db = &$db;
+ $this->db = &$db;
if (empty($uid)) {
if (empty($data) || !isset($data[KOLAB_ATTR_UID])) {
throw new Horde_Kolab_Server_Exception(_('Specify either the UID or a search result!'));
}
if (is_array($data[KOLAB_ATTR_UID])) {
- $this->_uid = $data[KOLAB_ATTR_UID][0];
+ $this->uid = $data[KOLAB_ATTR_UID][0];
} else {
- $this->_uid = $data[KOLAB_ATTR_UID];
+ $this->uid = $data[KOLAB_ATTR_UID];
}
$this->_cache = $data;
} else {
- $this->_uid = $uid;
+ $this->uid = $uid;
}
}
* @return Horde_Kolab_Server_Object|PEAR_Error The newly created concrete
* Horde_Kolab_Server_Object instance.
*/
- function &factory($type, $uid, &$storage, $data = null)
+ public function &factory($type, $uid, &$storage, $data = null)
{
$result = Horde_Kolab_Server_Object::loadClass($type);
*
* @return true|PEAR_Error True if successfull.
*/
- function loadClass($type)
+ public static function loadClass($type)
{
if (!class_exists($type)) {
throw new Horde_Kolab_Server_Exception('Class definition of ' . $type . ' not found.');
*
* @return NULL
*/
- function exists()
+ public function exists()
{
try {
- $this->_read();
+ $this->read();
} catch (Horde_Kolab_Server_Exception $e) {
return false;
}
*
* @return NULL
*/
- function _read()
+ protected function read()
{
- $this->_cache = $this->_db->read($this->_uid,
- $this->_supported_attributes);
+ $this->_cache = $this->db->read($this->uid,
+ $this->supported_attributes);
}
/**
* @param string $attr The attribute to read
*
* @return string the value of this attribute
+ *
+ * @todo: This needs to be magic
*/
- function get($attr)
+ public function get($attr)
{
if ($attr != KOLAB_ATTR_UID) {
- if (!in_array($attr, $this->_supported_attributes)
- && !in_array($attr, $this->_derived_attributes)) {
+ if (!in_array($attr, $this->supported_attributes)
+ && !in_array($attr, $this->derived_attributes)) {
throw new Horde_Kolab_Server_Exception(sprintf(_("Attribute \"%s\" not supported!"),
$attr));
}
if (!$this->_cache) {
- $this->_read();
+ $this->read();
}
}
- if (in_array($attr, $this->_derived_attributes)) {
- return $this->_derive($attr);
+ if (in_array($attr, $this->derived_attributes)) {
+ return $this->derive($attr);
}
switch ($attr) {
case KOLAB_ATTR_UID:
- return $this->_getUID();
+ return $this->uid;
case KOLAB_ATTR_FN:
- return $this->_getFn();
+ return $this->getFn();
case KOLAB_ATTR_SN:
case KOLAB_ATTR_CN:
case KOLAB_ATTR_GIVENNAME:
*
* @return string the value of this attribute
*/
- function _get($attr, $single = true)
+ protected function _get($attr, $single = true)
{
if (isset($this->_cache[$attr])) {
if ($single && is_array($this->_cache[$attr])) {
*
* @return mixed The value of the attribute.
*/
- function _derive($attr)
+ protected function derive($attr)
{
switch ($attr) {
case KOLAB_ATTR_ID:
- $result = split(',', $this->_uid);
+ $result = split(',', $this->uid);
if (substr($result[0], 0, 3) == 'cn=') {
return substr($result[0], 3);
} else {
*
* @return array|PEAR_Error The hash representing this object.
*/
- function toHash($attrs = null)
+ public function toHash($attrs = null)
{
if (!isset($attrs)) {
$attrs = array();
*
* @return string the UID of this object
*/
- function _getUid()
+ public function getUid()
{
- return $this->_uid;
+ return $this->uid;
}
/**
*
* @return string the "first name" of this object
*/
- function _getFn()
+ protected function getFn()
{
$sn = $this->_get(KOLAB_ATTR_SN, true);
$cn = $this->_get(KOLAB_ATTR_CN, true);
* @return mixed An array of group ids or a PEAR Error in case of
* an error.
*/
- function getGroups()
+ public function getGroups()
{
return array();
}
*
* @return string|PEAR_Error The server url or empty.
*/
- function getServer($server_type)
+ public function getServer($server_type)
{
throw new Horde_Kolab_Server_Exception('Not implemented!');
}
*
* @return string|PEAR_Error The ID.
*/
- function generateId($info)
+ public static function generateId($info)
{
$id_mapfields = array('givenName', 'sn');
$id_format = '%s %s';
*
* @return boolean|PEAR_Error True on success.
*/
- function save($info)
+ public function save($info)
{
- foreach ($this->_required_attributes as $attribute) {
+ foreach ($this->required_attributes as $attribute) {
if (!isset($info[$attribute])) {
throw new Horde_Kolab_Server_Exception(sprintf(_("The value for \"%s\" is missing!"),
$attribute));
}
}
- $info['objectClass'] = $this->_object_classes;
+ $info['objectClass'] = $this->object_classes;
- $result = $this->_db->save($this->_uid, $info);
+ $result = $this->db->save($this->uid, $info);
if ($result === false || is_a($result, 'PEAR_Error')) {
return $result;
}
/**
* An entry in the global addressbook.
*
- *
* PHP version 5
*
* @category Kolab
* This class provides methods to deal with global address book
* entries for Kolab.
*
- *
* Copyright 2008-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
*
* @var string
*/
- var $filter = '(&(objectclass=inetOrgPerson)(!(uid=*))(sn=*))';
+ public static $filter = '(&(objectclass=inetOrgPerson)(!(uid=*))(sn=*))';
/**
* The attributes supported by this class
*
* @var array
*/
- var $_supported_attributes = array(
+ public $supported_attributes = array(
KOLAB_ATTR_SN,
KOLAB_ATTR_CN,
KOLAB_ATTR_GIVENNAME,
*
* @var array
*/
- var $_derived_attributes = array(
+ public $derived_attributes = array(
KOLAB_ATTR_LNFN,
KOLAB_ATTR_FNLN,
);
*
* @var array
*/
- var $_required_attributes = array(
+ public $required_attributes = array(
KOLAB_ATTR_SN,
KOLAB_ATTR_GIVENNAME,
);
*
* @var array
*/
- var $_object_classes = array(
+ protected $object_classes = array(
KOLAB_OC_TOP,
KOLAB_OC_INETORGPERSON,
KOLAB_OC_KOLABINETORGPERSON,
*
* @return array|PEAR_Error The hash representing this object.
*/
- function toHash($attrs = null)
+ public function toHash($attrs = null)
{
if (!isset($attrs)) {
$attrs = array(
}
return parent::toHash($attrs);
}
-
}
/**
* A system administrator.
*
- *
* PHP version 5
*
* @category Kolab
* @link http://pear.horde.org/index.php?package=Kolab_Server
*/
-require_once 'Horde/Kolab/Server/Object/adminrole.php';
-
/**
* This class provides methods to deal with administrator
* entries for Kolab.
*
- *
* Copyright 2008-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
*
* @var string
*/
- var $required_group = 'cn=admin,cn=internal';
-
+ protected $required_group = 'cn=admin,cn=internal';
}
/**
* A Kolab object of type administrator.
*
- *
* PHP version 5
*
* @category Kolab
/**
* This class provides methods to deal with administrator object types.
*
- *
* Copyright 2008-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
*
* @var string
*/
- var $filter = '(&(cn=*)(objectClass=inetOrgPerson)(!(uid=manager))(sn=*))';
+ public static $filter = '(&(cn=*)(objectClass=inetOrgPerson)(!(uid=manager))(sn=*))';
/**
* The attributes supported by this class
*
* @var array
*/
- var $_supported_attributes = array(
+ public $supported_attributes = array(
KOLAB_ATTR_SN,
KOLAB_ATTR_CN,
KOLAB_ATTR_GIVENNAME,
*
* @var array
*/
- var $_required_attributes = array(
+ public $required_attributes = array(
KOLAB_ATTR_SN,
KOLAB_ATTR_GIVENNAME,
KOLAB_ATTR_USERPASSWORD,
*
* @var array
*/
- var $_derived_attributes = array(
+ public $derived_attributes = array(
KOLAB_ATTR_ID,
KOLAB_ATTR_LNFN,
);
*
* @var array
*/
- var $_object_classes = array(
+ protected $object_classes = array(
KOLAB_OC_TOP,
KOLAB_OC_INETORGPERSON,
KOLAB_OC_KOLABINETORGPERSON,
);
/**
+ * 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;
+
+ /**
* Convert the object attributes to a hash.
*
* @param string $attrs The attributes to return.
*
* @return array|PEAR_Error The hash representing this object.
*/
- function toHash($attrs = null)
+ public function toHash($attrs = null)
{
if (!isset($attrs)) {
$attrs = array(
*
* @return boolean|PEAR_Error True on success.
*/
- function save($info)
+ public function save($info)
{
if (!isset($info['cn'])) {
if (!isset($info['sn']) || !isset($info['givenName'])) {
}
$admins_uid = sprintf('%s,%s', $this->required_group,
- $this->_db->getBaseUid());
+ $this->db->getBaseUid());
- $admin_group = $this->_db->fetch($admins_uid, 'Horde_Kolab_Server_Object_group');
+ $admin_group = $this->db->fetch($admins_uid, 'Horde_Kolab_Server_Object_group');
if (is_a($admin_group, 'PEAR_Error') || !$admin_group->exists()) {
- $members = array($this->_uid);
+ $members = array($this->uid);
//FIXME: This is not okay and also contains too much LDAP knowledge
- $parts = split(',', $this->required_group);
+ $parts = split(',', $this->required_group);
list($groupname) = sscanf($parts[0], 'cn=%s');
- $result = $this->_db->add(array(KOLAB_ATTR_CN => $groupname,
+ $result = $this->db->add(array(KOLAB_ATTR_CN => $groupname,
'type' => 'Horde_Kolab_Server_Object_group',
KOLAB_ATTR_MEMBER => $members,
KOLAB_ATTR_VISIBILITY => false));
return $result;
}
} else {
- $result = $admin_group->isMember($this->_uid);
+ $result = $admin_group->isMember($this->uid);
if (is_a($result, 'PEAR_Error')) {
return $result;
}
if ($result === false) {
$members = $admin_group->getMembers();
- $members[] = $this->_uid;
+ $members[] = $this->uid;
$admin_group->save(array(KOLAB_ATTR_MEMBER => $members));
}
}
/**
* Representation of a Kolab distribution list.
*
- *
* PHP version 5
*
* @category Kolab
* @link http://pear.horde.org/index.php?package=Kolab_Server
*/
-require_once 'Horde/Kolab/Server/Object/group.php';
-
/**
* This class provides methods to deal with distribution lists for Kolab.
*
- *
* Copyright 2008-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
*
* @var string
*/
- var $filter = '(&(objectClass=kolabGroupOfNames)(mail=*))';
+ public static $filter = '(&(objectClass=kolabGroupOfNames)(mail=*))';
/**
*
* @var array
*/
- var $_required_attributes = array(
+ public $required_attributes = array(
KOLAB_ATTR_MAIL,
);
};
/**
* A Kolab domain maintainer.
*
- *
* PHP version 5
*
* @category Kolab
* @link http://pear.horde.org/index.php?package=Kolab_Server
*/
-require_once 'Horde/Kolab/Server/Object/adminrole.php';
-
/**
* This class provides methods associated to Kolab domain maintainers.
*
- *
* Copyright 2008-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
*
* @var array
*/
- var $_required_attributes = array(
+ public $required_attributes = array(
KOLAB_ATTR_SN,
KOLAB_ATTR_GIVENNAME,
KOLAB_ATTR_USERPASSWORD,
*
* @var array
*/
- var $_derived_attributes = array(
+ public $derived_attributes = array(
KOLAB_ATTR_ID,
KOLAB_ATTR_LNFN,
KOLAB_ATTR_DOMAIN,
*
* @var string
*/
- var $required_group = 'cn=domain-maintainer,cn=internal';
+ protected $required_group = 'cn=domain-maintainer,cn=internal';
/**
* Convert the object attributes to a hash.
*
* @return array|PEAR_Error The hash representing this object.
*/
- function toHash($attrs = null)
+ public function toHash($attrs = null)
{
if (!isset($attrs)) {
$attrs = array(
*
* @return boolean|PEAR_Error True on success.
*/
- function save($info)
+ public function save($info)
{
foreach ($info[KOLAB_ATTR_DOMAIN] as $domain) {
$domain_uid = sprintf('cn=%s,cn=domain,cn=internal,%s',
- $domain, $this->_db->getBaseUid());
+ $domain, $this->db->getBaseUid());
//FIXME: This should be made easier by the group object
- $domain_group = $this->_db->fetch($domain_uid, 'Horde_Kolab_Server_Object_group');
+ $domain_group = $this->db->fetch($domain_uid, 'Horde_Kolab_Server_Object_group');
if (is_a($domain_group, 'PEAR_Error')) {
return $domain_group;
}
if (!$domain_group->exists()) {
- $members = array($this->_uid);
+ $members = array($this->uid);
$domain_group->save(array(KOLAB_ATTR_CN => $domain,
KOLAB_ATTR_MEMBER => $members));
} else {
- $result = $domain_group->isMember($this->_uid);
+ $result = $domain_group->isMember($this->uid);
if (is_a($result, 'PEAR_Error')) {
return $result;
}
if ($result === false) {
$members = $domain_group->getMembers();
- $members[] = $this->_uid;
+ $members[] = $this->uid;
$domain_group->save(array(KOLAB_ATTR_MEMBER => $members));
}
}
/**
* Representation of a Kolab user group.
*
- *
* PHP version 5
*
* @category Kolab
/**
* This class provides methods to deal with groups for Kolab.
*
- *
* Copyright 2008-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
*
* @var string
*/
- var $filter = '(objectClass=kolabGroupOfNames)';
+ public static $filter = '(objectClass=kolabGroupOfNames)';
/**
* The attributes supported by this class
*
* @var array
*/
- var $_supported_attributes = array(
+ public $supported_attributes = array(
KOLAB_ATTR_CN,
KOLAB_ATTR_MAIL,
KOLAB_ATTR_MEMBER,
*
* @var array
*/
- var $_derived_attributes = array(
+ public $derived_attributes = array(
KOLAB_ATTR_ID,
KOLAB_ATTR_VISIBILITY,
);
*
* @var array
*/
- var $_required_attributes = array(
+ public $required_attributes = array(
KOLAB_ATTR_CN,
);
*
* @var array
*/
- var $_object_classes = array(
+ protected $object_classes = array(
KOLAB_OC_TOP,
KOLAB_OC_KOLABGROUPOFNAMES,
);
*
* @var string
*/
- var $sort_by = KOLAB_ATTR_MAIL;
+ public $sort_by = KOLAB_ATTR_MAIL;
/**
* Derive an attribute value.
*
* @return mixed The value of the attribute.
*/
- function _derive($attr)
+ protected function derive($attr)
{
switch ($attr) {
case KOLAB_ATTR_VISIBILITY:
return strpos($this->_uid, 'cn=internal') === false;
default:
- return parent::_derive($attr);
+ return parent::derive($attr);
}
}
*
* @return array|PEAR_Error The hash representing this object.
*/
- function toHash($attrs = null)
+ public function toHash($attrs = null)
{
if (!isset($attrs)) {
$attrs = array(
*
* @return string|PEAR_Error The ID.
*/
- function generateId($info)
+ public static function generateId($info)
{
if (isset($info['mail'])) {
return trim($info['mail'], " \t\n\r\0\x0B,");
*
* @return boolean|PEAR_Error True on success.
*/
- function save($info)
+ public function save($info)
{
if (!isset($info['cn'])) {
if (!isset($info['mail'])) {
*
* @return array|PEAR_Error The list of members in this group.
*/
- function getMembers()
+ public function getMembers()
{
return $this->_get(KOLAB_ATTR_MEMBER, false);
}
*
* @return array|PEAR_Error True if successful.
*/
- function addMember($member)
+ public function addMember($member)
{
$members = $this->getMembers();
if (is_a($members, 'PEAR_Error')) {
*
* @return array|PEAR_Error True if successful.
*/
- function deleteMember($member)
+ public function deleteMember($member)
{
$members = $this->getMembers();
if (is_a($members, 'PEAR_Error')) {
* @return boolean|PEAR_Error True if the UID is a member of the group,
* false otherwise.
*/
- function isMember($member)
+ public function isMember($member)
{
$members = $this->getMembers();
if (is_a($members, 'PEAR_Error') || !is_array($members)) {
/**
* A Kolab maintainer.
*
- *
* PHP version 5
*
* @category Kolab
* @link http://pear.horde.org/index.php?package=Kolab_Server
*/
-require_once 'Horde/Kolab/Server/Object/adminrole.php';
-
/**
* This class provides methods to deal with maintainer
* entries for Kolab.
*
- *
* Copyright 2008-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
*
* @var string
*/
- var $required_group = 'cn=maintainer,cn=internal';
+ protected $required_group = 'cn=maintainer,cn=internal';
}
/**
* The server configuration.
*
- *
* PHP version 5
*
* @category Kolab
/**
* This class provides methods to deal with Kolab server configuration.
*
- *
* Copyright 2008-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
*
* @var string
*/
- var $filter = '(&((k=kolab))(objectclass=kolab))';
+ public static $filter = '(&((k=kolab))(objectclass=kolab))';
/**
* The attributes supported by this class
*
* @var array
*/
- var $_supported_attributes = array(
+ public $supported_attributes = array(
KOLAB_ATTR_FBPAST,
);
/**
* A shared IMAP folder.
*
- *
* PHP version 5
*
* @category Kolab
* This class provides methods to deal with shared folders
* entries for Kolab.
*
- *
* Copyright 2008-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
*
* @var string
*/
- var $filter = '(objectClass=kolabSharedFolder)';
+ public static $filter = '(objectClass=kolabSharedFolder)';
/**
* The attributes supported by this class
*
* @var array
*/
- var $_supported_attributes = array(
+ public $supported_attributes = array(
KOLAB_ATTR_CN,
KOLAB_ATTR_DELETED,
KOLAB_ATTR_FOLDERTYPE,
*
* @var array
*/
- var $_required_attributes = array(
+ public $required_attributes = array(
KOLAB_ATTR_CN,
KOLAB_ATTR_HOMESERVER,
);
*
* @var array
*/
- var $_object_classes = array(
+ protected $object_classes = array(
KOLAB_OC_TOP,
KOLAB_OC_KOLABSHAREDFOLDER,
);
*
* @return string|PEAR_Error The ID.
*/
- function generateId($info)
+ public static function generateId($info)
{
return trim($info['cn'], " \t\n\r\0\x0B,");
}
*
* @return array|PEAR_Error The hash representing this object.
*/
- function toHash($attrs = null)
+ public function toHash($attrs = null)
{
if (!isset($attrs)) {
$attrs = array(
*
* @var string
*/
- var $filter = '(&(objectClass=kolabInetOrgPerson)(uid=*)(mail=*)(sn=*))';
+ public static $filter = '(&(objectClass=kolabInetOrgPerson)(uid=*)(mail=*)(sn=*))';
/**
* The attributes supported by this class
*
* @var array
*/
- var $_supported_attributes = array(
+ public $supported_attributes = array(
KOLAB_ATTR_SN,
KOLAB_ATTR_CN,
KOLAB_ATTR_GIVENNAME,
*
* @var array
*/
- var $_derived_attributes = array(
+ public $derived_attributes = array(
KOLAB_ATTR_ID,
KOLAB_ATTR_USERTYPE,
KOLAB_ATTR_LNFN,
*
* @var array
*/
- var $_required_attributes = array(
+ public $required_attributes = array(
KOLAB_ATTR_SN,
KOLAB_ATTR_GIVENNAME,
KOLAB_ATTR_USERPASSWORD,
*
* @var array
*/
- var $_object_classes = array(
+ protected $object_classes = array(
KOLAB_OC_TOP,
KOLAB_OC_INETORGPERSON,
KOLAB_OC_KOLABINETORGPERSON,
* @param string $dn UID of the object.
* @param array $data A possible array of data for the object
*/
- function Horde_Kolab_Server_Object_user(&$db, $dn = null, $data = null)
+ public function __construct(&$db, $dn = null, $data = null)
{
global $conf;
/** Allows to customize the supported user attributes. */
if (isset($conf['kolab']['server']['user_supported_attrs'])) {
- $this->_supported_attributes = $conf['kolab']['server']['user_supported_attrs'];
+ $this->supported_attributes = $conf['kolab']['server']['user_supported_attrs'];
}
/** Allows to customize the required user attributes. */
if (isset($conf['kolab']['server']['user_required_attrs'])) {
- $this->_required_attributes = $conf['kolab']['server']['user_required_attrs'];
+ $this->required_attributes = $conf['kolab']['server']['user_required_attrs'];
}
/** Allows to customize the user object classes. */
if (isset($conf['kolab']['server']['user_objectclasses'])) {
- $this->_object_classes = $conf['kolab']['server']['user_object_classes'];
+ $this->object_classes = $conf['kolab']['server']['user_object_classes'];
}
- Horde_Kolab_Server_Object::Horde_Kolab_Server_Object($db, $dn, $data);
+ parent::__construct($db, $dn, $data);
}
/**
*
* @return mixed The value of the attribute.
*/
- function _derive($attr)
+ protected function derive($attr)
{
switch ($attr) {
case KOLAB_ATTR_USERTYPE:
*
* @return array|PEAR_Error The hash representing this object.
*/
- function toHash($attrs = null)
+ public function toHash($attrs = null)
{
if (!isset($attrs)) {
$attrs = array(
* @return mixed|PEAR_Error An array of group ids, false if no groups were
* found.
*/
- function getGroups()
+ public function getGroups()
{
return $this->_db->getGroups($this->_uid);
}
*
* @return string The server url or empty on error.
*/
- function getServer($server_type)
+ public function getServer($server_type)
{
global $conf;
*
* @return string|PEAR_Error The ID.
*/
- function generateId($info)
+ public static function generateId($info)
{
global $conf;
* @throws Horde_Kolab_Server_Exception If the information to be saved is
* invalid.
*/
- function save($info)
+ public function save($info)
{
if (!isset($info['cn'])) {
if (!isset($info['sn']) || !isset($info['givenName'])) {