\Horde_Group_File

The Horde_Group_File class provides an implementation of the Horde group system for integration with /etc/group or a custom group file.

File format is:

group_name:encrypted_passwd:GID:user_list

encrypted_passwd is 'x' if shadow is used, user_list is comma separated Note: the gid is normally the group name. See 'use_gid' parameter.

Summary

Methods
Properties
Constants
__construct()
readOnly()
renameSupported()
setCache()
getCache()
create()
rename()
remove()
exists()
getName()
getData()
setData()
listAll()
listUsers()
listGroups()
addUser()
removeUser()
search()
No public properties found
CACHE_PREFIX
CACHE_VERSION
_create()
_rename()
_remove()
_checkExistsCache()
_exists()
_getName()
_getData()
_setData()
_listAll()
_listUsers()
_listGroups()
_addUser()
_removeUser()
_search()
_sig()
_getListCache()
_setListCache()
$_cache
$_groups
N/A
No private methods found
No private properties found
N/A

Constants

CACHE_PREFIX

CACHE_PREFIX

Cache prefix.

CACHE_VERSION

CACHE_VERSION

Cache version.

Properties

$_cache

$_cache : \Horde_Cache

Cache object.

Type

\Horde_Cache

$_groups

$_groups : array

List of groups parsed from the group file.

Type

array

Methods

__construct()

__construct(array  $params) 

Constructor.

Parameters

array $params

Driver parameters:

  • 'filename': Path to the groups file.
  • 'use_gid': (boolean) Use GID instead of the group name as the ID.

Throws

\Horde_Group_Exception

readOnly()

readOnly() : boolean

Returns whether the group backend is read-only.

Returns

boolean

renameSupported()

renameSupported() : boolean

Returns whether groups can be renamed.

Returns

boolean

setCache()

setCache(\Horde_Cache  $cache) 

Sets a cache object.

Parameters

\Horde_Cache $cache

The cache object.

getCache()

getCache() : \Horde_Cache

Returns the cache object.

Returns

\Horde_Cache

create()

create(string  $name, string  $email = null) : mixed

Creates a new group.

Parameters

string $name

A group name.

string $email

The group's email address.

Throws

\Horde_Group_Exception

Returns

mixed —

The ID of the created group.

rename()

rename(mixed  $gid, string  $name) 

Renames a group.

Parameters

mixed $gid

A group ID.

string $name

The new name.

Throws

\Horde_Group_Exception
\Horde_Exception_NotFound

remove()

remove(mixed  $gid) 

Removes a group.

Parameters

mixed $gid

A group ID.

Throws

\Horde_Group_Exception

exists()

exists(mixed  $gid) : boolean

Checks if a group exists.

Parameters

mixed $gid

A group ID.

Throws

\Horde_Group_Exception

Returns

boolean —

True if the group exists.

getName()

getName(mixed  $gid) : string

Returns a group name.

Parameters

mixed $gid

A group ID.

Throws

\Horde_Group_Exception
\Horde_Exception_NotFound

Returns

string —

The group's name.

getData()

getData(mixed  $gid) : array

Returns all available attributes of a group.

Parameters

mixed $gid

A group ID.

Throws

\Horde_Group_Exception
\Horde_Exception_NotFound

Returns

array —

The group's data.

setData()

setData(mixed  $gid, array|string  $attribute, string  $value = null) 

Sets one or more attributes of a group.

Parameters

mixed $gid

A group ID.

array|string $attribute

An attribute name or a hash of attributes.

string $value

An attribute value if $attribute is a string.

Throws

\Horde_Group_Exception
\Horde_Exception_NotFound

listAll()

listAll(string  $member = null) : array

Returns a list of all groups a user may see, with IDs as keys and names as values.

Parameters

string $member

Only return groups that this user is a member of.

Throws

\Horde_Group_Exception

Returns

array —

All existing groups.

listUsers()

listUsers(mixed  $gid) : array

Returns a list of users in a group.

Parameters

mixed $gid

A group ID.

Throws

\Horde_Group_Exception
\Horde_Exception_NotFound

Returns

array —

List of group users.

listGroups()

listGroups(string  $user) : array

