moved can_manage() to baseModule

This commit is contained in:
Roland Gruber 2004-06-13 19:58:58 +00:00
parent 44e3cfce7c
commit 94c117a770
13 changed files with 117 additions and 63 deletions

View File

@ -35,17 +35,15 @@ allowed to call other static functions.<br>
<tr> <tr>
<td <td
style="vertical-align: top; background-color: rgb(204, 204, 204); text-align: center;"><span style="vertical-align: top; background-color: rgb(204, 204, 204); text-align: center;"><span
style="font-weight: bold;">function can_manage($scope)</span><br> style="font-weight: bold;">function can_manage()</span><br>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<br> <br>
Returns <span style="font-style: italic;">true</span> if this module Returns <span style="font-style: italic;">true</span> if this module
can manage accounts of type <span style="font-style: italic;">$scope</span>, can manage accounts of the current type<span style="font-style: italic;"></span>,
otherwise <span style="font-style: italic;">false</span>.<br> otherwise <span style="font-style: italic;">false</span>.<br>
The <span style="font-weight: bold;">$scope</span> parameter defines
the account type ("user", "group", "host" at this time).<br>
<br> <br>
<br> <br>
<h3>2.1.2. get_alias</h3> <h3>2.1.2. get_alias</h3>
@ -558,10 +556,17 @@ which should be displayed when this help entry is called.
<br> <br>
<br> <br>
<h2>6. Module meta data</h2> <h2>6. Module meta data</h2>
<h3>6.1 is_base_module()</h3> <h3>6.1 can_manage()
</h3>
&nbsp;&nbsp;&nbsp; "account_types" =&gt; array<br>
<br>
<span style="font-weight: bold;">&nbsp;&nbsp;&nbsp; Example:
array("user", "host")</span><br style="font-weight: bold;">
<br>
<h3>6.2 is_base_module()</h3>
&nbsp;&nbsp;&nbsp; "is_base" =&gt; boolean<br> &nbsp;&nbsp;&nbsp; "is_base" =&gt; boolean<br>
<br> <br>
<h3>6.2 get_ldap_filter()</h3> <h3>6.3 get_ldap_filter()</h3>
&nbsp;&nbsp;&nbsp; "ldap_filter" =&gt; array<br> &nbsp;&nbsp;&nbsp; "ldap_filter" =&gt; array<br>
<br> <br>
<span style="font-weight: bold;">&nbsp;&nbsp; Example:</span><span <span style="font-weight: bold;">&nbsp;&nbsp; Example:</span><span

View File

