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>getListAttributeDescriptions() -&gt; use ConfiguredType-&gt;getBaseType()-&gt;getListAttributeDescriptions()</li>
</ul>
<li>baseType and subclasses have a new constructor argument - ConfiguredType<br>
</li>

View File

@ -1,4 +1,6 @@
<?php
use LAM\TYPES\ConfiguredType;
/*
$Id$
@ -40,10 +42,16 @@ class baseType {
/** label to return to account list */
public $LABEL_BACK_TO_ACCOUNT_LIST;
/** type configuration */
private $type;
/**
* 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_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;
}
}
?>

View File

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

View File

@ -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');
}

View File

@ -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');
}

View File

@ -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'])) {

View File

@ -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');
}

View File

@ -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"));
}
}

View File

@ -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 {

View File

@ -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 {

View File

@ -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"));
}
}

View File

@ -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"));
}
}

View File

@ -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 {

View File

@ -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');
}

View File

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