new type API
This commit is contained in:
parent
b4248bc898
commit
cd4cc1ae26
|
@ -16,6 +16,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -67,6 +68,12 @@ This is a list of API changes for all LAM releases.
|
|||
<li>getLDAPAliases() <br>
|
||||
</li>
|
||||
</ul>
|
||||
<li>Removed global functions:</li>
|
||||
<ul>
|
||||
<li>getListClassName() -> use ConfiguredType->getBaseType()->getListClassName() </li>
|
||||
<li>getTypeAlias() -> ConfiguredType->getBaseType()->getAlias()</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
namespace LAM\HELP;
|
||||
use \LAM\TYPES\TypeManager;
|
||||
/*
|
||||
$Id$
|
||||
|
||||
|
@ -34,11 +35,13 @@ $Id$
|
|||
*/
|
||||
|
||||
// generate help entry for translated list attributes
|
||||
$types = \LAM\TYPES\getTypes();
|
||||
$entry206Example = "";
|
||||
for ($i = 0; $i < sizeof($types); $i++) {
|
||||
$entry206Example .= "<b>" . \LAM\TYPES\getTypeAlias($types[$i]) . ":</b><br>\n";
|
||||
$descriptions = \LAM\TYPES\getListAttributeDescriptions($types[$i]);
|
||||
if (isset($_SESSION['conf_config'])) {
|
||||
$typeManager = new TypeManager($_SESSION['conf_config']);
|
||||
$types = $typeManager->getConfiguredTypes();
|
||||
foreach ($types as $type) {
|
||||
$entry206Example .= "<b>" . $type->getAlias() . ":</b><br>\n";
|
||||
$descriptions = $type->getBaseType()->getListAttributeDescriptions();
|
||||
$attributes = array_keys($descriptions);
|
||||
for ($a = 0; $a < sizeof($attributes); $a++) {
|
||||
$entry206Example .= "#" . $attributes[$a] . ": " . $descriptions[$attributes[$a]];
|
||||
|
@ -48,6 +51,7 @@ for ($i = 0; $i < sizeof($types); $i++) {
|
|||
}
|
||||
$entry206Example .= "<br><br>";
|
||||
}
|
||||
}
|
||||
|
||||
$helpArray = array (
|
||||
// 200 - 299
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue