fixed documentation about save_attributes(), module_ready() and module_complete()
This commit is contained in:
		
							parent
							
								
									ede8c042a0
								
							
						
					
					
						commit
						8241515be5
					
				| 
						 | 
				
			
			@ -271,11 +271,16 @@ $this->inputCorrect = true;<br>
 | 
			
		|||
</table>
 | 
			
		||||
<br>
 | 
			
		||||
<br>
 | 
			
		||||
<h2>4. Defining that your module is ready for LDAP add/modify</h2>
 | 
			
		||||
Before a new account can be created or modified all modules are asked
 | 
			
		||||
if they are ready.<br>
 | 
			
		||||
<h2>4. Defining that your module is ready for user input and LDAP
 | 
			
		||||
add/modify</h2>
 | 
			
		||||
In most cases you will not need to implement these functions. The <span
 | 
			
		||||
 style="font-style: italic;">baseModule</span> will return <span
 | 
			
		||||
 style="font-style: italic;">true</span> for both functions.<br>
 | 
			
		||||
<br>
 | 
			
		||||
<span style="text-decoration: underline;"><br>
 | 
			
		||||
There are two functions which control the module status:</span><br
 | 
			
		||||
 style="text-decoration: underline;">
 | 
			
		||||
<br>
 | 
			
		||||
There are two functions which control the module status:<br>
 | 
			
		||||
The <span style="font-weight: bold;">module_ready()</span> function
 | 
			
		||||
has to
 | 
			
		||||
return <span style="font-style: italic;">true</span> if the user may
 | 
			
		||||
| 
						 | 
				
			
			@ -283,49 +288,64 @@ move to your module page. If it is <span style="font-style: italic;">false</span
 | 
			
		|||
the user will be shown an error message that your module is not yet
 | 
			
		||||
ready. You can use this if your module depends on input data from other
 | 
			
		||||
modules (e.g. you need the user name from posixAccount first).<br>
 | 
			
		||||
<br>
 | 
			
		||||
The second function is
 | 
			
		||||
<span style="font-weight: bold;">module_complete()</span>. The user
 | 
			
		||||
cannot do the LDAP operation if one or more modules return <span
 | 
			
		||||
 style="font-style: italic;">false</span>. This defines if all needed
 | 
			
		||||
input data for your module was entered.<br>
 | 
			
		||||
Use this function if you want to check that all required attributes are
 | 
			
		||||
set.<br>
 | 
			
		||||
<br>
 | 
			
		||||
<span style="font-weight: bold; text-decoration: underline;">Example:</span><br
 | 
			
		||||
 style="font-weight: bold; text-decoration: underline;">
 | 
			
		||||
<br>
 | 
			
		||||
The
 | 
			
		||||
<span style="font-style: italic;">ieee802Device</span>
 | 
			
		||||
module uses a global variable to store the status: <span
 | 
			
		||||
 style="font-style: italic;">$this->inputCorrect</span>. It is set
 | 
			
		||||
in <span style="font-style: italic;">process_attributes()</span>. The
 | 
			
		||||
variable can be preset to <span style="font-style: italic;">true</span>
 | 
			
		||||
because the MAC address is optional.<br>
 | 
			
		||||
The <span style="font-style: italic;">sambaSamAccount</span>
 | 
			
		||||
module needs the user's <span style="font-style: italic;">uidNumber</span>
 | 
			
		||||
and <span style="font-style: italic;">gidNumber</span> before it can
 | 
			
		||||
accept input and the account needs a <span style="font-style: italic;">sambaSID</span>
 | 
			
		||||
before it can be saved.<br>
 | 
			
		||||
<br>
 | 
			
		||||
<table style="width: 100%; text-align: left;" class="mod-code"
 | 
			
		||||
 border="0" cellpadding="2" cellspacing="2">
 | 
			
		||||
  <tbody>
 | 
			
		||||
    <tr>
 | 
			
		||||
      <td style="vertical-align: top;">    /** used for
 | 
			
		||||
account pages, true if input data is correct */<br>
 | 
			
		||||
    <span style="font-weight: bold;">var</span>
 | 
			
		||||
