new type API
This commit is contained in:
parent
cd4cc1ae26
commit
394faed7eb
|
@ -71,7 +71,9 @@ This is a list of API changes for all LAM releases.
|
||||||
<li>Removed global functions:</li>
|
<li>Removed global functions:</li>
|
||||||
<ul>
|
<ul>
|
||||||
<li>getListClassName() -> use ConfiguredType->getBaseType()->getListClassName() </li>
|
<li>getListClassName() -> use ConfiguredType->getBaseType()->getListClassName() </li>
|
||||||
<li>getTypeAlias() -> ConfiguredType->getBaseType()->getAlias()</li>
|
<li>getTypeAlias() -> use ConfiguredType->getBaseType()->getAlias()</li>
|
||||||
|
<li>getDefaultListAttributes() -> use ConfiguredType->getBaseType()->getDefaultListAttributes()</li>
|
||||||
|
<li>getListAttributeDescriptions() -> use ConfiguredType->getBaseType()->getListAttributeDescriptions()</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -80,30 +80,6 @@ function getTypeDescription($type) {
|
||||||
return $obj->getDescription();
|
return $obj->getDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the default attribute list for an account type.
|
|
||||||
* It is used as default value for the configuration editor.
|
|
||||||
*
|
|
||||||
* @param string $type account type
|
|
||||||
* @return string attribute list
|
|
||||||
*/
|
|
||||||
function getDefaultListAttributes($type) {
|
|
||||||
$obj = new $type();
|
|
||||||
return $obj->getDefaultListAttributes();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a list of attributes which have a translated description.
|
|
||||||
* This is used for the head row in the list view.
|
|
||||||
*
|
|
||||||
* @param string $type account type
|
|
||||||
* @return array list of descriptions
|
|
||||||
*/
|
|
||||||
function getListAttributeDescriptions($type) {
|
|
||||||
$obj = new $type();
|
|
||||||
return $obj->getListAttributeDescriptions();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the account type for a given type id.
|
* Returns the account type for a given type id.
|
||||||
*
|
*
|
||||||
|
@ -207,7 +183,7 @@ class ConfiguredType {
|
||||||
$attributeSpecs = explode(';', $attributeString);
|
$attributeSpecs = explode(';', $attributeString);
|
||||||
$attributes = array();
|
$attributes = array();
|
||||||
foreach ($attributeSpecs as $attributeSpec) {
|
foreach ($attributeSpecs as $attributeSpec) {
|
||||||
$attributes[] = new ListAttribute($attributeSpec, $this->scope);
|
$attributes[] = new ListAttribute($attributeSpec, $this);
|
||||||
}
|
}
|
||||||
$this->attributes = $attributes;
|
$this->attributes = $attributes;
|
||||||
return $this->attributes;
|
return $this->attributes;
|
||||||
|
@ -333,17 +309,17 @@ class ListAttribute {
|
||||||
|
|
||||||
private $attributeSpec;
|
private $attributeSpec;
|
||||||
|
|
||||||
private $scope;
|
private $type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param string $attributeSpec spec of attribute (e.g. '#uid' or 'uid:User')
|
* @param string $attributeSpec spec of attribute (e.g. '#uid' or 'uid:User')
|
||||||
* @param string $scope account type (e.g. 'user')
|
* @param ConfiguredType $type account type (e.g. 'user')
|
||||||
*/
|
*/
|
||||||
public function __construct($attributeSpec, $scope) {
|
public function __construct($attributeSpec, $type) {
|
||||||
$this->attributeSpec = $attributeSpec;
|
$this->attributeSpec = $attributeSpec;
|
||||||
$this->scope = $scope;
|
$this->type = $type;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns the name of the LDAP attribute.
|
* Returns the name of the LDAP attribute.
|
||||||
|
@ -366,7 +342,7 @@ class ListAttribute {
|
||||||
public function getAlias() {
|
public function getAlias() {
|
||||||
if ($this->isPredefined()) {
|
if ($this->isPredefined()) {
|
||||||
$name = strtolower(substr($this->attributeSpec, 1));
|
$name = strtolower(substr($this->attributeSpec, 1));
|
||||||
$hash_table = getListAttributeDescriptions($this->scope);
|
$hash_table = $this->type->getBaseType()->getListAttributeDescriptions();
|
||||||
$hash_table = array_change_key_case($hash_table, CASE_LOWER);
|
$hash_table = array_change_key_case($hash_table, CASE_LOWER);
|
||||||
if (isset($hash_table[$name])) {
|
if (isset($hash_table[$name])) {
|
||||||
return $hash_table[$name];
|
return $hash_table[$name];
|
||||||
|
|
|
@ -291,7 +291,7 @@ if (sizeof($activeTypes) > 0) {
|
||||||
$attributes = $typeSettings['attr_' . $activeType->getId()];
|
$attributes = $typeSettings['attr_' . $activeType->getId()];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$attributes = \LAM\TYPES\getDefaultListAttributes($activeType->getScope());
|
$attributes = $activeType->getBaseType()->getDefaultListAttributes();
|
||||||
}
|
}
|
||||||
$attrsInput = new htmlTableExtendedInputField(_("List attributes"), 'attr_' . $activeType->getId(), $attributes, '206');
|
$attrsInput = new htmlTableExtendedInputField(_("List attributes"), 'attr_' . $activeType->getId(), $attributes, '206');
|
||||||
$attrsInput->setFieldSize(40);
|
$attrsInput->setFieldSize(40);
|
||||||
|
|
Loading…
Reference in New Issue