@ -73,6 +73,16 @@ class baseModule {
return $this->scope; return $this->scope;
} }
/**
* Returns true if this module fits for the current scope.
*
* @return boolean true if module fits
*/
function can_manage() {
if (is_array($this->meta["account_types"]) && in_array($this->scope, $this->meta["account_types"])) return true;
else return false;
}
/** /**
* Returns true if this module is enough to provide a sensible account. * Returns true if this module is enough to provide a sensible account.
* *

View File

@ -164,8 +164,12 @@ function check_module_conflicts($selected, $deps) {
else return false; else return false;
} }
// returns an array with all available user module names /**
// $scope = user, group, host, ... * Returns an array with all available user module names
*
* @param string $scope account type (user, group, host)
* @return array list of possible modules
*/
function getAvailableModules($scope) { function getAvailableModules($scope) {
global $relative; global $relative;
$return = array(); $return = array();
@ -174,7 +178,8 @@ function getAvailableModules($scope) {
while ($entry = readdir($dir)) while ($entry = readdir($dir))
if ((substr($entry, strlen($entry) - 4, 4) == '.inc') && is_file($relative . 'lib/modules/'.$entry)) { if ((substr($entry, strlen($entry) - 4, 4) == '.inc') && is_file($relative . 'lib/modules/'.$entry)) {
$entry = substr($entry, 0, strpos($entry, '.')); $entry = substr($entry, 0, strpos($entry, '.'));
if (call_user_func(array($entry, "can_manage"), $scope)) $return[] = $entry; $temp = new $entry($scope);
if ($temp->can_manage()) $return[] = $entry;
} }
return $return; return $return;
} }

View File

@ -38,6 +38,19 @@ $Id$
*/ */
class account extends baseModule { class account extends baseModule {
/**
* Returns meta data that is interpreted by parent class
*
* @return array array with meta data
*/
function get_metaData() {
$return = array();
// manages host accounts
$return["account_types"] = array("host");
return $return;
}
// Constructor // Constructor
function init($base) { function init($base) {
// Get local copy of name of account_container in session // Get local copy of name of account_container in session
@ -67,11 +80,6 @@ class account extends baseModule {
return _('Account'); return _('Account');
} }
function can_manage($scope) {
if ($scope == "host") return true;
else return false;
}
/* This function returns a list with all required modules /* This function returns a list with all required modules
*/ */
function get_dependencies($scope) { function get_dependencies($scope) {

View File

@ -37,6 +37,19 @@ $Id$
*/ */
class inetOrgPerson extends baseModule { class inetOrgPerson extends baseModule {
/**
* Returns meta data that is interpreted by parent class
*
* @return array array with meta data
*/
function get_metaData() {
$return = array();
// manages user accounts
$return["account_types"] = array("user");
return $return;
}
// Constructor // Constructor
function init($base) { function init($base) {
// Get local copy of name of account_container in session // Get local copy of name of account_container in session
@ -70,11 +83,6 @@ class inetOrgPerson extends baseModule {
return _('Personal'); return _('Personal');
} }
function can_manage($scope) {
if ($scope == "user") return true;
else return false;
}
/* This function returns a list with all required modules /* This function returns a list with all required modules
*/ */
function get_dependencies($scope) { function get_dependencies($scope) {

View File

@ -44,6 +44,19 @@ $Id$
* It also chooses which page to show. * It also chooses which page to show.
*/ */
class main extends baseModule { class main extends baseModule {
/**
* Returns meta data that is interpreted by parent class
*
* @return array array with meta data
*/
function get_metaData() {
$return = array();
// manages no accounts
$return["account_types"] = array();
return $return;
}
// Constructor // Constructor
function init($base) { function init($base) {
// Set counter to first page // Set counter to first page
@ -67,10 +80,6 @@ class main extends baseModule {
return _('main'); return _('main');
} }
function can_manage($scope) {
return false;
}
/* This function returns a list with all required modules /* This function returns a list with all required modules
*/ */
function get_dependencies($scope) { function get_dependencies($scope) {

View File

@ -61,6 +61,9 @@ class posixAccount extends baseModule {
*/ */
function get_metaData() { function get_metaData() {
$return = array(); $return = array();
// manages user and host accounts
$return["account_types"] = array("user", "host");
// user specific data
if ($this->get_scope() == "user") { if ($this->get_scope() == "user") {
// this is a base module // this is a base module
$return["is_base"] = true; $return["is_base"] = true;
@ -150,12 +153,6 @@ class posixAccount extends baseModule {
return "Unix"; return "Unix";
} }
function can_manage($scope) {
if ($scope == "host") return true;
elseif ($scope == "user") return true;
else return false;
}
/* This function returns a list with all required modules /* This function returns a list with all required modules
*/ */
function get_dependencies($scope) { function get_dependencies($scope) {

View File

@ -61,6 +61,8 @@ class posixGroup extends baseModule {
*/ */
function get_metaData() { function get_metaData() {
$return = array(); $return = array();
// manages group accounts
$return["account_types"] = array("group");
if ($this->get_scope() == "group") { if ($this->get_scope() == "group") {
// this is a base module // this is a base module
$return["is_base"] = true; $return["is_base"] = true;
@ -140,11 +142,6 @@ class posixGroup extends baseModule {
return _('Unix'); return _('Unix');
} }
function can_manage($scope) {
if ($scope == "group") return true;
else return false;
}
/* This function returns a list with all required modules /* This function returns a list with all required modules
*/ */
function get_dependencies($scope) { function get_dependencies($scope) {

View File

@ -22,6 +22,19 @@ $Id$
class quota extends baseModule { class quota extends baseModule {
/**
* Returns meta data that is interpreted by parent class
*
* @return array array with meta data
*/
function get_metaData() {
$return = array();
// manages user and group accounts
$return["account_types"] = array("user", "group");
return $return;
}
// Constructor // Constructor
function init($base) { function init($base) {
$this->base = $base; $this->base = $base;
@ -71,12 +84,6 @@ class quota extends baseModule {
return _('Quota'); return _('Quota');
} }
function can_manage($scope) {
if ($scope == "group") return true;
elseif ($scope == "user") return true;
else return false;
}
/* This function returns a list with all required modules /* This function returns a list with all required modules
*/ */
function get_dependencies($scope) { function get_dependencies($scope) {

View File

@ -61,6 +61,8 @@ class sambaAccount extends baseModule {
*/ */
function get_metaData() { function get_metaData() {
$return = array(); $return = array();
// manages user and host accounts
$return["account_types"] = array("user", "host");
if ($this->get_scope() == "host") { if ($this->get_scope() == "host") {
// this is a base module // this is a base module
$return["is_base"] = true; $return["is_base"] = true;
@ -143,12 +145,6 @@ class sambaAccount extends baseModule {
return _('Samba 2'); return _('Samba 2');
} }
function can_manage($scope) {
if ($scope == "host") return true;
elseif ($scope == "user") return true;
else return false;
}
/* This function returns a list with all required modules /* This function returns a list with all required modules
*/ */
function get_dependencies($scope) { function get_dependencies($scope) {

View File

@ -53,6 +53,19 @@ $Id$
* 'attributes': this is a list of arrays with all ldap attributes wich are allowed for this account * 'attributes': this is a list of arrays with all ldap attributes wich are allowed for this account
*/ */
class sambaGroupMapping extends baseModule { class sambaGroupMapping extends baseModule {
/**
* Returns meta data that is interpreted by parent class
*
* @return array array with meta data
*/
function get_metaData() {
$return = array();
// manages group accounts
$return["account_types"] = array("group");
return $return;
}
// Constructor // Constructor
function init($base) { function init($base) {
/* Return an error if sambaGroupMapping should be created without /* Return an error if sambaGroupMapping should be created without
@ -97,11 +110,6 @@ class sambaGroupMapping extends baseModule {
return _('Samba 3'); return _('Samba 3');
} }
function can_manage($scope) {
if ($scope == "group") return true;
else return false;
}
/* This function returns a list with all required modules /* This function returns a list with all required modules
*/ */
function get_dependencies($scope) { function get_dependencies($scope) {

View File

@ -61,6 +61,8 @@ class sambaSamAccount extends baseModule {
*/ */
function get_metaData() { function get_metaData() {
$return = array(); $return = array();
// manages user and host accounts
$return["account_types"] = array("user", "host");
if ($this->get_scope() == "host") { if ($this->get_scope() == "host") {
// this is a base module // this is a base module
$return["is_base"] = true; $return["is_base"] = true;
@ -143,12 +145,6 @@ class sambaSamAccount extends baseModule {
return _('Samba 3'); return _('Samba 3');
} }
function can_manage($scope) {
if ($scope == "host") return true;
elseif ($scope == "user") return true;
else return false;
}
/* This function returns a list with all required modules /* This function returns a list with all required modules
*/ */
function get_dependencies($scope) { function get_dependencies($scope) {

View File

@ -53,6 +53,19 @@ $Id$
* 'attributes': this is a list of arrays with all ldap attributes wich are allowed for this account * 'attributes': this is a list of arrays with all ldap attributes wich are allowed for this account
*/ */
class shadowAccount extends baseModule { class shadowAccount extends baseModule {
/**
* Returns meta data that is interpreted by parent class
*
* @return array array with meta data
*/
function get_metaData() {
$return = array();
// manages user accounts
$return["account_types"] = array("user");
return $return;
}
// Constructor // Constructor
function init($base) { function init($base) {
/* Return an error if shadowAccount should be created without /* Return an error if shadowAccount should be created without
@ -91,11 +104,6 @@ class shadowAccount extends baseModule {
return _('Shadow'); return _('Shadow');
} }
function can_manage($scope) {
if ($scope == "user") return true;
else return false;
}
/* This function returns a list with all required modules /* This function returns a list with all required modules
*/ */
function get_dependencies($scope) { function get_dependencies($scope) {