$inputCorrect = true;<br>
 | 
			
		||||
      <br>
 | 
			
		||||
    /**<br>
 | 
			
		||||
    * This function returns true if all needed settings
 | 
			
		||||
are done.<br>
 | 
			
		||||
    */<br>
 | 
			
		||||
    <span style="font-weight: bold;">function</span> <span
 | 
			
		||||
 style="color: rgb(255, 0, 0);">module_complete</span>() {<br>
 | 
			
		||||
        return $this->inputCorrect;<br>
 | 
			
		||||
    }<br>
 | 
			
		||||
    <br>
 | 
			
		||||
    /**<br>
 | 
			
		||||
    * Returns true if all settings on module page are
 | 
			
		||||
correct.<br>
 | 
			
		||||
      <td style="vertical-align: top;">    /**<br>
 | 
			
		||||
    * This function is used to check if this module page
 | 
			
		||||
can be displayed.<br>
 | 
			
		||||
    * It returns false if a module depends on data from
 | 
			
		||||
other modules which was not yet entered.<br>
 | 
			
		||||
    *<br>
 | 
			
		||||
    * @return boolean true, if page can be displayed<br>
 | 
			
		||||
    */<br>
 | 
			
		||||
    <span style="font-weight: bold;">function</span> <span
 | 
			
		||||
 style="color: rgb(255, 0, 0);">module_ready</span>() {<br>
 | 
			
		||||
        return $this->inputCorrect;<br>
 | 
			
		||||
        if
 | 
			
		||||
($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]=='')
 | 
			
		||||
return false;<br>
 | 
			
		||||
        if
 | 
			
		||||
($_SESSION[$this->base]->module['posixAccount']->attributes['uidNumber'][0]=='')
 | 
			
		||||
return false;<br>
 | 
			
		||||
        if
 | 
			
		||||
($this->attributes['uid'][0]=='') return false;<br>
 | 
			
		||||
        return true;<br>
 | 
			
		||||
    }<br>
 | 
			
		||||
      <br>
 | 
			
		||||
    /**<br>
 | 
			
		||||
    * This functions is used to check if all settings
 | 
			
		||||
for this module have been made.<br>
 | 
			
		||||
    *<br>
 | 
			
		||||
    * @return boolean true, if settings are complete<br>
 | 
			
		||||
    */<br>
 | 
			
		||||
    <span style="font-weight: bold;">function</span> <span
 | 
			
		||||
 style="color: rgb(255, 0, 0);">module_complete</span>() {<br>
 | 
			
		||||
        if (!$this->module_ready())
 | 
			
		||||
return false;<br>
 | 
			
		||||
        if
 | 
			
		||||
($this->attributes['sambaSID'][0] == '') return false;<br>
 | 
			
		||||
        return true;<br>
 | 
			
		||||
    }<br>
 | 
			
		||||
      <br>
 | 
			
		||||
      </td>
 | 
			
		||||
    </tr>
 | 
			
		||||
  </tbody>
 | 
			
		||||
| 
						 | 
				
			
			@ -334,23 +354,23 @@ correct.<br>
 | 
			
		|||
<br>
 | 
			
		||||
<h2>5. Saving the LDAP attributes<br>
 | 
			
		||||
</h2>
 | 
			
		||||
In most cases you will not have to implement this option if you use <span
 | 
			
		||||
 style="font-weight: bold;">$this->attributes</span> and <span
 | 
			
		||||
 style="font-weight: bold;">$this->orig</span> to manage the LDAP
 | 
			
		||||
attributes. The <span style="font-style: italic;">baseModule</span>
 | 
			
		||||
will generate the save comands for you.<br>
 | 
			
		||||
<br>
 | 
			
		||||
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.<br>
 | 
			
		||||
This is done in the function <span style="font-weight: bold;">save_attributes()</span>
 | 
			
		||||
which must be implemented by your module.<br>
 | 
			
		||||
This is done in the function <span style="font-weight: bold;">save_attributes()</span>.<br>
 | 
			
		||||
<br>
 | 
			
		||||
<span style="font-weight: bold; text-decoration: underline;">Example:</span><br
 | 
			
		||||
 style="font-weight: bold; text-decoration: underline;">
 | 
			
		||||
<br>
 | 
			
		||||
The <span style="font-style: italic;">ieee802Device</span>
 | 
			
		||||
module saves the attribute states in <span style="font-style: italic;">$attributes</span>
 | 
			
		||||
and <span style="font-style: italic;">$orig</span> and there are no
 | 
			
		||||
other DNs which may be modified. Therefore we can use the <span
 | 
			
		||||
 style="font-weight: bold;">save_module_attributes()</span> function in
 | 
			
		||||
<span style="font-weight: bold;">accountContainer</span>. You can
 | 
			
		||||
always access the current <span style="font-weight: bold;">accountContainer</span>
 | 
			
		||||
