new type API
This commit is contained in:
parent
01f2d618f2
commit
9ac206a613
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,8 +56,18 @@ This is a list of API changes for all LAM releases.
|
||||||
<h2>5.7 -> 5.8</h2>
|
<h2>5.7 -> 5.8</h2>
|
||||||
<ul>
|
<ul>
|
||||||
<li>All account types allow multiple configurations by default.</li>
|
<li>All account types allow multiple configurations by default.</li>
|
||||||
<li>check_profileOptions()/get_profileOptions()/get_pdfEntries()/get_pdfFields() has new parameter $typeId<br>
|
<li>the following methods in baseModule have a new parameter $typeId:</li>
|
||||||
|
<ul>
|
||||||
|
<li>check_profileOptions()</li>
|
||||||
|
<li>get_profileOptions()</li>
|
||||||
|
<li>get_pdfEntries()</li>
|
||||||
|
<li>get_pdfFields()</li>
|
||||||
|
<li>getManagedObjectClasses()</li>
|
||||||
|
<li>getManagedAttributes()</li>
|
||||||
|
<li>getLDAPAliases() <br>
|
||||||
</li>
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
|
|
|
@ -124,7 +124,7 @@ abstract class baseModule {
|
||||||
$this->attributes['objectClass'] = array();
|
$this->attributes['objectClass'] = array();
|
||||||
$this->orig['objectClass'] = array();
|
$this->orig['objectClass'] = array();
|
||||||
if ($this->autoAddObjectClasses === true) {
|
if ($this->autoAddObjectClasses === true) {
|
||||||
$objectClasses = $this->getManagedObjectClasses();
|
$objectClasses = $this->getManagedObjectClasses($this->getAccountContainer()->get_type()->getId());
|
||||||
for ($i = 0; $i < sizeof($objectClasses); $i++) {
|
for ($i = 0; $i < sizeof($objectClasses); $i++) {
|
||||||
if (!in_array($objectClasses[$i], $this->attributes['objectClass'])) {
|
if (!in_array($objectClasses[$i], $this->attributes['objectClass'])) {
|
||||||
$this->attributes['objectClass'][] = $objectClasses[$i];
|
$this->attributes['objectClass'][] = $objectClasses[$i];
|
||||||
|
@ -156,9 +156,10 @@ abstract class baseModule {
|
||||||
$this->attributes['objectClass'] = array();
|
$this->attributes['objectClass'] = array();
|
||||||
$this->orig['objectClass'] = array();
|
$this->orig['objectClass'] = array();
|
||||||
}
|
}
|
||||||
|
$typeId = $this->getAccountContainer()->get_type()->getId();
|
||||||
// add object classes if needed
|
// add object classes if needed
|
||||||
if ($this->autoAddObjectClasses === true) {
|
if ($this->autoAddObjectClasses === true) {
|
||||||
$objectClasses = $this->getManagedObjectClasses();
|
$objectClasses = $this->getManagedObjectClasses($typeId);
|
||||||
for ($i = 0; $i < sizeof($objectClasses); $i++) {
|
for ($i = 0; $i < sizeof($objectClasses); $i++) {
|
||||||
if (!in_array($objectClasses[$i], $this->attributes['objectClass'])) {
|
if (!in_array($objectClasses[$i], $this->attributes['objectClass'])) {
|
||||||
$this->attributes['objectClass'][] = $objectClasses[$i];
|
$this->attributes['objectClass'][] = $objectClasses[$i];
|
||||||
|
@ -166,7 +167,7 @@ abstract class baseModule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// load attributes
|
// load attributes
|
||||||
$attributeNames = $this->getManagedAttributes();
|
$attributeNames = $this->getManagedAttributes($typeId);
|
||||||
for ($i = 0; $i < sizeof($attributeNames); $i++) {
|
for ($i = 0; $i < sizeof($attributeNames); $i++) {
|
||||||
if (isset($attributes[$attributeNames[$i]])) {
|
if (isset($attributes[$attributeNames[$i]])) {
|
||||||
$this->attributes[$attributeNames[$i]] = $attributes[$attributeNames[$i]];
|
$this->attributes[$attributeNames[$i]] = $attributes[$attributeNames[$i]];
|
||||||
|
@ -1532,11 +1533,12 @@ abstract class baseModule {
|
||||||
* <br>
|
* <br>
|
||||||
* <b>Example:</b> return array('posixAccount')
|
* <b>Example:</b> return array('posixAccount')
|
||||||
*
|
*
|
||||||
|
* @param string $typeId type id (user, group, host)
|
||||||
* @return array list of object classes
|
* @return array list of object classes
|
||||||
*
|
*
|
||||||
* @see baseModule::get_metaData()
|
* @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'];
|
if (isset($this->meta['objectClasses']) && is_array($this->meta['objectClasses'])) return $this->meta['objectClasses'];
|
||||||
else return array();
|
else return array();
|
||||||
}
|
}
|
||||||
|
@ -1548,11 +1550,12 @@ abstract class baseModule {
|
||||||
* <br>
|
* <br>
|
||||||
* All alias attributes will be renamed to the given attribute names.
|
* 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")
|
* @return array list of aliases like array("alias name" => "attribute name")
|
||||||
*
|
*
|
||||||
* @see baseModule::get_metaData()
|
* @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'];
|
if (isset($this->meta['LDAPaliases']) && is_array($this->meta['LDAPaliases'])) return $this->meta['LDAPaliases'];
|
||||||
else return array();
|
else return array();
|
||||||
}
|
}
|
||||||
|
@ -1561,11 +1564,12 @@ abstract class baseModule {
|
||||||
* Returns a list of LDAP attributes which are managed by this module.
|
* Returns a list of LDAP attributes which are managed by this module.
|
||||||
* All attribute names will be renamed to match the given spelling.
|
* All attribute names will be renamed to match the given spelling.
|
||||||
*
|
*
|
||||||
|
* @param string $typeId type id (user, group, host)
|
||||||
* @return array list of attributes
|
* @return array list of attributes
|
||||||
*
|
*
|
||||||
* @see baseModule::get_metaData()
|
* @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'];
|
if (isset($this->meta['attributes']) && is_array($this->meta['attributes'])) return $this->meta['attributes'];
|
||||||
else return array();
|
else return array();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1234,7 +1234,7 @@ class accountContainer {
|
||||||
*/
|
*/
|
||||||
private function anyModuleManagesMail() {
|
private function anyModuleManagesMail() {
|
||||||
foreach ($this->module as $mod) {
|
foreach ($this->module as $mod) {
|
||||||
if (in_array('mail', $mod->getManagedAttributes())) {
|
if (in_array('mail', $mod->getManagedAttributes($this->get_type()->getId()))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1639,9 +1639,9 @@ class accountContainer {
|
||||||
$ldapAttributesTemp = array();
|
$ldapAttributesTemp = array();
|
||||||
foreach ($modules as $module) {
|
foreach ($modules as $module) {
|
||||||
$moduleObj = moduleCache::getModule($module, $this->type->getScope());
|
$moduleObj = moduleCache::getModule($module, $this->type->getScope());
|
||||||
$objectClasses = array_merge($objectClasses, $moduleObj->getManagedObjectClasses());
|
$objectClasses = array_merge($objectClasses, $moduleObj->getManagedObjectClasses($this->type->getId()));
|
||||||
$aliases = array_merge($aliases, $moduleObj->getLDAPAliases());
|
$aliases = array_merge($aliases, $moduleObj->getLDAPAliases($this->type->getId()));
|
||||||
$ldapAttributesTemp = array_merge($ldapAttributesTemp, $moduleObj->getManagedAttributes());
|
$ldapAttributesTemp = array_merge($ldapAttributesTemp, $moduleObj->getManagedAttributes($this->type->getId()));
|
||||||
}
|
}
|
||||||
// build lower case attribute names
|
// build lower case attribute names
|
||||||
$ldapAttributes = array();
|
$ldapAttributes = array();
|
||||||
|
|
|
@ -993,7 +993,7 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
}
|
}
|
||||||
if (isset($_POST['remObjectClass'])) {
|
if (isset($_POST['remObjectClass'])) {
|
||||||
$this->attributes['objectClass'] = array_delete(array('posixAccount'), $this->attributes['objectClass']);
|
$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) {
|
foreach ($attrs as $name) {
|
||||||
if (isset($this->attributes[$name])) {
|
if (isset($this->attributes[$name])) {
|
||||||
unset($this->attributes[$name]);
|
unset($this->attributes[$name]);
|
||||||
|
|
|
@ -728,7 +728,7 @@ class posixGroup extends baseModule implements passwordService {
|
||||||
}
|
}
|
||||||
if (isset($_POST['remObjectClass'])) {
|
if (isset($_POST['remObjectClass'])) {
|
||||||
$this->attributes['objectClass'] = array_delete(array('posixGroup'), $this->attributes['objectClass']);
|
$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) {
|
foreach ($attrs as $name) {
|
||||||
if (isset($this->attributes[$name])) {
|
if (isset($this->attributes[$name])) {
|
||||||
unset($this->attributes[$name]);
|
unset($this->attributes[$name]);
|
||||||
|
|
|
@ -69,7 +69,7 @@ else {
|
||||||
$modules = $_SESSION['config']->get_AccountModules($type->getId());
|
$modules = $_SESSION['config']->get_AccountModules($type->getId());
|
||||||
$container->addElement(new htmlSubTitle($type->getAlias()), true);
|
$container->addElement(new htmlSubTitle($type->getAlias()), true);
|
||||||
for ($m = 0; $m < sizeof($modules); $m++) {
|
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.");
|
$message = _("No problems found.");
|
||||||
$icon = '../../graphics/pass.png';
|
$icon = '../../graphics/pass.png';
|
||||||
if ($error != null) {
|
if ($error != null) {
|
||||||
|
@ -98,14 +98,15 @@ include '../main_footer.php';
|
||||||
* Checks if the object classes and attributes for this module are available.
|
* Checks if the object classes and attributes for this module are available.
|
||||||
*
|
*
|
||||||
* @param String $name module name
|
* @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
|
* @return String error message or null
|
||||||
*/
|
*/
|
||||||
function checkSchemaForModule($name, $type) {
|
function checkSchemaForModule($name, $scope, $typeId) {
|
||||||
$module = new $name($type);
|
$module = new $name($scope);
|
||||||
$classes = $module->getManagedObjectClasses();
|
$classes = $module->getManagedObjectClasses($typeId);
|
||||||
$attrs = $module->getManagedAttributes();
|
$attrs = $module->getManagedAttributes($typeId);
|
||||||
$aliases = array_flip($module->getLDAPAliases());
|
$aliases = array_flip($module->getLDAPAliases($typeId));
|
||||||
if (sizeof($classes) == 0) {
|
if (sizeof($classes) == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue