Horde_Group_File
        
        extends Horde_Group_Base
    
    
            
            in package
            
        
    
    
    
        
            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.
Tags
Table of Contents
- CACHE_PREFIX = 'horde_group_'
 - Cache prefix.
 - CACHE_VERSION = 1
 - Cache version.
 - $_cache : Horde_Cache
 - Cache object.
 - $_groups : array<string|int, mixed>
 - List of groups parsed from the group file.
 - __construct() : mixed
 - Constructor.
 - addUser() : mixed
 - Add a user to a group.
 - create() : mixed
 - Creates a new group.
 - exists() : bool
 - Checks if a group exists.
 - getCache() : Horde_Cache
 - Returns the cache object.
 - getData() : array<string|int, mixed>
 - Returns all available attributes of a group.
 - getName() : string
 - Returns a group name.
 - listAll() : array<string|int, mixed>
 - Returns a list of all groups a user may see, with IDs as keys and names as values.
 - listGroups() : array<string|int, mixed>
 - Returns a list of groups a user belongs to.
 - listUsers() : array<string|int, mixed>
 - Returns a list of users in a group.
 - readOnly() : bool
 - Returns whether the group backend is read-only.
 - remove() : mixed
 - Removes a group.
 - removeUser() : mixed
 - Removes a user from a group.
 - rename() : mixed
 - Renames a group.
 - renameSupported() : bool
 - Returns whether groups can be renamed.
 - search() : array<string|int, mixed>
 - Searches for group names.
 - setCache() : mixed
 - Sets a cache object.
 - setData() : mixed
 - Sets one or more attributes of a group.
 - _addUser() : mixed
 - Add a user to a group.
 - _checkExistsCache() : mixed
 - _create() : mixed
 - Creates a new group.
 - _exists() : bool
 - Checks if a group exists.
 - _getData() : array<string|int, mixed>
 - Returns all available attributes of a group.
 - _getListCache() : array<string|int, mixed>
 - Returns the cached group list.
 - _getName() : string
 - Returns a group name.
 - _listAll() : array<string|int, mixed>
 - Returns a list of all groups a user may see, with IDs as keys and names as values.
 - _listGroups() : array<string|int, mixed>
 - Returns a list of groups a user belongs to.
 - _listUsers() : array<string|int, mixed>
 - Returns a list of users in a group.
 - _remove() : mixed
 - Removes a group.
 - _removeUser() : mixed
 - Removes a user from a group.
 - _rename() : mixed
 - Renames a group.
 - _search() : array<string|int, mixed>
 - Searches for group names.
 - _setData() : mixed
 - Sets one or more attributes of a group.
 - _setListCache() : mixed
 - Sets the cached group list.
 - _sig() : string
 - Returns a full cache key.
 
Constants
CACHE_PREFIX
Cache prefix.
    public
        mixed
    CACHE_PREFIX
    = 'horde_group_'
    
        
    
CACHE_VERSION
Cache version.
    public
        mixed
    CACHE_VERSION
    = 1
    
        
    
Properties
$_cache
Cache object.
    protected
        Horde_Cache
    $_cache
    
    
    
    
    Tags
$_groups
List of groups parsed from the group file.
    protected
        array<string|int, mixed>
    $_groups
     = array()
    
    
    
Methods
__construct()
Constructor.
    public
                    __construct(array<string|int, mixed> $params) : mixed
    
        Parameters
- $params : array<string|int, mixed>
 - 
                    
Driver parameters:
- 'filename': Path to the groups file.
 - 'use_gid': (boolean) Use GID instead of the group name as the ID.
 
 
Tags
Return values
mixed —addUser()
Add a user to a group.
    public
                    addUser(mixed $gid, string $user) : mixed
    
        Parameters
- $gid : mixed
 - 
                    
A group ID.
 - $user : string
 - 
                    
A user name.
 
Tags
Return values
mixed —create()
Creates a new group.
    public
                    create(string $name[, string $email = null ]) : mixed
    
        Parameters
- $name : string
 - 
                    