with <span style="font-weight: bold;">$_SESSION[$this->base]</span>.<br>
 | 
			
		||||
The <span style="font-style: italic;">kolabUser</span> module uses
 | 
			
		||||
this function to make sure that its object class is saved. Other
 | 
			
		||||
modules (e.g. quota) use it build the lamdaemon commands.<br>
 | 
			
		||||
<br>
 | 
			
		||||
<table style="width: 100%; text-align: left;" class="mod-code"
 | 
			
		||||
 border="0" cellpadding="2" cellspacing="2">
 | 
			
		||||
| 
						 | 
				
			
			@ -375,11 +395,15 @@ removed from LDAP entry<br>
 | 
			
		|||
    * <br>"modify" are attributes which have to
 | 
			
		||||
been modified in LDAP entry<br>
 | 
			
		||||
    */<br>
 | 
			
		||||
    <span style="font-weight: bold;">function</span> <span
 | 
			
		||||
 style="color: rgb(255, 0, 0);">save_attributes</span>() {<br>
 | 
			
		||||
        return
 | 
			
		||||
$_SESSION[$this->base]->save_module_attributes($this->attributes,
 | 
			
		||||
$this->orig);<br>
 | 
			
		||||
    function save_attributes() {<br>
 | 
			
		||||
        // add object class if needed<br>
 | 
			
		||||
        if
 | 
			
		||||
(!isset($this->attributes['objectClass']) ||
 | 
			
		||||
!in_array('kolabInetOrgPerson', $this->attributes['objectClass'])) {<br>
 | 
			
		||||
           
 | 
			
		||||
$this->attributes['objectClass'][] = 'kolabInetOrgPerson';<br>
 | 
			
		||||
        }<br>
 | 
			
		||||
        return parent::save_attributes();<br>
 | 
			
		||||
    }<br>
 | 
			
		||||
      </td>
 | 
			
		||||
    </tr>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -533,6 +533,9 @@ determines if the user can change to your module page or not.<br>
 | 
			
		|||
The return value is <span style="font-weight: bold;">true</span> if
 | 
			
		||||
your module accepts input, otherwise <span style="font-weight: bold;">false</span>.<br>
 | 
			
		||||
<br>
 | 
			
		||||
This function is implemented by the <span style="font-style: italic;">baseModule</span>
 | 
			
		||||
which returns <span style="font-weight: bold;">true</span> as default.<br>
 | 
			
		||||
<br>
 | 
			
		||||
<h3>2.2.3. module_complete</h3>
 | 
			
		||||
<br>
 | 
			
		||||
<table border="0" cellpadding="2" cellspacing="2">
 | 
			
		||||
| 
						 | 
				
			
			@ -550,6 +553,9 @@ 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>
 | 
			
		||||
This function is implemented by the <span style="font-style: italic;">baseModule</span>
 | 
			
		||||
which returns <span style="font-weight: bold;">true</span> as default.<br>
 | 
			
		||||
<br>
 | 
			
		||||
<h3>2.2.4. getButtonStatus<br>
 | 
			
		||||
</h3>
 | 
			
		||||
<br>
 | 
			
		||||
| 
						 | 
				
			
			@ -697,10 +703,7 @@ separat.<br>
 | 
			
		|||
  </tbody>
 | 
			
		||||
</table>
 | 
			
		||||
<br>
 | 
			
		||||
This function returns an array with changes which should be saved. If
 | 
			
		||||
all attributes are very simple are part of<br>
 | 
			
		||||
the dn of account it's possible to just call
 | 
			
		||||
$this->save_ldap_attributes($this->attributes, $this->orig).<br>
 | 
			
		||||
This function returns an array with changes which should be saved.<br>
 | 
			
		||||
The return array has the following syntax: First index is the ldap dn
 | 
			
		||||
which should be changed. Second<br>
 | 
			
		||||
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<br>
 | 
			
		||||
itself which should be executed by lamdaemon.<br>
 | 
			
		||||
<br>
 | 
			
		||||
This function is implemented by the <span style="font-style: italic;">baseModule</span>
 | 
			
		||||
which builds the required comands from <span style="font-weight: bold;">$this-attributes</span>
 | 
			
		||||
and <span style="font-weight: bold;">$this->orig</span>.<br>
 | 
			
		||||
<br>
 | 
			
		||||
<h3>2.2.12. delete_attributes<br>
 | 
			
		||||
</h3>
 | 
			
		||||
<br>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue