Cell width: allows an attribute "width" to set the cell width (e.g. | or | ).
* Line breaks: Line breaks can be specified by adding a < > tag. The new line will start at the left border of the PDF document.
*
*
* Examples:
*
* Simple name+value lines:
* In most cases you will just want to display a single line per attribute with its name and value.
*
* 'myAttribute' => 'AttrName12345'
*
* This will give the following PDF output:
*
* Attribute name: 12345
*
*
* Multiline values:
* Sometimes you have multivalued attributes where it is not applicable to write all values in one line but
* where you want to list your values one below the other or show a table. This can be done by using the | tag.
*
* This example only uses one column but you can just use more | tags per tag to display more columns.
*
* 'myAttribute' => 'AttrName123 | 456 | 789 | '
*
* @return array PDF entries
*
* @see baseModule::get_metaData()
*/
public function get_pdfFields() {
return ((isset($this->meta['PDF_fields'])) ? $this->meta['PDF_fields'] : array());
}
/**
* Returns the PDF entries for this module.
*
* @return array list of possible PDF entries
*/
public function get_pdfEntries() {
return array();
}
/**
* Returns an array containing all input columns for the file upload.
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.
*
* This funtion returns an array which contains subarrays which represent an upload column.
* Syntax of column arrays:
*
* 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
* string: values, // possible input values (optional)
* string: default, // default value (optional)
* boolean: required // true, if user must set a value for this column
* boolean: unique // true if all values of this column must be different values (optional, default: "false")
* )
*
* @param array $selectedModules list of selected account modules
* @return array column list
*
* @see baseModule::get_metaData()
*/
public function get_uploadColumns($selectedModules) {
if (isset($this->meta['upload_columns'])) return $this->meta['upload_columns'];
else return array();
}
/**
* Returns a list of module names which must be processed in building the account befor this module.
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.
*
* The named modules may not be active, LAM will check this automatically.
*
* @return array list of module names
*
* @see baseModule::get_metaData()
*/
public function get_uploadPreDepends() {
if (isset($this->meta['upload_preDepends'])) return $this->meta['upload_preDepends'];
else return array();
}
/**
* In this function the LDAP accounts are built.
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.
*
* Returns an array which contains subarrays to generate StatusMessages if any errors occured.
*
* @param array $rawAccounts the user input data, contains one subarray for each account.
* @param array $ids list of IDs for column position (e.g. "posixAccount_uid" => 5)
* @param array $partialAccounts list of hash arrays (name => value) which are later added to LDAP
* @param array $selectedModules list of selected account modules
* @return array list of error messages if any
*/
public function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
// must be implemented in sub modules
return array();
}
/**
* This function returns the help entry array for a specific help id.
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.
*
* The result is an hashtable with the following keys:
*
* - Headline (required)
* The headline of this help entry. Can consist of any alpha-numeric characters. No HTML/CSS elements are allowed.
* - Text (required)
* The text of the help entry which may contain any alpha-numeric characters.
* - SeeAlso (optional)
* A reference to anonther related web site. It must be an array containing a field called "text" with the link text
* that should be displayed and a field called "link" which is the link target.
*
*
* Example:
*
* array('Headline' => 'This is the head line', 'Text' => 'Help content', 'SeeAlso' => array('text' => 'LAM homepage', 'link' => 'http://www.ldap-account-manager.org/'))
*
* @param string $id The id string for the help entry needed.
* @return array The desired help entry.
*
* @see baseModule::get_metaData()
*/
public function get_help($id) {
if(isset($this->meta['help'][$id])) {
return $this->meta['help'][$id];
}
elseif(isset($this->meta['help'][$this->scope][$id])) {
return $this->meta['help'][$this->scope][$id];
}
else {
return false;
}
}
/**
* This function is used to check if this module page can be displayed.
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.
*
* Your module might depend on input of other modules. This function determines if the user
* can change to your module page or not. The return value is true if your module accepts
* input, otherwise false.
* This method's return value defaults to true.
*
* @return boolean true, if page can be displayed
*/
public function module_ready() {
return true;
}
/**
* This function is used to check if all settings for this module have been made.
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.
*
* This function tells LAM if it can create/modify the LDAP account. If your module needs any
* additional input then set this to false. The user will be notified that your module needs
* more input.
* This method's return value defaults to true.
*
* @return boolean true, if settings are complete
*/
public function module_complete() {
return true;
}
/**
* Controls if the module button the account page is visible and activated.
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.
*
* Possible return values:
*
* - enabled: button is visible and active
* - disabled: button is visible and deactivated (greyed)
* - hidden: no button will be shown
*
*
* @return string status ("enabled", "disabled", "hidden")
*/
public function getButtonStatus() {
return "enabled";
}
/**
* This function is responsible to do additional tasks after the account has been created in LDAP (e.g. modifying group memberships, adding Quota etc..).
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.
*
* This function is called as long as the returned status is 'finished'. Please make sure
* that one function call lasts no longer than 3-4 seconds. Otherwise the upload may fail
* because the time limit is exceeded. You should not make more than one LDAP operation in
* each call.
*
* @param array $data array containing one account in each element
* @param array $ids maps the column names to keys for the sub arrays (array( => ))
* @param array $failed list of account numbers which could not be successfully uploaded to LDAP
* @param array $temp variable to store temporary data between two post actions
* @param array $accounts list of LDAP entries
* @return array current status
* array (
* 'status' => 'finished' | 'inProgress' // defines if all operations are complete
* 'progress' => 0..100 // the progress of the operations in percent
* 'errors' => array // list of arrays which are used to generate StatusMessages
* )
*/
public function doUploadPostActions(&$data, $ids, $failed, &$temp, &$accounts) {
return array(
'status' => 'finished',
'progress' => 100,
'errors' => array()
);
}
/**
* Returns a list of modifications which have to be made to the LDAP account.
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.
*
*
* This function returns an array with 3 entries:
* array( DN1 ('add' => array($attr), 'remove' => array($attr), 'modify' => array($attr)), DN2 .... )
* DN is the DN to change. It is possible to change several DNs (e.g. create a new user and add him
* to some groups via attribute memberUid)
* "add" are attributes which have to be added to the LDAP entry
* "remove" are attributes which have to be removed from the LDAP entry
* "modify" are attributes which have to be modified in the LDAP entry
* "notchanged" are attributes which stay unchanged
* "info" values with informational value (e.g. to be used later by pre/postModify actions)
*
* This builds the required comands from $this-attributes and $this->orig.
*
* @return array list of modifications
*/
public function save_attributes() {
return $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig);
}
/**
* Allows the module to run commands before the LDAP entry is changed or created.
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.
*
* The modification is aborted if an error message is returned.
*
* @param boolean $newAccount new account
* @param array $attributes LDAP attributes of this entry
* @return array array which contains status messages. Each entry is an array containing the status message parameters.
*/
public function preModifyActions($newAccount, $attributes) {
return array();
}
/**
* Allows the module to run commands after the LDAP entry is changed or created.
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.
*
* @param boolean $newAccount new account
* @param array $attributes LDAP attributes of this entry
* @return array array which contains status messages. Each entry is an array containing the status message parameters.
*/
public function postModifyActions($newAccount, $attributes) {
return array();
}
/**
* Allows the module to run commands before the LDAP entry is deleted.
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.
*
* @return array Array which contains status messages. Each entry is an array containing the status message parameters.
*/
public function preDeleteActions() {
return array();
}
/**
* Allows the module to run commands after the LDAP entry is deleted.
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.
*
* @return array Array which contains status messages. Each entry is an array containing the status message parameters.
*/
public function postDeleteActions() {
return array();
}
/**
* This function returns an array with the same syntax as save_attributes().
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.
*
* It allows additional LDAP changes when an account is deleted.
*
* @return List of LDAP operations, same as for save_attributes()
*/
public function delete_attributes() {
return 0;
}
/**
* This function creates meta HTML code which will be displayed when an account should be deleted.
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.
*
* This can be used to interact with the user, e.g. should the home directory be deleted? The output
* of all modules is displayed on a single page.
*
* @return htmlElement meta HTML object
* @see htmlElement
*/
public function display_html_delete() {
return 0;
}
/**
* This function processes user input.
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.
*
* It checks the user input and saves changes in the module's data structures.
*
* Example: return array(array('ERROR', 'Invalid input!', 'This is not allowed here.'));
*
* @return array Array which contains status messages. Each entry is an array containing the status message parameters.
*/
public abstract function process_attributes();
/**
* This function creates meta HTML code to display the module page.
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.
*
* @return htmlElement meta HTML object
*
* @see htmlElement
*/
public abstract function display_html_attributes();
/**
* Returns a list of managed object classes for this module.
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.
*
* This is used to fix spelling errors in LDAP-Entries (e.g. if "posixACCOUNT" is read instead of "posixAccount" from LDAP).
*
* Example: return array('posixAccount')
*
* @return array list of object classes
*
* @see baseModule::get_metaData()
*/
public function getManagedObjectClasses() {
if (isset($this->meta['objectClasses']) && is_array($this->meta['objectClasses'])) return $this->meta['objectClasses'];
else return array();
}
/**
* Returns a list of aliases for LDAP attributes.
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.
*
* All alias attributes will be renamed to the given attribute names.
*
* @return array list of aliases like array("alias name" => "attribute name")
*
* @see baseModule::get_metaData()
*/
public function getLDAPAliases() {
if (isset($this->meta['LDAPaliases']) && is_array($this->meta['LDAPaliases'])) return $this->meta['LDAPaliases'];
else return array();
}
/**
* Returns a list of LDAP attributes which are managed by this module.
* All attribute names will be renamed to match the given spelling.
*
* @return array list of attributes
*
* @see baseModule::get_metaData()
*/
public function getManagedAttributes() {
if (isset($this->meta['attributes']) && is_array($this->meta['attributes'])) return $this->meta['attributes'];
else return array();
}
/**
* This function returns a list of PHP extensions (e.g. hash) which are needed by this module.
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.
*
* @return array extensions
*
* @see baseModule::get_metaData()
*/
public function getRequiredExtensions() {
if (isset($this->meta['extensions']) && is_array($this->meta['extensions'])) return $this->meta['extensions'];
else return array();
}
/**
* This function returns a list of possible LDAP attributes (e.g. uid, cn, ...) which can be used to search for LDAP objects.
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.
*
* @return array attributes
*
* @see baseModule::get_metaData()
*/
public function getSelfServiceSearchAttributes() {
if (isset($this->meta['selfServiceSearchAttributes']) && is_array($this->meta['selfServiceSearchAttributes'])) return $this->meta['selfServiceSearchAttributes'];
else return array();
}
/**
* Returns a list of possible input fields and their descriptions.
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.
*
* Format: array( => )
*
* @return array fields
*
* @see baseModule::get_metaData()
*/
public function getSelfServiceFields() {
if (isset($this->meta['selfServiceFieldSettings']) && is_array($this->meta['selfServiceFieldSettings'])) return $this->meta['selfServiceFieldSettings'];
else return array();
}
/**
* Returns the meta HTML code for each input field.
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.
*
* It is not possible to display help links.
*
* @param array $fields list of active fields
* @param array $attributes attributes of LDAP account
* @param boolean $passwordChangeOnly indicates that the user is only allowed to change his password and no LDAP content is readable
* @return array list of meta HTML elements (field name => htmlTableRow)
*
* @see htmlElement
*/
public function getSelfServiceOptions($fields, $attributes, $passwordChangeOnly) {
// this function must be overwritten by subclasses.
return array();
}
/**
* Checks if all input values are correct and returns the LDAP attributes which should be changed.
* Return values:
* messages: array of parameters to create status messages
* add: array of attributes to add
* del: array of attributes to remove
* mod: array of attributes to modify
* info: array of values with informational value (e.g. to be used later by pre/postModify actions)
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.
*
* @param string $fields input fields
* @param array $attributes LDAP attributes
* @param boolean $passwordChangeOnly indicates that the user is only allowed to change his password and no LDAP content is readable
* @return array messages and attributes (array('messages' => array(), 'add' => array('mail' => array('test@test.com')), 'del' => array(), 'mod' => array(), 'info' => array()))
*/
public function checkSelfServiceOptions($fields, $attributes, $passwordChangeOnly) {
$return = array('messages' => array(), 'add' => array(), 'del' => array(), 'mod' => array(), 'info' => array());
return $return;
}
/**
* Returns a list of self service configuration settings.
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.
*
* The name attributes are used as keywords to load
* and save settings. We recommend to use the module name as prefix for them
* (e.g. posixAccount_homeDirectory) to avoid naming conflicts.
*
* @param selfServiceProfile $profile currently edited profile
* @return htmlElement meta HTML object
*
* @see baseModule::get_metaData()
* @see htmlElement
*/
public function getSelfServiceSettings($profile) {
if (isset($this->meta['selfServiceSettings'])) {
return $this->meta['selfServiceSettings'];
}
else {
return array();
}
}
/**
* Checks if the self service settings are valid.
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.
*
* If the input data is invalid the return value is an array that contains arrays
* to build StatusMessages (message type, message head, message text). If no errors
* occured the function returns an empty array.
*
* @param array $options hash array (option name => value) that contains the input. The option values are all arrays containing one or more elements.
* @param selfServiceProfile $profile self service profile
* @return array error messages
*/
public function checkSelfServiceSettings(&$options, &$profile) {
// needs to be implemented by the subclasses, if needed
return array();
}
/**
* Allows the module to run commands before the LDAP entry is changed or created.
*
* An error message should be printed if the function returns false.
*
* @param array $attributes LDAP attributes of this entry
* @return boolean true, if no problems occured
*/
public function preModifySelfService($attributes) {
return true;
}
/**
* Allows the module to run commands after the LDAP entry is changed or created.
*
* @param array $attributes LDAP attributes of this entry
* @return boolean true, if no problems occured
*/
public function postModifySelfService($attributes) {
return true;
}
/**
* This allows modules to create a link to a module specific page
* for the self service.
* The link is shown on the login page of the self service. You
* can use this to provide e.g. a page to reset passwords.
*
* @param array $settings self service settings
* @return String link text (null if no special page used)
*/
public function getLinkToSpecialSelfServicePage($settings) {
return null;
}
/**
* This function creates meta HTML code to display the module specific page
* for the self service.
*
* @param selfServiceProfile $profile self service settings
* @return htmlElement meta HTML object
*
* @see htmlElement
*/
public function displaySpecialSelfServicePage($profile) {
return null;
}
/**
* Returns the {@link accountContainer} object.
*
* @return accountContainer accountContainer object
*
* @see accountContainer
*/
protected function getAccountContainer() {
if (isset($this->base) && isset($_SESSION[$this->base])) {
return $_SESSION[$this->base];
}
else {
return null;
}
}
/**
* Returns the LDAP attributes which are managed in this module.
*
* @return array attributes
*/
public function getAttributes() {
return $this->attributes;
}
/**
* Returns the LDAP attributes which are managed in this module (with unchanged values).
*
* @return array attributes
*/
public function getOriginalAttributes() {
return $this->orig;
}
/**
* Returns the path to the module icon.
* The path must be releative to graphics (e.g. key.png). You can also set $this->meta['icon'].
* The preferred size is 32x32px.
*
* @return unknown
*
* @see baseModule::get_metaData()
*/
public function getIcon() {
if (isset($this->meta['icon'])) {
return $this->meta['icon'];
}
return null;
}
/**
* Manages AJAX requests.
* This function may be called with or without an account container.
*/
public function handleAjaxRequest() {
// modules that use AJAX need to implement this function
}
/**
* Specifies if this module supports the LAM admin interface.
* The LAM admin interface are the pages that allow to manage e.g. users and groups.
* In contrast there is also the LAM self service interface. Most modules support
* the admin interface.
*
* @return boolean support admin interface
*/
public static function supportsAdminInterface() {
return true;
}
// helper functions
/**
* Returns if the given configuration option is set.
* This function returns false if the configuration options cannot be read.
*
* @param String $optionName name of the option
* @return boolean true if option is set
*/
protected function isBooleanConfigOptionSet($optionName) {
// abort if configuration is not available
if (!isset($this->moduleSettings) || !is_array($this->moduleSettings)) {
return false;
}
if (isset($this->moduleSettings[$optionName][0]) && ($this->moduleSettings[$optionName][0] == 'true')) {
return true;
}
return false;
}
}
?> |