moved can_manage() to baseModule
This commit is contained in:
parent
44e3cfce7c
commit
94c117a770
|
@ -35,17 +35,15 @@ allowed to call other static functions.<br>
|
|||
<tr>
|
||||
<td
|
||||
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>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
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>
|
||||
The <span style="font-weight: bold;">$scope</span> parameter defines
|
||||
the account type ("user", "group", "host" at this time).<br>
|
||||
<br>
|
||||
<br>
|
||||
<h3>2.1.2. get_alias</h3>
|
||||
|
@ -558,10 +556,17 @@ which should be displayed when this help entry is called.
|
|||
<br>
|
||||
<br>
|
||||
<h2>6. Module meta data</h2>
|
||||
<h3>6.1 is_base_module()</h3>
|
||||
<h3>6.1 can_manage()
|
||||
</h3>
|
||||
"account_types" => array<br>
|
||||
<br>
|
||||
<span style="font-weight: bold;"> Example:
|
||||
array("user", "host")</span><br style="font-weight: bold;">
|
||||
<br>
|
||||
<h3>6.2 is_base_module()</h3>
|
||||
"is_base" => boolean<br>
|
||||
<br>
|
||||
<h3>6.2 get_ldap_filter()</h3>
|
||||
<h3>6.3 get_ldap_filter()</h3>
|
||||
"ldap_filter" => array<br>
|
||||
<br>
|
||||
<span style="font-weight: bold;"> Example:</span><span
|
||||
|
|
|
@ -73,6 +73,16 @@ class baseModule {
|
|||
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.
|
||||
*
|
||||
|
|
|
@ -164,8 +164,12 @@ function check_module_conflicts($selected, $deps) {
|
|||
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) {
|
||||
global $relative;
|
||||
$return = array();
|
||||
|
@ -174,7 +178,8 @@ function getAvailableModules($scope) {
|
|||
while ($entry = readdir($dir))
|
||||
if ((substr($entry, strlen($entry) - 4, 4) == '.inc') && is_file($relative . 'lib/modules/'.$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;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,19 @@ $Id$
|
|||
*/
|
||||
|
||||
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
|
||||
function init($base) {
|
||||
// Get local copy of name of account_container in session
|
||||
|
@ -67,11 +80,6 @@ class account extends baseModule {
|
|||
return _('Account');
|
||||
}
|
||||
|
||||
function can_manage($scope) {
|
||||
if ($scope == "host") return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
/* This function returns a list with all required modules
|
||||
*/
|
||||
function get_dependencies($scope) {
|
||||
|
|
|
@ -37,6 +37,19 @@ $Id$
|
|||
*/
|
||||
|
||||
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
|
||||
function init($base) {
|
||||
// Get local copy of name of account_container in session
|
||||
|
@ -70,11 +83,6 @@ class inetOrgPerson extends baseModule {
|
|||
return _('Personal');
|
||||
}
|
||||
|
||||
function can_manage($scope) {
|
||||
if ($scope == "user") return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
/* This function returns a list with all required modules
|
||||
*/
|
||||
function get_dependencies($scope) {
|
||||
|
|
|
@ -44,6 +44,19 @@ $Id$
|
|||
* It also chooses which page to show.
|
||||
*/
|
||||
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
|
||||
function init($base) {
|
||||
// Set counter to first page
|
||||
|
@ -67,10 +80,6 @@ class main extends baseModule {
|
|||
return _('main');
|
||||
}
|
||||
|
||||
function can_manage($scope) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* This function returns a list with all required modules
|
||||
*/
|
||||
function get_dependencies($scope) {
|
||||
|
|
|
@ -61,6 +61,9 @@ class posixAccount extends baseModule {
|
|||
*/
|
||||
function get_metaData() {
|
||||
$return = array();
|
||||
// manages user and host accounts
|
||||
$return["account_types"] = array("user", "host");
|
||||
// user specific data
|
||||
if ($this->get_scope() == "user") {
|
||||
// this is a base module
|
||||
$return["is_base"] = true;
|
||||
|
@ -150,12 +153,6 @@ class posixAccount extends baseModule {
|
|||
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
|
||||
*/
|
||||
function get_dependencies($scope) {
|
||||
|
|
|
@ -61,6 +61,8 @@ class posixGroup extends baseModule {
|
|||
*/
|
||||
function get_metaData() {
|
||||
$return = array();
|
||||
// manages group accounts
|
||||
$return["account_types"] = array("group");
|
||||
if ($this->get_scope() == "group") {
|
||||
// this is a base module
|
||||
$return["is_base"] = true;
|
||||
|
@ -140,11 +142,6 @@ class posixGroup extends baseModule {
|
|||
return _('Unix');
|
||||
}
|
||||
|
||||
function can_manage($scope) {
|
||||
if ($scope == "group") return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
/* This function returns a list with all required modules
|
||||
*/
|
||||
function get_dependencies($scope) {
|
||||
|
|
|
@ -22,6 +22,19 @@ $Id$
|
|||
|
||||
|
||||
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
|
||||
function init($base) {
|
||||
$this->base = $base;
|
||||
|
@ -71,12 +84,6 @@ class quota extends baseModule {
|
|||
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
|
||||
*/
|
||||
function get_dependencies($scope) {
|
||||
|
|
|
@ -61,6 +61,8 @@ class sambaAccount extends baseModule {
|
|||
*/
|
||||
function get_metaData() {
|
||||
$return = array();
|
||||
// manages user and host accounts
|
||||
$return["account_types"] = array("user", "host");
|
||||
if ($this->get_scope() == "host") {
|
||||
// this is a base module
|
||||
$return["is_base"] = true;
|
||||
|
@ -143,12 +145,6 @@ class sambaAccount extends baseModule {
|
|||
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
|
||||
*/
|
||||
function get_dependencies($scope) {
|
||||
|
|
|
@ -53,6 +53,19 @@ $Id$
|
|||
* 'attributes': this is a list of arrays with all ldap attributes wich are allowed for this account
|
||||
*/
|
||||
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
|
||||
function init($base) {
|
||||
/* Return an error if sambaGroupMapping should be created without
|
||||
|
@ -97,11 +110,6 @@ class sambaGroupMapping extends baseModule {
|
|||
return _('Samba 3');
|
||||
}
|
||||
|
||||
function can_manage($scope) {
|
||||
if ($scope == "group") return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
/* This function returns a list with all required modules
|
||||
*/
|
||||
function get_dependencies($scope) {
|
||||
|
|
|
@ -61,6 +61,8 @@ class sambaSamAccount extends baseModule {
|
|||
*/
|
||||
function get_metaData() {
|
||||
$return = array();
|
||||
// manages user and host accounts
|
||||
$return["account_types"] = array("user", "host");
|
||||
if ($this->get_scope() == "host") {
|
||||
// this is a base module
|
||||
$return["is_base"] = true;
|
||||
|
@ -143,12 +145,6 @@ class sambaSamAccount extends baseModule {
|
|||
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
|
||||
*/
|
||||
function get_dependencies($scope) {
|
||||
|
|
|
@ -53,6 +53,19 @@ $Id$
|
|||
* 'attributes': this is a list of arrays with all ldap attributes wich are allowed for this account
|
||||
*/
|
||||
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
|
||||
function init($base) {
|
||||
/* Return an error if shadowAccount should be created without
|
||||
|
@ -91,11 +104,6 @@ class shadowAccount extends baseModule {
|
|||
return _('Shadow');
|
||||
}
|
||||
|
||||
function can_manage($scope) {
|
||||
if ($scope == "user") return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
/* This function returns a list with all required modules
|
||||
*/
|
||||
function get_dependencies($scope) {
|
||||
|
|
Loading…
Reference in New Issue