added button status

This commit is contained in:
Roland Gruber 2005-08-26 08:53:16 +00:00
parent 8c44807366
commit e0d76141d5
8 changed files with 158 additions and 23 deletions

View File

@ -1,6 +1,9 @@
??? 0.5.rc3
- fixed bugs:
-> buttons on account page are better sorted
-> account module: some problems solved when used for user accounts
-> nisMailAlias: fixed missing RDN possibility
-> fixed conflicts when accounts were built with other base modules
18.08.2005 0.5.rc2

View File

@ -550,6 +550,32 @@ your module needs any additional input then set this to <span
style="font-weight: bold;">false</span>. The user will be notified
that your module needs more input.<br>
<br>
<h3>2.2.4. getButtonStatus<br>
</h3>
<br>
<table border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top; text-align: center;"><span
style="font-weight: bold;">function getButtonStatus()</span><br>
</td>
</tr>
</tbody>
</table>
<br>
This function tells LAM if the module button on the account page is
visible and active.<br>
The function may return these values:<br>
<ul>
<li><span style="font-weight: bold;">enabled:</span> button is
visible and active</li>
<li><span style="font-weight: bold;">disabled:</span> button is
visible and deactivated (greyed)</li>
<li><span style="font-weight: bold;">hidden:</span> no button will be
shown<br>
</li>
</ul>
<br>
<h3>2.2.4. get_help</h3>
<br>
<table border="0" cellpadding="2" cellspacing="2">

View File

