From 1a16b3cd5b55aab6a3640e1ebfc5380daa0f0833 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Wed, 26 Apr 2017 18:22:05 +0200 Subject: [PATCH] new type API --- lam/docs/devel/upgrade.htm | 4 ++++ lam/lib/baseType.inc | 19 ++++++++++++++++++- lam/lib/types.inc | 2 +- lam/lib/types/asteriskExt.inc | 6 ++++-- lam/lib/types/dhcp.inc | 6 ++++-- lam/lib/types/group.inc | 6 ++++-- lam/lib/types/host.inc | 6 ++++-- lam/lib/types/kolabSharedFolderType.inc | 22 ++++++++++++---------- lam/lib/types/mailAlias.inc | 18 ++++++++++-------- lam/lib/types/netgroup.inc | 18 ++++++++++-------- lam/lib/types/pykotaBillingCodeType.inc | 22 ++++++++++++---------- lam/lib/types/pykotaPrinterType.inc | 22 ++++++++++++---------- lam/lib/types/smbDomain.inc | 18 ++++++++++-------- lam/lib/types/user.inc | 6 ++++-- lam/templates/config/conftypes.php | 2 +- 15 files changed, 110 insertions(+), 67 deletions(-) diff --git a/lam/docs/devel/upgrade.htm b/lam/docs/devel/upgrade.htm index 9e4945f6..275a3da4 100644 --- a/lam/docs/devel/upgrade.htm +++ b/lam/docs/devel/upgrade.htm @@ -17,6 +17,7 @@ + @@ -75,6 +76,9 @@ This is a list of API changes for all LAM releases.
  • getDefaultListAttributes() -> use ConfiguredType->getBaseType()->getDefaultListAttributes()
  • getListAttributeDescriptions() -> use ConfiguredType->getBaseType()->getListAttributeDescriptions()
  • +
  • baseType and subclasses have a new constructor argument - ConfiguredType
    +
  • + diff --git a/lam/lib/baseType.inc b/lam/lib/baseType.inc index 1e9d5b98..b8f3a834 100644 --- a/lam/lib/baseType.inc +++ b/lam/lib/baseType.inc @@ -1,4 +1,6 @@ type = $type; $this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another account'); $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to account list'); } @@ -184,6 +192,15 @@ class baseType { return true; } + /** + * Returns the type configuration. + * + * @return ConfiguredType type configuration + */ + protected function getType() { + return $this->type; + } + } ?> \ No newline at end of file diff --git a/lam/lib/types.inc b/lam/lib/types.inc index b0135d6b..4d85e600 100644 --- a/lam/lib/types.inc +++ b/lam/lib/types.inc @@ -242,7 +242,7 @@ class ConfiguredType { return $this->baseType; } $scope = $this->scope; - $this->baseType = new $scope(); + $this->baseType = new $scope($this); return $this->baseType; } diff --git a/lam/lib/types/asteriskExt.inc b/lam/lib/types/asteriskExt.inc index 319d271d..2d5a4407 100644 --- a/lam/lib/types/asteriskExt.inc +++ b/lam/lib/types/asteriskExt.inc @@ -40,9 +40,11 @@ class asteriskExt extends baseType { /** * Constructs a new domain type object. + * + * @param ConfiguredType $type configuration */ - public function __construct() { - parent::__construct(); + public function __construct($type) { + parent::__construct($type); $this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another extension'); $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to extensions list'); } diff --git a/lam/lib/types/dhcp.inc b/lam/lib/types/dhcp.inc index e8b179a9..bce4b03d 100644 --- a/lam/lib/types/dhcp.inc +++ b/lam/lib/types/dhcp.inc @@ -40,9 +40,11 @@ class dhcp extends baseType { /** * Constructs a new DHCP type object. + * + * @param ConfiguredType $type configuration */ - public function __construct() { - parent::__construct(); + public function __construct($type) { + parent::__construct($type); $this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another DHCP entry'); $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to DHCP list'); } diff --git a/lam/lib/types/group.inc b/lam/lib/types/group.inc index bbd1377f..16f68f90 100644 --- a/lam/lib/types/group.inc +++ b/lam/lib/types/group.inc @@ -39,9 +39,11 @@ class group extends baseType { /** * Constructs a new group type object. + * + * @param ConfiguredType $type configuration */ - public function __construct() { - parent::__construct(); + public function __construct($type) { + parent::__construct($type); $this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another group'); $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to group list'); if (isset($_SESSION['config'])) { diff --git a/lam/lib/types/host.inc b/lam/lib/types/host.inc index cf762443..76031024 100644 --- a/lam/lib/types/host.inc +++ b/lam/lib/types/host.inc @@ -37,9 +37,11 @@ class host extends baseType { /** * Constructs a new host type object. + * + * @param ConfiguredType $type configuration */ - public function __construct() { - parent::__construct(); + public function __construct($type) { + parent::__construct($type); $this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another host'); $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to host list'); } diff --git a/lam/lib/types/kolabSharedFolderType.inc b/lam/lib/types/kolabSharedFolderType.inc index c8774e08..f1524701 100644 --- a/lam/lib/types/kolabSharedFolderType.inc +++ b/lam/lib/types/kolabSharedFolderType.inc @@ -34,16 +34,18 @@ $Id$ * @package types */ class kolabSharedFolderType extends baseType { - + /** * Constructs a new shared folder object. + * + * @param ConfiguredType $type configuration */ - public function __construct() { - parent::__construct(); + public function __construct($type) { + parent::__construct($type); $this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another shared folder'); $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to shared folder list'); } - + /** * Returns the alias name of this account type. * @@ -52,7 +54,7 @@ class kolabSharedFolderType extends baseType { function getAlias() { return _("Kolab shared folders"); } - + /** * Returns the description of this account type. * @@ -61,7 +63,7 @@ class kolabSharedFolderType extends baseType { function getDescription() { return _("Kolab shared folders (e.g. mail folders)"); } - + /** * Returns the class name for the list object. * @@ -70,7 +72,7 @@ class kolabSharedFolderType extends baseType { function getListClassName() { return "kolabSharedFolderTypeList"; } - + /** * Returns the default attribute list for this account type. * @@ -116,7 +118,7 @@ class kolabSharedFolderType extends baseType { // fall back to default return parent::getTitleBarTitle($container); } - + } @@ -125,7 +127,7 @@ class kolabSharedFolderType extends baseType { * * @package lists * @author Roland Gruber - * + * */ class kolabSharedFolderTypeList extends lamList { @@ -143,7 +145,7 @@ class kolabSharedFolderTypeList extends lamList { 'newEntry' => _("New shared folder"), 'deleteEntry' => _("Delete selected shared folders")); } - + } diff --git a/lam/lib/types/mailAlias.inc b/lam/lib/types/mailAlias.inc index a25a558d..5fc43905 100644 --- a/lam/lib/types/mailAlias.inc +++ b/lam/lib/types/mailAlias.inc @@ -34,16 +34,18 @@ $Id$ * @package types */ class mailAlias extends baseType { - + /** * Constructs a new alias type object. + * + * @param ConfiguredType $type configuration */ - public function __construct() { - parent::__construct(); + public function __construct($type) { + parent::__construct($type); $this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another alias'); $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to alias list'); } - + /** * Returns the alias name of this account type. * @@ -52,7 +54,7 @@ class mailAlias extends baseType { function getAlias() { return _("Mail aliases"); } - + /** * Returns the description of this account type. * @@ -61,7 +63,7 @@ class mailAlias extends baseType { function getDescription() { return _("Mailing aliases (e.g. NIS mail aliases)"); } - + /** * Returns the class name for the list object. * @@ -70,7 +72,7 @@ class mailAlias extends baseType { function getListClassName() { return "lamMailAliasList"; } - + /** * Returns the default attribute list for this account type. * @@ -125,7 +127,7 @@ class mailAlias extends baseType { * * @package lists * @author Roland Gruber - * + * */ class lamMailAliasList extends lamList { diff --git a/lam/lib/types/netgroup.inc b/lam/lib/types/netgroup.inc index c560c80e..b0423ee8 100644 --- a/lam/lib/types/netgroup.inc +++ b/lam/lib/types/netgroup.inc @@ -34,16 +34,18 @@ $Id$ * @package types */ class netgroup extends baseType { - + /** * Constructs a new group type object. + * + * @param ConfiguredType $type configuration */ - public function __construct() { - parent::__construct(); + public function __construct($type) { + parent::__construct($type); $this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another group'); $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to group list'); } - + /** * Returns the alias name of this account type. * @@ -52,7 +54,7 @@ class netgroup extends baseType { function getAlias() { return _("NIS netgroups"); } - + /** * Returns the description of this account type. * @@ -61,7 +63,7 @@ class netgroup extends baseType { function getDescription() { return _("NIS netgroup entries"); } - + /** * Returns the class name for the list object. * @@ -70,7 +72,7 @@ class netgroup extends baseType { function getListClassName() { return "lamNetgroupList"; } - + /** * Returns the default attribute list for this account type. * @@ -153,7 +155,7 @@ class netgroup extends baseType { * * @package lists * @author Roland Gruber - * + * */ class lamNetgroupList extends lamList { diff --git a/lam/lib/types/pykotaBillingCodeType.inc b/lam/lib/types/pykotaBillingCodeType.inc index d7555c2c..d7d11638 100644 --- a/lam/lib/types/pykotaBillingCodeType.inc +++ b/lam/lib/types/pykotaBillingCodeType.inc @@ -34,16 +34,18 @@ $Id$ * @package types */ class pykotaBillingCodeType extends baseType { - + /** * Constructs a new billing code object. + * + * @param ConfiguredType $type configuration */ - public function __construct() { - parent::__construct(); + public function __construct($type) { + parent::__construct($type); $this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another billing code'); $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to billing code list'); } - + /** * Returns the alias name of this account type. * @@ -52,7 +54,7 @@ class pykotaBillingCodeType extends baseType { function getAlias() { return _("Billing codes"); } - + /** * Returns the description of this account type. * @@ -61,7 +63,7 @@ class pykotaBillingCodeType extends baseType { function getDescription() { return _("PyKota billing codes"); } - + /** * Returns the class name for the list object. * @@ -70,7 +72,7 @@ class pykotaBillingCodeType extends baseType { function getListClassName() { return "lamPykotaBillingCodeTypeList"; } - + /** * Returns the default attribute list for this account type. * @@ -118,7 +120,7 @@ class pykotaBillingCodeType extends baseType { // fall back to default return parent::getTitleBarTitle($container); } - + /** * Returns the the subtitle text for the title bar on the new/edit page. * @@ -147,7 +149,7 @@ class pykotaBillingCodeType extends baseType { * * @package lists * @author Roland Gruber - * + * */ class lamPykotaBillingCodeTypeList extends lamList { @@ -165,7 +167,7 @@ class lamPykotaBillingCodeTypeList extends lamList { 'newEntry' => _("New billing code"), 'deleteEntry' => _("Delete selected billing codes")); } - + } diff --git a/lam/lib/types/pykotaPrinterType.inc b/lam/lib/types/pykotaPrinterType.inc index becee5f9..a4305958 100644 --- a/lam/lib/types/pykotaPrinterType.inc +++ b/lam/lib/types/pykotaPrinterType.inc @@ -34,16 +34,18 @@ $Id$ * @package types */ class pykotaPrinterType extends baseType { - + /** * Constructs a new printer type object. + * + * @param ConfiguredType $type configuration */ - public function __construct() { - parent::__construct(); + public function __construct($type) { + parent::__construct($type); $this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another printer'); $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to printer list'); } - + /** * Returns the alias name of this account type. * @@ -52,7 +54,7 @@ class pykotaPrinterType extends baseType { function getAlias() { return _("Printers"); } - + /** * Returns the description of this account type. * @@ -61,7 +63,7 @@ class pykotaPrinterType extends baseType { function getDescription() { return _("PyKota printers"); } - + /** * Returns the class name for the list object. * @@ -70,7 +72,7 @@ class pykotaPrinterType extends baseType { function getListClassName() { return "lamPykotaPrinterTypeList"; } - + /** * Returns the default attribute list for this account type. * @@ -119,7 +121,7 @@ class pykotaPrinterType extends baseType { // fall back to default return parent::getTitleBarTitle($container); } - + /** * Returns the the subtitle text for the title bar on the new/edit page. * @@ -148,7 +150,7 @@ class pykotaPrinterType extends baseType { * * @package lists * @author Roland Gruber - * + * */ class lamPykotaPrinterTypeList extends lamList { @@ -166,7 +168,7 @@ class lamPykotaPrinterTypeList extends lamList { 'newEntry' => _("New printer"), 'deleteEntry' => _("Delete selected printers")); } - + } diff --git a/lam/lib/types/smbDomain.inc b/lam/lib/types/smbDomain.inc index 7e8a8174..4af23b69 100644 --- a/lam/lib/types/smbDomain.inc +++ b/lam/lib/types/smbDomain.inc @@ -34,16 +34,18 @@ $Id$ * @package types */ class smbDomain extends baseType { - + /** * Constructs a new domain type object. + * + * @param ConfiguredType $type configuration */ - public function __construct() { - parent::__construct(); + public function __construct($type) { + parent::__construct($type); $this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another domain'); $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to domain list'); } - + /** * Returns the alias name of this account type. * @@ -52,7 +54,7 @@ class smbDomain extends baseType { function getAlias() { return _("Samba domains"); } - + /** * Returns the description of this account type. * @@ -61,7 +63,7 @@ class smbDomain extends baseType { function getDescription() { return _("Samba 3 domain entries"); } - + /** * Returns the class name for the list object. * @@ -70,7 +72,7 @@ class smbDomain extends baseType { function getListClassName() { return "lamSmbDomainList"; } - + /** * Returns the default attribute list for this account type. * @@ -151,7 +153,7 @@ class smbDomain extends baseType { * * @package lists * @author Roland Gruber - * + * */ class lamSmbDomainList extends lamList { diff --git a/lam/lib/types/user.inc b/lam/lib/types/user.inc index c3d67b02..726e2d03 100644 --- a/lam/lib/types/user.inc +++ b/lam/lib/types/user.inc @@ -37,9 +37,11 @@ class user extends baseType { /** * Constructs a new user type object. + * + * @param ConfiguredType $type configuration */ - public function __construct() { - parent::__construct(); + public function __construct($type) { + parent::__construct($type); $this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another user'); $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to user list'); } diff --git a/lam/templates/config/conftypes.php b/lam/templates/config/conftypes.php index 7b90e956..270e0405 100644 --- a/lam/templates/config/conftypes.php +++ b/lam/templates/config/conftypes.php @@ -127,7 +127,7 @@ foreach ($activeTypes as $activeType) { $activeScopes = array_unique($activeScopes); $availableScopes = array(); foreach ($allScopes as $scope) { - $scopeObj = new $scope(); + $scopeObj = new $scope(null); if (!in_array($scope, $activeScopes) || $scopeObj->supportsMultipleConfigs()) { $availableScopes[$scope] = $scopeObj->getAlias(); }