A group name.
 - $email : string = null
 - 
                    
The group's email address.
 
Tags
Return values
mixed —The ID of the created group.
exists()
Checks if a group exists.
    public
                    exists(mixed $gid) : bool
    
        Parameters
- $gid : mixed
 - 
                    
A group ID.
 
Tags
Return values
bool —True if the group exists.
getCache()
Returns the cache object.
    public
                    getCache() : Horde_Cache
    
    
    
    Tags
Return values
Horde_Cache —getData()
Returns all available attributes of a group.
    public
                    getData(mixed $gid) : array<string|int, mixed>
    
        Parameters
- $gid : mixed
 - 
                    
A group ID.
 
Tags
Return values
array<string|int, mixed> —The group's data.
getName()
Returns a group name.
    public
                    getName(mixed $gid) : string
    
        Parameters
- $gid : mixed
 - 
                    
A group ID.
 
Tags
Return values
string —The group's name.
listAll()
Returns a list of all groups a user may see, with IDs as keys and names as values.
    public
                    listAll([string $member = null ]) : array<string|int, mixed>
    
        Parameters
- $member : string = null
 - 
                    
Only return groups that this user is a member of.
 
Tags
Return values
array<string|int, mixed> —All existing groups.
listGroups()
Returns a list of groups a user belongs to.
    public
                    listGroups(string $user) : array<string|int, mixed>
    
        Parameters
- $user : string
 - 
                    
A user name.
 
Tags
Return values
array<string|int, mixed> —A list of groups, with IDs as keys and names as values.
listUsers()
Returns a list of users in a group.
    public
                    listUsers(mixed $gid) : array<string|int, mixed>
    
        Parameters
- $gid : mixed
 - 
                    
A group ID.
 
Tags
Return values
array<string|int, mixed> —List of group users.
readOnly()
Returns whether the group backend is read-only.
    public
                    readOnly() : bool
    
    
    
        Return values
bool —remove()
Removes a group.
    public
                    remove(mixed $gid) : mixed
    
        Parameters
- $gid : mixed
 - 
                    
A group ID.
 
Tags
Return values
mixed —removeUser()
Removes a user from a group.
    public
                    removeUser(mixed $gid, string $user) : mixed
    
        Parameters
- $gid : mixed
 - 
                    
A group ID.
 - $user : string
 - 
                    
A user name.
 
Tags
Return values
mixed —rename()
Renames a group.
    public
                    rename(mixed $gid, string $name) : mixed
    
        Parameters
- $gid : mixed
 - 
                    
A group ID.
 - $name : string
 - 
                    
The new name.
 
Tags
Return values
mixed —renameSupported()
Returns whether groups can be renamed.
    public
                    renameSupported() : bool
    
    
    
        Return values
bool —search()
Searches for group names.
    public
                    search(string $name) : array<string|int, mixed>
    
        Parameters
- $name : string
 - 
                    
A search string.
 
Tags
Return values
array<string|int, mixed> —A list of matching groups, with IDs as keys and names as values.
setCache()
Sets a cache object.
    public
                    setCache(Horde_Cache $cache) : mixed
    
        Parameters
- $cache : Horde_Cache
 - 
                    
The cache object.
 
Tags
Return values
mixed —setData()
Sets one or more attributes of a group.
    public
                    setData(mixed $gid, array<string|int, mixed>|string $attribute[, string $value = null ]) : mixed
    
        Parameters
- $gid : mixed
 - 
                    
A group ID.
 - $attribute : array<string|int, mixed>|string
 - 
                    
An attribute name or a hash of attributes.
 - $value : string = null
 - 
                    
An attribute value if $attribute is a string.
 
Tags
Return values
mixed —_addUser()
Add a user to a group.
    protected
                    _addUser(mixed $gid, string $user) : mixed
    
        Parameters
- $gid : mixed
 - 
                    
A group ID.
 - $user : string
 - 
                    
A user name.
 
Tags
Return values
mixed —_checkExistsCache()
    protected
                    _checkExistsCache(mixed $gid) : mixed
        
        Parameters
