From 8241515be5c1871630f1158d287bd33717e21ff7 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Wed, 1 Feb 2006 19:12:31 +0000 Subject: [PATCH] fixed documentation about save_attributes(), module_ready() and module_complete() --- lam/docs/devel/mod_accountPages.htm | 112 ++++++++++++++--------- lam/docs/devel/modules-specification.htm | 15 ++- 2 files changed, 79 insertions(+), 48 deletions(-) diff --git a/lam/docs/devel/mod_accountPages.htm b/lam/docs/devel/mod_accountPages.htm index f7d56ec4..cc3cb440 100644 --- a/lam/docs/devel/mod_accountPages.htm +++ b/lam/docs/devel/mod_accountPages.htm @@ -271,11 +271,16 @@ $this->inputCorrect = true;


-

4. Defining that your module is ready for LDAP add/modify

-Before a new account can be created or modified all modules are asked -if they are ready.
+

4. Defining that your module is ready for user input and LDAP +add/modify

+In most cases you will not need to implement these functions. The baseModule will return true for both functions.
+
+
+There are two functions which control the module status:


-There are two functions which control the module status:
The module_ready() function has to return true if the user may @@ -283,49 +288,64 @@ move to your module page. If it is false +
The second function is module_complete(). The user cannot do the LDAP operation if one or more modules return false. This defines if all needed input data for your module was entered.
+Use this function if you want to check that all required attributes are +set.

Example:

-The -ieee802Device -module uses a global variable to store the status: $this->inputCorrect. It is set -in process_attributes(). The -variable can be preset to true -because the MAC address is optional.
+The sambaSamAccount +module needs the user's uidNumber +and gidNumber before it can +accept input and the account needs a sambaSID +before it can be saved.

- @@ -334,23 +354,23 @@ correct.

5. Saving the LDAP attributes

+In most cases you will not have to implement this option if you use $this->attributes and $this->orig to manage the LDAP +attributes. The baseModule +will generate the save comands for you.
+
When all modules report that they are ready for LDAP add/modify and the user clicks on the add/modify button your module will be asked what changes have to be made.
-This is done in the function save_attributes() -which must be implemented by your module.
+This is done in the function save_attributes().

Example:

-The ieee802Device -module saves the attribute states in $attributes -and $orig and there are no -other DNs which may be modified. Therefore we can use the save_module_attributes() function in -accountContainer. You can -always access the current accountContainer -with $_SESSION[$this->base].
+The kolabUser module uses +this function to make sure that its object class is saved. Other +modules (e.g. quota) use it build the lamdaemon commands.

    /** used for -account pages, true if input data is correct */
-    var -$inputCorrect = true;
-
-    /**
-    * This function returns true if all needed settings -are done.
-    */
-    function module_complete() {
-        return $this->inputCorrect;
-    }
-   
-    /**
-    * Returns true if all settings on module page are -correct.
+
    /**
+    * This function is used to check if this module page +can be displayed.
+    * It returns false if a module depends on data from +other modules which was not yet entered.
+    *
+    * @return boolean true, if page can be displayed
    */
    function module_ready() {
-        return $this->inputCorrect;
+        if +($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]=='') +return false;
+        if +($_SESSION[$this->base]->module['posixAccount']->attributes['uidNumber'][0]=='') +return false;
+        if +($this->attributes['uid'][0]=='') return false;
+        return true;
    }
+
+    /**
+    * This functions is used to check if all settings +for this module have been made.
+    *
+    * @return boolean true, if settings are complete
+    */
+    function module_complete() {
+        if (!$this->module_ready()) +return false;
+        if +($this->attributes['sambaSID'][0] == '') return false;
+        return true;
+    }
+
@@ -375,11 +395,15 @@ removed from LDAP entry
    * <br>"modify" are attributes which have to been modified in LDAP entry
    */
-    functionsave_attributes() {
-        return -$_SESSION[$this->base]->save_module_attributes($this->attributes, -$this->orig);
+    function save_attributes() {
+        // add object class if needed
+        if +(!isset($this->attributes['objectClass']) || +!in_array('kolabInetOrgPerson', $this->attributes['objectClass'])) {
+            +$this->attributes['objectClass'][] = 'kolabInetOrgPerson';
+        }
+        return parent::save_attributes();
    }
diff --git a/lam/docs/devel/modules-specification.htm b/lam/docs/devel/modules-specification.htm index f90dbd99..4369a4dc 100644 --- a/lam/docs/devel/modules-specification.htm +++ b/lam/docs/devel/modules-specification.htm @@ -533,6 +533,9 @@ determines if the user can change to your module page or not.
The return value is true if your module accepts input, otherwise false.

+This function is implemented by the baseModule +which returns true as default.
+

2.2.3. module_complete


@@ -550,6 +553,9 @@ your module needs any additional input then set this to false. The user will be notified that your module needs more input.

+This function is implemented by the baseModule +which returns true as default.
+

2.2.4. getButtonStatus


@@ -697,10 +703,7 @@ separat.

-This function returns an array with changes which should be saved. If -all attributes are very simple are part of
-the dn of account it's possible to just call -$this->save_ldap_attributes($this->attributes, $this->orig).
+This function returns an array with changes which should be saved.
The return array has the following syntax: First index is the ldap dn which should be changed. Second
index is the kind of modification. Possible values are: 'add', @@ -713,6 +716,10 @@ first index is 'lamdaemon'. Second index is 'command'. Third index is the command
itself which should be executed by lamdaemon.

+This function is implemented by the baseModule +which builds the required comands from $this-attributes +and $this->orig.
+

2.2.12. delete_attributes