new type API
This commit is contained in:
parent
b4248bc898
commit
cd4cc1ae26
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,8 +66,14 @@ This is a list of API changes for all LAM releases.
|
||||||
<li>getManagedObjectClasses()</li>
|
<li>getManagedObjectClasses()</li>
|
||||||
<li>getManagedAttributes()</li>
|
<li>getManagedAttributes()</li>
|
||||||
<li>getLDAPAliases() <br>
|
<li>getLDAPAliases() <br>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<li>Removed global functions:</li>
|
||||||
|
<ul>
|
||||||
|
<li>getListClassName() -> use ConfiguredType->getBaseType()->getListClassName() </li>
|
||||||
|
<li>getTypeAlias() -> ConfiguredType->getBaseType()->getAlias()</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
namespace LAM\HELP;
|
namespace LAM\HELP;
|
||||||
|
use \LAM\TYPES\TypeManager;
|
||||||
/*
|
/*
|
||||||
$Id$
|
$Id$
|
||||||
|
|
||||||
|
@ -34,19 +35,22 @@ $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// generate help entry for translated list attributes
|
// generate help entry for translated list attributes
|
||||||
$types = \LAM\TYPES\getTypes();
|
|
||||||
$entry206Example = "";
|
$entry206Example = "";
|
||||||
for ($i = 0; $i < sizeof($types); $i++) {
|
if (isset($_SESSION['conf_config'])) {
|
||||||
$entry206Example .= "<b>" . \LAM\TYPES\getTypeAlias($types[$i]) . ":</b><br>\n";
|
$typeManager = new TypeManager($_SESSION['conf_config']);
|
||||||
$descriptions = \LAM\TYPES\getListAttributeDescriptions($types[$i]);
|
$types = $typeManager->getConfiguredTypes();
|
||||||
$attributes = array_keys($descriptions);
|
foreach ($types as $type) {
|
||||||
for ($a = 0; $a < sizeof($attributes); $a++) {
|
$entry206Example .= "<b>" . $type->getAlias() . ":</b><br>\n";
|
||||||
$entry206Example .= "#" . $attributes[$a] . ": " . $descriptions[$attributes[$a]];
|
$descriptions = $type->getBaseType()->getListAttributeDescriptions();
|
||||||
if ($a < (sizeof($attributes) - 1)) {
|
$attributes = array_keys($descriptions);
|
||||||
$entry206Example .= ", ";
|
for ($a = 0; $a < sizeof($attributes); $a++) {
|
||||||
|
$entry206Example .= "#" . $attributes[$a] . ": " . $descriptions[$attributes[$a]];
|
||||||
|
if ($a < (sizeof($attributes) - 1)) {
|
||||||
|
$entry206Example .= ", ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
$entry206Example .= "<br><br>";
|
||||||
}
|
}
|
||||||
$entry206Example .= "<br><br>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$helpArray = array (
|
$helpArray = array (
|
||||||
|
|
|
@ -69,28 +69,6 @@ function getTypes() {
|
||||||
return $return;
|
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.
|
* Returns the description of an account type.
|
||||||
*
|
*
|
||||||
|
@ -98,21 +76,10 @@ function getTypeAlias($type, $config = null) {
|
||||||
* @return string type description
|
* @return string type description
|
||||||
*/
|
*/
|
||||||
function getTypeDescription($type) {
|
function getTypeDescription($type) {
|
||||||
$obj = new $type();
|
$obj = new $type(null);
|
||||||
return $obj->getDescription();
|
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.
|
* Returns the default attribute list for an account type.
|
||||||
* It is used as default value for the configuration editor.
|
* It is used as default value for the configuration editor.
|
||||||
|
@ -255,8 +222,11 @@ class ConfiguredType {
|
||||||
if ($this->alias !== null) {
|
if ($this->alias !== null) {
|
||||||
return $this->alias;
|
return $this->alias;
|
||||||
}
|
}
|
||||||
$this->alias = getTypeAlias($this->id, $this->typeManager->getConfig());
|
$typeSettings = $this->typeManager->getConfig()->get_typeSettings();
|
||||||
return $this->alias;
|
if (!empty($typeSettings['customLabel_' . $this->id])) {
|
||||||
|
return $typeSettings['customLabel_' . $this->id];
|
||||||
|
}
|
||||||
|
return $this->getBaseType()->getAlias();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -427,17 +427,17 @@ function checkInput() {
|
||||||
// set suffixes
|
// set suffixes
|
||||||
elseif (substr($key, 0, 7) == "suffix_") {
|
elseif (substr($key, 0, 7) == "suffix_") {
|
||||||
$typeSettings[$key] = trim($_POST[$key]);
|
$typeSettings[$key] = trim($_POST[$key]);
|
||||||
$type = substr($postKeys[$i], 7);
|
$type = $typeManager->getConfiguredType(substr($postKeys[$i], 7));
|
||||||
if (strlen($_POST[$key]) < 1) {
|
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
|
// set attributes
|
||||||
elseif (substr($key, 0, 5) == "attr_") {
|
elseif (substr($key, 0, 5) == "attr_") {
|
||||||
$typeSettings[$key] = $_POST[$key];
|
$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])) {
|
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
|
// set filter
|
||||||
|
|
|
@ -52,7 +52,7 @@ if ($type->isHidden()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// create list object if needed
|
// create list object if needed
|
||||||
$listClass = LAM\TYPES\getListClassName($type->getScope());
|
$listClass = $type->getBaseType()->getListClassName();
|
||||||
if (!isset($_SESSION['list_' . $type->getId()])) {
|
if (!isset($_SESSION['list_' . $type->getId()])) {
|
||||||
$list = new $listClass($type);
|
$list = new $listClass($type);
|
||||||
$_SESSION['list_' . $type->getId()] = $list;
|
$_SESSION['list_' . $type->getId()] = $list;
|
||||||
|
|
|
@ -105,14 +105,15 @@ $container = new htmlTable();
|
||||||
$container->addElement(new htmlTitle(_('PDF editor')), true);
|
$container->addElement(new htmlTitle(_('PDF editor')), true);
|
||||||
|
|
||||||
if (isset($_POST['deleteProfile']) && ($_POST['deleteProfile'] == 'true')) {
|
if (isset($_POST['deleteProfile']) && ($_POST['deleteProfile'] == 'true')) {
|
||||||
|
$typeToDelete = $typeManager->getConfiguredType($_POST['profileDeleteType']);
|
||||||
// delete structure
|
// delete structure
|
||||||
if (\LAM\PDF\deletePDFStructure($_POST['profileDeleteType'], $_POST['profileDeleteName'])) {
|
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;
|
$message->colspan = 10;
|
||||||
$container->addElement($message, true);
|
$container->addElement($message, true);
|
||||||
}
|
}
|
||||||
else {
|
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;
|
$message->colspan = 10;
|
||||||
$container->addElement($message, true);
|
$container->addElement($message, true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue