LDAPAccountManager/lam/lib/baseModule.inc

2241 lines
81 KiB
PHP
Raw Normal View History

2004-06-08 18:39:53 +00:00
<?php
2017-02-18 09:13:08 +00:00
use \LAM\PDF\PDFLabelValue;
use \LAM\PDF\PDFTable;
2017-05-20 08:55:26 +00:00
use LAM\TYPES\ConfiguredType;
2017-12-20 19:44:08 +00:00
use function LAM\TYPES\getScopeFromTypeId;
2018-08-25 17:39:47 +00:00
use LAM\PDF\PDFImage;
2004-06-08 18:39:53 +00:00
/*
2009-10-27 18:47:12 +00:00
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
2018-01-13 18:58:55 +00:00
Copyright (C) 2003 - 2018 Roland Gruber
2004-06-08 18:39:53 +00:00
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* This is the parent class for all account modules.
*
* It implements the complete module interface and uses meta-data
* provided by the account modules for its functions.
*
* @package modules
* @author Roland Gruber
* @see baseModule
2004-06-08 18:39:53 +00:00
*/
2017-02-15 20:45:26 +00:00
/** PDF functions */
include_once('pdf.inc');
2004-06-08 18:39:53 +00:00
/**
2007-07-08 19:00:55 +00:00
* Parent class of all account modules.
* It implements the complete module interface and uses meta-data
* provided by the account modules for its functions.<br>
* <br>
* <b>Location and naming of modules</b><br>
* All LAM modules are placed in lib/modules/ and are named "<class name>.inc".
* E.g. if you create a new module and its class name is "qmail" then the filename would be "qmail.inc".
* The class name of a module must contain only a-z, A-Z, 0-9, -, and _.<br>
* <br>
* You can avoid to override many functions by using {@link get_metaData()}.<br>
* <br>
* All module classes should extend the baseModule class.
2004-06-08 18:39:53 +00:00
*
* @package modules
* @author Roland Gruber
2004-06-08 18:39:53 +00:00
*/
2007-07-08 19:00:55 +00:00
abstract class baseModule {
2004-06-08 18:39:53 +00:00
/** includes all meta data provided by the sub class */
2007-07-08 19:00:55 +00:00
protected $meta;
2004-06-08 18:39:53 +00:00
/** the account type of this module (user, group, host) */
2007-10-04 16:45:05 +00:00
private $scope;
2004-06-08 18:39:53 +00:00
2004-07-26 15:15:30 +00:00
/** configuration settings of all modules */
2007-07-08 19:00:55 +00:00
protected $moduleSettings;
2004-07-26 15:15:30 +00:00
2018-10-15 19:05:39 +00:00
/**
* self service profile with settings of all modules
* @var selfServiceProfile profile
*/
2007-07-08 19:00:55 +00:00
protected $selfServiceSettings;
2006-11-21 17:37:12 +00:00
/** name of parent accountContainer ($_SESSION[$base]) */
2007-10-03 18:02:10 +00:00
private $base;
/** contains all ldap attributes which should be written */
2007-07-08 19:00:55 +00:00
protected $attributes;
2006-08-14 17:29:45 +00:00
/** contains all ldap attributes which are loaded from ldap */
2007-07-08 19:00:55 +00:00
protected $orig;
/** contains all error messages of a module */
2007-07-08 19:00:55 +00:00
protected $messages;
2015-07-08 17:14:52 +00:00
2007-11-18 10:35:56 +00:00
/** if true, managed object classes are added when an account is created or loaded (default: true) */
2013-12-26 11:22:45 +00:00
protected $autoAddObjectClasses = true;
2004-06-08 18:39:53 +00:00
/**
* Creates a new base module class
*
* @param string $scope the account type (user, group, host)
*/
2007-12-28 16:08:56 +00:00
public function __construct($scope) {
2004-06-08 18:39:53 +00:00
$this->scope = $scope;
// load configuration
2014-05-26 18:42:55 +00:00
if ($this->can_manage() || ($scope == 'none')) {
2018-12-26 08:53:58 +00:00
if (isset($_SESSION['config'])) {
$this->moduleSettings = $_SESSION['config']->get_moduleSettings();
}
if (isset($_SESSION['selfServiceProfile'])) {
$this->selfServiceSettings = $_SESSION['selfServiceProfile'];
}
// initialize module
$this->load_Messages();
$this->meta = $this->get_metaData();
}
2004-06-08 18:39:53 +00:00
}
2004-09-27 19:12:22 +00:00
/**
* This function fills the $messages variable with output messages from this module.
2015-07-08 17:14:52 +00:00
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.
2004-09-27 19:12:22 +00:00
*/
2007-10-04 16:45:05 +00:00
protected function load_Messages() {
2004-09-27 19:12:22 +00:00
}
/**
* Initializes the module after it became part of an {@link accountContainer}
2015-07-08 17:14:52 +00:00
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.
*
* @param string $base the name of the {@link accountContainer} object ($_SESSION[$base])
*/
public function init($base) {
$this->base = $base;
2006-05-14 07:47:50 +00:00
$this->attributes = array();
$this->orig = array();
// add object classes if needed
$this->attributes['objectClass'] = array();
$this->orig['objectClass'] = array();
2007-11-18 10:35:56 +00:00
if ($this->autoAddObjectClasses === true) {
2017-04-22 14:14:15 +00:00
$objectClasses = $this->getManagedObjectClasses($this->getAccountContainer()->get_type()->getId());
2007-11-18 10:35:56 +00:00
for ($i = 0; $i < sizeof($objectClasses); $i++) {
if (!in_array($objectClasses[$i], $this->attributes['objectClass'])) {
$this->attributes['objectClass'][] = $objectClasses[$i];
}
}
2006-05-14 07:47:50 +00:00
}
}
/**
* This function loads the LDAP attributes when an account should be loaded.
2015-07-08 17:14:52 +00:00
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.<br>
* <br>
* By default this method loads the object classes and accounts which are specified in {@link getManagedObjectClasses()}
* and {@link getManagedAttributes()}.
*
* @param array $attributes array like the array returned by get_ldap_attributes(dn of account) but without count indices
2004-09-18 18:44:47 +00:00
*/
public function load_attributes($attributes) {
2006-05-13 08:55:31 +00:00
$this->attributes = array();
$this->attributes = array();
// load object classes
if (isset($attributes['objectClass'])) {
$this->attributes['objectClass'] = $attributes['objectClass'];
$this->orig['objectClass'] = $attributes['objectClass'];
}
else {
$this->attributes['objectClass'] = array();
$this->orig['objectClass'] = array();
}
2017-04-22 14:14:15 +00:00
$typeId = $this->getAccountContainer()->get_type()->getId();
2006-05-13 08:55:31 +00:00
// add object classes if needed
2007-11-18 10:35:56 +00:00
if ($this->autoAddObjectClasses === true) {
2017-04-22 14:14:15 +00:00
$objectClasses = $this->getManagedObjectClasses($typeId);
2007-11-18 10:35:56 +00:00
for ($i = 0; $i < sizeof($objectClasses); $i++) {
if (!in_array($objectClasses[$i], $this->attributes['objectClass'])) {
$this->attributes['objectClass'][] = $objectClasses[$i];
}
}
2006-05-13 08:55:31 +00:00
}
// load attributes
2017-12-22 09:41:31 +00:00
$attributeNames = array_merge($this->getManagedAttributes($typeId), $this->getManagedHiddenAttributes($typeId));
$attributeNames = array_unique($attributeNames);
2018-01-13 18:58:55 +00:00
$attributeNames = array_values($attributeNames);
2006-05-13 08:55:31 +00:00
for ($i = 0; $i < sizeof($attributeNames); $i++) {
if (isset($attributes[$attributeNames[$i]])) {
$this->attributes[$attributeNames[$i]] = $attributes[$attributeNames[$i]];
$this->orig[$attributeNames[$i]] = $attributes[$attributeNames[$i]];
2004-09-18 18:44:47 +00:00
}
}
}
2004-06-08 18:39:53 +00:00
/**
2008-02-03 14:28:28 +00:00
* This function provides meta data which is interpreted by baseModule.
* Only subclasses will return real data.<br>
* <br>
* The aim of the meta data is to reduce the number
* of functions in the subclasses. All major data is centralized in one place.<br>
* <br>
* The returned array contains a list of key-value pairs for the different functions.<br>
* <ul>
2015-07-08 17:14:52 +00:00
*
2008-02-03 14:28:28 +00:00
* <li><b>{@link is_base_module()}</b><br>
* <br>
* <b>Key:</b> is_base<br>
* <b>Value:</b> boolean<br>
* <br>
* <b>Example:</b> "is_base" => true
* <br><br>
* </li>
2015-07-08 17:14:52 +00:00
*
2008-02-03 14:28:28 +00:00
* <li><b>{@link get_ldap_filter()}</b><br>
* <br>
* <b>Key:</b> ldap_filter<br>
* <b>Value:</b> array of filters<br>
* <br>
* <b>Example:</b> "ldap_filter" => array('or' => 'objectClass=posixAccount', 'and' => '(!(uid=*$))')
* <br><br>
* </li>
2015-07-08 17:14:52 +00:00
*
2008-02-03 14:28:28 +00:00
* <li><b>{@link getManagedObjectClasses()}</b><br>
* <br>
* <b>Key:</b> objectClasses<br>
* <b>Value:</b> array of object classes<br>
* <br>
* <b>Example:</b> "objectClasses" => array('posixAccount')
* <br><br>
* </li>
2015-07-08 17:14:52 +00:00
*
2008-02-03 14:28:28 +00:00
* <li><b>{@link getLDAPAliases()}</b><br>
* <br>
* <b>Key:</b> LDAPaliases<br>
* <b>Value:</b> array of aliases<br>
* <br>
* <b>Example:</b> "LDAPaliases" => array('commonName' => 'cn')
* <br><br>
* </li>
2015-07-08 17:14:52 +00:00
*
2008-02-03 14:28:28 +00:00
* <li><b>{@link get_RDNAttributes()}</b><br>
* <br>
* <b>Key:</b> RDN<br>
* <b>Value:</b> array of RDNs<br>
* <br>
* <b>Example:</b> "RDN" => array('uid' => 'normal', 'cn' => 'low')
* <br><br>
* </li>
2015-07-08 17:14:52 +00:00
*
2008-02-03 14:28:28 +00:00
* <li><b>{@link get_dependencies()}</b><br>
* <br>
* <b>Key:</b> dependencies<br>
* <b>Value:</b> array of dependencies<br>
* <br>
* <b>Example:</b> "dependencies" => array("depends" => array("posixAccount", array("qmail", "sendmail")), "conflicts" => array("exim"))
* <br><br>
* </li>
2015-07-08 17:14:52 +00:00
*
2008-02-03 14:28:28 +00:00
* <li><b>{@link get_profileOptions()}</b><br>
* <br>
* <b>Key:</b> profile_options<br>
* <b>Value:</b> array of profile options<br>
* <br>
* The syntax for the value array is the same as for the return value of get_profileOptions().
* <br><br>
* </li>
2015-07-08 17:14:52 +00:00
*
2008-02-03 14:28:28 +00:00
* <li><b>{@link check_profileOptions()}</b><br>
* <br>
* <b>Key:</b> profile_checks<br>
* <b>Value:</b> array of checks (array("optionName" => array()))<br>
* <br>
* The "optionName" keys of the value array are the names of the option identifiers.<br>
* Each array element is an array itself containing these values:
* <ul>
* <li><b>type:</b> determines how to check input<br>
* Possible values:
* <ul>
* <li><b>regex:</b> check with regular expression from regex variable, case sensitive</li>
* <li><b>regex_i:</b> check with regular expression from regex variable, case insensitive</li>
* <li><b>int_greater:</b> integer value of cmp_name1 must be greater than the integer value from the option cmp_name2</li>
* <li><b>int_greaterOrEqual:</b> integer value of cmp_name1 must be greater or equal than the integer value from the option cmp_name2</li>
* </ul>
* </li>
* <li><b>error_message:</b> message that is displayed if input value was syntactically incorrect<br>
* error_message is an array to build StatusMessages (message type, message head, message text, additional variables)
* <li><b>regex:</b> regular expression string (only if type is regex/regex_i)</li>
* <li><b>cmp_name1:</b> name of first input variable that is used for comparison (only if type is int_greater/int_greaterOrEqual)</li>
* <li><b>cmp_name2:</b> name of second input variable that is used for comparison (only if type is int_greater/int_greaterOrEqual)</li>
* <li><b>required:</b> true or false, if this input field must be filled set to true (optional)
* <li><b>required_message:</b> message that is displayed if no input value was given (only if required == true)<br>
* required_message is an array to build StatusMessages (message type, message head, message text, additional variables)
* </li>
* </ul>
* <br><br>
* </li>
2015-07-08 17:14:52 +00:00
*
2008-02-03 14:28:28 +00:00
* <li><b>{@link load_profile()}</b><br>
* <br>
* <b>Key:</b> profile_mappings<br>
* <b>Value:</b> array('profile_identifier1' => 'LDAP_attribute1', 'profile_identifier2' => 'LDAP_attribute2')<br>
* <br>
* The mapped values are stored directly in $this->attributes.
* <br>
* <b>Example:</b> "profile_mappings" => array('inetOrgPerson_title' => 'title')
* <br><br>
* </li>
2015-07-08 17:14:52 +00:00
*
2008-02-03 14:28:28 +00:00
* <li><b>{@link get_configOptions()}</b><br>
* <br>
* <b>Key:</b> config_options<br>
* <b>Value:</b> array('user' => array, 'host' => array, 'all' => array)<br>
* <br>
* The values from 'all' are always returned, the other values only if they are inside the $scopes array.<br>
* The syntax for sub arrays is the same as for the return value of {@link get_configOptions()}.
* <br><br>
* </li>
2015-07-08 17:14:52 +00:00
*
2008-02-03 14:28:28 +00:00
* <li><b>{@link check_configOptions()}</b><br>
* <br>
* <b>Key:</b> config_checks<br>
* <b>Value:</b> array('user' => array, 'host' => 'array', 'all' => array)<br>
* <br>
* The values from 'all' are always used for checking, the other values only if they are inside the $scopes array.
* The syntax for sub arrays is the same as for {@link check_configOptions()}.
* <br><br>
* </li>
2015-07-08 17:14:52 +00:00
*
2008-02-03 14:28:28 +00:00
* <li><b>{@link get_uploadColumns()}</b><br>
* <br>
* <b>Key:</b> upload_columns<br>
* <b>Value:</b> array<br>
* <br>
* The syntax for array is the same as for the return value of {@link get_uploadColumns()}.
* <br><br>
* </li>
2015-07-08 17:14:52 +00:00
*
2008-02-03 14:28:28 +00:00
* <li><b>{@link get_uploadPreDepends()}</b><br>
* <br>
* <b>Key:</b> upload_preDepends<br>
* <b>Value:</b> array<br>
* <br>
* The syntax for array is the same as for the return value of {@link get_uploadPreDepends()}.
* <br><br>
* </li>
2015-07-08 17:14:52 +00:00
*
2008-02-03 14:28:28 +00:00
* <li><b>{@link getRequiredExtensions()}</b><br>
* <br>
* <b>Key:</b> extensions<br>
* <b>Value:</b> array of extension names<br>
* <br>
2008-08-09 11:18:36 +00:00
* <b>Example:</b> "extensions" => array('hash')
2008-02-03 14:28:28 +00:00
* <br><br>
* </li>
2015-07-08 17:14:52 +00:00
*
2008-02-03 18:46:11 +00:00
* <li><b>{@link get_help()}</b><br>
* <br>
* <b>Key:</b> help<br>
* <b>Value:</b> hashtable of help entries<br>
* <br>
* The hashtable is an array which maps help IDs to help entries.<br>
* <br>
* <b>Example:</b> 'help' => array('myEntry' => array('Headline' => 'This is the head line', 'Text' => 'Help content'))
* <br><br>
* </li>
2015-07-08 17:14:52 +00:00
*
2008-02-03 14:28:28 +00:00
* <li><b>{@link getSelfServiceSearchAttributes()}</b><br>
* <br>
* <b>Key:</b> selfServiceSearchAttributes<br>
* <b>Value:</b> array of attribute names<br>
* <br>
* <b>Example:</b> "selfServiceSearchAttributes" => array('uid')
* <br><br>
* </li>
2015-07-08 17:14:52 +00:00
*
2008-02-03 14:28:28 +00:00
* <li><b>{@link getSelfServiceFields()}</b><br>
* <br>
* <b>Key:</b> selfServiceFieldSettings<br>
* <b>Value:</b> array of self service fields<br>
* <br>
* <b>Example:</b> "selfServiceFieldSettings" => array('pwd' => 'Password')
* <br><br>
* </li>
2015-07-08 17:14:52 +00:00
*
2008-02-03 14:28:28 +00:00
* </ul>
* <b>Example:</b> return array("is_base" => true);
2004-06-08 18:39:53 +00:00
*
* @return array meta data
2004-06-08 18:39:53 +00:00
*/
public function get_metaData() {
2004-06-08 18:39:53 +00:00
return array();
}
/**
* Returns the account type of this module (user, group, host)
*
* @return string account type
*/
public function get_scope() {
2004-06-08 18:39:53 +00:00
return $this->scope;
}
2004-06-13 19:58:58 +00:00
/**
* Returns true if this module can manage accounts of the current type, otherwise false.
2015-07-08 17:14:52 +00:00
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.
2015-07-08 17:14:52 +00:00
*
2004-06-13 19:58:58 +00:00
* @return boolean true if module fits
2015-07-08 17:14:52 +00:00
*
* @see baseModule::get_metaData()
2004-06-13 19:58:58 +00:00
*/
public abstract function can_manage();
2004-06-13 19:58:58 +00:00
2004-06-08 18:39:53 +00:00
/**
* Returns true if your module is a base module and otherwise false.
2015-07-08 17:14:52 +00:00
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.<br>
* <br>
* Every account type needs exactly one base module. A base module manages a structural object class.
* E.g. the inetOrgPerson module is a base module since its object class is structural.
2004-06-08 18:39:53 +00:00
*
2008-02-03 14:28:28 +00:00
* @return boolean true if base module (defaults to false if no meta data is provided)
2015-07-08 17:14:52 +00:00
*
* @see baseModule::get_metaData()
2004-06-08 18:39:53 +00:00
*/
public function is_base_module() {
2018-12-26 08:53:58 +00:00
return (isset($this->meta['is_base']) && ($this->meta['is_base']));
2004-06-08 18:39:53 +00:00
}
2004-06-11 15:44:49 +00:00
/**
* Returns an LDAP filter for the account lists
2015-07-08 17:14:52 +00:00
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.<br>
* <br>
* Returns an array('or' => '...', 'and' => '...') that is used to build the LDAP filter. Usually, this is used to filter object classes.
* All "or" filter parts of the base modules are combined with OR and then combined with the "and" parts.<br>
* The resulting LDAP filter will look like this: (&(|(OR1)(OR2)(OR3))(AND1)(AND2)(AND3))<br>
* <br>
* <b>Example:</b> return array('or' => '(objectClass=posixAccount)', 'and' => '(!(uid=*$))')
2004-06-11 15:44:49 +00:00
*
2017-12-22 08:41:52 +00:00
* @param string $typeId account type id
2004-06-11 15:44:49 +00:00
* @return string LDAP filter
2015-07-08 17:14:52 +00:00
*
* @see baseModule::get_metaData()
2004-06-11 15:44:49 +00:00
*/
2017-12-22 08:41:52 +00:00
public function get_ldap_filter($typeId) {
2018-12-26 08:53:58 +00:00
if (isset($this->meta['ldap_filter'])) {
return $this->meta['ldap_filter'];
}
return "";
2004-06-11 15:44:49 +00:00
}
2004-06-14 16:05:36 +00:00
/**
* Returns an alias name for the module.
2015-07-08 17:14:52 +00:00
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.<br>
* <br>
* This function returns a more descriptive string than the class name. Alias names are used for the buttons on the account pages and the module selection in the configuration wizard.<br>
* Please take care that your alias name is not too long. It may contain any character but should not include parts that may be interpreted by the browser (e.g. '<' or '>').
* If you use different aliases dependent on the account type please make sure that there is a general alias for unknown types.
2015-07-08 17:14:52 +00:00
*
2004-06-14 16:05:36 +00:00
* @return string alias name
2015-07-08 17:14:52 +00:00
*
* @see baseModule::get_metaData()
2004-06-14 16:05:36 +00:00
*/
public function get_alias() {
2018-12-26 08:53:58 +00:00
if (isset($this->meta['alias'])) {
return $this->meta['alias'];
}
return get_class($this);
2004-06-14 16:05:36 +00:00
}
2004-10-06 18:17:22 +00:00
/**
* Returns a hash array containing a list of possible LDAP attributes that can be used to form the RDN (Relative Distinguished Name).
2015-07-08 17:14:52 +00:00
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.<br>
* <br>
2004-10-06 18:17:22 +00:00
* The returned elements have this form: <attribute> => <priority>
* <br> <attribute> is the name of the LDAP attribute
* <br> <priority> defines the priority of the attribute (can be "low", "normal", "high")<br>
* <br>
* <b>Example:</b> return array('uid' => 'normal', 'cn' => 'low')
2004-10-06 18:17:22 +00:00
*
2017-06-11 19:15:41 +00:00
* @param string $typeId account type
2004-10-06 18:17:22 +00:00
* @return array list of attributes
2015-07-08 17:14:52 +00:00
*
* @see baseModule::get_metaData()
2004-10-06 18:17:22 +00:00
*/
2017-06-11 19:15:41 +00:00
public function get_RDNAttributes($typeId) {
2018-12-26 08:53:58 +00:00
if (isset($this->meta['RDN'])) {
return $this->meta['RDN'];
}
return array();
2004-10-06 18:17:22 +00:00
}
2004-06-20 17:32:02 +00:00
/**
* This function returns a list with all depending and conflicting modules.
2015-07-08 17:14:52 +00:00
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.<br>
* <br>
* The return value is an array with two sub arrays, "depends" and "conflicts".
* All values of the conflict array are string values with module names. All values of the depends
* array are either string values with module names or arrays which include only string values with
* module names.<br>
* If an element of the depends array is itself an array, this means that your module
* depends on one of these modules.<br>
* <br>
* <b>Example:</b> return array("depends" => array("posixAccount", array("qmail", "sendmail")), "conflicts" => array("exim"))
2004-06-20 17:32:02 +00:00
*
* @return array list of dependencies and conflicts
2015-07-08 17:14:52 +00:00
*
* @see baseModule::get_metaData()
2004-06-20 17:32:02 +00:00
*/
public function get_dependencies() {
2018-12-26 08:53:58 +00:00
if (isset($this->meta['dependencies'])) {
return $this->meta['dependencies'];
2004-06-20 17:32:02 +00:00
}
2018-12-26 08:53:58 +00:00
return array('depends' => array(), 'conflicts' => array());
}
2004-06-20 17:32:02 +00:00
/**
* This function defines what attributes will be used in the account profiles and their appearance in the profile editor.
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.<br>
* <br>
2010-06-11 19:39:19 +00:00
* The return value is an object implementing htmlElement.<br>
* The field name are used as keywords to load
* and save profiles. We recommend to use the module name as prefix for them
* (e.g. posixAccount_homeDirectory) to avoid naming conflicts.
2015-07-08 17:14:52 +00:00
*
2017-03-30 18:39:24 +00:00
* @param string $typeId type id (user, group, host, ...)
2010-06-11 19:39:19 +00:00
* @return htmlElement meta HTML object
2015-07-08 17:14:52 +00:00
*
* @see baseModule::get_metaData()
2010-06-11 19:39:19 +00:00
* @see htmlElement
*/
2017-03-30 18:39:24 +00:00
public function get_profileOptions($typeId) {
2018-12-26 08:53:58 +00:00
if (isset($this->meta['profile_options'])) {
return $this->meta['profile_options'];
}
return array();
}
/**
* Checks input values of account profiles.
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.<br>
* <br>
* $options is an hash array (option name => value) that contains the user input.
* The option values are all arrays containing one or more elements.<br>
* 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 a hash array (name => value) containing the user input
2017-03-30 18:39:24 +00:00
* @param string $typeId type id (user, group, host)
* @return array list of error messages (array(type, title, text)) to generate StatusMessages, if any
2015-07-08 17:14:52 +00:00
*
* @see baseModule::get_metaData()
*/
2017-03-30 18:39:24 +00:00
public function check_profileOptions($options, $typeId) {
2019-05-20 09:09:02 +00:00
$errors = array();
2010-12-19 13:34:58 +00:00
if (isset($this->meta['profile_checks'])) {
2019-05-20 09:09:02 +00:00
foreach ($this->meta['profile_checks'] as $identifier => $check) {
// check if option is required
if (isset($check['required']) && $check['required']
&& (!isset($options[$identifier][0]) || ($options[$identifier][0] == ''))) {
$errors[] = $check['required_message'];
2005-07-07 13:45:55 +00:00
continue;
}
2019-05-20 09:09:02 +00:00
switch ($check['type']) {
// check by regular expression (from account.inc)
case "ext_preg":
// ignore empty fileds
2019-05-20 09:09:02 +00:00
if (!empty($options[$identifier][0])
&& !get_preg($options[$identifier][0], $check['regex'])) {
$errors[] = $check['error_message'];
}
break;
// check by regular expression (case insensitive)
case 'regex_i':
// ignore empty fileds
2019-05-20 09:09:02 +00:00
if (!empty($options[$identifier][0])
&& !preg_match('/' . $check['regex'] . '/i', $options[$identifier][0])) {
$errors[] = $check['error_message'];
}
break;
// check by regular expression (case sensitive)
case 'regex':
// ignore empty fileds
2019-05-20 09:09:02 +00:00
if (!empty($options[$identifier][0])
&& !preg_match('/' . $check['regex'] . '/', $options[$identifier][0])) {
$errors[] = $check['error_message'];
}
break;
// check by integer comparison (greater)
case 'int_greater':
2019-05-20 09:09:02 +00:00
$val1 = $options[$check['cmp_name1']][0];
$val2 = $options[$check['cmp_name2']][0];
// ignore if both fields are empty
2019-05-20 09:09:02 +00:00
if (!(empty($val1) && empty($val2))
&& (($val1 == '') || ($val2 == '') || !(intval($val1) > intval($val2)))) {
$errors[] = $check['error_message'];
}
break;
// check by integer comparison (greater or equal)
case 'int_greaterOrEqual':
2019-05-20 09:09:02 +00:00
$val1 = $options[$check['cmp_name1']][0];
$val2 = $options[$check['cmp_name2']][0];
// ignore if both fields are empty
2019-05-20 09:09:02 +00:00
if (!(empty($val1) && empty($val2))
&& (($val1 == '') || ($val2 == '') || !(intval($val1) >= intval($val2)))) {
$errors[] = $check['error_message'];
}
break;
// print error message for invalid types
default:
2019-05-20 09:09:02 +00:00
StatusMessage("ERROR", "Unsupported type!", $check['type']);
break;
}
}
}
2019-05-20 09:09:02 +00:00
return $errors;
}
2005-01-07 10:55:05 +00:00
/**
* This function loads the values from an account profile to the module's internal data structures.
2015-07-08 17:14:52 +00:00
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.
2005-01-07 10:55:05 +00:00
*
* @param array $profile hash array with profile values (identifier => value)
2015-07-08 17:14:52 +00:00
*
* @see baseModule::get_metaData()
2005-01-07 10:55:05 +00:00
*/
public function load_profile($profile) {
2005-01-07 10:55:05 +00:00
if (isset($this->meta['profile_mappings'])) {
$identifiers = array_keys($this->meta['profile_mappings']);
for ($i = 0; $i < sizeof($identifiers); $i++) {
if (isset($profile[$identifiers[$i]])) {
$this->attributes[$this->meta['profile_mappings'][$identifiers[$i]]] = $profile[$identifiers[$i]];
}
}
}
}
2006-08-14 17:29:45 +00:00
/**
* Returns a list of configuration options.
2015-07-08 17:14:52 +00:00
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.<br>
* <br>
2010-06-11 19:39:19 +00:00
* The field names 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 array $scopes account types (user, group, host)
2017-12-18 20:52:24 +00:00
* @param array $allScopes list of all active account modules and their account type id (module => array(type id))
2010-06-11 19:39:19 +00:00
* @return mixed htmlElement or array of htmlElement
2015-07-08 17:14:52 +00:00
*
* @see baseModule::get_metaData()
2010-06-11 19:39:19 +00:00
* @see htmlElement
*/
public function get_configOptions($scopes, $allScopes) {
$return = array();
for ($i = 0; $i < sizeof($scopes); $i++) {
2010-06-10 15:39:35 +00:00
if (isset($this->meta['config_options'][$scopes[$i]])) {
if (is_array($this->meta['config_options'][$scopes[$i]])) {
$return = array_merge($return, $this->meta['config_options'][$scopes[$i]]);
}
2010-09-25 14:28:37 +00:00
elseif (isset($return[0]) && ($return[0] instanceof htmlTable) && ($this->meta['config_options'][$scopes[$i]] instanceof htmlTable)) {
$return[0]->mergeTableElements($this->meta['config_options'][$scopes[$i]]);
}
2010-06-10 15:39:35 +00:00
else {
$return[] = $this->meta['config_options'][$scopes[$i]];
}
}
}
if (isset($this->meta['config_options']['all'])) {
if (is_array($this->meta['config_options']['all'])) {
$return = array_merge($return, $this->meta['config_options']['all']);
}
2010-09-25 14:28:37 +00:00
elseif (isset($return[0]) && ($return[0] instanceof htmlTable) && ($this->meta['config_options']['all'] instanceof htmlTable)) {
$return[0]->mergeTableElements($this->meta['config_options']['all']);
}
2010-06-10 15:39:35 +00:00
else {
$return[] = $this->meta['config_options']['all'];
}
}
return $return;
}
/**
* Checks input values of module settings.
2015-07-08 17:14:52 +00:00
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.<br>
* <br>
* If the input data is invalid the return value is an array that contains subarrays to build StatusMessages ('message type', 'message head', 'message text').
* <br>If no errors occured the function returns an empty array.
*
2017-12-20 19:44:08 +00:00
* @param array $typeIds list of account type ids which are used
* @param array $options hash array (option name => value) that contains the input. The option values are all arrays containing one or more elements.
* @return array list of error messages
2015-07-08 17:14:52 +00:00
*
* @see baseModule::get_metaData()
*/
2017-12-20 19:44:08 +00:00
public function check_configOptions($typeIds, &$options) {
$messages = array();
2017-12-20 19:44:08 +00:00
// add checks that are independent of scope
$scopes = array('all');
foreach ($typeIds as $typeId) {
$scopes[] = getScopeFromTypeId($typeId);
}
$scopes = array_unique($scopes);
for ($s = 0; $s < sizeof($scopes); $s++) {
2006-05-13 08:55:31 +00:00
if (isset($this->meta['config_checks'][$scopes[$s]]) && is_array($this->meta['config_checks'][$scopes[$s]])) {
$identifiers = array_keys($this->meta['config_checks'][$scopes[$s]]);
for ($i = 0; $i < sizeof($identifiers); $i++) {
// check if option is required
2017-04-17 18:29:31 +00:00
if (isset($this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['required']) && ($this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['required']) && ($options[$identifiers[$i]][0] == '')) {
$messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['required_message'];
}
switch ($this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['type']) {
// check by regular expression (from account.inc)
case "ext_preg":
// ignore empty fileds
2018-12-26 08:53:58 +00:00
if ($options[$identifiers[$i]][0] == '') {
2019-02-01 19:27:21 +00:00
break;
2018-12-26 08:53:58 +00:00
}
if (! get_preg($options[$identifiers[$i]][0], $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['regex'])) {
$messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message'];
2006-08-14 17:29:45 +00:00
}
break;
// check by regular expression (case insensitive)
case "regex_i":
// ignore empty fileds
2018-12-26 08:53:58 +00:00
if ($options[$identifiers[$i]][0] == '') {
2019-02-01 19:27:21 +00:00
break;
2018-12-26 08:53:58 +00:00
}
2009-08-13 18:57:26 +00:00
if (! preg_match('/' . $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['regex'] . '/i', $options[$identifiers[$i]][0])) {
$messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message'];
2006-08-14 17:29:45 +00:00
}
break;
// check by regular expression (case sensitive)
case "regex":
// ignore empty fileds
2018-12-26 08:53:58 +00:00
if ($options[$identifiers[$i]][0] == '') {
2019-02-01 19:27:21 +00:00
break;
2018-12-26 08:53:58 +00:00
}
2009-08-13 18:57:26 +00:00
if (! preg_match('/' . $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['regex'] . '/', $options[$identifiers[$i]][0])) {
$messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message'];
}
break;
// check by integer comparison (greater)
case "int_greater":
// ignore if both fields are empty
2018-12-26 08:53:58 +00:00
if (($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0] == '') && ($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0] == '')) {
2019-02-01 19:27:21 +00:00
break;
2018-12-26 08:53:58 +00:00
}
// print error message if only one field is empty
if (($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0] == '') || ($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0] == '')) {
$messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message'];
2019-02-01 19:27:21 +00:00
break;
}
// compare
if (!(intval($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0]) > intval($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0]))) {
$messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message'];
}
break;
// check by integer comparison (greater or equal)
case "int_greaterOrEqual":
// ignore if both fields are empty
2018-12-26 08:53:58 +00:00
if (($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0] == '') && ($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0] == '')) {
2019-02-01 19:27:21 +00:00
break;
2018-12-26 08:53:58 +00:00
}
// print error message if only one field is empty
if (($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0] == '') || ($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0] == '')) {
$messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message'];
2019-02-01 19:27:21 +00:00
break;
}
// compare
if (!(intval($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0]) >= intval($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0]))) {
$messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message'];
}
break;
// print error message on undefined type
default:
StatusMessage("ERROR", "Unsupported type!", $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['type']);
break;
}
}
}
}
return $messages;
}
2006-08-14 17:29:45 +00:00
/**
2008-02-03 17:56:02 +00:00
* Returns a hashtable with all entries that may be printed out in the PDF.
*
2017-04-01 07:57:03 +00:00
* @param string $typeId type id (user, group, host)
* @return array PDF entries as key => label
2015-07-08 17:14:52 +00:00
*
2008-02-03 17:56:02 +00:00
* @see baseModule::get_metaData()
*/
2017-04-01 07:57:03 +00:00
public function get_pdfFields($typeId) {
return ((isset($this->meta['PDF_fields'])) ? $this->meta['PDF_fields'] : array());
}
2008-12-17 17:09:23 +00:00
/**
* Returns the PDF entries for this module.
*
2015-01-07 17:16:35 +00:00
* @param array $pdfKeys list of PDF keys that are included in document
2017-04-01 07:57:03 +00:00
* @param string $typeId type id (user, group, host)
2017-02-19 08:14:11 +00:00
* @return PDFEntry[] list of key => PDFEntry
2008-12-17 17:09:23 +00:00
*/
2017-04-01 07:57:03 +00:00
public function get_pdfEntries($pdfKeys, $typeId) {
2008-12-17 17:09:23 +00:00
return array();
}
2015-07-08 17:14:52 +00:00
2013-03-09 17:25:02 +00:00
/**
* Adds a simple PDF entry to the given array.
2015-07-08 17:14:52 +00:00
*
2013-03-09 17:25:02 +00:00
* @param array $result result array (entry will be added here)
* @param String $name ID
* @param String $label label name
* @param String $attrName attribute name (default: =$name)
2013-05-04 18:20:08 +00:00
* @param String $delimiter delimiter if multiple attribute values exist (default: ", ")
2013-03-09 17:25:02 +00:00
*/
protected function addSimplePDFField(&$result, $name, $label, $attrName = null, $delimiter = ', ') {
if ($attrName == null) {
$attrName = $name;
}
$value = '';
if (isset($this->attributes[$attrName]) && (sizeof($this->attributes[$attrName]) > 0)) {
2013-05-05 18:26:30 +00:00
natcasesort($this->attributes[$attrName]);
2013-03-09 17:25:02 +00:00
$value = implode($delimiter, $this->attributes[$attrName]);
2013-05-07 19:19:00 +00:00
$value = trim($value);
2013-03-09 17:25:02 +00:00
}
2017-02-15 20:45:26 +00:00
$result[get_class($this) . '_' . $name][] = new PDFLabelValue($label, $value);
2015-03-01 19:20:17 +00:00
}
/**
* Adds a simple PDF entry with the given key and value.
2015-07-08 17:14:52 +00:00
*
2015-03-01 19:20:17 +00:00
* @param array $result result array (entry will be added here)
* @param String $name ID
* @param String $label label name
* @param mixed $value value as String or array
* @param String $delimiter delimiter if value is array (default: ", ")
*/
2015-04-19 17:17:17 +00:00
public function addPDFKeyValue(&$result, $name, $label, $value, $delimiter = ', ') {
2015-03-01 19:20:17 +00:00
if (is_array($value)) {
natcasesort($value);
$value = implode($delimiter, $value);
}
2017-02-15 20:45:26 +00:00
$result[get_class($this) . '_' . $name][] = new PDFLabelValue($label, $value);
2013-03-09 17:25:02 +00:00
}
2008-12-17 17:09:23 +00:00
2015-07-08 17:14:52 +00:00
/**
* Adds a table entry to the PDF.
*
* @param array $result result array (entry will be added here)
* @param String $name ID
* @param PDFTable $table table
*/
public function addPDFTable(&$result, $name, $table) {
2015-07-08 18:41:53 +00:00
if (empty($table->rows)) {
return;
}
2017-02-15 20:45:26 +00:00
$result[get_class($this) . '_' . $name][] = $table;
2015-07-08 17:14:52 +00:00
}
2018-08-25 17:39:47 +00:00
/**
* Adds an image to the PDF.
*
* @param array $result result array (entry will be added here)
* @param String $attrName attribute name
* @param PDFTable $table table
*/
public function addPDFImage(&$result, $attrName) {
if (isset($this->attributes[$attrName]) && (sizeof($this->attributes[$attrName]) > 0)) {
$result[get_class($this) . '_' . $attrName][] = new PDFImage($this->attributes[$attrName][0]);
}
}
2004-08-23 20:01:40 +00:00
/**
* Returns an array containing all input columns for the file upload.
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.<br>
* <br>
* This funtion returns an array which contains subarrays which represent an upload column.
* <b>Syntax of column arrays:</b>
2008-02-03 18:46:11 +00:00
* <br>
2004-08-23 20:01:40 +00:00
* <br> array(
* <br> string: name, // fixed non-translated name which is used as column name (should be of format: <module name>_<column name>)
2004-08-28 11:53:40 +00:00
* <br> string: description, // short descriptive name
* <br> string: help, // help ID
2004-08-23 20:01:40 +00:00
* <br> string: example, // example value
* <br> string: values, // possible input values (optional)
* <br> string: default, // default value (optional)
2004-08-23 20:01:40 +00:00
* <br> boolean: required // true, if user must set a value for this column
* <br> boolean: unique // true if all values of this column must be different values (optional, default: "false")
2004-08-23 20:01:40 +00:00
* <br> )
*
* @param array $selectedModules list of selected account modules
2017-05-20 08:55:26 +00:00
* @param ConfiguredType $type account type
2004-08-23 20:01:40 +00:00
* @return array column list
2015-07-08 17:14:52 +00:00
*
* @see baseModule::get_metaData()
2004-08-23 20:01:40 +00:00
*/
2017-05-20 08:55:26 +00:00
public function get_uploadColumns($selectedModules, &$type) {
2018-12-26 08:53:58 +00:00
if (isset($this->meta['upload_columns'])) {
return $this->meta['upload_columns'];
}
return array();
2004-08-23 20:01:40 +00:00
}
/**
* 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}.<br>
* <br>
* The named modules may not be active, LAM will check this automatically.
*
2004-08-23 20:01:40 +00:00
* @return array list of module names
2015-07-08 17:14:52 +00:00
*
* @see baseModule::get_metaData()
2004-08-23 20:01:40 +00:00
*/
public function get_uploadPreDepends() {
2018-12-26 08:53:58 +00:00
if (isset($this->meta['upload_preDepends'])) {
return $this->meta['upload_preDepends'];
}
return array();
2004-08-23 20:01:40 +00:00
}
/**
* In this function the LDAP accounts are built.
2004-08-23 20:01:40 +00:00
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.<br>
* <br>
* 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)
2012-07-15 12:05:47 +00:00
* @param array $partialAccounts list of hash arrays (name => value) which are later added to LDAP
* @param array $selectedModules list of selected account modules
2017-05-20 09:46:49 +00:00
* @param ConfiguredType $type account type
* @return array list of error messages if any
2004-08-23 20:01:40 +00:00
*/
2017-05-20 09:46:49 +00:00
public function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules, &$type) {
2004-08-23 20:01:40 +00:00
// must be implemented in sub modules
return array();
2004-08-23 20:01:40 +00:00
}
2015-07-08 17:14:52 +00:00
2014-02-11 19:31:22 +00:00
/**
* Maps simple upload fields directly to LDAP attribute values.
*
* @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 String $position current position in CSV
* @param String $colName column name
* @param String $attrName LDAP attribute name
* @param String|String[] $regex for get_preg() (e.g. 'ascii')
2014-02-11 19:31:22 +00:00
* @param array $message error message to add if regex does not match
* @param array $errors list of error messages if any
* @param String $regexSplit multiple values are separated and can be split with this preg_split expression (e.g. "/;[ ]?/")
2014-02-11 19:31:22 +00:00
*/
2015-07-13 18:05:39 +00:00
protected function mapSimpleUploadField(&$rawAccounts, &$ids, &$partialAccounts, $position, $colName, $attrName, $regex = null, $message = array(), &$errors = array(), $regexSplit = null) {
2014-02-11 19:31:22 +00:00
if (!isset($ids[$colName])) {
return;
}
if (!empty($rawAccounts[$position][$ids[$colName]])) {
$regexIDs = is_array($regex) ? $regex : array($regex);
// single value
if ($regexSplit == null) {
if (!empty($regex)) {
$this->checkUploadRegex($regexIDs, $rawAccounts[$position][$ids[$colName]], $message, $position, $errors);
}
2017-01-22 17:01:24 +00:00
$partialAccounts[$position][$attrName] = trim($rawAccounts[$position][$ids[$colName]]);
}
// multi-value
else {
$list = preg_split($regexSplit, trim($rawAccounts[$position][$ids[$colName]]));
$partialAccounts[$position][$attrName] = $list;
if (!empty($regex)) {
for ($x = 0; $x < sizeof($list); $x++) {
if (!$this->checkUploadRegex($regexIDs, $list[$x], $message, $position, $errors)) {
break;
}
}
}
2014-02-11 19:31:22 +00:00
}
}
}
2006-08-14 17:29:45 +00:00
/**
* Checks the upload value against a list of regular expressions.
*
* @param string[] $regexIDs regular expression IDs for get_preg()
* @param string $value value to check
* @param array $message error message array if not matching
* @param int $position upload position
* @param array $errors error messages
* @return value is ok
* @see get_preg()
*/
private function checkUploadRegex($regexIDs, $value, $message, $position, &$errors) {
$matched = false;
foreach ($regexIDs as $regexID) {
if (get_preg($value, $regexID)) {
$matched = true;
break;
}
}
if (!$matched) {
$errMsg = $message;
array_push($errMsg, array($position));
$errors[] = $errMsg;
return false;
}
return true;
}
/**
* 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}.<br>
* <br>
* The result is an hashtable with the following keys:<br>
* <ul>
* <li><b>Headline (required)</b><br>
* The headline of this help entry. Can consist of any alpha-numeric characters. No HTML/CSS elements are allowed.</li>
* <li><b>Text (required)</b><br>
* The text of the help entry which may contain any alpha-numeric characters.</li>
* <li><b>SeeAlso (optional)</b><br>
* 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.</li>
* </ul>
* <br>
* <b>Example:</b><br>
* <br>
2009-08-10 16:13:27 +00:00
* array('Headline' => 'This is the head line', 'Text' => 'Help content', 'SeeAlso' => array('text' => 'LAM homepage', 'link' => 'http://www.ldap-account-manager.org/'))
2006-08-14 17:29:45 +00:00
*
* @param string $id The id string for the help entry needed.
* @return array The desired help entry.
2015-07-08 17:14:52 +00:00
*
* @see baseModule::get_metaData()
*/
public function get_help($id) {
if(isset($this->meta['help'][$id])) {
return $this->meta['help'][$id];
}
2004-10-30 16:46:06 +00:00
elseif(isset($this->meta['help'][$this->scope][$id])) {
return $this->meta['help'][$this->scope][$id];
}
else {
return false;
}
}
2004-08-23 20:01:40 +00:00
/**
* This function is used to check if this module page can be displayed.
2015-07-08 17:14:52 +00:00
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.<br>
* <br>
* 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.<br>
* This method's return value defaults to true.
*
* @return boolean true, if page can be displayed
*/
public function module_ready() {
return true;
}
/**
2009-02-01 16:18:25 +00:00
* This function is used to check if all settings for this module have been made.
2015-07-08 17:14:52 +00:00
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.<br>
* <br>
* 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.<br>
* This method's return value defaults to true.
*
* @return boolean true, if settings are complete
*/
public function module_complete() {
return true;
}
2006-08-14 17:29:45 +00:00
2005-08-26 08:53:16 +00:00
/**
* Controls if the module button the account page is visible and activated.
2015-07-08 17:14:52 +00:00
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.<br>
* <br>
* <b>Possible return values:</b>
* <ul>
* <li><b>enabled:</b> button is visible and active</li>
* <li><b>disabled:</b> button is visible and deactivated (greyed)</li>
* <li><b>hidden:</b> no button will be shown</li>
* </ul>
2005-08-26 08:53:16 +00:00
*
* @return string status ("enabled", "disabled", "hidden")
*/
public function getButtonStatus() {
2005-08-26 08:53:16 +00:00
return "enabled";
}
2015-07-08 17:14:52 +00:00
2012-10-06 16:37:36 +00:00
/**
* Runs any actions that need to be done before an LDAP entry is created.
2015-07-08 17:14:52 +00:00
*
2012-10-06 16:37:36 +00:00
* @param array $attributes LDAP attributes of this entry (attributes are provided as reference, handle modifications of $attributes with care)
2017-09-02 11:03:36 +00:00
* @param ConfiguredType $type account type
2012-10-06 16:37:36 +00:00
* @return array array which contains status messages. Each entry is an array containing the status message parameters.
*/
2017-09-02 11:03:36 +00:00
public function doUploadPreActions($attributes, $type) {
2012-10-06 16:37:36 +00:00
return array();
}
2004-10-19 18:18:46 +00:00
/**
* This function is responsible to do additional tasks after the account has been created in LDAP (e.g. modifying group memberships, adding Quota etc..).
2015-07-08 17:14:52 +00:00
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.<br>
* <br>
* 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.
2004-10-19 18:18:46 +00:00
*
* @param array $data array containing one account in each element
* @param array $ids maps the column names to keys for the sub arrays (array(<column_name> => <column number>))
* @param array $failed list of account numbers which could not be successfully uploaded to LDAP
2004-10-19 18:18:46 +00:00
* @param array $temp variable to store temporary data between two post actions
2010-12-16 17:59:04 +00:00
* @param array $accounts list of LDAP entries
2017-05-10 17:23:28 +00:00
* @param string[] $selectedModules selected account modules
2004-10-19 18:18:46 +00:00
* @return array current status
* <br> array (
* <br> 'status' => 'finished' | 'inProgress' // defines if all operations are complete
* <br> 'progress' => 0..100 // the progress of the operations in percent
* <br> 'errors' => array // list of arrays which are used to generate StatusMessages
2004-10-19 18:18:46 +00:00
* <br> )
2017-09-02 11:03:36 +00:00
* @param ConfiguredType $type account type
2004-10-19 18:18:46 +00:00
*/
2017-09-02 11:03:36 +00:00
public function doUploadPostActions(&$data, $ids, $failed, &$temp, &$accounts, $selectedModules, $type) {
2004-10-19 18:18:46 +00:00
return array(
'status' => 'finished',
'progress' => 100,
'errors' => array()
);
}
2004-06-08 18:39:53 +00:00
/**
* Returns a list of modifications which have to be made to the LDAP account.
2015-07-08 17:14:52 +00:00
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.<br>
* <br>
*
* <br>This function returns an array with 3 entries:
* <br>array( DN1 ('add' => array($attr), 'remove' => array($attr), 'modify' => array($attr)), DN2 .... )
* <br>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)<br>
* <br><b>"add"</b> are attributes which have to be added to the LDAP entry
* <br><b>"remove"</b> are attributes which have to be removed from the LDAP entry
* <br><b>"modify"</b> are attributes which have to be modified in the LDAP entry
* <br><b>"notchanged"</b> are attributes which stay unchanged
2011-02-26 13:14:10 +00:00
* <br><b>"info"</b> values with informational value (e.g. to be used later by pre/postModify actions)
* <br>
* <br>This builds the required comands from $this-attributes and $this->orig.
2015-07-08 17:14:52 +00:00
*
* @return array list of modifications
*/
public function save_attributes() {
2007-10-03 19:18:07 +00:00
return $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig);
}
/**
2007-02-25 13:48:51 +00:00
* Allows the module to run commands before the LDAP entry is changed or created.
2015-07-08 17:14:52 +00:00
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.<br>
* <br>
* The modification is aborted if an error message is returned.
2015-07-08 17:14:52 +00:00
*
2007-02-25 13:48:51 +00:00
* @param boolean $newAccount new account
2012-10-06 16:37:36 +00:00
* @param array $attributes LDAP attributes of this entry (added/modified attributes are provided as reference, handle modifications of $attributes with care)
* @return array array which contains status messages. Each entry is an array containing the status message parameters.
2007-02-25 13:48:51 +00:00
*/
public function preModifyActions($newAccount, $attributes) {
return array();
2007-02-25 13:48:51 +00:00
}
2015-07-08 17:14:52 +00:00
2007-02-25 13:48:51 +00:00
/**
* Allows the module to run commands after the LDAP entry is changed or created.
2015-07-08 17:14:52 +00:00
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.
*
* @param boolean $newAccount new account
* @param array $attributes LDAP attributes of this entry
2012-01-04 19:08:19 +00:00
* @return array array which contains status messages. Each entry is an array containing the status message parameters.
*/
public function postModifyActions($newAccount, $attributes) {
2012-01-04 19:08:19 +00:00
return array();
}
2015-07-08 17:14:52 +00:00
/**
2007-02-25 13:48:51 +00:00
* Allows the module to run commands before the LDAP entry is deleted.
2015-07-08 17:14:52 +00:00
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.<br>
2015-07-08 17:14:52 +00:00
*
* @return array Array which contains status messages. Each entry is an array containing the status message parameters.
2007-02-25 13:48:51 +00:00
*/
public function preDeleteActions() {
return array();
2007-02-25 13:48:51 +00:00
}
2015-07-08 17:14:52 +00:00
2007-02-25 13:48:51 +00:00
/**
* Allows the module to run commands after the LDAP entry is deleted.
2015-07-08 17:14:52 +00:00
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.
2015-07-08 17:14:52 +00:00
*
* @return array Array which contains status messages. Each entry is an array containing the status message parameters.
*/
public function postDeleteActions() {
return array();
}
2015-07-08 17:14:52 +00:00
2005-04-04 16:54:10 +00:00
/**
* This function returns an array with the same syntax as save_attributes().
2015-07-08 17:14:52 +00:00
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.<br>
* <br>
* It allows additional LDAP changes when an account is deleted.
2005-04-04 16:54:10 +00:00
*
* @return List of LDAP operations, same as for save_attributes()
*/
public function delete_attributes() {
2005-04-04 16:54:10 +00:00
return 0;
}
/**
* This function creates meta HTML code which will be displayed when an account should be deleted.
2015-07-08 17:14:52 +00:00
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.<br>
* <br>
* 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.
2005-04-04 16:54:10 +00:00
*
2010-06-11 19:39:19 +00:00
* @return htmlElement meta HTML object
* @see htmlElement
2005-04-04 16:54:10 +00:00
*/
public function display_html_delete() {
2018-11-20 18:18:23 +00:00
return null;
2005-04-04 16:54:10 +00:00
}
2015-07-08 17:14:52 +00:00
2016-01-06 15:05:52 +00:00
/**
* Defines if the LDAP entry has only virtual child entries. This is the case for e.g. LDAP views.
*
* @return boolean has only virtual children
*/
public function hasOnlyVirtualChildren() {
return false;
}
/**
* This function processes user input.
2015-07-08 17:14:52 +00:00
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.<br>
* <br>
* It checks the user input and saves changes in the module's data structures.<br>
* <br>
* <b>Example:</b> return array(array('ERROR', 'Invalid input!', 'This is not allowed here.'));
2015-07-08 17:14:52 +00:00
*
* @return array Array which contains status messages. Each entry is an array containing the status message parameters.
*/
public abstract function process_attributes();
2015-07-08 17:14:52 +00:00
/**
* This function creates meta HTML code to display the module page.
2015-07-08 17:14:52 +00:00
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.
2015-07-08 17:14:52 +00:00
*
2010-06-11 19:39:19 +00:00
* @return htmlElement meta HTML object
*
2010-06-11 19:39:19 +00:00
* @see htmlElement
*/
public abstract function display_html_attributes();
2006-08-14 17:29:45 +00:00
/**
2019-08-15 12:13:10 +00:00
* Adds a simple text input field to the given htmlTable/htmlResponsiveRow.
* The field name will be the same as the attribute name. There must also be a help entry with the attribute name as ID.
* A new line will also be added after this entry so multiple calls will show the fields one below the other.
2015-07-08 17:14:52 +00:00
*
* @param htmlTable|htmlResponsiveRow $container parent container
* @param String $attrName attribute name
* @param String $label label name
* @param boolean $required this is a required field (default false)
* @param integer $length field length
2013-04-06 15:00:53 +00:00
* @param boolean $isTextArea show as text area (default false)
2013-11-02 10:25:08 +00:00
* @param array $autoCompleteValues values for auto-completion
2013-10-19 10:25:39 +00:00
* @return mixed reference to htmlTableExtendedInputField/htmlTableExtendedInputTextarea
*/
protected function &addSimpleInputTextField(&$container, $attrName, $label, $required = false, $length = null, $isTextArea = false, $autoCompleteValues = null) {
$value = '';
if (isset($this->attributes[$attrName][0])) {
$value = $this->attributes[$attrName][0];
}
2013-04-06 15:00:53 +00:00
if ($isTextArea) {
$cols = 30;
if ($length != null) {
$cols = $length;
}
if ($container instanceof htmlResponsiveRow) {
$input = new htmlResponsiveInputTextarea($attrName, $value, $cols, 3, $label, $attrName);
}
else {
$input = new htmlTableExtendedInputTextarea($attrName, $value, $cols, 3, $label, $attrName);
}
2013-04-06 15:00:53 +00:00
}
else {
if ($container instanceof htmlResponsiveRow) {
$input = new htmlResponsiveInputField($label, $attrName, $value, $attrName);
}
else {
$input = new htmlTableExtendedInputField($label, $attrName, $value, $attrName);
}
2013-04-06 15:00:53 +00:00
if ($length != null) {
$input->setFieldSize($length);
}
2013-11-02 10:25:08 +00:00
if (!empty($autoCompleteValues)) {
$input->enableAutocompletion($autoCompleteValues);
}
}
2013-04-06 15:00:53 +00:00
$input->setRequired($required);
if ($container instanceof htmlResponsiveRow) {
$container->add($input, 12);
}
else {
$container->addElement($input, true);
}
2013-10-19 10:25:39 +00:00
return $input;
}
2015-07-08 17:14:52 +00:00
/**
* Adds a simple read-only field to the given container.
*
2019-09-06 19:13:43 +00:00
* @param htmlTable|htmlResponsiveRow $container parent container
* @param String $attrName attribute name
* @param String $label field label
*/
protected function addSimpleReadOnlyField(&$container, $attrName, $label) {
2019-09-06 19:13:43 +00:00
$val = '&nbsp;';
if (!empty($this->attributes[$attrName][0])) {
$values = $this->attributes[$attrName];
array_map('htmlspecialchars', $values);
$val = implode('<br>', $values);
}
$labelBox = new htmlOutputText($label);
if (!empty($this->attributes[$attrName]) && (sizeof($this->attributes[$attrName]) > 1)) {
$labelBox->alignment = htmlElement::ALIGN_TOP;
}
2019-09-06 19:13:43 +00:00
if ($container instanceof htmlTable) {
$container->addElement($labelBox);
$container->addElement(new htmlOutputText($val, false), true);
}
else {
$container->addLabel($labelBox);
$container->addField(new htmlOutputText($val, false));
}
}
2013-04-06 15:00:53 +00:00
/**
* Adds a text input field that may contain multiple values to the given htmlTable.
* The field name will be the same as the attribute name plus a counting number (e.g. street_0).
* The last field will be followed by a button to add a new value. This is named add_{attribute name} (e.g. add_street).
* There must be a help entry with the attribute name as ID.
* A new line will also be added after this entry so multiple calls will show the fields one below the other.
2015-07-08 17:14:52 +00:00
*
2019-08-17 08:52:26 +00:00
* @param htmlTable|htmlResponsiveRow $container parent container
2013-04-06 15:00:53 +00:00
* @param String $attrName attribute name
* @param String $label label name
* @param boolean $required this is a required field (default false)
* @param integer $length field length
2013-08-18 11:38:20 +00:00
* @param boolean $isTextArea show as text area (default false)
2013-11-02 11:08:04 +00:00
* @param array $autoCompleteValues values for auto-completion
* @param integer $fieldSize field size
2014-01-06 14:29:09 +00:00
* @param array $htmlIDs reference to array where to add the generated HTML IDs of the input fields
2018-12-29 19:06:13 +00:00
* @param string $cssClasses additional CSS classes of input fields
2013-04-06 15:00:53 +00:00
*/
2014-01-06 14:29:09 +00:00
protected function addMultiValueInputTextField(&$container, $attrName, $label, $required = false, $length = null, $isTextArea = false,
2018-12-29 19:06:13 +00:00
$autoCompleteValues = null, $fieldSize = null, &$htmlIDs = null, $cssClasses = '') {
2013-04-06 15:00:53 +00:00
$values = array();
if (isset($this->attributes[$attrName][0])) {
$values = $this->attributes[$attrName];
}
if (sizeof($values) == 0) {
$values[] = '';
}
2013-10-19 14:29:02 +00:00
natcasesort($values);
$values = array_values($values);
2013-11-02 11:08:04 +00:00
if ($label !== null) {
2017-05-29 17:00:32 +00:00
$labelTextOut = new htmlOutputText($label, true, $required);
2013-11-02 11:08:04 +00:00
$labelTextOut->alignment = htmlElement::ALIGN_TOP;
2019-08-17 08:52:26 +00:00
if ($container instanceof htmlTable) {
$container->addElement($labelTextOut);
}
else {
$container->addLabel($labelTextOut);
}
2013-11-02 11:08:04 +00:00
}
2019-09-02 16:04:21 +00:00
$help = new htmlHelpLink($attrName);
$help->alignment = htmlElement::ALIGN_TOP;
2013-10-20 14:26:29 +00:00
$subContainer = new htmlTable();
2019-09-03 19:31:29 +00:00
$subContainer->setCSSClasses(array('fullwidth'));
2013-10-20 14:26:29 +00:00
$subContainer->alignment = htmlElement::ALIGN_TOP;
2013-04-06 15:00:53 +00:00
for ($i = 0; $i < sizeof($values); $i++) {
2013-08-18 11:38:20 +00:00
if (!$isTextArea) {
2013-10-19 14:29:02 +00:00
$input = new htmlInputField($attrName . '_' . $i, $values[$i]);
2018-12-29 19:06:13 +00:00
if (!empty($cssClasses)) {
$input->setCSSClasses(array($cssClasses));
}
2013-11-02 11:08:04 +00:00
if (!empty($length)) {
$input->setFieldMaxLength($length);
}
if (!empty($fieldSize)) {
$input->setFieldSize($fieldSize);
}
2013-10-19 14:29:02 +00:00
if (!empty($autoCompleteValues)) {
$input->enableAutocompletion($autoCompleteValues);
}
$subContainer->addElement($input);
2013-08-18 11:38:20 +00:00
}
else {
$cols = 30;
if ($length != null) {
$cols = $length;
}
2018-12-29 19:06:13 +00:00
$textArea = new htmlInputTextarea($attrName . '_' . $i, $values[$i], $cols, 3);
if (!empty($cssClasses)) {
$textArea->setCSSClasses(array($cssClasses));
}
$subContainer->addElement($textArea);
2013-08-18 11:38:20 +00:00
}
2014-01-06 14:29:09 +00:00
if (!empty($htmlIDs)) {
$htmlIDs[] = $attrName . '_' . $i;
}
2013-11-01 18:59:55 +00:00
if (!empty($values[$i])) {
2019-09-02 16:04:21 +00:00
$delButton = new htmlButton('del_' . $attrName . '_' . $i, 'del.png', true);
$delButton->setCSSClasses(array('noMarginSides'));
$subContainer->addElement($delButton);
2013-11-01 18:59:55 +00:00
}
2013-10-20 14:26:29 +00:00
if ($i == 0) {
2019-09-02 16:04:21 +00:00
$addButton = new htmlButton('add_' . $attrName, 'add.png', true);
$addButton->setCSSClasses(array('noMarginSides'));
$subContainer->addElement($addButton);
if ($container instanceof htmlResponsiveRow) {
$subContainer->addElement($help);
}
2013-04-06 15:00:53 +00:00
}
2013-10-20 14:26:29 +00:00
$subContainer->addNewLine();
2013-04-06 15:00:53 +00:00
}
2019-08-17 08:52:26 +00:00
if ($container instanceof htmlTable) {
$container->addElement($subContainer);
$container->addElement($help, true);
}
else {
if ($label !== null) {
2019-09-02 16:04:21 +00:00
$container->addField($subContainer);
2019-08-17 08:52:26 +00:00
}
else {
2019-09-02 16:04:21 +00:00
$container->add($subContainer, 12);
2019-08-17 08:52:26 +00:00
}
}
2013-04-06 15:00:53 +00:00
}
2015-07-08 17:14:52 +00:00
2013-04-06 15:00:53 +00:00
/**
* Validates a multi-value text field.
* The input fields must be created with function addMultiValueInputTextField().
* If validation is used then there must exist a message named [{attribute name}][0] (e.g. $this->messages['street'][0]).
2015-07-08 17:14:52 +00:00
*
2013-04-06 15:00:53 +00:00
* @param String $attrName attribute name
* @param array $errors errors array where to put validation errors
* @param String $validationID validation ID for function get_preg() (default: null, null means no validation)
*/
protected function processMultiValueInputTextField($attrName, &$errors, $validationID = null) {
$counter = 0;
while (isset($_POST[$attrName . '_' . $counter])) {
2013-11-02 10:25:08 +00:00
$this->attributes[$attrName][$counter] = trim($_POST[$attrName . '_' . $counter]);
2013-10-20 14:26:29 +00:00
if (($this->attributes[$attrName][$counter] == '') || isset($_POST['del_' . $attrName . '_' . $counter])) {
2013-04-06 15:00:53 +00:00
unset($this->attributes[$attrName][$counter]);
}
2013-10-20 14:26:29 +00:00
elseif (($validationID != null) && ($this->attributes[$attrName][$counter] != '') && !get_preg($this->attributes[$attrName][$counter], $validationID)) {
2013-11-02 11:08:04 +00:00
$msg = $this->messages[$attrName][0];
if (sizeof($msg) < 3) {
$msg[] = htmlspecialchars($this->attributes[$attrName][$counter]);
}
$errors[] = $msg;
2013-10-20 14:26:29 +00:00
}
2013-04-06 15:00:53 +00:00
$counter++;
}
if (isset($_POST['add_' . $attrName])) {
$this->attributes[$attrName][] = '';
}
2013-10-19 14:29:02 +00:00
$this->attributes[$attrName] = array_values(array_unique($this->attributes[$attrName]));
2013-04-06 15:00:53 +00:00
}
2015-07-08 17:14:52 +00:00
2016-02-13 14:29:25 +00:00
/**
* Adds a select field type that may contain multiple values to the given htmlTable.
* The field name will be the same as the attribute name plus a counting number (e.g. street_0).
* The last field will be followed by a button to add a new value. This is named add_{attribute name} (e.g. add_street).
* There must be a help entry with the attribute name as ID.
* A new line will also be added after this entry so multiple calls will show the fields one below the other.
*
* @param htmlTable $container parent container
* @param String $attrName attribute name
* @param String $label label name
* @param array $options options for the selects
* @param boolean $hasDescriptiveOptions has descriptive options
* @param boolean $required this is a required field (default false)
* @param integer $fieldSize field size
* @param array $htmlIDs reference to array where to add the generated HTML IDs of the input fields
*/
protected function addMultiValueSelectField(&$container, $attrName, $label, $options, $hasDescriptiveOptions = false,
$required = false, $fieldSize = 1, &$htmlIDs = null) {
$values = array();
if (isset($this->attributes[$attrName][0])) {
$values = $this->attributes[$attrName];
}
if (sizeof($values) == 0) {
$values[] = '';
}
natcasesort($values);
$values = array_values($values);
if ($label !== null) {
$labelTextOut = new htmlOutputText($label);
$labelTextOut->alignment = htmlElement::ALIGN_TOP;
$labelTextOut->setMarkAsRequired($required);
2016-02-13 14:29:25 +00:00
$container->addElement($labelTextOut);
}
$subContainer = new htmlTable();
$subContainer->alignment = htmlElement::ALIGN_TOP;
for ($i = 0; $i < sizeof($values); $i++) {
$input = new htmlSelect($attrName . '_' . $i, $options, array($values[$i]), $fieldSize);
$input->setHasDescriptiveElements($hasDescriptiveOptions);
2016-02-13 14:29:25 +00:00
$subContainer->addElement($input);
if (!empty($htmlIDs)) {
$htmlIDs[] = $attrName . '_' . $i;
}
if (!empty($values[$i])) {
$subContainer->addElement(new htmlButton('del_' . $attrName . '_' . $i, 'del.png', true));
}
if ($i == 0) {
$subContainer->addElement(new htmlButton('add_' . $attrName, 'add.png', true));
}
$subContainer->addNewLine();
}
$container->addElement($subContainer);
$help = new htmlHelpLink($attrName);
$help->alignment = htmlElement::ALIGN_TOP;
$container->addElement($help, true);
}
/**
* Validates a multi-value select field.
* The select fields must be created with function addMultiValueSelectField().
*
* @param String $attrName attribute name
*/
protected function processMultiValueSelectField($attrName) {
$counter = 0;
while (isset($_POST[$attrName . '_' . $counter])) {
$this->attributes[$attrName][$counter] = trim($_POST[$attrName . '_' . $counter]);
if (($this->attributes[$attrName][$counter] == '') || isset($_POST['del_' . $attrName . '_' . $counter])) {
unset($this->attributes[$attrName][$counter]);
}
$counter++;
}
if (isset($_POST['add_' . $attrName])) {
$this->attributes[$attrName][] = '';
}
$this->attributes[$attrName] = array_values(array_unique($this->attributes[$attrName]));
}
/**
* Adds an area with two multi-select fields with buttons to move items from right to left and vice-versa.
* <br>Names:
* <ul>
* <li>First select: $namePrefix_1
* <li>Second select: $namePrefix_2
* <li>Button move left: $namePrefix_left
* <li>Button move right: $namePrefix_right
* </ul>
*
* @param htmlResponsiveRow $container row
* @param string $labelFirst label of first selct
* @param string $labelSecond label of second select
* @param string[] $optionsFirst options of first select ('label' => 'value')
* @param string[] $selectedFirst selected options of first select
* @param string[] $optionsSecond options of first select ('label' => 'value')
* @param string[] $selectedSecond selected options of second select
* @param string $namePrefix prefix for select field and button names
* @param bool $rightToLeftText sets the text direction in select to right to left
2019-08-26 18:26:00 +00:00
* @param bool $showFilter displays a live filter
*/
protected function addDoubleSelectionArea(&$container, $labelFirst, $labelSecond, $optionsFirst, $selectedFirst,
2019-08-26 18:26:00 +00:00
$optionsSecond, $selectedSecond, $namePrefix, $rightToLeftText = false, $showFilter = false) {
// first select
$firstRow = new htmlResponsiveRow();
$firstRow->add(new htmlOutputText($labelFirst), 12);
$firstSelect = new htmlSelect($namePrefix . '_1', $optionsFirst, $selectedFirst, 15);
$firstSelect->setHasDescriptiveElements(true);
$firstSelect->setMultiSelect(true);
$firstSelect->setRightToLeftTextDirection($rightToLeftText);
$firstRow->add($firstSelect, 12);
2019-08-26 18:26:00 +00:00
if ($showFilter) {
$firstFilterGroup = new htmlGroup();
$firstFilterGroup->addElement(new htmlOutputText(_('Filter')));
$firstFilterInput = new htmlInputField($namePrefix . '_filterFirst');
$firstFilterInput->filterSelectBox($namePrefix . '_1');
$firstFilterGroup->addElement($firstFilterInput);
$firstRow->add($firstFilterGroup, 12);
}
$container->add($firstRow, 12, 5);
// buttons
$buttonRow = new htmlResponsiveRow();
$buttonRow->setCSSClasses(array('text-center'));
$buttonRow->add(new htmlSpacer(null, '1rem'), 0, 12);
2019-08-15 15:15:57 +00:00
$buttonRow->add(new htmlButton($namePrefix . '_left', 'back.gif', true), 0, 12);
$buttonRow->add(new htmlButton($namePrefix . '_left', 'up.gif', true), 6, 0);
$buttonRow->add(new htmlButton($namePrefix . '_right', 'forward.gif', true), 0, 12);
$buttonRow->add(new htmlButton($namePrefix . '_right', 'down.gif', true), 6, 0);
$container->add($buttonRow, 12, 2);
// second select
$secondRow = new htmlResponsiveRow();
$secondRow->add(new htmlOutputText($labelSecond), 12);
$secondSelect = new htmlSelect($namePrefix . '_2', $optionsSecond, $selectedSecond, 15);
$secondSelect->setHasDescriptiveElements(true);
$secondSelect->setMultiSelect(true);
$secondSelect->setRightToLeftTextDirection($rightToLeftText);
$secondRow->add($secondSelect, 12);
2019-08-26 18:26:00 +00:00
if ($showFilter) {
$secondFilterGroup = new htmlGroup();
$secondFilterGroup->addElement(new htmlOutputText(_('Filter')));
$secondFilterInput = new htmlInputField($namePrefix . '_filterSecond');
$secondFilterInput->filterSelectBox($namePrefix . '_2');
$secondFilterGroup->addElement($secondFilterInput);
$secondRow->add($secondFilterGroup, 12);
}
$container->add($secondRow, 12, 5);
}
2013-04-20 16:14:03 +00:00
/**
* Adds a simple text input field for the self service.
* The field name will be the same as the class name plus "_" plus attribute name (e.g. posixAccount_cn).
2015-07-08 17:14:52 +00:00
*
2013-04-20 16:14:03 +00:00
* @param array $container array that is used as return value for getSelfServiceOptions()
* @param String $name attribute name (== field name)
* @param String $label label to display in front of input field
* @param array $fields list of active fields
* @param array $attributes attributes of LDAP account
* @param array $readOnlyFields list of read-only fields
* @param boolean $required field is required
* @param boolean $isTextArea display as text area
*/
protected function addSimpleSelfServiceTextField(&$container, $name, $label, &$fields, &$attributes, &$readOnlyFields, $required = false, $isTextArea = false) {
$value = '';
if (isset($attributes[$name][0])) {
$value = $attributes[$name][0];
}
if (!$isTextArea && !in_array($name, $readOnlyFields)) {
$field = new htmlInputField(get_class($this) . '_' . $name, $value);
$field->setRequired($required);
2015-08-04 18:41:12 +00:00
$field->setFieldSize(null);
2013-04-20 16:14:03 +00:00
}
elseif ($isTextArea && !in_array($name, $readOnlyFields)) {
2015-08-04 18:41:12 +00:00
$field = new htmlInputTextarea(get_class($this) . '_' . $name, $value, null, null);
2013-04-20 16:14:03 +00:00
}
else {
if (!$isTextArea) {
$field = new htmlOutputText($value);
}
else {
$value = htmlspecialchars($value);
$value = str_replace("\n", '<br>', $value);
$field = new htmlOutputText($value, false);
}
}
2015-08-04 18:41:12 +00:00
$row = new htmlResponsiveRow();
2015-08-09 07:57:56 +00:00
$row->addLabel(new htmlOutputText($this->getSelfServiceLabel($name, $label)));
$row->addField($field);
2015-08-04 18:41:12 +00:00
$container[$name] = $row;
2013-04-20 16:14:03 +00:00
}
2015-07-08 17:14:52 +00:00
2013-04-20 16:14:03 +00:00
/**
* Checks the input value of a self service text field.
* The field name must be the same as the class name plus "_" plus attribute name (e.g. posixAccount_cn).
* If validation is used then there must exist a message named [{attribute name}][0] (e.g. $this->messages['street'][0]).
2015-07-08 17:14:52 +00:00
*
2013-04-20 16:14:03 +00:00
* @param array $container return value of checkSelfServiceOptions()
* @param String $name attribute name
* @param array $attributes LDAP attributes
* @param string $fields input fields
* @param array $readOnlyFields list of read-only fields
* @param String $validationID validation ID for get_preg()
*/
protected function checkSimpleSelfServiceTextField(&$container, $name, &$attributes, $fields, &$readOnlyFields, $validationID = null) {
if (in_array($name, $fields) && !in_array($name, $readOnlyFields)) {
$fieldName = get_class($this) . '_' . $name;
if (isset($_POST[$fieldName]) && ($_POST[$fieldName] != '')) {
if (($validationID != null) && !get_preg($_POST[$fieldName], $validationID)) {
$container['messages'][] = $this->messages[$name][0];
}
else {
2016-09-02 09:07:15 +00:00
if (isset($attributes[$name]) && ($attributes[$name][0] != $_POST[$fieldName])) {
2013-04-20 16:14:03 +00:00
$container['mod'][$name] = array($_POST[$fieldName]);
}
2016-09-02 09:07:15 +00:00
elseif (!isset($attributes[$name])) {
2013-04-20 16:14:03 +00:00
$container['add'][$name] = array($_POST[$fieldName]);
}
}
}
elseif (isset($attributes[$name])) {
$container['del'][$name] = $attributes[$name];
}
}
}
2015-07-08 17:14:52 +00:00
/**
* Adds a simple text input field for the self service.
* The field name will be the same as the class name plus "_" plus attribute name (e.g. posixAccount_cn).
*
* @param array $container array that is used as return value for getSelfServiceOptions()
* @param String $name attribute name (== field name)
* @param String $label label to display in front of input field
* @param array $fields list of active fields
* @param array $attributes attributes of LDAP account
* @param array $readOnlyFields list of read-only fields
* @param boolean $required field is required
* @param boolean $isTextArea display as text area
*/
protected function addMultiValueSelfServiceTextField(&$container, $name, $label, &$fields, &$attributes, &$readOnlyFields, $required = false, $isTextArea = false) {
$values = array();
if (isset($attributes[$name][0])) {
$values = $attributes[$name];
}
$readOnly = in_array($name, $readOnlyFields);
$field = new htmlResponsiveRow();
if (!$readOnly) {
if (empty($values)) {
$values[] = '';
}
$fieldNamePrefix = get_class($this) . '_' . $name . '_';
for ($i = 0; $i < sizeof($values); $i++) {
$fieldRow = new htmlResponsiveRow();
$value = $values[$i];
if (!$isTextArea) {
$inputField = new htmlInputField($fieldNamePrefix . $i, $value);
$inputField->setRequired($required);
$inputField->setFieldSize(null);
}
else {
$inputField = new htmlInputTextarea($fieldNamePrefix . $i, $value, null, null);
}
$fieldRow->add($inputField, 9);
if (!empty($value)) {
$linkGroup = new htmlGroup();
$delLink = new htmlLink(null, '#', '../../graphics/del.png');
$delLink->setOnClick('window.lam.selfservice.delMultiValue(\'' . $fieldNamePrefix . '\', this); return false;');
$delLink->setCSSClasses(array('del-link'));
$linkGroup->addElement($delLink);
if ($i === (sizeof($values) - 1)) {
$addLink = new htmlLink(null, '#', '../../graphics/add.png');
$addLink->setOnClick('window.lam.selfservice.addMultiValue(\'' . $fieldNamePrefix . '\', this); return false;');
$addLink->setCSSClasses(array('add-link', 'margin-left5'));
$linkGroup->addElement($addLink);
}
$fieldRow->add($linkGroup, 3);
}
$field->add($fieldRow, 12);
}
}
else {
foreach ($values as $value) {
if (!$isTextArea) {
$inputField = new htmlOutputText($value);
}
else {
$inputField = new htmlOutputText($value);
$inputField->setPreformatted(true);
}
$field->add($inputField, 12);
}
}
$row = new htmlResponsiveRow();
$label = new htmlOutputText($this->getSelfServiceLabel($name, $label));
$label->setMarkAsRequired($required);
$row->addLabel($label);
$row->addField($field);
$container[$name] = $row;
}
/**
* Checks the input value of a self service multi-value text field.
* The field name must be the same as the class name plus "_" plus attribute name (e.g. posixAccount_cn).
* If validation is used then there must exist a message named [{attribute name}][0] (e.g. $this->messages['street'][0]).
*
* @param array $container return value of checkSelfServiceOptions()
* @param String $name attribute name
* @param array $attributes LDAP attributes
* @param string $fields input fields
* @param array $readOnlyFields list of read-only fields
* @param String $validationID validation ID for get_preg()
*/
protected function checkMultiValueSelfServiceTextField(&$container, $name, &$attributes, $fields, &$readOnlyFields, $validationID = null) {
if (in_array($name, $fields) && !in_array($name, $readOnlyFields)) {
$fieldName = get_class($this) . '_' . $name;
$valuesNew = array();
foreach ($_POST as $postKey => $postValue) {
if (strpos($postKey, $fieldName) === false) {
continue;
}
if (empty($postValue)) {
continue;
}
if (($validationID != null) && !get_preg($postValue, $validationID)) {
$container['messages'][] = $this->messages[$name][0];
return;
}
$valuesNew[] = $postValue;
}
$valuesOld = isset($attributes[$name]) ? $attributes[$name] : array();
$intersect = array_intersect($valuesOld, $valuesNew);
if ((sizeof($valuesOld) != sizeof($valuesNew)) || (sizeof($intersect) != sizeof($valuesOld))) {
$container['mod'][$name] = $valuesNew;
}
}
}
/**
* Returns a list of managed object classes for this module.
2015-07-08 17:14:52 +00:00
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.<br>
* <br>
* This is used to fix spelling errors in LDAP-Entries (e.g. if "posixACCOUNT" is read instead of "posixAccount" from LDAP).<br>
* <br>
* <b>Example:</b> return array('posixAccount')
*
2017-04-22 14:14:15 +00:00
* @param string $typeId type id (user, group, host)
* @return array list of object classes
2015-07-08 17:14:52 +00:00
*
* @see baseModule::get_metaData()
*/
2017-04-22 14:14:15 +00:00
public function getManagedObjectClasses($typeId) {
2018-12-26 08:53:58 +00:00
if (isset($this->meta['objectClasses']) && is_array($this->meta['objectClasses'])) {
return $this->meta['objectClasses'];
}
return array();
}
2006-08-14 17:29:45 +00:00
2006-05-01 16:13:10 +00:00
/**
* Returns a list of aliases for LDAP attributes.
2015-07-08 17:14:52 +00:00
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.<br>
* <br>
2006-05-01 16:13:10 +00:00
* All alias attributes will be renamed to the given attribute names.
*
2017-04-22 14:14:15 +00:00
* @param string $typeId type id (user, group, host)
* @return array list of aliases like array("alias name" => "attribute name")
2015-07-08 17:14:52 +00:00
*
* @see baseModule::get_metaData()
2006-05-01 16:13:10 +00:00
*/
2017-04-22 14:14:15 +00:00
public function getLDAPAliases($typeId) {
2018-12-26 08:53:58 +00:00
if (isset($this->meta['LDAPaliases']) && is_array($this->meta['LDAPaliases'])) {
return $this->meta['LDAPaliases'];
}
return array();
2006-05-01 16:13:10 +00:00
}
2006-08-14 17:29:45 +00:00
2006-05-13 08:55:31 +00:00
/**
* Returns a list of LDAP attributes which are managed by this module.
* All attribute names will be renamed to match the given spelling.
*
2017-04-22 14:14:15 +00:00
* @param string $typeId type id (user, group, host)
2006-05-13 08:55:31 +00:00
* @return array list of attributes
2015-07-08 17:14:52 +00:00
*
* @see baseModule::get_metaData()
2006-05-13 08:55:31 +00:00
*/
2017-04-22 14:14:15 +00:00
public function getManagedAttributes($typeId) {
2018-12-26 08:53:58 +00:00
if (isset($this->meta['attributes']) && is_array($this->meta['attributes'])) {
return $this->meta['attributes'];
}
return array();
2006-05-13 08:55:31 +00:00
}
2006-08-14 17:29:45 +00:00
/**
* Returns a list of operational LDAP attributes which are managed by this module and need to be explicitly set for LDAP search.
*
2017-12-22 09:41:31 +00:00
* @param string $typeId account type id
* @return array list of hidden attributes
*
* @see baseModule::get_metaData()
*/
2017-12-22 09:41:31 +00:00
public function getManagedHiddenAttributes($typeId) {
2018-12-26 08:53:58 +00:00
if (isset($this->meta['hiddenAttributes']) && is_array($this->meta['hiddenAttributes'])) {
return $this->meta['hiddenAttributes'];
}
return array();
}
2006-04-29 09:58:17 +00:00
/**
2008-08-09 11:18:36 +00:00
* This function returns a list of PHP extensions (e.g. hash) which are needed by this module.
2015-07-08 17:14:52 +00:00
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.
2006-04-29 09:58:17 +00:00
*
* @return array extensions
2015-07-08 17:14:52 +00:00
*
* @see baseModule::get_metaData()
2006-04-29 09:58:17 +00:00
*/
public function getRequiredExtensions() {
2018-12-26 08:53:58 +00:00
if (isset($this->meta['extensions']) && is_array($this->meta['extensions'])) {
return $this->meta['extensions'];
}
return array();
2006-04-29 09:58:17 +00:00
}
2006-08-14 17:29:45 +00:00
2006-06-28 15:12:29 +00:00
/**
* This function returns a list of possible LDAP attributes (e.g. uid, cn, ...) which can be used to search for LDAP objects.
2015-07-08 17:14:52 +00:00
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.
2006-06-28 15:12:29 +00:00
*
* @return array attributes
2015-07-08 17:14:52 +00:00
*
* @see baseModule::get_metaData()
2006-06-28 15:12:29 +00:00
*/
public function getSelfServiceSearchAttributes() {
2018-12-26 08:53:58 +00:00
if (isset($this->meta['selfServiceSearchAttributes']) && is_array($this->meta['selfServiceSearchAttributes'])) {
return $this->meta['selfServiceSearchAttributes'];
}
return array();
2006-06-28 15:12:29 +00:00
}
2006-07-16 17:15:37 +00:00
/**
* Returns a list of possible input fields and their descriptions.
2015-07-08 17:14:52 +00:00
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.<br>
* <br>
* <b>Format:</b> array(<field identifier> => <field description>)
2006-07-16 17:15:37 +00:00
*
* @return array fields
2015-07-08 17:14:52 +00:00
*
* @see baseModule::get_metaData()
2006-07-16 17:15:37 +00:00
*/
public function getSelfServiceFields() {
2018-12-26 08:53:58 +00:00
if (isset($this->meta['selfServiceFieldSettings']) && is_array($this->meta['selfServiceFieldSettings'])) {
return $this->meta['selfServiceFieldSettings'];
}
return array();
2006-07-16 17:15:37 +00:00
}
2015-07-08 17:14:52 +00:00
2012-08-18 15:55:43 +00:00
/**
* Returns if a given self service field can be set in read-only mode.
2015-07-08 17:14:52 +00:00
*
2012-08-18 15:55:43 +00:00
* @param String $fieldID field identifier
* @param selfServiceProfile $profile currently edited profile
2013-11-30 15:02:06 +00:00
* @return boolean may be set read-only
2012-08-18 15:55:43 +00:00
*/
public function canSelfServiceFieldBeReadOnly($fieldID, $profile) {
if (isset($this->meta['selfServiceReadOnlyFields']) && is_array($this->meta['selfServiceReadOnlyFields'])) {
return in_array($fieldID, $this->meta['selfServiceReadOnlyFields']);
}
return false;
}
2015-07-08 17:14:52 +00:00
2013-11-30 15:02:06 +00:00
/**
* Returns if a self service field can be relabeled.
2015-07-08 17:14:52 +00:00
*
2013-11-30 15:02:06 +00:00
* @param String $fieldID field ID
* @param selfServiceProfile $profile currently edited profile
* @return boolean may be relabeled
*/
public function canSelfServiceFieldBeRelabeled($fieldID, $profile) {
if (isset($this->meta['selfServiceNoRelabelFields']) && is_array($this->meta['selfServiceNoRelabelFields'])) {
return !in_array($fieldID, $this->meta['selfServiceNoRelabelFields']);
}
return true;
}
2015-07-08 17:14:52 +00:00
2013-11-30 15:02:06 +00:00
/**
* Returns the field label. This can be either the given default label or an override value from profile.
2015-07-08 17:14:52 +00:00
*
2013-11-30 15:02:06 +00:00
* @param String $fieldID field ID
* @param String $defaultLabel default label text
* @return String label
*/
protected function getSelfServiceLabel($fieldID, $defaultLabel) {
if (!$this->canSelfServiceFieldBeRelabeled($fieldID, $this->selfServiceSettings)) {
return $defaultLabel;
}
$key = get_class($this) . '_' . $fieldID;
return empty($this->selfServiceSettings->relabelFields[$key]) ? $defaultLabel : $this->selfServiceSettings->relabelFields[$key];
}
2006-08-14 17:29:45 +00:00
2006-07-23 15:04:12 +00:00
/**
* Returns the meta HTML code for each input field.
2015-07-08 17:14:52 +00:00
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.<br>
* <br>
2006-07-23 15:04:12 +00:00
* It is not possible to display help links.
*
* @param array $fields list of active fields
2011-08-20 17:59:36 +00:00
* @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
2012-08-18 15:55:43 +00:00
* @param array $readOnlyFields list of read-only fields
2015-08-04 18:41:12 +00:00
* @return array list of meta HTML elements (field name => htmlResponsiveRow)
2015-07-08 17:14:52 +00:00
*
2010-06-11 19:39:19 +00:00
* @see htmlElement
2006-07-23 15:04:12 +00:00
*/
2012-08-18 15:55:43 +00:00
public function getSelfServiceOptions($fields, $attributes, $passwordChangeOnly, $readOnlyFields) {
2006-07-23 15:04:12 +00:00
// 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.
2011-02-26 13:14:10 +00:00
* <br>Return values:
* <br>messages: array of parameters to create status messages
* <br>add: array of attributes to add
* <br>del: array of attributes to remove
* <br>mod: array of attributes to modify
* <br>info: array of values with informational value (e.g. to be used later by pre/postModify actions)
2015-07-08 17:14:52 +00:00
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.
2006-07-23 15:04:12 +00:00
*
* @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
2012-08-18 15:55:43 +00:00
* @param array $readOnlyFields list of read-only fields
2011-02-26 13:14:10 +00:00
* @return array messages and attributes (array('messages' => array(), 'add' => array('mail' => array('test@test.com')), 'del' => array(), 'mod' => array(), 'info' => array()))
2006-07-23 15:04:12 +00:00
*/
2012-08-18 15:55:43 +00:00
public function checkSelfServiceOptions($fields, $attributes, $passwordChangeOnly, $readOnlyFields) {
2011-02-26 13:14:10 +00:00
$return = array('messages' => array(), 'add' => array(), 'del' => array(), 'mod' => array(), 'info' => array());
2006-07-23 15:04:12 +00:00
return $return;
}
2005-04-04 16:54:10 +00:00
2006-11-21 17:37:12 +00:00
/**
* Returns a list of self service configuration settings.
2015-07-08 17:14:52 +00:00
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.<br>
* <br>
2010-06-11 19:39:19 +00:00
* 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.
2006-11-21 17:37:12 +00:00
*
* @param selfServiceProfile $profile currently edited profile
2010-06-11 19:39:19 +00:00
* @return htmlElement meta HTML object
2015-07-08 17:14:52 +00:00
*
* @see baseModule::get_metaData()
2010-06-11 19:39:19 +00:00
* @see htmlElement
2006-11-21 17:37:12 +00:00
*/
public function getSelfServiceSettings($profile) {
2010-06-10 15:39:35 +00:00
if (isset($this->meta['selfServiceSettings'])) {
return $this->meta['selfServiceSettings'];
}
else {
2019-09-05 19:26:49 +00:00
return null;
2010-06-10 15:39:35 +00:00
}
2006-11-21 17:37:12 +00:00
}
/**
* Checks if the self service settings are valid.
2015-07-08 17:14:52 +00:00
*
* Calling this method does not require the existence of an enclosing {@link accountContainer}.<br>
* <br>
* 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.
2006-11-21 17:37:12 +00:00
*
* @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
2006-11-21 17:37:12 +00:00
* @return array error messages
*/
public function checkSelfServiceSettings(&$options, &$profile) {
2006-11-21 17:37:12 +00:00
// needs to be implemented by the subclasses, if needed
return array();
}
2015-07-08 17:14:52 +00:00
2009-11-23 18:39:26 +00:00
/**
* Allows the module to run commands before the LDAP entry is changed or created.
2015-07-08 17:14:52 +00:00
*
2009-11-23 18:39:26 +00:00
* An error message should be printed if the function returns false.
2015-07-08 17:14:52 +00:00
*
* @param boolean $newAccount is new account or existing one
2009-11-23 18:39:26 +00:00
* @param array $attributes LDAP attributes of this entry
* @return boolean true, if no problems occured
*/
public function preModifySelfService($newAccount, $attributes) {
2009-11-23 18:39:26 +00:00
return true;
}
2015-07-08 17:14:52 +00:00
2009-11-23 18:39:26 +00:00
/**
* Allows the module to run commands after the LDAP entry is changed or created.
*
* @param boolean $newAccount is new account or existing one
2009-11-23 18:39:26 +00:00
* @param array $attributes LDAP attributes of this entry
* @return boolean true, if no problems occured
*/
public function postModifySelfService($newAccount, $attributes) {
2009-11-23 18:39:26 +00:00
return true;
}
2015-07-08 17:14:52 +00:00
/**
* 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.
2015-07-08 17:14:52 +00:00
*
* @param array $settings self service settings
* @return String link text (null if no special page used)
*/
public function getLinkToSpecialSelfServicePage($settings) {
return null;
}
2015-07-08 17:14:52 +00:00
/**
* This function creates meta HTML code to display the module specific page
* for the self service.
2015-07-08 17:14:52 +00:00
*
* @param selfServiceProfile $profile self service settings
* @return htmlElement meta HTML object
*
* @see htmlElement
*/
public function displaySpecialSelfServicePage($profile) {
return null;
}
2007-10-03 18:02:10 +00:00
/**
* Returns the {@link accountContainer} object.
2015-07-08 17:14:52 +00:00
*
2007-10-03 18:02:10 +00:00
* @return accountContainer accountContainer object
*
* @see accountContainer
2007-10-03 18:02:10 +00:00
*/
protected function getAccountContainer() {
if (isset($this->base) && isset($_SESSION[$this->base])) {
return $_SESSION[$this->base];
}
else {
return null;
}
}
2015-07-08 17:14:52 +00:00
2007-10-10 19:04:39 +00:00
/**
* Returns the LDAP attributes which are managed in this module.
*
* @return array attributes
*/
public function getAttributes() {
return $this->attributes;
}
2015-07-08 17:14:52 +00:00
2007-10-10 19:04:39 +00:00
/**
* Returns the LDAP attributes which are managed in this module (with unchanged values).
*
* @return array attributes
*/
public function getOriginalAttributes() {
return $this->orig;
}
2015-07-08 17:14:52 +00:00
2007-11-19 18:42:03 +00:00
/**
* Returns the path to the module icon.
* The path must be releative to graphics (e.g. key.png) or an URL (/icons/icon.png or http://server/icon.png).
* You can also set $this->meta['icon']. The preferred size is 32x32px.
2007-11-19 18:42:03 +00:00
*
* @return unknown
2015-07-08 17:14:52 +00:00
*
* @see baseModule::get_metaData()
2007-11-19 18:42:03 +00:00
*/
public function getIcon() {
if (isset($this->meta['icon'])) {
return $this->meta['icon'];
}
return null;
}
2015-07-08 17:14:52 +00:00
/**
* 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
}
2015-07-08 17:14:52 +00:00
/**
* 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.
2015-07-08 17:14:52 +00:00
*
* @return boolean support admin interface
*/
2012-09-26 17:36:22 +00:00
public function supportsAdminInterface() {
return true;
}
2015-07-08 17:14:52 +00:00
2015-06-16 18:59:56 +00:00
/**
* Returns a list of jobs that can be run.
2015-07-08 17:14:52 +00:00
*
2015-06-16 18:59:56 +00:00
* @param LAMConfig $config configuration
*/
public function getSupportedJobs(&$config) {
return array();
}
2015-07-08 17:14:52 +00:00
// 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
* @param boolean $default default value if config option is not set at all (default: false)
* @return boolean true if option is set
*/
protected function isBooleanConfigOptionSet($optionName, $default = false) {
// abort if configuration is not available
if (!isset($this->moduleSettings) || !is_array($this->moduleSettings) || !isset($this->moduleSettings[$optionName][0])) {
return $default;
}
return ($this->moduleSettings[$optionName][0] == 'true');
}
2006-11-21 17:37:12 +00:00
2016-11-19 18:20:44 +00:00
/**
* Returns a list of wildcards that can be replaced in input fileds.
2017-06-05 07:39:29 +00:00
* E.g. "$firstname" is replaced with "givenName" attribute value.
2016-11-19 18:20:44 +00:00
*
* @return array replacements as wildcard => value
*/
public function getWildCardReplacements() {
return array();
}
2004-10-19 18:18:46 +00:00
}
2004-06-08 18:39:53 +00:00
?>