lib/modules.inc
Properties
Description
Interface between modules and other parts of LAM.Functions
getModuleAlias( string $name, string $scope, ) : string
Description
Returns the alias name of a moduleArguments
Name | Type | Description | Default |
---|---|---|---|
$name | string | the module name |
|
$scope | string | the account type ("user", "group", "host") |
Return value
Type | Description |
---|---|
string | alias name |
is_base_module( string $name, string $scope, ) : boolean
Description
Returns true if the module is a base moduleArguments
Name | Type | Description | Default |
---|---|---|---|
$name | string | the module name |
|
$scope | string | the account type ("user", "group", "host") |
Return value
Type | Description |
---|---|
boolean | true if base module |
get_ldap_filter( string $scope, ) : string
Description
Returns the LDAP filter used by the account listsArguments
Name | Type | Description | Default |
---|---|---|---|
$scope | string | the account type ("user", "group", "host") |
Return value
Type | Description |
---|---|
string | LDAP filter |
getRDNAttributes( string $scope, array $selectedModules = null, ) : array
Description
Returns a list of LDAP attributes which can be used to form the RDN.The list is already sorted by the priority given by the nodules.
Arguments
Name | Type | Description | Default |
---|---|---|---|
$scope | string | account type (user, group, host) |
|
$selectedModules | array | return only RDN attributes of these modules |
null |
Return value
Type | Description |
---|---|
array | list of LDAP attributes |
getModulesDependencies( string $scope, ) : array
Description
Returns a hash array (module name => dependencies) of all module dependencies"dependencies" contains an array with two sub arrays: depends, conflicts
The elements of "depends" are either module names or an array of module names (OR-case).
The elements of conflicts are module names.
Arguments
Name | Type | Description | Default |
---|---|---|---|
$scope | string | the account type (user, group, host) |
Return value
Type | Description |
---|---|
array | dependencies |
check_module_depends( array $selected, array $deps, ) : mixed
Description
Checks if there are missing dependencies between modules.Arguments
Name | Type | Description | Default |
---|---|---|---|
$selected | array | selected module names |
|
$deps | array | module dependencies |
Return value
Type | Description |
---|---|
mixed | false if no misssing dependency was found, otherwise an array of array(selected module, depending module) if missing dependencies were found |
check_module_conflicts( array $selected, array $deps, ) : boolean
Description
Checks if there are conflicts between modulesArguments
Name | Type | Description | Default |
---|---|---|---|
$selected | array | selected module names |
|
$deps | array | module dependencies |
Return value
Type | Description |
---|---|
boolean | false if no conflict was found, otherwise an array of array(selected module, conflicting module) if conflicts were found |
getAvailableModules( string $scope, boolean $mustSupportAdminInterface = false, ) : array
Description
Returns an array with all available user module namesArguments
Name | Type | Description | Default |
---|---|---|---|
$scope | string | account type (user, group, host) |
|
$mustSupportAdminInterface | boolean | module must support LAM admin interface (default: false) |
false |
Return value
Type | Description |
---|---|
array | list of possible modules |
getProfileOptions( string $scope, ) : array
Description
Returns the elements for the profile page.Arguments
Name | Type | Description | Default |
---|---|---|---|
$scope | string | account type (user, group, host) |
Return value
Type | Description |
---|---|
array | profile elements |
checkProfileOptions( string $scope, array $options, ) : array
Description
Checks if the profile options are validArguments
Name | Type | Description | Default |
---|---|---|---|
$scope | string | account type (user, group, host) |
|
$options | array | hash array containing all options (name => array(...)) |
Return value
Type | Description |
---|---|
array | list of error messages |
getConfigOptions( array $scopes, ) : array
Description
Returns a hash array (module name => elements) of all module options for the configuration page.Arguments
Name | Type | Description | Default |
---|---|---|---|
$scopes | array | hash array (module name => array(account types)) |
Return value
Type | Description |
---|---|
array | configuration options |
checkConfigOptions( array $scopes, array $options, ) : array
Description
Checks if the configuration options are validArguments
Name | Type | Description | Default |
---|---|---|---|
$scopes | array | hash array (module name => array(account types)) |
|
$options | array | hash array containing all options (name => array(...)) |
Return value
Type | Description |
---|---|
array | list of error messages |
getHelp( string $module, string $helpID, string $scope = '', ) : array
Description
Returns a help entry from an account module.Arguments
Name | Type | Description | Default |
---|---|---|---|
$module | string | module name |
|
$helpID | string | help identifier |
|
$scope | string | account type |
'' |
Return value
Type | Description |
---|---|
array | help entry |
getAvailablePDFFields( string $scope, ) : array
Description
Returns a list of available PDF entries.Arguments
Name | Type | Description | Default |
---|---|---|---|
$scope | string | account type (user, group, host) |
Return value
Type | Description |
---|---|
array | PDF entries (field ID => field label) |
getUploadColumns( string $scope, array $selectedModules, ) : array
Description
Returns an array containing all input columns for the file upload.Syntax:
array(
string: name, // fixed non-translated name which is used as column name (should be of format:
string: description, // short descriptive name
string: help, // help ID
string: example, // example value
boolean: required // true, if user must set a value for this column
)
Arguments
Name | Type | Description | Default |
---|---|---|---|
$scope | string | account type |
|
$selectedModules | array | selected account modules |
Return value
Type | Description |
---|---|
array | column list |
buildUploadAccounts( string $scope, array $data, array $ids, array $selectedModules, ) : mixed
Description
This function builds the LDAP accounts for the file upload.If there are problems status messages will be printed automatically.
Arguments
Name | Type | Description | Default |
---|---|---|---|
$scope | string | account type |
|
$data | array | array containing one account in each element |
|
$ids | array | array( |
|
$selectedModules | array | selected account modules |
Return value
Type | Description |
---|---|
mixed | array including accounts or false if there were errors |
doUploadPreActions( String $scope, array $selectedModules, array $attributes, ) : array
Description
Runs any actions that need to be done before an LDAP entry is created.Arguments
Name | Type | Description | Default |
---|---|---|---|
$scope | String | account type |
|
$selectedModules | array | list of selected account modules |
|
$attributes | array | LDAP attributes of this entry (attributes are provided as reference, handle modifications of $attributes with care) |
Return value
Type | Description |
---|---|
array | array which contains status messages. Each entry is an array containing the status message parameters. |
doUploadPostActions( string $scope, array $data, array $ids, array $failed, array $selectedModules, array $accounts, ) : array
Description
This function executes one post upload action.Arguments
Name | Type | Description | Default |
---|---|---|---|
$scope | string | account type |
|
$data | array | array containing one account in each element |
|
$ids | array | array( |
|
$failed | array | list of accounts which were not created successfully |
|
$selectedModules | array | list of selected account modules |
|
$accounts | array | list of LDAP entries |
Return value
Type | Description |
---|---|
array | current status <br> array ( <br> 'status' => 'finished' | 'inProgress' <br> 'module' => <name of active module> <br> 'progress' => 0..100 <br> 'errors' => array (<array of parameters for StatusMessage>) <br> ) |
getRequiredExtensions( ) : array
Description
Returns true if the module is a base moduleReturn value
Type | Description |
---|---|
array | required extensions |
parseHtml( string $module, mixed $input, array $values, boolean $restricted, integer $tabindex, string $scope, ) : array
Description
Takes a list of meta-HTML elements and prints the equivalent HTML output.The modules are not allowed to display HTML code directly but return meta HTML code. This allows to have a common design for all module pages.
Arguments
Name | Type | Description | Default |
---|---|---|---|
$module | string | Name of account module |
|
$input | mixed | htmlElement or array of htmlElement elements |
|
$values | array | List of values which override the defaults in $input (name => value) |
|
$restricted | boolean | If true then no buttons will be displayed |
|
$tabindex | integer | Start value of tabulator index for input fields |
|
$scope | string | Account type |
Return value
Type | Description |
---|---|
array | List of input field names and their type (name => type) |
lamCompareDescriptiveOptions( array $a, array $b, ) : integer
Description
Helper function to sort descriptive options in parseHTML().It compares the second entries of two arrays.
Arguments
Name | Type | Description | Default |
---|---|---|---|
$a | array | first array |
|
$b | array | second array |
Return value
Type | Description |
---|---|
integer | compare result |
printHelpLink( array $entry, String $number, String $module = '', String $scope = '', ) : n/a
Description
Prints a LAM help link.Arguments
Name | Type | Description | Default |
---|---|---|---|
$entry | array | help entry |
|
$number | String | help number |
|
$module | String | module name |
'' |
$scope | String | account scope |
'' |
Return value
Type | Description |
---|---|
n/a | n/a |
Classes
accountContainer
Description
This class includes all modules and attributes of an account.Methods
__construct, __sleep, __wakeup, continue_main, fixLDAPAttributes, getAccountModule, getAccountModules, getOUs, getParentDN, getRDN, get_pdfEntries, get_type, loadProfileIfRequested, load_account, new_account, printCommonControls, printModuleContent, printModuleTabs, printPageFooter, printPageHeader, printPasswordPromt, printSuccessPage, save_account, save_module_attributes, setNewPassword, showSetPasswordButton, sortModules,__construct( string $type, string $base, ) : n/a
Description
ConstructorArguments
Name | Type | Description | Default |
---|---|---|---|
$type | string | account type |
|
$base | string | key in $_SESSION where this object is saved |
Return value
Type | Description |
---|---|
n/a | n/a |
__sleep( ) : array
Description
Encrypts sensitive data before storing in session.Return value
Type | Description |
---|---|
array | list of attributes which are serialized |
__wakeup( ) : n/a
Description
Decrypts sensitive data after accountContainer was loaded from session.Return value
Type | Description |
---|---|
n/a | n/a |
continue_main( ) : n/a
Description
This function is called when the user clicks on any button on the account pages.It prints the HTML code of each account page.
Return value
Type | Description |
---|---|
n/a | n/a |
fixLDAPAttributes( array $attributes, array $modules, ) : array
Description
Fixes spelling errors in the attribute names.Arguments
Name | Type | Description | Default |
---|---|---|---|
$attributes | array | LDAP attributes |
|
$modules | array | list of active modules |
Return value
Type | Description |
---|---|
array | fixed attributes |
getAccountModule( string $name, ) : \baseModule
Description
Returns the account module with the given class nameArguments
Name | Type | Description | Default |
---|---|---|---|
$name | string | class name (e.g. posixAccount) |
Return value
Type | Description |
---|---|
\baseModule | account module |
getAccountModules( ) : array
Description
Returns the included account modules.Return value
Type | Description |
---|---|
array | modules |
getOUs( ) : array
Description
Returns a list of OUs that exist for this account type.Return value
Type | Description |
---|---|
array | OU list |
getParentDN( String $dn, ) : String
Description
Returns the parent DN of a given DN.Arguments
Name | Type | Description | Default |
---|---|---|---|
$dn | String | DN |
Return value
Type | Description |
---|---|
String | DN |
getRDN( String $dn, ) : String
Description
Returns the RDN part of a given DN.Arguments
Name | Type | Description | Default |
---|---|---|---|
$dn | String | DN |
Return value
Type | Description |
---|---|
String | RDN |
get_pdfEntries( ) : \list
Description
Returns a list of possible PDF entries for this account.Return value
Type | Description |
---|---|
\list | of PDF entries (array(<name> => <PDF lines>)) |
get_type( ) : string
Description
Returns the accout type of this object (e.g. user, group, host).Return value
Type | Description |
---|---|
string | account type |
loadProfileIfRequested( ) : boolean
Description
Checks if the user requested to load a profile.Return value
Type | Description |
---|---|
boolean | true, if profile was loaded |
load_account( string $dn, array $infoAttributes = array(), ) : array
Description
Loads an LDAP account with the given DN.Arguments
Name | Type | Description | Default |
---|---|---|---|
$dn | string | the DN of the account |
|
$infoAttributes | array | list of additional informational attributes that are added to the LDAP attributes E.g. this is used to inject the clear text password in the file upload. Informational attribute names must start with "INFO.". |
array() |
Return value
Type | Description |
---|---|
array | error messages |
new_account( ) : n/a
Description
This function will prepare the object for a new account.Return value
Type | Description |
---|---|
n/a | n/a |
printCommonControls( int $tabindex, ) : n/a
Description
Prints common controls like the save button and the ou selection.Arguments
Name | Type | Description | Default |
---|---|---|---|
$tabindex | int | tabindex for GUI elements |
Return value
Type | Description |
---|---|
n/a | n/a |
printModuleContent( array $result, boolean $stopProcessing, ) : n/a
Description
Prints the content part provided by the current module.Arguments
Name | Type | Description | Default |
---|---|---|---|
$result | array | list of messages |
|
$stopProcessing | boolean | true if page should end after displaying the messages |
Return value
Type | Description |
---|---|
n/a | n/a |
printModuleTabs( ) : n/a
Description
Prints the HTML code of the module tabs.Return value
Type | Description |
---|---|
n/a | n/a |
printPageFooter( ) : n/a
Description
Prints the footer of the account pages.Return value
Type | Description |
---|---|
n/a | n/a |
printPageHeader( ) : n/a
Description
Prints the header of the account pages.Return value
Type | Description |
---|---|
n/a | n/a |
printPasswordPromt( ) : n/a
Description
Prints the input fields of the central password service.Return value
Type | Description |
---|---|
n/a | n/a |
printSuccessPage( array $messages, ) : n/a
Description
Prints the HTML code to notify the user about the successful saving.Arguments
Name | Type | Description | Default |
---|---|---|---|
$messages | array | array which contains status messages. Each entry is an array containing the status message parameters. |
Return value
Type | Description |
---|---|
n/a | n/a |
save_account( ) : array
Description
This function will save an account to the LDAP database.Return value
Type | Description |
---|---|
array | list of status messages |
save_module_attributes( array $attributes, array $orig, ) : array
Description
This function checks which LDAP attributes have changed while the account was edited.Arguments
Name | Type | Description | Default |
---|---|---|---|
$attributes | array | list of current LDAP attributes |
|
$orig | array | list of old attributes when account was loaded |
Return value
Type | Description |
---|---|
array | an array which can be passed to $this->saveAccount() |
setNewPassword( array $input, ) : n/a
Description
Sets the new password in all selected account modules.Arguments
Name | Type | Description | Default |
---|---|---|---|
$input | array | input parameters |
Return value
Type | Description |
---|---|
n/a | n/a |
Properties
$attributes, $attributes_orig, $base, $cachedOUs, $current_page, $dnSuffix, $dn_orig, $finalDN, $isNewAccount, $lastLoadedProfile, $module, $order, $rdn, $sendPasswordViaMail, $sendPasswordViaMailAlternateAddress, $subpage, $titleBarSubtitle, $titleBarTitle, $type,public $attributes =
Array of all used attributes Syntax is attribute => array ( objectClass => MUST or MAY, ...)
Interfaces
passwordService
Description
This interface needs to be implemented by all account modules which manage passwords.It allows LAM to provide central password changes.
Methods
managesPasswordAttributes, passwordChangeRequested, supportsForcePasswordChange,managesPasswordAttributes( ) : boolean
Description
This method specifies if a module manages password attributes. The module alias will then appear as option in the GUI.If the module only wants to get notified about password changes then return false.
Return value
Type | Description |
---|---|
boolean | true if this module manages password attributes |
passwordChangeRequested( String $password, array $modules, boolean $forcePasswordChange, ) : array
Description
This function is called whenever the password should be changed. Account modules must change their password attributes only if the modules list contains their module name.Arguments
Name | Type | Description | Default |
---|---|---|---|
$password | String | new password |
|
$modules | array | list of modules for which the password should be changed |
|
$forcePasswordChange | boolean | force the user to change his password at next login |
Return value
Type | Description |
---|---|
array | list of error messages if any as parameter array for StatusMessage e.g. return arrray(array('ERROR', 'Password change failed.')) |