Returns a list of groups a user belongs to.

Parameters

string $user

A user name.

Throws

\Horde_Group_Exception

Returns

array —

A list of groups, with IDs as keys and names as values.

addUser()

addUser(mixed  $gid, string  $user) 

Add a user to a group.

Parameters

mixed $gid

A group ID.

string $user

A user name.

Throws

\Horde_Group_Exception
\Horde_Exception_NotFound

removeUser()

removeUser(mixed  $gid, string  $user) 

Removes a user from a group.

Parameters

mixed $gid

A group ID.

string $user

A user name.

Throws

\Horde_Group_Exception
\Horde_Exception_NotFound

search()

search(string  $name) : array

Searches for group names.

Parameters

string $name

A search string.

Throws

\Horde_Group_Exception

Returns

array —

A list of matching groups, with IDs as keys and names as values.

_create()

_create(string  $name, string  $email = null) : mixed

Creates a new group.

Parameters

string $name

A group name.

string $email

The group's email address.

Throws

\Horde_Group_Exception

Returns

mixed —

The ID of the created group.

_rename()

_rename(mixed  $gid, string  $name) 

Renames a group.

Parameters

mixed $gid

A group ID.

string $name

The new name.

Throws

\Horde_Group_Exception
\Horde_Exception_NotFound

_remove()

_remove(mixed  $gid) 

Removes a group.

Parameters

mixed $gid

A group ID.

Throws

\Horde_Group_Exception

_checkExistsCache()

_checkExistsCache(  $gid) 

Parameters

$gid

_exists()

_exists(mixed  $gid) : boolean

Checks if a group exists.

Parameters

mixed $gid

A group ID.

Returns

boolean —

True if the group exists.

_getName()

_getName(mixed  $gid) : string

Returns a group name.

Parameters

mixed $gid

A group ID.

Throws

\Horde_Exception_NotFound

Returns

string —

The group's name.

_getData()

_getData(mixed  $gid) : array

Returns all available attributes of a group.

Parameters

mixed $gid

A group ID.

Throws

\Horde_Exception_NotFound

Returns

array —

The group's date.

_setData()

_setData(mixed  $gid, array|string  $attribute, string  $value = null) 

Sets one or more attributes of a group.

Parameters

mixed $gid

A group ID.

array|string $attribute

An attribute name or a hash of attributes.

string $value

An attribute value if $attribute is a string.

Throws

\Horde_Group_Exception
\Horde_Exception_NotFound

_listAll()

_listAll() : array

Returns a list of all groups a user may see, with IDs as keys and names as values.

Returns

array —

All existing groups.

_listUsers()

_listUsers(mixed  $gid) : array

Returns a list of users in a group.

Parameters

mixed $gid

A group ID.

Throws

\Horde_Exception_NotFound

Returns

array —

List of group users.

_listGroups()

_listGroups(string  $user) : array

Returns a list of groups a user belongs to.

Parameters

string $user

A user name.

Returns

array —

A list of groups, with IDs as keys and names as values.

_addUser()

_addUser(mixed  $gid, string  $user) 

Add a user to a group.

Parameters

mixed $gid

A group ID.

string $user

A user name.

Throws

\Horde_Group_Exception
\Horde_Exception_NotFound

_removeUser()

_removeUser(mixed  $gid, string  $user) 

Removes a user from a group.

Parameters

mixed $gid

A group ID.

string $user

A user name.

Throws

\Horde_Group_Exception
\Horde_Exception_NotFound

_search()

_search(string  $name) : array

Searches for group names.

Parameters

string $name

A search string.

Returns

array —

A list of matching groups, with IDs as keys and names as values.

_sig()

_sig(string  $key) : string

Returns a full cache key.

Parameters

string $key

The internal key.

Returns

string —

The full key for Horde_Cache consumption.

_getListCache()

_getListCache(string  $user = null) : array

Returns the cached group list.

Parameters

string $user

A user name.

Returns

array —

The group list or null if not cached.

_setListCache()

_setListCache(array  $list, string  $user = null) 

Sets the cached group list.

Parameters

array $list

A group list.

string $user

A user name.