From 3a3c88ba4b1e0466e5bc6b31823cd69e093f50e3 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Thu, 30 Mar 2017 20:39:24 +0200 Subject: [PATCH] added typeId for profile methods --- lam/docs/devel/upgrade.htm | 4 ++++ lam/lib/baseModule.inc | 6 ++++-- lam/lib/modules.inc | 14 ++++++++------ lam/lib/modules/freeRadius.inc | 11 ++++------- lam/lib/modules/inetOrgPerson.inc | 9 +++------ lam/lib/modules/nisNetGroupHost.inc | 6 ++---- lam/lib/modules/nisNetGroupUser.inc | 6 ++---- lam/lib/modules/posixAccount.inc | 6 ++---- lam/lib/modules/puppetClient.inc | 18 +++--------------- lam/lib/modules/quota.inc | 13 ++++--------- lam/lib/modules/sambaGroupMapping.inc | 6 ++---- lam/lib/modules/sambaSamAccount.inc | 10 ++++------ lam/lib/modules/systemQuotas.inc | 9 +++------ lam/lib/modules/windowsUser.inc | 10 ++++------ 14 files changed, 49 insertions(+), 79 deletions(-) diff --git a/lam/docs/devel/upgrade.htm b/lam/docs/devel/upgrade.htm index 91d4e83c..8a51ff0f 100644 --- a/lam/docs/devel/upgrade.htm +++ b/lam/docs/devel/upgrade.htm @@ -19,6 +19,7 @@ + @@ -53,6 +54,9 @@ This is a list of API changes for all LAM releases.

5.7 -> 5.8


5.6 -> 5.7

diff --git a/lam/lib/baseModule.inc b/lam/lib/baseModule.inc index b19c5bc5..b11055ff 100644 --- a/lam/lib/baseModule.inc +++ b/lam/lib/baseModule.inc @@ -502,12 +502,13 @@ abstract class baseModule { * and save profiles. We recommend to use the module name as prefix for them * (e.g. posixAccount_homeDirectory) to avoid naming conflicts. * + * @param string $typeId type id (user, group, host, ...) * @return htmlElement meta HTML object * * @see baseModule::get_metaData() * @see htmlElement */ - public function get_profileOptions() { + public function get_profileOptions($typeId) { if (isset($this->meta['profile_options'])) return $this->meta['profile_options']; else return array(); } @@ -524,11 +525,12 @@ abstract class baseModule { * the function returns an empty array. * * @param array $options a hash array (name => value) containing the user input + * @param string $typeId type id (user, group, host) * @return array list of error messages (array(type, title, text)) to generate StatusMessages, if any * * @see baseModule::get_metaData() */ - public function check_profileOptions($options) { + public function check_profileOptions($options, $typeId) { $messages = array(); if (isset($this->meta['profile_checks'])) { $identifiers = array_keys($this->meta['profile_checks']); diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index 42eb959f..3bf2d436 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -316,7 +316,7 @@ function getProfileOptions($typeId) { $return = array(); for ($i = 0; $i < sizeof($mods); $i++) { $module = moduleCache::getModule($mods[$i], $type->getScope()); - $return[$mods[$i]] = $module->get_profileOptions(); + $return[$mods[$i]] = $module->get_profileOptions($typeId); } return $return; } @@ -324,16 +324,18 @@ function getProfileOptions($typeId) { /** * Checks if the profile options are valid * -* @param string $scope account type (user, group, host) +* @param string $typeId account type (user, group, host) * @param array $options hash array containing all options (name => array(...)) * @return array list of error messages */ -function checkProfileOptions($scope, $options) { - $mods = $_SESSION['config']->get_AccountModules($scope); +function checkProfileOptions($typeId, $options) { + $typeManager = new TypeManager(); + $type = $typeManager->getConfiguredType($typeId); + $mods = $type->getModules(); $return = array(); for ($i = 0; $i < sizeof($mods); $i++) { - $module = moduleCache::getModule($mods[$i], $scope); - $temp = $module->check_profileOptions($options); + $module = moduleCache::getModule($mods[$i], $type->getScope()); + $temp = $module->check_profileOptions($options, $type->getId()); $return = array_merge($return, $temp); } return $return; diff --git a/lam/lib/modules/freeRadius.inc b/lam/lib/modules/freeRadius.inc index 6753b9ab..e5c26206 100644 --- a/lam/lib/modules/freeRadius.inc +++ b/lam/lib/modules/freeRadius.inc @@ -3,7 +3,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2011 - 2016 Roland Gruber + Copyright (C) 2011 - 2017 Roland Gruber 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 @@ -710,13 +710,10 @@ class freeRadius extends baseModule { } /** - * Checks input values of account profiles. - * - * @param array $options a hash array (name => value) containing the options - * @return array list of error messages (array(type, title, text)) to generate StatusMessages, if any + * {@inheritDoc} */ - function check_profileOptions($options) { - $messages = parent::check_profileOptions($options); + function check_profileOptions($options, $typeId) { + $messages = parent::check_profileOptions($options, $typeId); // group names if (!$this->isBooleanConfigOptionSet('freeRadius_hideRadiusGroupName')) { if (isset($options['freeRadius_radiusGroupName'][0]) && ($options['freeRadius_radiusGroupName'][0] != '')) { diff --git a/lam/lib/modules/inetOrgPerson.inc b/lam/lib/modules/inetOrgPerson.inc index eafcbf10..d43732cb 100644 --- a/lam/lib/modules/inetOrgPerson.inc +++ b/lam/lib/modules/inetOrgPerson.inc @@ -2080,13 +2080,10 @@ class inetOrgPerson extends baseModule implements passwordService { } /** - * Checks input values of account profiles. - * - * @param array $options a hash array (name => value) containing the options - * @return array list of error messages (array(type, title, text)) to generate StatusMessages, if any + * {@inheritDoc} */ - function check_profileOptions($options) { - $messages = parent::check_profileOptions($options); + function check_profileOptions($options, $typeId) { + $messages = parent::check_profileOptions($options, $typeId); if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideTelephoneNumber')) { $telephoneNumberList = preg_split('/;[ ]*/', $options['inetOrgPerson_telephoneNumber'][0]); for ($i = 0; $i < sizeof($telephoneNumberList); $i++) { diff --git a/lam/lib/modules/nisNetGroupHost.inc b/lam/lib/modules/nisNetGroupHost.inc index 22ee257d..3fc44078 100644 --- a/lam/lib/modules/nisNetGroupHost.inc +++ b/lam/lib/modules/nisNetGroupHost.inc @@ -206,11 +206,9 @@ class nisNetGroupHost extends nisNetGroupUser { } /** - * Returns a list of elements for the account profiles. - * - * @return profile elements + * {@inheritDoc} */ - function get_profileOptions() { + function get_profileOptions($typeId) { $groups = $this->findGroups(); $groupOptions = array('' => ''); foreach ($groups as $group) { diff --git a/lam/lib/modules/nisNetGroupUser.inc b/lam/lib/modules/nisNetGroupUser.inc index d5f019f2..62131fdb 100644 --- a/lam/lib/modules/nisNetGroupUser.inc +++ b/lam/lib/modules/nisNetGroupUser.inc @@ -424,11 +424,9 @@ class nisNetGroupUser extends baseModule { } /** - * Returns a list of elements for the account profiles. - * - * @return profile elements + * {@inheritDoc} */ - function get_profileOptions() { + function get_profileOptions($typeId) { $groups = $this->findGroups(); $groupOptions = array('' => ''); foreach ($groups as $group) { diff --git a/lam/lib/modules/posixAccount.inc b/lam/lib/modules/posixAccount.inc index 50e701b8..6fec28cf 100644 --- a/lam/lib/modules/posixAccount.inc +++ b/lam/lib/modules/posixAccount.inc @@ -1701,11 +1701,9 @@ class posixAccount extends baseModule implements passwordService { } /** - * Returns a list of elements for the account profiles. - * - * @return profile elements + * {@inheritDoc} */ - function get_profileOptions() { + function get_profileOptions($typeId) { $return = new htmlTable(); $groupList = $this->findGroups(); $groups = array(); diff --git a/lam/lib/modules/puppetClient.inc b/lam/lib/modules/puppetClient.inc index 8df3810f..cfcfadbd 100644 --- a/lam/lib/modules/puppetClient.inc +++ b/lam/lib/modules/puppetClient.inc @@ -430,22 +430,10 @@ class puppetClient extends baseModule { } /** - * 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}.
- *
- * The return value is an object implementing htmlElement.
- * 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. - * - * @return htmlElement meta HTML object - * - * @see baseModule::get_metaData() - * @see htmlElement + * {@inheritDoc} */ - public function get_profileOptions() { - $return = parent::get_profileOptions(); + public function get_profileOptions($typeId) { + $return = parent::get_profileOptions($typeId); $possibleParentNodes = $this->getPossibleParentNodes(); array_unshift($possibleParentNodes, '-'); $possibleParentNodes = array_values($possibleParentNodes); diff --git a/lam/lib/modules/quota.inc b/lam/lib/modules/quota.inc index f44816c9..3ccf6e7f 100644 --- a/lam/lib/modules/quota.inc +++ b/lam/lib/modules/quota.inc @@ -467,11 +467,9 @@ class quota extends baseModule { } /** - * Returns a list of elements for the account profiles. - * - * @return htmlElement profile elements + * {@inheritDoc} */ - function get_profileOptions() { + function get_profileOptions($typeId) { $return = new htmlTable(); $optionsAvailable = false; // get list of lamdaemon servers @@ -547,12 +545,9 @@ class quota extends baseModule { } /** - * Checks input values of account profiles. - * - * @param array $options a hash array (name => value) containing the options - * @return array list of error messages (array(type, title, text)) to generate StatusMessages, if any + * {@inheritDoc} */ - function check_profileOptions($options) { + function check_profileOptions($options, $typeId) { $return = array(); // get list of lamdaemon servers $lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers()); diff --git a/lam/lib/modules/sambaGroupMapping.inc b/lam/lib/modules/sambaGroupMapping.inc index bbfd1ca9..65501de2 100644 --- a/lam/lib/modules/sambaGroupMapping.inc +++ b/lam/lib/modules/sambaGroupMapping.inc @@ -561,11 +561,9 @@ class sambaGroupMapping extends baseModule { /** - * Returns a list of elements for the account profiles. - * - * @return htmlElement profile elements + * {@inheritDoc} */ - function get_profileOptions() { + function get_profileOptions($typeId) { $return = new htmlTable(); // get list of domains $sambaDomains = $this->getDomains(); diff --git a/lam/lib/modules/sambaSamAccount.inc b/lam/lib/modules/sambaSamAccount.inc index 1ee6f3d4..1cd5064c 100644 --- a/lam/lib/modules/sambaSamAccount.inc +++ b/lam/lib/modules/sambaSamAccount.inc @@ -4,7 +4,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) Copyright (C) 2003 - 2006 Tilo Lutz - 2005 - 2016 Roland Gruber + 2005 - 2017 Roland Gruber 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 @@ -1663,12 +1663,10 @@ class sambaSamAccount extends baseModule implements passwordService { } /** - * Returns a list of elements for the account profiles. - * - * @return htmlElement profile elements + * {@inheritDoc} */ - function get_profileOptions() { - $return = parent::get_profileOptions(); + function get_profileOptions($typeId) { + $return = parent::get_profileOptions($typeId); if ($this->get_scope() == 'user') { // lists for expiration date $day = array(); $mon = array(); $year = array(); diff --git a/lam/lib/modules/systemQuotas.inc b/lam/lib/modules/systemQuotas.inc index bfa06cd7..cf8992fc 100644 --- a/lam/lib/modules/systemQuotas.inc +++ b/lam/lib/modules/systemQuotas.inc @@ -317,13 +317,10 @@ class systemQuotas extends baseModule { } /** - * Checks input values of account profiles. - * - * @param array $options a hash array (name => value) containing the options - * @return array list of error messages (array(type, title, text)) to generate StatusMessages, if any + * {@inheritDoc} */ - function check_profileOptions($options) { - $messages = parent::check_profileOptions($options); + function check_profileOptions($options, $typeId) { + $messages = parent::check_profileOptions($options, $typeId); $quotas = explode(';', $options['systemQuotas_quota'][0]); for ($q = 0; $q < sizeof($quotas); $q++) { if ($quotas[$q] == '') { diff --git a/lam/lib/modules/windowsUser.inc b/lam/lib/modules/windowsUser.inc index aa2945d3..6e137744 100644 --- a/lam/lib/modules/windowsUser.inc +++ b/lam/lib/modules/windowsUser.inc @@ -3,7 +3,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2013 - 2016 Roland Gruber + Copyright (C) 2013 - 2017 Roland Gruber 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 @@ -2500,12 +2500,10 @@ class windowsUser extends baseModule implements passwordService { } /** - * Returns a list of elements for the account profiles. - * - * @return htmlElement profile elements + * {@inheritDoc} */ - function get_profileOptions() { - $return = parent::get_profileOptions(); + function get_profileOptions($typeId) { + $return = parent::get_profileOptions($typeId); // domain $domains = $this->getDomains(); $domains[] = '';