LDAPCommittee
        
        extends LDAPObject
    
    
            
            in package
            
        
    
    
    
        
            LDAP Committee class
Each committee (group) returned from the LDAPI will be an instance of the this class.
Tags
Table of Contents
- BIND_KEY = 'groups'
 - Key to the type of bind address (actual bind address is read by LDAPI)
 - FIXED_FIELDS = ['id', 'name', 'member_usernames']
 - List of fields that cannot be patched directly (when altered directly changes are not saved!)
 - LDAP_KEYS = [ // LDAP Required 'cn' => 'name', 'gidnumber' => 'id', // LDAP Optional 'memberuid' => 'member_usernames', ]
 - Maps LDAP keys to properties ('ldap_key' => 'property')
 - SEARCH_PREFIX = '(objectClass=posixGroup)(description=com)'
 - Search addition needed for ldap_search (contains object type)
 - $id : int|null
 - Primary id of this object
 - $member_usernames : array<string|int, mixed>
 - $members : array<string|int, LDAPUser>|null
 - $name : string
 - $dirty : array<string|int, mixed>
 - Altered fields, queue to be saved, 'field' => 'new_value'
 - $DISPLAY_KEYS : array<string|int, mixed>
 - Redeclare keys so they are separate from the parent class
 - $errors : array<string|int, mixed>
 - Validation errors, ordered by field as key
 - $ldapi_link : LDAPI
 - Link to LDAPI instance
 - $validators : array<string|int, mixed>
 - Validators to apply: 'field' => [list of rules]
 - __construct() : void
 - Extend parent construct, make sure member_usernames array is actually an array
 - __debugInfo() : array<string|int, mixed>
 - Override the standard PHP debug information to skip boring stuff
 - __toString() : string
 - Response when object is used as string (return name)
 - _clearDirty() : void
 - Clear all dirty fields
 - _dirty() : array<string|int, mixed>
 - Return dirty fields with their new values
 - _dirtyToLDAPArray() : array<string|int, mixed>
 - Collect all dirty fields and return an array compatible with ldap_save
 - _getDisplayKey() : string|false|array<string|int, mixed>
 - Find a display key (property) based on ldap_key
 - _getDNPrefix() : string
 - Return prefix needed for LDAP binds
 - _getLdapKey() : string|false|array<string|int, mixed>
 - Find an ldap key based on a display key (property)
 - _setErrors() : void
 - Add validation errors
 - _validate() : bool
 - Verify the content, errors are saved in $this->errors
 - addMembers() : bool
 - Add new member(s) to a committee and save it to the LDAP, also works on committee aliasing, pass committee name in this case
 - collectMembers() : void
 - Collect user object of members and save to property
 - getErrors() : array<string|int, mixed>|false
 - Return validation errors
 - init() : mixed
 - Initialize protected static values
 - patchEntity() : bool
 - Alter or insert data, validate it and mark it to be saved
 - removeMembers() : bool
 - Remove member(s) from a committee and save it to the LDAP
 - saveRename() : bool
 - Change the name of the committee and save it to the LDAP (recursively, aliases are modified accordingly) (errors are saved under 'name')
 - _buildObjectFromLdapData() : void
 - Fill instance according to LDAP data
 - validateMemberRecursion() : bool
 - Checks if new uid will create circular reference, which might break the mail server
 
Constants
BIND_KEY
Key to the type of bind address (actual bind address is read by LDAPI)
    public
    string
    BIND_KEY
    = 'groups'
        
    
FIXED_FIELDS
List of fields that cannot be patched directly (when altered directly changes are not saved!)
    public
    array<string|int, string>
    FIXED_FIELDS
    = ['id', 'name', 'member_usernames']
        
    
LDAP_KEYS
Maps LDAP keys to properties ('ldap_key' => 'property')
    public
    array<string|int, mixed>
    LDAP_KEYS
    = [
    // LDAP Required
    'cn' => 'name',
    'gidnumber' => 'id',
    // LDAP Optional
    'memberuid' => 'member_usernames',
]
        
    
SEARCH_PREFIX
Search addition needed for ldap_search (contains object type)
    public
    string
    SEARCH_PREFIX
    = '(objectClass=posixGroup)(description=com)'
        
    
Properties
$id
Primary id of this object
    public
        int|null
    $id
     = null
        
    
$member_usernames
    public
        array<string|int, mixed>
    $member_usernames
     = null
        
    
$members
    public
        array<string|int, LDAPUser>|null
    $members
     = null
        
    
$name
    public
        string
    $name
     = null
        
    
$dirty
Altered fields, queue to be saved, 'field' => 'new_value'
    protected
        array<string|int, mixed>
    $dirty
     = []
        
    
$DISPLAY_KEYS
Redeclare keys so they are separate from the parent class
    protected
    static    array<string|int, mixed>
    $DISPLAY_KEYS
     = []
        
    
    Tags
$errors
Validation errors, ordered by field as key
    protected
        array<string|int, mixed>
    $errors
     = []
        
    
$ldapi_link
Link to LDAPI instance
    protected
        LDAPI
    $ldapi_link
    
        
    
$validators
Validators to apply: 'field' => [list of rules]
    protected
    static    array<string|int, mixed>
    $validators
     = ['id' => ['optional' => [], 'is_number' => []], 'name' => ['is_string' => [], 'string_length' => [4, 99]], 'member_usernames' => ['optional' => [], 'is_array' => []]]
        
    
Methods
__construct()
Extend parent construct, make sure member_usernames array is actually an array
    public
                __construct([array<string|int, mixed>|null $ldap_entry = null ][, LDAPI|null &$ldapi_link = null ]) : void
        
        Parameters
- $ldap_entry : array<string|int, mixed>|null = null
 - 
                    
LDAP array
 - $ldapi_link : LDAPI|null = null
 - 
                    
Link to LDAPI instance
 
Return values
void —__debugInfo()
Override the standard PHP debug information to skip boring stuff
    public
                __debugInfo() : array<string|int, mixed>
        
    
    
        Return values
array<string|int, mixed> —__toString()
Response when object is used as string (return name)
    public
                __toString() : string
        
    
    
        Return values
string —_clearDirty()
Clear all dirty fields
    public
                _clearDirty() : void
        
    
    
        Return values
void —_dirty()
Return dirty fields with their new values
    public
                _dirty() : array<string|int, mixed>
        
    
    
        Return values
array<string|int, mixed> —_dirtyToLDAPArray()
Collect all dirty fields and return an array compatible with ldap_save
    public
                _dirtyToLDAPArray() : array<string|int, mixed>
        The keys of the array will be ldap keys.
Return values
array<string|int, mixed> —_getDisplayKey()
Find a display key (property) based on ldap_key
    public
            static    _getDisplayKey([ $ldap_key = null ]) : string|false|array<string|int, mixed>
        If a key could not be found, false is returned and a warning is triggered.
The LDAP_KEYS array contains display keys as values, hence it's used here.
Parameters
Return values
string|false|array<string|int, mixed> —_getDNPrefix()
Return prefix needed for LDAP binds
    public
                _getDNPrefix() : string
        
    
    
        Return values
string —_getLdapKey()
Find an ldap key based on a display key (property)
    public
            static    _getLdapKey([ $display_key = null ]) : string|false|array<string|int, mixed>
        If a key could not be found, false is returned and a warning is triggered.
The DISPLAY_KEYS array contains ldap keys as values, hence it's used here.
Parameters
Return values
string|false|array<string|int, mixed> —_setErrors()
Add validation errors
    public
                _setErrors(string $field, array<string|int, mixed>|string $errors) : void
        
        Parameters
- $field : string
 - 
                    
For property or field
 - $errors : array<string|int, mixed>|string
 - 
                    
Error message(s)
 
Return values
void —_validate()
Verify the content, errors are saved in $this->errors
    public
                _validate([array<string|int, mixed>|null $fields = null ]) : bool
        
        Parameters
- $fields : array<string|int, mixed>|null = null
 - 
                    
Verify these fields only, if null all dirty fields are processed
 
Return values
bool —False on errors
addMembers()
Add new member(s) to a committee and save it to the LDAP, also works on committee aliasing, pass committee name in this case
    public
                addMembers(string|array<string|int, string>|LDAPUser|array<string|int, LDAPUser> $new_members[, bool $check = true ]) : bool
        The method will return true if at least one update has been made. It no new members were passed or checks failed for each entry, the method will return false.
Parameters
- $new_members : string|array<string|int, string>|LDAPUser|array<string|int, LDAPUser>
 - 
                    
Array or single, username or LDAPUser object
 - $check : bool = true
 - 
                    
False to disable check, useful for external aliases
 
Return values
bool —collectMembers()
Collect user object of members and save to property
    public
                collectMembers() : void
        
    
    
        Return values
void —getErrors()
Return validation errors
    public
                getErrors([string|null $val = null ]) : array<string|int, mixed>|false
        
        Parameters
- $val : string|null = null
 - 
                    
Return errors for this field or return all errors
 
Return values
array<string|int, mixed>|false —Array of errors or false if none exist
init()
Initialize protected static values
    public
            static    init() : mixed
        
    
    
        Return values
mixed —patchEntity()
Alter or insert data, validate it and mark it to be saved
    public
                patchEntity(array<string|int, mixed> $data) : bool
        
        Parameters
- $data : array<string|int, mixed>
 
Return values
bool —False on validation errors
removeMembers()
Remove member(s) from a committee and save it to the LDAP
    public
                removeMembers(string|array<string|int, string>|LDAPUser|array<string|int, LDAPUser> $old_members) : bool
        
        Parameters
- $old_members : string|array<string|int, string>|LDAPUser|array<string|int, LDAPUser>
 - 
                    
List or single item, username or LDAPUser
 
Return values
bool —saveRename()
Change the name of the committee and save it to the LDAP (recursively, aliases are modified accordingly) (errors are saved under 'name')
    public
                saveRename(string $new_name) : bool
        
        Parameters
- $new_name : string
 
Return values
bool —_buildObjectFromLdapData()
Fill instance according to LDAP data
    protected
                _buildObjectFromLdapData(array<string|int, mixed> $entry) : void
        
        Parameters
- $entry : array<string|int, mixed>
 - 
                    
LDAP entry array (single entry!)
 
Return values
void —validateMemberRecursion()
Checks if new uid will create circular reference, which might break the mail server
    private
                validateMemberRecursion(string $root_id[, null|array<string|int, string> &$committees_check_list = null ]) : bool
        This method should be called from committee that is to be added, not from the modified committee. Note: this method will also return false when an existing circle has been found, even if it's outside the new alias that's being checked.
Parameters
- $root_id : string
 - 
                    
Name of committee that should not be in any of the other committees
 - $committees_check_list : null|array<string|int, string> = null
 - 
                    
List of all the committees already checked, used to detect an existing circular dependency - Leave at default when calling the method for the first time
 
Return values
bool —Returns false when there is a recursive problem