- $gid : mixed
 
Return values
mixed —_create()
Creates a new group.
    protected
                    _create(string $name[, string $email = null ]) : mixed
    
        Parameters
- $name : string
 - 
                    
A group name.
 - $email : string = null
 - 
                    
The group's email address.
 
Tags
Return values
mixed —The ID of the created group.
_exists()
Checks if a group exists.
    protected
                    _exists(mixed $gid) : bool
    
        Parameters
- $gid : mixed
 - 
                    
A group ID.
 
Return values
bool —True if the group exists.
_getData()
Returns all available attributes of a group.
    protected
                    _getData(mixed $gid) : array<string|int, mixed>
    
        Parameters
- $gid : mixed
 - 
                    
A group ID.
 
Tags
Return values
array<string|int, mixed> —The group's date.
_getListCache()
Returns the cached group list.
    protected
                    _getListCache([string $user = null ]) : array<string|int, mixed>
    
        Parameters
- $user : string = null
 - 
                    
A user name.
 
Return values
array<string|int, mixed> —The group list or null if not cached.
_getName()
Returns a group name.
    protected
                    _getName(mixed $gid) : string
    
        Parameters
- $gid : mixed
 - 
                    
A group ID.
 
Tags
Return values
string —The group's name.
_listAll()
Returns a list of all groups a user may see, with IDs as keys and names as values.
    protected
                    _listAll() : array<string|int, mixed>
    
    
    
        Return values
array<string|int, mixed> —All existing groups.
_listGroups()
Returns a list of groups a user belongs to.
    protected
                    _listGroups(string $user) : array<string|int, mixed>
    
        Parameters
- $user : string
 - 
                    
A user name.
 
Return values
array<string|int, mixed> —A list of groups, with IDs as keys and names as values.
_listUsers()
Returns a list of users in a group.
    protected
                    _listUsers(mixed $gid) : array<string|int, mixed>
    
        Parameters
- $gid : mixed
 - 
                    
A group ID.
 
Tags
Return values
array<string|int, mixed> —List of group users.
_remove()
Removes a group.
    protected
                    _remove(mixed $gid) : mixed
    
        Parameters
- $gid : mixed
 - 
                    
A group ID.
 
Tags
Return values
mixed —_removeUser()
Removes a user from a group.
    protected
                    _removeUser(mixed $gid, string $user) : mixed
    
        Parameters
- $gid : mixed
 - 
                    
A group ID.
 - $user : string
 - 
                    
A user name.
 
Tags
Return values
mixed —_rename()
Renames a group.
    protected
                    _rename(mixed $gid, string $name) : mixed
    
        Parameters
- $gid : mixed
 - 
                    
A group ID.
 - $name : string
 - 
                    
The new name.
 
Tags
Return values
mixed —_search()
Searches for group names.
    protected
                    _search(string $name) : array<string|int, mixed>
    
        Parameters
- $name : string
 - 
                    
A search string.
 
Return values
array<string|int, mixed> —A list of matching groups, with IDs as keys and names as values.
_setData()
Sets one or more attributes of a group.
    protected
                    _setData(mixed $gid, array<string|int, mixed>|string $attribute[, string $value = null ]) : mixed
    
        Parameters
- $gid : mixed
 - 
                    
A group ID.
 - $attribute : array<string|int, mixed>|string
 - 
                    
An attribute name or a hash of attributes.
 - $value : string = null
 - 
                    
An attribute value if $attribute is a string.
 
Tags
Return values
mixed —_setListCache()
Sets the cached group list.
    protected
                    _setListCache(array<string|int, mixed> $list[, string $user = null ]) : mixed
    
        Parameters
- $list : array<string|int, mixed>
 - 
                    
A group list.
 - $user : string = null
 - 
                    
A user name.
 
Return values
mixed —_sig()
Returns a full cache key.
    protected
                    _sig(string $key) : string
    
        Parameters
- $key : string
 - 
                    
The internal key.
 
Return values
string —The full key for Horde_Cache consumption.