moved get_alias() to baseModule

This commit is contained in:
Roland Gruber 2004-06-14 16:05:36 +00:00
parent 94c117a770
commit 6ce5f9d1d3
13 changed files with 48 additions and 45 deletions

View File

@ -22,9 +22,6 @@ All module classes should extend the baseModule class.<br>
<h2>2. Class functions</h2>
<h3>2.1. Functions that have to work without superior accountContainer<br>
</h3>
These functions are called without instanciating an object of the
module class. They must not depend on class variables and are only
allowed to call other static functions.<br>
<h3><br>
</h3>
<h3>2.1.1. can_manage</h3>
@ -54,7 +51,7 @@ otherwise <span style="font-style: italic;">false</span>.<br>
<tr>
<td
style="vertical-align: top; background-color: rgb(204, 204, 204); text-align: center;"><span
style="font-weight: bold;">function get_alias($scope)</span><br>
style="font-weight: bold;">function get_alias()</span><br>
</td>
</tr>
</tbody>
@ -64,9 +61,8 @@ This function returns a more descriptive string than the class name.
Alias names are used for the buttons of the account pages and the
module selection of the configuration wizard.<br>
Please take care that your alias name is not too long. It may contain
a-z, A-Z, 0-9, -, _ and spaces.<br>
The <span style="font-weight: bold;">$scope</span> parameter defines
the account type ("user", "group", "host" at this time).<br>
any character but should not include parts that may be interpreted by
the browser (e.g. '&lt;' or '&gt;').<br>
<br>
<h3>2.1.3. is_base_module*</h3>
<br>

View File

@ -105,6 +105,19 @@ class baseModule {
else return "";
}
/**
* Returns an alias name for the module.
*
* This alias is used in various places instead of the less descriptive class name.
* The alias also has less syntax restrictions and may contain spaces or special characters.
*
* @return string alias name
*/
function get_alias() {
if (isset($this->meta['alias'])) return $this->meta['alias'];
else return get_class($this);
}
// TODO implement missing interface
}

View File

@ -48,11 +48,16 @@ while ($stay<7) {
}
}
// returns the alias name of a module
// $name: the module name
// $scope: the account type ("user", "group", "host")
/**
* Returns the alias name of a module
*
* @param string $name the module name
* @param string $scope the account type ("user", "group", "host")
* @return string alias name
*/
function getModuleAlias($name, $scope) {
return call_user_func(array($name, "get_alias"), $scope);
$module = new $name($scope);
return $module->get_alias();
}
// returns if the module is a base module

View File

