use type ids for config check

This commit is contained in:
Roland Gruber 2017-12-20 20:44:08 +01:00
parent 1e51b59cf9
commit ea33f2f5ac
7 changed files with 39 additions and 43 deletions

View File

@ -60,6 +60,15 @@ This is a list of API changes for all LAM releases.
<br>
<h2>6.2 -&gt; 6.3</h2>
<ul>
<li>Module API
<ul>
<li>get_configOptions(): $allScopes contains type ids instead of account types</li>
<li>check_configOptions(): first parameter contains type ids instead of account types</li>
</ul>
</li>
</ul>
<h2>6.1 -&gt; 6.2</h2>
<ul>
<li>No major API changes</li>

View File

@ -2,6 +2,7 @@
use \LAM\PDF\PDFLabelValue;
use \LAM\PDF\PDFTable;
use LAM\TYPES\ConfiguredType;
use function LAM\TYPES\getScopeFromTypeId;
/*
$Id$
@ -681,15 +682,20 @@ abstract class baseModule {
* 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.
*
* @param array $scopes list of account types which are used
* @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
*
* @see baseModule::get_metaData()
*/
public function check_configOptions($scopes, &$options) {
public function check_configOptions($typeIds, &$options) {
$messages = array();
$scopes[] = 'all'; // add checks that are independent of scope
// 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++) {
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]]);

View File

@ -360,7 +360,7 @@ function getConfigOptions($scopes) {
/**
* Checks if the configuration options are valid
*
* @param array $scopes hash array (module name => array(account types))
* @param array $scopes hash array (module name => array(account type ids))
* @param array $options hash array containing all options (name => array(...))
* @return array list of error messages
*/

View File

@ -497,21 +497,11 @@ class imapAccess extends baseModule {
}
/**
* Checks input values of module settings.
*
* 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.
*
* @param array $scopes list of account types 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
*
* @see baseModule::get_metaData()
*/
public function check_configOptions($scopes, &$options) {
$errors = parent::check_configOptions($scopes, $options);
* {@inheritDoc}
* @see baseModule::check_configOptions()
*/
public function check_configOptions($typeIds, &$options) {
$errors = parent::check_configOptions($typeIds, $options);
if ($options['ImapAccess_ImapAdminPasswordSelect'][0] == 'config') {
if (empty($options['ImapAccess_ImapAdminPassword'][0])) {
$errors[] = $this->messages['config'][2];

View File

@ -1,5 +1,6 @@
<?php
use \LAM\TYPES\TypeManager;
use function LAM\TYPES\getScopeFromTypeId;
/*
$Id$
@ -2026,15 +2027,15 @@ class posixAccount extends baseModule implements passwordService {
}
/**
* Checks input values of module settings.
*
* @param array $scopes list of account types which are used
* @param array $options hash array containing the settings (array('option' => array('value')))
* @return array list of error messages
*/
function check_configOptions($scopes, &$options) {
* {@inheritDoc}
* @see baseModule::check_configOptions()
*/
function check_configOptions($typeIds, &$options) {
$return = array();
// user settings
$scopes = array();
foreach ($typeIds as $typeId) {
$scopes[] = getScopeFromTypeId($typeId);
} // user settings
if (in_array('user', $scopes)) {
if ($options['posixAccount_uidGeneratorUsers'][0] == 'range') {
// min/maxUID are required, check if they are numeric

View File

@ -1016,20 +1016,10 @@ class posixGroup extends baseModule implements passwordService {
}
/**
* Checks input values of module settings.
*
* 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.
*
* @param array $scopes list of account types 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
*
* @see baseModule::get_metaData()
*/
public function check_configOptions($scopes, &$options) {
* {@inheritDoc}
* @see baseModule::check_configOptions()
*/
public function check_configOptions($typeIds, &$options) {
if ($options['posixGroup_gidGenerator'][0] == 'range') {
$this->meta['config_checks']['group']['posixGroup_minGID'] = array (
'type' => 'ext_preg',
@ -1065,7 +1055,7 @@ class posixGroup extends baseModule implements passwordService {
'required_message' => $this->messages['windowsIDPoolDN'][0],
'error_message' => $this->messages['windowsIDPoolDN'][0]);
}
return parent::check_configOptions($scopes, $options);
return parent::check_configOptions($typeIds, $options);
}
/**

View File

@ -224,7 +224,7 @@ function checkInput() {
foreach ($types as $type) {
$mods = $conf->get_AccountModules($type->getId());
for ($i = 0; $i < sizeof($mods); $i++) {
$scopes[$mods[$i]][] = $type->getScope();
$scopes[$mods[$i]][] = $type->getId();
}
}
// check options