@ -539,6 +539,15 @@ class baseModule {
function module_complete() {
return true;
}
/**
* Controls if the module button the account page is visible and activated.
*
* @return string status ("enabled", "disabled", "hidden")
*/
function getButtonStatus() {
return "enabled";
}
/**
* Checks if the attribute values follow the LDAP syntax.

View File

@ -943,14 +943,17 @@ class accountContainer {
// Loop for module
// $x is used to count up tabindex
for ($i=1; $i<count($this->order); $i++ ) {
$buttonStatus = $this->module[$this->order[$i]]->getButtonStatus();
// skip hidden buttons
if ($buttonStatus == 'hidden') continue;
// print normal button
echo "<input style=\"width:" . $buttonWidth ."em;margin:2px;\" name=\"form_main_".$this->order[$i]."\" type=\"submit\" value=\"";
echo $this->module[$this->order[$i]]->get_alias();
echo "\" tabindex=$x";
if ($this->subpage == 'finish') echo " disabled";
if (($buttonStatus == 'disabled') || $this->subpage == 'finish') echo " disabled";
echo ">\n<br>";
$x++;
}
}
if ($this->dn_orig!='') {
echo "<br><input style=\"width:" . $buttonWidth ."em;margin:2px;\" name=\"form_main_reset\" type=\"submit\" value=\"" . _('Reset changes') . "\"";
if ($this->subpage == 'finish') echo " disabled";

View File

@ -119,10 +119,27 @@ class account extends baseModule {
* @return boolean true if LDAP operation can be done
*/
function module_complete() {
if ($this->attributes['uid'][0] == '') return false;
$modules = $_SESSION['config']->get_AccountModules($this->get_scope());
if (!in_array('posixAccount', $modules) && $this->attributes['uid'][0] == '') return false;
return true;
}
/**
* Controls if the module button the account page is visible and activated.
*
* @return string status ("enabled", "disabled", "hidden")
*/
function getButtonStatus() {
if (!$_SESSION[$this->base]->isNewAccount) {
// check if account is based on our object class
$objectClasses = $_SESSION[$this->base]->attributes_orig['objectClass'];
if (is_array($objectClasses) && !in_array('account', $objectClasses)) {
return "disabled";
}
}
return "enabled";
}
/**
* This function returns a list of all possible pages of this module.
*
@ -156,11 +173,15 @@ class account extends baseModule {
* lamdaemon are lamdaemon commands to modify homedir, quotas, ...
*/
function save_attributes() {
// skip saving if account is based on another structural object class
if (!$_SESSION[$this->base]->isNewAccount && !in_array('account', $_SESSION[$this->base]->attributes_orig['objectClass'])) {
return array();
}
// Get easy attributes
$return = $_SESSION[$this->base]->save_module_attributes($this->attributes, $this->orig);
// Return attributes
return $return;
}
}
function delete_attributes($post) {
return 0;
@ -171,11 +192,15 @@ class account extends baseModule {
function process_attributes(&$post) {
// Load attributes
$this->attributes['description'][0] = $post['description'];
$this->attributes['uid'][0] = $post['uid'];
if (!get_preg($this->attributes['uid'][0], '!upper')) $triggered_messages['uid'][] = $this->messages['uid'][2];
if (!get_preg($this->attributes['uid'][0], 'username')) $triggered_messages['uid'][] = $this->messages['uid'][3];
return 0;
// user name if no posixAccount
$modules = $_SESSION['config']->get_AccountModules($this->get_scope());
if (!in_array('posixAccount', $modules)) {
$this->attributes['uid'][0] = $post['uid'];
if (!get_preg($this->attributes['uid'][0], '!upper')) $triggered_messages['uid'][] = $this->messages['uid'][2];
if (!get_preg($this->attributes['uid'][0], 'username')) $triggered_messages['uid'][] = $this->messages['uid'][3];
}
return 0;
}
/* This function will create the html-page
* to show a page with all attributes.

View File

@ -350,10 +350,33 @@ class inetOrgPerson extends baseModule {
* @return boolean true, if all is ok
*/
function module_complete() {
if (!$_SESSION[$this->base]->isNewAccount) {
// check if account is based on our object class
$objectClasses = $_SESSION[$this->base]->attributes_orig['objectClass'];
if (is_array($objectClasses) && !in_array('inetOrgPerson', $objectClasses)) {
return true;
}
}
if ($this->attributes['sn'][0] == '') return false;
return true;
}
/**
* Controls if the module button the account page is visible and activated.
*
* @return string status ("enabled", "disabled", "hidden")
*/
function getButtonStatus() {
if (!$_SESSION[$this->base]->isNewAccount) {
// check if account is based on our object class
$objectClasses = $_SESSION[$this->base]->attributes_orig['objectClass'];
if (is_array($objectClasses) && !in_array('inetOrgPerson', $objectClasses)) {
return "disabled";
}
}
return "enabled";
}
/* This function returns a list of all html-pages in module
* This is usefull for mass upload and pdf-files
* because lam can walk trough all pages itself and do some
@ -372,6 +395,10 @@ class inetOrgPerson extends baseModule {
* lamdaemon are lamdaemon commands to modify homedir, quotas, ...
*/
function save_attributes() {
// skip saving if account is based on another structural object class
if (!$_SESSION[$this->base]->isNewAccount && !in_array('inetOrgPerson', $_SESSION[$this->base]->attributes_orig['objectClass'])) {
return array();
}
$return = $_SESSION[$this->base]->save_module_attributes($this->attributes, $this->orig);
// do not set password if posixAccount is active
$modules = $_SESSION['config']->get_AccountModules($this->get_scope());

View File

@ -52,6 +52,8 @@ class nisMailAlias extends baseModule {
$return["ldap_filter"] = array('or' => "(objectClass=nisMailAlias)");
// alias name
$return["alias"] = _("Mail aliases");
// RDN attribute
$return["RDN"] = array("cn" => "normal");
// module dependencies
$return['dependencies'] = array('depends' => array(), 'conflicts' => array());
// help Entries
@ -144,6 +146,10 @@ class nisMailAlias extends baseModule {
* <br>"modify" are attributes which have to been modified in LDAP entry
*/
function save_attributes() {
// skip saving if account is based on another structural object class
if (!$_SESSION[$this->base]->isNewAccount && !in_array('nisMailAlias', $_SESSION[$this->base]->attributes_orig['objectClass'])) {
return array();
}
return $_SESSION[$this->base]->save_module_attributes($this->attributes, $this->orig);
}
@ -244,9 +250,32 @@ class nisMailAlias extends baseModule {
* This function returns true if all needed settings are done.
*/
function module_complete() {
if (!$_SESSION[$this->base]->isNewAccount) {
// check if account is based on our object class
$objectClasses = $_SESSION[$this->base]->attributes_orig['objectClass'];
if (is_array($objectClasses) && !in_array('nisMailAlias', $objectClasses)) {
return true;
}
}
return $this->inputCorrect;
}
/**
* Controls if the module button the account page is visible and activated.
*
* @return string status ("enabled", "disabled", "hidden")
*/
function getButtonStatus() {
if (!$_SESSION[$this->base]->isNewAccount) {
// check if account is based on our object class
$objectClasses = $_SESSION[$this->base]->attributes_orig['objectClass'];
if (is_array($objectClasses) && !in_array('nisMailAlias', $objectClasses)) {
return "disabled";
}
}
return "enabled";
}
/**
* In this function the LDAP account is built up.
*

View File

@ -48,16 +48,6 @@ class posixGroup extends baseModule {
// change gids of users and hosts?
var $changegids;
/**
* Creates a new posixGroup object.
*
* @param string $scope account type
*/
function posixGroup($scope) {
// call parent constructor
parent::baseModule($scope);
}
/**
* In this function the LDAP account is built up.
@ -225,11 +215,6 @@ class posixGroup extends baseModule {
}
function display_html_delete(&$post) {
// Get list of primary groupmembers.
return 0;
}
/**
* Displays selections to add or remove users from current group.
*
@ -504,12 +489,36 @@ class posixGroup extends baseModule {
* if all needed settings are done
*/
function module_complete() {
if (!$_SESSION[$this->base]->isNewAccount) {
// check if account is based on our object class
$objectClasses = $_SESSION[$this->base]->attributes_orig['objectClass'];
if (is_array($objectClasses) && !in_array('posixGroup', $objectClasses)) {
return true;
}
}
if ($this->attributes['cn'][0] == '') return false;
if ($this->attributes['gidNumber'][0] == '') return false;
return true;
}
/**
* Controls if the module button the account page is visible and activated.
*
* @return string status ("enabled", "disabled", "hidden")
*/
function getButtonStatus() {
if (!$_SESSION[$this->base]->isNewAccount) {
// check if account is based on our object class
$objectClasses = $_SESSION[$this->base]->attributes_orig['objectClass'];
if (is_array($objectClasses) && !in_array('posixGroup', $objectClasses)) {
return "disabled";
}
}
return "enabled";
}
/* This function returns a list of all html-pages in module
* This is usefull for mass upload and pdf-files
* because lam can walk trough all pages itself and do some
@ -728,6 +737,10 @@ class posixGroup extends baseModule {
* modify are attributes which have to been modified in ldap entry
*/
function save_attributes() {
// skip saving if account is based on another structural object class
if (!$_SESSION[$this->base]->isNewAccount && !in_array('posixGroup', $_SESSION[$this->base]->attributes_orig['objectClass'])) {
return array();
}
$return = $_SESSION[$this->base]->save_module_attributes($this->attributes, $this->orig);
// unset password when needed
if (isset($return[$_SESSION[$this->base]->dn]['add']['userPassword']))