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

@ -34,16 +34,18 @@ $Id$
* @package types * @package types
*/ */
class kolabSharedFolderType extends baseType { 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');
} }
/** /**
* Returns the alias name of this account type. * Returns the alias name of this account type.
* *
@ -52,7 +54,7 @@ class kolabSharedFolderType extends baseType {
function getAlias() { function getAlias() {
return _("Kolab shared folders"); return _("Kolab shared folders");
} }
/** /**
* Returns the description of this account type. * Returns the description of this account type.
* *
@ -61,7 +63,7 @@ class kolabSharedFolderType extends baseType {
function getDescription() { function getDescription() {
return _("Kolab shared folders (e.g. mail folders)"); return _("Kolab shared folders (e.g. mail folders)");
} }
/** /**
* Returns the class name for the list object. * Returns the class name for the list object.
* *
@ -70,7 +72,7 @@ class kolabSharedFolderType extends baseType {
function getListClassName() { function getListClassName() {
return "kolabSharedFolderTypeList"; return "kolabSharedFolderTypeList";
} }
/** /**
* Returns the default attribute list for this account type. * Returns the default attribute list for this account type.
* *
@ -116,7 +118,7 @@ class kolabSharedFolderType extends baseType {
// fall back to default // fall back to default
return parent::getTitleBarTitle($container); return parent::getTitleBarTitle($container);
} }
} }
@ -125,7 +127,7 @@ class kolabSharedFolderType extends baseType {
* *
* @package lists * @package lists
* @author Roland Gruber * @author Roland Gruber
* *
*/ */
class kolabSharedFolderTypeList extends lamList { class kolabSharedFolderTypeList extends lamList {
@ -143,7 +145,7 @@ class kolabSharedFolderTypeList extends lamList {
'newEntry' => _("New shared folder"), 'newEntry' => _("New shared folder"),
'deleteEntry' => _("Delete selected shared folders")); 'deleteEntry' => _("Delete selected shared folders"));
} }
} }

View File

@ -34,16 +34,18 @@ $Id$
* @package types * @package types
*/ */
class mailAlias extends baseType { 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');
} }
/** /**
* Returns the alias name of this account type. * Returns the alias name of this account type.
* *
@ -52,7 +54,7 @@ class mailAlias extends baseType {
function getAlias() { function getAlias() {
return _("Mail aliases"); return _("Mail aliases");
} }
/** /**
* Returns the description of this account type. * Returns the description of this account type.
* *
@ -61,7 +63,7 @@ class mailAlias extends baseType {
function getDescription() { function getDescription() {
return _("Mailing aliases (e.g. NIS mail aliases)"); return _("Mailing aliases (e.g. NIS mail aliases)");
} }
/** /**
* Returns the class name for the list object. * Returns the class name for the list object.
* *
@ -70,7 +72,7 @@ class mailAlias extends baseType {
function getListClassName() { function getListClassName() {
return "lamMailAliasList"; return "lamMailAliasList";
} }
/** /**
* Returns the default attribute list for this account type. * Returns the default attribute list for this account type.
* *
@ -125,7 +127,7 @@ class mailAlias extends baseType {
* *
* @package lists * @package lists
* @author Roland Gruber * @author Roland Gruber
* *
*/ */
class lamMailAliasList extends lamList { class lamMailAliasList extends lamList {

View File

@ -34,16 +34,18 @@ $Id$
* @package types * @package types
*/ */
class netgroup extends baseType { 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');
} }
/** /**
* Returns the alias name of this account type. * Returns the alias name of this account type.
* *
@ -52,7 +54,7 @@ class netgroup extends baseType {
function getAlias() { function getAlias() {
return _("NIS netgroups"); return _("NIS netgroups");
} }
/** /**
* Returns the description of this account type. * Returns the description of this account type.
* *
@ -61,7 +63,7 @@ class netgroup extends baseType {
function getDescription() { function getDescription() {
return _("NIS netgroup entries"); return _("NIS netgroup entries");
} }
/** /**
* Returns the class name for the list object. * Returns the class name for the list object.
* *
@ -70,7 +72,7 @@ class netgroup extends baseType {
function getListClassName() { function getListClassName() {
return "lamNetgroupList"; return "lamNetgroupList";
} }
/** /**
* Returns the default attribute list for this account type. * Returns the default attribute list for this account type.
* *
@ -153,7 +155,7 @@ class netgroup extends baseType {
* *
* @package lists * @package lists
* @author Roland Gruber * @author Roland Gruber
* *
*/ */
class lamNetgroupList extends lamList { class lamNetgroupList extends lamList {

View File

@ -34,16 +34,18 @@ $Id$
* @package types * @package types
*/ */
class pykotaBillingCodeType extends baseType { 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');
} }
/** /**
* Returns the alias name of this account type. * Returns the alias name of this account type.
* *
@ -52,7 +54,7 @@ class pykotaBillingCodeType extends baseType {
function getAlias() { function getAlias() {
return _("Billing codes"); return _("Billing codes");
} }
/** /**
* Returns the description of this account type. * Returns the description of this account type.
* *
@ -61,7 +63,7 @@ class pykotaBillingCodeType extends baseType {
function getDescription() { function getDescription() {
return _("PyKota billing codes"); return _("PyKota billing codes");
} }
/** /**
* Returns the class name for the list object. * Returns the class name for the list object.
* *
@ -70,7 +72,7 @@ class pykotaBillingCodeType extends baseType {
function getListClassName() { function getListClassName() {
return "lamPykotaBillingCodeTypeList"; return "lamPykotaBillingCodeTypeList";
} }
/** /**
* Returns the default attribute list for this account type. * Returns the default attribute list for this account type.
* *
@ -118,7 +120,7 @@ class pykotaBillingCodeType extends baseType {
// fall back to default // fall back to default
return parent::getTitleBarTitle($container); return parent::getTitleBarTitle($container);
} }
/** /**
* Returns the the subtitle text for the title bar on the new/edit page. * Returns the the subtitle text for the title bar on the new/edit page.
* *
@ -147,7 +149,7 @@ class pykotaBillingCodeType extends baseType {
* *
* @package lists * @package lists
* @author Roland Gruber * @author Roland Gruber
* *
*/ */
class lamPykotaBillingCodeTypeList extends lamList { class lamPykotaBillingCodeTypeList extends lamList {
@ -165,7 +167,7 @@ class lamPykotaBillingCodeTypeList extends lamList {
'newEntry' => _("New billing code"), 'newEntry' => _("New billing code"),
'deleteEntry' => _("Delete selected billing codes")); 'deleteEntry' => _("Delete selected billing codes"));
} }
} }

View File

@ -34,16 +34,18 @@ $Id$
* @package types * @package types
*/ */
class pykotaPrinterType extends baseType { 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');
} }
/** /**
* Returns the alias name of this account type. * Returns the alias name of this account type.
* *
@ -52,7 +54,7 @@ class pykotaPrinterType extends baseType {
function getAlias() { function getAlias() {
return _("Printers"); return _("Printers");
} }
/** /**
* Returns the description of this account type. * Returns the description of this account type.
* *
@ -61,7 +63,7 @@ class pykotaPrinterType extends baseType {
function getDescription() { function getDescription() {
return _("PyKota printers"); return _("PyKota printers");
} }
/** /**
* Returns the class name for the list object. * Returns the class name for the list object.
* *
@ -70,7 +72,7 @@ class pykotaPrinterType extends baseType {
function getListClassName() { function getListClassName() {
return "lamPykotaPrinterTypeList"; return "lamPykotaPrinterTypeList";
} }
/** /**
* Returns the default attribute list for this account type. * Returns the default attribute list for this account type.
* *
@ -119,7 +121,7 @@ class pykotaPrinterType extends baseType {
// fall back to default // fall back to default
return parent::getTitleBarTitle($container); return parent::getTitleBarTitle($container);
} }
/** /**
* Returns the the subtitle text for the title bar on the new/edit page. * Returns the the subtitle text for the title bar on the new/edit page.
* *
@ -148,7 +150,7 @@ class pykotaPrinterType extends baseType {
* *
* @package lists * @package lists
* @author Roland Gruber * @author Roland Gruber
* *
*/ */
class lamPykotaPrinterTypeList extends lamList { class lamPykotaPrinterTypeList extends lamList {
@ -166,7 +168,7 @@ class lamPykotaPrinterTypeList extends lamList {
'newEntry' => _("New printer"), 'newEntry' => _("New printer"),
'deleteEntry' => _("Delete selected printers")); 'deleteEntry' => _("Delete selected printers"));
} }
} }

View File

@ -34,16 +34,18 @@ $Id$
* @package types * @package types
*/ */
class smbDomain extends baseType { 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');
} }
/** /**
* Returns the alias name of this account type. * Returns the alias name of this account type.
* *
@ -52,7 +54,7 @@ class smbDomain extends baseType {
function getAlias() { function getAlias() {
return _("Samba domains"); return _("Samba domains");
} }
/** /**
* Returns the description of this account type. * Returns the description of this account type.
* *
@ -61,7 +63,7 @@ class smbDomain extends baseType {
function getDescription() { function getDescription() {
return _("Samba 3 domain entries"); return _("Samba 3 domain entries");
} }
/** /**
* Returns the class name for the list object. * Returns the class name for the list object.
* *
@ -70,7 +72,7 @@ class smbDomain extends baseType {
function getListClassName() { function getListClassName() {
return "lamSmbDomainList"; return "lamSmbDomainList";
} }
/** /**
* Returns the default attribute list for this account type. * Returns the default attribute list for this account type.
* *
@ -151,7 +153,7 @@ class smbDomain extends baseType {
* *
* @package lists * @package lists
* @author Roland Gruber * @author Roland Gruber
* *
*/ */
class lamSmbDomainList extends lamList { class lamSmbDomainList extends lamList {

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();
} }