diff --git a/lam/docs/devel/upgrade.htm b/lam/docs/devel/upgrade.htm
index bd0531fd..4e53e27d 100644
--- a/lam/docs/devel/upgrade.htm
+++ b/lam/docs/devel/upgrade.htm
@@ -16,6 +16,7 @@
+
@@ -65,8 +66,14 @@ This is a list of API changes for all LAM releases.
getManagedObjectClasses()
getManagedAttributes()
getLDAPAliases()
-
+
+ Removed global functions:
+
+ - getListClassName() -> use ConfiguredType->getBaseType()->getListClassName()
+ - getTypeAlias() -> ConfiguredType->getBaseType()->getAlias()
+
+
diff --git a/lam/help/help.inc b/lam/help/help.inc
index f7547ac4..66af25ef 100644
--- a/lam/help/help.inc
+++ b/lam/help/help.inc
@@ -1,5 +1,6 @@
" . \LAM\TYPES\getTypeAlias($types[$i]) . ":
\n";
- $descriptions = \LAM\TYPES\getListAttributeDescriptions($types[$i]);
- $attributes = array_keys($descriptions);
- for ($a = 0; $a < sizeof($attributes); $a++) {
- $entry206Example .= "#" . $attributes[$a] . ": " . $descriptions[$attributes[$a]];
- if ($a < (sizeof($attributes) - 1)) {
- $entry206Example .= ", ";
+if (isset($_SESSION['conf_config'])) {
+ $typeManager = new TypeManager($_SESSION['conf_config']);
+ $types = $typeManager->getConfiguredTypes();
+ foreach ($types as $type) {
+ $entry206Example .= "" . $type->getAlias() . ":
\n";
+ $descriptions = $type->getBaseType()->getListAttributeDescriptions();
+ $attributes = array_keys($descriptions);
+ for ($a = 0; $a < sizeof($attributes); $a++) {
+ $entry206Example .= "#" . $attributes[$a] . ": " . $descriptions[$attributes[$a]];
+ if ($a < (sizeof($attributes) - 1)) {
+ $entry206Example .= ", ";
+ }
}
+ $entry206Example .= "
";
}
- $entry206Example .= "
";
}
$helpArray = array (
diff --git a/lam/lib/types.inc b/lam/lib/types.inc
index 9993e7fa..77585eb5 100644
--- a/lam/lib/types.inc
+++ b/lam/lib/types.inc
@@ -69,28 +69,6 @@ function getTypes() {
return $return;
}
-/**
-* Returns the alias name of an account type.
-*
-* @param string $type type name
-* @param \LAMConfig $config config (optional, uses $_SESSION['config'] by default)
-* @return string type alias
-*/
-function getTypeAlias($type, $config = null) {
- if (($config == null) && !empty($_SESSION['config'])) {
- $config = $_SESSION['config'];
- }
- if ($config != null) {
- $typeSettings = $config->get_typeSettings();
- if (!empty($typeSettings['customLabel_' . $type])) {
- return $typeSettings['customLabel_' . $type];
- }
- }
- $scope = getScopeFromTypeId($type);
- $obj = new $scope();
- return $obj->getAlias();
-}
-
/**
* Returns the description of an account type.
*
@@ -98,21 +76,10 @@ function getTypeAlias($type, $config = null) {
* @return string type description
*/
function getTypeDescription($type) {
- $obj = new $type();
+ $obj = new $type(null);
return $obj->getDescription();
}
-/**
-* Returns the class name for the list object.
-*
-* @param string $type account type
-* @return string class name
-*/
-function getListClassName($type) {
- $obj = new $type();
- return $obj->getListClassName();
-}
-
/**
* Returns the default attribute list for an account type.
* It is used as default value for the configuration editor.
@@ -255,8 +222,11 @@ class ConfiguredType {
if ($this->alias !== null) {
return $this->alias;
}
- $this->alias = getTypeAlias($this->id, $this->typeManager->getConfig());
- return $this->alias;
+ $typeSettings = $this->typeManager->getConfig()->get_typeSettings();
+ if (!empty($typeSettings['customLabel_' . $this->id])) {
+ return $typeSettings['customLabel_' . $this->id];
+ }
+ return $this->getBaseType()->getAlias();
}
/**
diff --git a/lam/templates/config/conftypes.php b/lam/templates/config/conftypes.php
index 5be3a5df..1341a456 100644
--- a/lam/templates/config/conftypes.php
+++ b/lam/templates/config/conftypes.php
@@ -427,17 +427,17 @@ function checkInput() {
// set suffixes
elseif (substr($key, 0, 7) == "suffix_") {
$typeSettings[$key] = trim($_POST[$key]);
- $type = substr($postKeys[$i], 7);
+ $type = $typeManager->getConfiguredType(substr($postKeys[$i], 7));
if (strlen($_POST[$key]) < 1) {
- $errors[] = array("ERROR", _("LDAP Suffix is invalid!"), \LAM\TYPES\getTypeAlias($type));
+ $errors[] = array("ERROR", _("LDAP Suffix is invalid!"), $type->getAlias());
}
}
// set attributes
elseif (substr($key, 0, 5) == "attr_") {
$typeSettings[$key] = $_POST[$key];
- $type = substr($postKeys[$i], 5);
+ $type = $typeManager->getConfiguredType(substr($postKeys[$i], 5));
if (!is_string($_POST[$key]) || !preg_match("/^((#[^:;]+)|([^:;]*:[^:;]+))(;((#[^:;]+)|([^:;]*:[^:;]+)))*$/", $_POST[$key])) {
- $errors[] = array("ERROR", _("List attributes are invalid!"), \LAM\TYPES\getTypeAlias($type));
+ $errors[] = array("ERROR", _("List attributes are invalid!"), $type->getAlias());
}
}
// set filter
diff --git a/lam/templates/lists/list.php b/lam/templates/lists/list.php
index c9c7ab38..632d4109 100644
--- a/lam/templates/lists/list.php
+++ b/lam/templates/lists/list.php
@@ -52,7 +52,7 @@ if ($type->isHidden()) {
}
// create list object if needed
-$listClass = LAM\TYPES\getListClassName($type->getScope());
+$listClass = $type->getBaseType()->getListClassName();
if (!isset($_SESSION['list_' . $type->getId()])) {
$list = new $listClass($type);
$_SESSION['list_' . $type->getId()] = $list;
diff --git a/lam/templates/pdfedit/pdfmain.php b/lam/templates/pdfedit/pdfmain.php
index 711d12fa..18e2e7a3 100644
--- a/lam/templates/pdfedit/pdfmain.php
+++ b/lam/templates/pdfedit/pdfmain.php
@@ -105,14 +105,15 @@ $container = new htmlTable();
$container->addElement(new htmlTitle(_('PDF editor')), true);
if (isset($_POST['deleteProfile']) && ($_POST['deleteProfile'] == 'true')) {
+ $typeToDelete = $typeManager->getConfiguredType($_POST['profileDeleteType']);
// delete structure
if (\LAM\PDF\deletePDFStructure($_POST['profileDeleteType'], $_POST['profileDeleteName'])) {
- $message = new htmlStatusMessage('INFO', _('Deleted PDF structure.'), \LAM\TYPES\getTypeAlias($_POST['profileDeleteType']) . ': ' . htmlspecialchars($_POST['profileDeleteName']));
+ $message = new htmlStatusMessage('INFO', _('Deleted PDF structure.'), $typeToDelete->getAlias() . ': ' . htmlspecialchars($_POST['profileDeleteName']));
$message->colspan = 10;
$container->addElement($message, true);
}
else {
- $message = new htmlStatusMessage('ERROR', _('Unable to delete PDF structure!'), \LAM\TYPES\getTypeAlias($_POST['profileDeleteType']) . ': ' . htmlspecialchars($_POST['profileDeleteName']));
+ $message = new htmlStatusMessage('ERROR', _('Unable to delete PDF structure!'), $typeToDelete->getAlias() . ': ' . htmlspecialchars($_POST['profileDeleteName']));
$message->colspan = 10;
$container->addElement($message, true);
}