From e0d76141d5c375d869d4ed3225dac92bf96c025e Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Fri, 26 Aug 2005 08:53:16 +0000 Subject: [PATCH] added button status --- lam/HISTORY | 3 ++ lam/docs/devel/modules-specification.htm | 26 ++++++++++++++ lam/lib/baseModule.inc | 9 +++++ lam/lib/modules.inc | 7 ++-- lam/lib/modules/account.inc | 37 ++++++++++++++++---- lam/lib/modules/inetOrgPerson.inc | 27 +++++++++++++++ lam/lib/modules/nisMailAlias.inc | 29 ++++++++++++++++ lam/lib/modules/posixGroup.inc | 43 +++++++++++++++--------- 8 files changed, 158 insertions(+), 23 deletions(-) diff --git a/lam/HISTORY b/lam/HISTORY index d264f5ce..9f15c0ba 100644 --- a/lam/HISTORY +++ b/lam/HISTORY @@ -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 diff --git a/lam/docs/devel/modules-specification.htm b/lam/docs/devel/modules-specification.htm index 0a8e0f39..ec199b9e 100644 --- a/lam/docs/devel/modules-specification.htm +++ b/lam/docs/devel/modules-specification.htm @@ -550,6 +550,32 @@ your module needs any additional input then set this to false. The user will be notified that your module needs more input.

+

2.2.4. getButtonStatus
+

+
+ + + + + + +
function getButtonStatus()
+
+
+This function tells LAM if the module button on the account page is +visible and active.
+The function may return these values:
+ +

2.2.4. get_help


diff --git a/lam/lib/baseModule.inc b/lam/lib/baseModule.inc index 9dca1eb8..28b68eb4 100644 --- a/lam/lib/baseModule.inc +++ b/lam/lib/baseModule.inc @@ -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. diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index 9c062c04..50a24ccd 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -943,14 +943,17 @@ class accountContainer { // Loop for module // $x is used to count up tabindex for ($i=1; $iorder); $i++ ) { + $buttonStatus = $this->module[$this->order[$i]]->getButtonStatus(); + // skip hidden buttons + if ($buttonStatus == 'hidden') continue; // print normal button echo "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
"; $x++; - } + } if ($this->dn_orig!='') { echo "
subpage == 'finish') echo " disabled"; diff --git a/lam/lib/modules/account.inc b/lam/lib/modules/account.inc index 451b3c66..30cd95f7 100644 --- a/lam/lib/modules/account.inc +++ b/lam/lib/modules/account.inc @@ -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. diff --git a/lam/lib/modules/inetOrgPerson.inc b/lam/lib/modules/inetOrgPerson.inc index 549d30bd..c1c7c0db 100644 --- a/lam/lib/modules/inetOrgPerson.inc +++ b/lam/lib/modules/inetOrgPerson.inc @@ -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()); diff --git a/lam/lib/modules/nisMailAlias.inc b/lam/lib/modules/nisMailAlias.inc index adcc5b2d..cebf7677 100644 --- a/lam/lib/modules/nisMailAlias.inc +++ b/lam/lib/modules/nisMailAlias.inc @@ -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 { *
"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. * diff --git a/lam/lib/modules/posixGroup.inc b/lam/lib/modules/posixGroup.inc index 535d71e7..d8d6cc5d 100644 --- a/lam/lib/modules/posixGroup.inc +++ b/lam/lib/modules/posixGroup.inc @@ -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']))