allow to hide self service only modules

This commit is contained in:
Roland Gruber 2012-07-22 18:10:44 +00:00
parent 7cc3a97be9
commit 0893d176fe
4 changed files with 32 additions and 5 deletions

View File

@ -10,6 +10,7 @@
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-15"><title>Upgrade notes</title>
@ -27,8 +28,16 @@ This is a list of API changes for all LAM releases.
<br>
<h2>3.8 -&gt; 3.9</h2>Module interface:<br>
<ul>
<li><span style="font-weight: bold;">supportsAdminInterface()</span>: Can be used mark modules that only support the self service.<br>
</li>
</ul>
<br>
<h2>3.7 -&gt; 3.8<br>
</h2>Type interface:<br>
</h2>
Type interface:<br>
<ul>
<li><span style="font-weight: bold;">getTitleBarTitle()/getTitleBarSubtitle(): </span>changed
parameter from attribute array to accountContainer object.

View File

@ -1409,6 +1409,18 @@ abstract class baseModule {
// modules that use AJAX need to implement this function
}
/**
* Specifies if this module supports the LAM admin interface.
* The LAM admin interface are the pages that allow to manage e.g. users and groups.
* In contrast there is also the LAM self service interface. Most modules support
* the admin interface.
*
* @return boolean support admin interface
*/
public static function supportsAdminInterface() {
return true;
}
// helper functions

View File

@ -247,9 +247,10 @@ function check_module_conflicts($selected, $deps) {
* Returns an array with all available user module names
*
* @param string $scope account type (user, group, host)
* @param boolean $mustSupportAdminInterface module must support LAM admin interface (default: false)
* @return array list of possible modules
*/
function getAvailableModules($scope) {
function getAvailableModules($scope, $mustSupportAdminInterface = false) {
$dirname = substr(__FILE__, 0, strlen(__FILE__) - 12) . "/modules";
$dir = dir($dirname);
$return = array();
@ -258,7 +259,12 @@ function getAvailableModules($scope) {
if ((substr($entry, strlen($entry) - 4, 4) == '.inc') && is_file($dirname . '/'.$entry)) {
$entry = substr($entry, 0, strpos($entry, '.'));
$temp = new $entry($scope);
if ($temp->can_manage()) $return[] = $entry;
if ($mustSupportAdminInterface && !$entry::supportsAdminInterface()) {
continue;
}
if ($temp->can_manage()) {
$return[] = $entry;
}
}
return $return;
}

View File

@ -237,7 +237,7 @@ function config_showAccountModules($scope, $title, &$container) {
$conf = &$_SESSION['conf_config'];
$typeSettings = $conf->get_typeSettings();
// account modules
$available = getAvailableModules($scope);
$available = getAvailableModules($scope, true);
$selected = $typeSettings['modules_' . $scope];
if (isset($selected) && ($selected != '')) {
$selected = explode(',', $selected);
@ -332,7 +332,7 @@ function checkInput() {
$accountTypes = $conf->get_ActiveTypes();
for ($t = 0; $t < sizeof($accountTypes); $t++) {
$scope = $accountTypes[$t];
$available = getAvailableModules($scope);
$available = getAvailableModules($scope, true);
$selected_temp = $typeSettings['modules_' . $scope];
if (isset($selected_temp)) $selected_temp = explode(',', $selected_temp);
$selected = array();