new type API

This commit is contained in:
Roland Gruber 2017-04-26 18:22:05 +02:00
parent 394faed7eb
commit 1a16b3cd5b
15 changed files with 110 additions and 67 deletions

View File

@ -17,6 +17,7 @@
@ -75,6 +76,9 @@ This is a list of API changes for all LAM releases.
<li>getDefaultListAttributes() -&gt; use ConfiguredType-&gt;getBaseType()-&gt;getDefaultListAttributes()</li> <li>getDefaultListAttributes() -&gt; use ConfiguredType-&gt;getBaseType()-&gt;getDefaultListAttributes()</li>
<li>getListAttributeDescriptions() -&gt; use ConfiguredType-&gt;getBaseType()-&gt;getListAttributeDescriptions()</li> <li>getListAttributeDescriptions() -&gt; use ConfiguredType-&gt;getBaseType()-&gt;getListAttributeDescriptions()</li>
</ul> </ul>
<li>baseType and subclasses have a new constructor argument - ConfiguredType<br>
</li>

View File

@ -1,4 +1,6 @@
<?php <?php
use LAM\TYPES\ConfiguredType;
/* /*
$Id$ $Id$
@ -40,10 +42,16 @@ class baseType {
/** label to return to account list */ /** label to return to account list */
public $LABEL_BACK_TO_ACCOUNT_LIST; public $LABEL_BACK_TO_ACCOUNT_LIST;
/** type configuration */
private $type;
/** /**
* Creates a new type object. * Creates a new type object.
*
* @param ConfiguredType $type configuration
*/ */
public function __construct() { public function __construct($type) {
$this->type = $type;
$this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another account'); $this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another account');
$this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to account list'); $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to account list');
} }
@ -184,6 +192,15 @@ class baseType {
return true; return true;
} }
/**
* Returns the type configuration.
*
* @return ConfiguredType type configuration
*/
protected function getType() {
return $this->type;
}
} }
?> ?>

View File

@ -242,7 +242,7 @@ class ConfiguredType {
return $this->baseType; return $this->baseType;
} }
$scope = $this->scope; $scope = $this->scope;
$this->baseType = new $scope(); $this->baseType = new $scope($this);
return $this->baseType; return $this->baseType;
} }

View File

@ -40,9 +40,11 @@ class asteriskExt extends baseType {
/** /**
* Constructs a new domain type object. * Constructs a new domain type object.
*
* @param ConfiguredType $type configuration
*/ */
public function __construct() { public function __construct($type) {
parent::__construct(); parent::__construct($type);
$this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another extension'); $this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another extension');
$this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to extensions list'); $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to extensions list');
} }

View File

@ -40,9 +40,11 @@ class dhcp extends baseType {
/** /**
* Constructs a new DHCP type object. * Constructs a new DHCP type object.
*
* @param ConfiguredType $type configuration
*/ */
public function __construct() { public function __construct($type) {
parent::__construct(); parent::__construct($type);
$this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another DHCP entry'); $this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another DHCP entry');
$this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to DHCP list'); $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to DHCP list');
} }

View File

@ -39,9 +39,11 @@ class group extends baseType {
/** /**
* Constructs a new group type object. * Constructs a new group type object.
*
* @param ConfiguredType $type configuration
*/ */
public function __construct() { public function __construct($type) {
parent::__construct(); parent::__construct($type);
$this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another group'); $this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another group');
$this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to group list'); $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to group list');
if (isset($_SESSION['config'])) { if (isset($_SESSION['config'])) {

View File

@ -37,9 +37,11 @@ class host extends baseType {
/** /**
* Constructs a new host type object. * Constructs a new host type object.
*
* @param ConfiguredType $type configuration
*/ */
public function __construct() { public function __construct($type) {
parent::__construct(); parent::__construct($type);
$this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another host'); $this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another host');
$this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to host list'); $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to host list');
} }

View File

@ -37,9 +37,11 @@ class kolabSharedFolderType extends baseType {
/** /**
* Constructs a new shared folder object. * Constructs a new shared folder object.
*
* @param ConfiguredType $type configuration
*/ */
public function __construct() { public function __construct($type) {
parent::__construct(); parent::__construct($type);
$this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another shared folder'); $this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another shared folder');
$this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to shared folder list'); $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to shared folder list');
} }

View File

@ -37,9 +37,11 @@ class mailAlias extends baseType {
/** /**
* Constructs a new alias type object. * Constructs a new alias type object.
*
* @param ConfiguredType $type configuration
*/ */
public function __construct() { public function __construct($type) {
parent::__construct(); parent::__construct($type);
$this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another alias'); $this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another alias');
$this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to alias list'); $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to alias list');
} }

View File

@ -37,9 +37,11 @@ class netgroup extends baseType {
/** /**
* Constructs a new group type object. * Constructs a new group type object.
*
* @param ConfiguredType $type configuration
*/ */
public function __construct() { public function __construct($type) {
parent::__construct(); parent::__construct($type);
$this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another group'); $this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another group');
$this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to group list'); $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to group list');
} }

View File

@ -37,9 +37,11 @@ class pykotaBillingCodeType extends baseType {
/** /**
* Constructs a new billing code object. * Constructs a new billing code object.
*
* @param ConfiguredType $type configuration
*/ */
public function __construct() { public function __construct($type) {
parent::__construct(); parent::__construct($type);
$this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another billing code'); $this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another billing code');
$this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to billing code list'); $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to billing code list');
} }

View File

@ -37,9 +37,11 @@ class pykotaPrinterType extends baseType {
/** /**
* Constructs a new printer type object. * Constructs a new printer type object.
*
* @param ConfiguredType $type configuration
*/ */
public function __construct() { public function __construct($type) {
parent::__construct(); parent::__construct($type);
$this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another printer'); $this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another printer');
$this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to printer list'); $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to printer list');
} }

View File

@ -37,9 +37,11 @@ class smbDomain extends baseType {
/** /**
* Constructs a new domain type object. * Constructs a new domain type object.
*
* @param ConfiguredType $type configuration
*/ */
public function __construct() { public function __construct($type) {
parent::__construct(); parent::__construct($type);
$this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another domain'); $this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another domain');
$this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to domain list'); $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to domain list');
} }

View File

@ -37,9 +37,11 @@ class user extends baseType {
/** /**
* Constructs a new user type object. * Constructs a new user type object.
*
* @param ConfiguredType $type configuration
*/ */
public function __construct() { public function __construct($type) {
parent::__construct(); parent::__construct($type);
$this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another user'); $this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another user');
$this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to user list'); $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to user list');
} }

View File

@ -127,7 +127,7 @@ foreach ($activeTypes as $activeType) {
$activeScopes = array_unique($activeScopes); $activeScopes = array_unique($activeScopes);
$availableScopes = array(); $availableScopes = array();
foreach ($allScopes as $scope) { foreach ($allScopes as $scope) {
$scopeObj = new $scope(); $scopeObj = new $scope(null);
if (!in_array($scope, $activeScopes) || $scopeObj->supportsMultipleConfigs()) { if (!in_array($scope, $activeScopes) || $scopeObj->supportsMultipleConfigs()) {
$availableScopes[$scope] = $scopeObj->getAlias(); $availableScopes[$scope] = $scopeObj->getAlias();
} }