@ -48,6 +48,8 @@ class account extends baseModule {
$return = array();
// manages host accounts
$return["account_types"] = array("host");
// alias name
$return["alias"] = _('Account');
return $return;
}
@ -76,9 +78,6 @@ class account extends baseModule {
*/
var $orig;
function get_alias($scope) {
return _('Account');
}
/* This function returns a list with all required modules
*/

View File

@ -47,6 +47,8 @@ class inetOrgPerson extends baseModule {
$return = array();
// manages user accounts
$return["account_types"] = array("user");
// alias name
$return["alias"] = _('Personal');
return $return;
}
@ -79,9 +81,6 @@ class inetOrgPerson extends baseModule {
*/
var $orig;
function get_alias($scope) {
return _('Personal');
}
/* This function returns a list with all required modules
*/

View File

@ -54,6 +54,8 @@ class main extends baseModule {
$return = array();
// manages no accounts
$return["account_types"] = array();
// alias name
$return["alias"] = _('Main');
return $return;
}
@ -76,9 +78,6 @@ class main extends baseModule {
// name of accountContainer so we can read other classes in accuontArray
var $base;
function get_alias($scope) {
return _('main');
}
/* This function returns a list with all required modules
*/

View File

@ -70,6 +70,8 @@ class posixAccount extends baseModule {
// LDAP filter
$return["ldap_filter"] = array('or' => "(objectClass=posixAccount)", 'and' => "(!(uid=*$))");
}
// alias name
$return["alias"] = _("Unix");
return $return;
}
@ -127,6 +129,7 @@ class posixAccount extends baseModule {
var $groups_orig;
var $createhomedir;
/* $attribute['userPassword'] can't accessed directly because it's enrcypted
* To read / write password function userPassword is needed
* This function will return the unencrypted password when
@ -149,10 +152,6 @@ class posixAccount extends baseModule {
}
}
function get_alias($scope) {
return "Unix";
}
/* This function returns a list with all required modules
*/
function get_dependencies($scope) {

View File

@ -69,6 +69,8 @@ class posixGroup extends baseModule {
// LDAP filter
$return["ldap_filter"] = array('or' => "(objectClass=posixGroup)");
}
// alias name
$return["alias"] = _('Unix');
return $return;
}
@ -99,6 +101,7 @@ class posixGroup extends baseModule {
$this->changegids=false;
}
// Variables
// name of accountContainer so we can read other classes in accuontArray
var $base;
@ -138,10 +141,6 @@ class posixGroup extends baseModule {
}
}
function get_alias($scope) {
return _('Unix');
}
/* This function returns a list with all required modules
*/
function get_dependencies($scope) {

View File

@ -32,6 +32,8 @@ class quota extends baseModule {
$return = array();
// manages user and group accounts
$return["account_types"] = array("user", "group");
// alias name
$return["alias"] = _('Quota');
return $return;
}
@ -80,9 +82,6 @@ class quota extends baseModule {
var $quota;
function get_alias($scope) {
return _('Quota');
}
/* This function returns a list with all required modules
*/

View File

@ -69,6 +69,8 @@ class sambaAccount extends baseModule {
// LDAP filter
$return["ldap_filter"] = array('and' => '(uid=*$)', 'or' => "(objectClass=posixAccount)");
}
// alias name
$return["alias"] = _('Samba 2');
return $return;
}
@ -141,10 +143,6 @@ class sambaAccount extends baseModule {
}
}
function get_alias($scope) {
return _('Samba 2');
}
/* This function returns a list with all required modules
*/
function get_dependencies($scope) {

View File

@ -63,6 +63,8 @@ class sambaGroupMapping extends baseModule {
$return = array();
// manages group accounts
$return["account_types"] = array("group");
// alias name
$return["alias"] = _('Samba 3');
return $return;
}
@ -106,9 +108,6 @@ class sambaGroupMapping extends baseModule {
// Array of well known rids
var $rids;
function get_alias($scope) {
return _('Samba 3');
}
/* This function returns a list with all required modules
*/

View File

@ -69,6 +69,8 @@ class sambaSamAccount extends baseModule {
// LDAP filter
$return["ldap_filter"] = array('and' => '(uid=*$)', 'or' => "(objectClass=posixAccount)");
}
// alias name
$return["alias"] = _('Samba 3');
return $return;
}
@ -118,6 +120,7 @@ class sambaSamAccount extends baseModule {
// Array of well known rids
var $rids;
/* $attribute['sambaLMPassword'] and sambaNTPassword can't accessed directly because it's enrcypted
* To read / write password function userPassword is needed
* This function will return the unencrypted password when
@ -141,10 +144,6 @@ class sambaSamAccount extends baseModule {
}
}
function get_alias($scope) {
return _('Samba 3');
}
/* This function returns a list with all required modules
*/
function get_dependencies($scope) {

View File

@ -63,6 +63,8 @@ class shadowAccount extends baseModule {
$return = array();
// manages user accounts
$return["account_types"] = array("user");
// alias name
$return["alias"] = _('Shadow');
return $return;
}
@ -100,9 +102,6 @@ class shadowAccount extends baseModule {
*/
var $orig;
function get_alias($scope) {
return _('Shadow');
}
/* This function returns a list with all required modules
*/