diff --git a/lam/docs/devel/upgrade.htm b/lam/docs/devel/upgrade.htm index bc2fddab..bd0531fd 100644 --- a/lam/docs/devel/upgrade.htm +++ b/lam/docs/devel/upgrade.htm @@ -15,6 +15,7 @@ + @@ -55,8 +56,18 @@ This is a list of API changes for all LAM releases.

5.7 -> 5.8


diff --git a/lam/lib/baseModule.inc b/lam/lib/baseModule.inc index b84dab78..105f531b 100644 --- a/lam/lib/baseModule.inc +++ b/lam/lib/baseModule.inc @@ -124,7 +124,7 @@ abstract class baseModule { $this->attributes['objectClass'] = array(); $this->orig['objectClass'] = array(); if ($this->autoAddObjectClasses === true) { - $objectClasses = $this->getManagedObjectClasses(); + $objectClasses = $this->getManagedObjectClasses($this->getAccountContainer()->get_type()->getId()); for ($i = 0; $i < sizeof($objectClasses); $i++) { if (!in_array($objectClasses[$i], $this->attributes['objectClass'])) { $this->attributes['objectClass'][] = $objectClasses[$i]; @@ -156,9 +156,10 @@ abstract class baseModule { $this->attributes['objectClass'] = array(); $this->orig['objectClass'] = array(); } + $typeId = $this->getAccountContainer()->get_type()->getId(); // add object classes if needed if ($this->autoAddObjectClasses === true) { - $objectClasses = $this->getManagedObjectClasses(); + $objectClasses = $this->getManagedObjectClasses($typeId); for ($i = 0; $i < sizeof($objectClasses); $i++) { if (!in_array($objectClasses[$i], $this->attributes['objectClass'])) { $this->attributes['objectClass'][] = $objectClasses[$i]; @@ -166,7 +167,7 @@ abstract class baseModule { } } // load attributes - $attributeNames = $this->getManagedAttributes(); + $attributeNames = $this->getManagedAttributes($typeId); for ($i = 0; $i < sizeof($attributeNames); $i++) { if (isset($attributes[$attributeNames[$i]])) { $this->attributes[$attributeNames[$i]] = $attributes[$attributeNames[$i]]; @@ -1532,11 +1533,12 @@ abstract class baseModule { *
* Example: return array('posixAccount') * + * @param string $typeId type id (user, group, host) * @return array list of object classes * * @see baseModule::get_metaData() */ - public function getManagedObjectClasses() { + public function getManagedObjectClasses($typeId) { if (isset($this->meta['objectClasses']) && is_array($this->meta['objectClasses'])) return $this->meta['objectClasses']; else return array(); } @@ -1548,11 +1550,12 @@ abstract class baseModule { *
* All alias attributes will be renamed to the given attribute names. * + * @param string $typeId type id (user, group, host) * @return array list of aliases like array("alias name" => "attribute name") * * @see baseModule::get_metaData() */ - public function getLDAPAliases() { + public function getLDAPAliases($typeId) { if (isset($this->meta['LDAPaliases']) && is_array($this->meta['LDAPaliases'])) return $this->meta['LDAPaliases']; else return array(); } @@ -1561,11 +1564,12 @@ abstract class baseModule { * Returns a list of LDAP attributes which are managed by this module. * All attribute names will be renamed to match the given spelling. * + * @param string $typeId type id (user, group, host) * @return array list of attributes * * @see baseModule::get_metaData() */ - public function getManagedAttributes() { + public function getManagedAttributes($typeId) { if (isset($this->meta['attributes']) && is_array($this->meta['attributes'])) return $this->meta['attributes']; else return array(); } diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index a24350fa..e2191a51 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -1234,7 +1234,7 @@ class accountContainer { */ private function anyModuleManagesMail() { foreach ($this->module as $mod) { - if (in_array('mail', $mod->getManagedAttributes())) { + if (in_array('mail', $mod->getManagedAttributes($this->get_type()->getId()))) { return true; } } @@ -1639,9 +1639,9 @@ class accountContainer { $ldapAttributesTemp = array(); foreach ($modules as $module) { $moduleObj = moduleCache::getModule($module, $this->type->getScope()); - $objectClasses = array_merge($objectClasses, $moduleObj->getManagedObjectClasses()); - $aliases = array_merge($aliases, $moduleObj->getLDAPAliases()); - $ldapAttributesTemp = array_merge($ldapAttributesTemp, $moduleObj->getManagedAttributes()); + $objectClasses = array_merge($objectClasses, $moduleObj->getManagedObjectClasses($this->type->getId())); + $aliases = array_merge($aliases, $moduleObj->getLDAPAliases($this->type->getId())); + $ldapAttributesTemp = array_merge($ldapAttributesTemp, $moduleObj->getManagedAttributes($this->type->getId())); } // build lower case attribute names $ldapAttributes = array(); diff --git a/lam/lib/modules/posixAccount.inc b/lam/lib/modules/posixAccount.inc index 19d78675..8946d9fc 100644 --- a/lam/lib/modules/posixAccount.inc +++ b/lam/lib/modules/posixAccount.inc @@ -993,7 +993,7 @@ class posixAccount extends baseModule implements passwordService { } if (isset($_POST['remObjectClass'])) { $this->attributes['objectClass'] = array_delete(array('posixAccount'), $this->attributes['objectClass']); - $attrs = $this->getManagedAttributes(); + $attrs = $this->getManagedAttributes($this->getAccountContainer()->get_type()->getId()); foreach ($attrs as $name) { if (isset($this->attributes[$name])) { unset($this->attributes[$name]); diff --git a/lam/lib/modules/posixGroup.inc b/lam/lib/modules/posixGroup.inc index 258dba0f..596f986a 100644 --- a/lam/lib/modules/posixGroup.inc +++ b/lam/lib/modules/posixGroup.inc @@ -728,7 +728,7 @@ class posixGroup extends baseModule implements passwordService { } if (isset($_POST['remObjectClass'])) { $this->attributes['objectClass'] = array_delete(array('posixGroup'), $this->attributes['objectClass']); - $attrs = $this->getManagedAttributes(); + $attrs = $this->getManagedAttributes($this->getAccountContainer()->get_type()->getId()); foreach ($attrs as $name) { if (isset($this->attributes[$name])) { unset($this->attributes[$name]); diff --git a/lam/templates/tests/schemaTest.php b/lam/templates/tests/schemaTest.php index 8feddde3..76dcbd16 100644 --- a/lam/templates/tests/schemaTest.php +++ b/lam/templates/tests/schemaTest.php @@ -69,7 +69,7 @@ else { $modules = $_SESSION['config']->get_AccountModules($type->getId()); $container->addElement(new htmlSubTitle($type->getAlias()), true); for ($m = 0; $m < sizeof($modules); $m++) { - $error = checkSchemaForModule($modules[$m], $type->getScope()); + $error = checkSchemaForModule($modules[$m], $type->getScope(), $type->getId()); $message = _("No problems found."); $icon = '../../graphics/pass.png'; if ($error != null) { @@ -98,14 +98,15 @@ include '../main_footer.php'; * Checks if the object classes and attributes for this module are available. * * @param String $name module name - * @param String $type type (user, group, ...) + * @param String $scope type (user, group, ...) + * @param String $typeId type id * @return String error message or null */ -function checkSchemaForModule($name, $type) { - $module = new $name($type); - $classes = $module->getManagedObjectClasses(); - $attrs = $module->getManagedAttributes(); - $aliases = array_flip($module->getLDAPAliases()); +function checkSchemaForModule($name, $scope, $typeId) { + $module = new $name($scope); + $classes = $module->getManagedObjectClasses($typeId); + $attrs = $module->getManagedAttributes($typeId); + $aliases = array_flip($module->getLDAPAliases($typeId)); if (sizeof($classes) == 0) { return null; }