254 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			HTML
		
	
	
	
		
		
			
		
	
	
			254 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			HTML
		
	
	
	
|  | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | ||
|  | <html> | ||
|  | <head> | ||
|  |   <title>Module HowTo - Account profiles</title> | ||
|  |   <link rel="stylesheet" type="text/css" href="style/layout.css"> | ||
|  | </head> | ||
|  | <body> | ||
|  | 
 | ||
|  | <p align="center"> | ||
|  | <script type="text/javascript"><!-- | ||
|  | google_ad_client = "pub-4179059556107138"; | ||
|  | google_alternate_ad_url = "http://lam.sourceforge.net/google_adsense_script.html"; | ||
|  | google_ad_width = 728; | ||
|  | google_ad_height = 90; | ||
|  | google_ad_format = "728x90_as"; | ||
|  | google_ad_type = "text_image"; | ||
|  | google_ad_channel =""; | ||
|  | google_page_url = document.location; | ||
|  | google_color_border = "EEEEEE"; | ||
|  | google_color_bg = "FFFFFF"; | ||
|  | google_color_link = "0000FF"; | ||
|  | google_color_url = "008000"; | ||
|  | google_color_text = "000000"; | ||
|  | //--></script> | ||
|  | <script type="text/javascript" | ||
|  |   src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> | ||
|  | </script> | ||
|  | </p> | ||
|  | 
 | ||
|  | 
 | ||
|  | <div style="text-align: center;"> | ||
|  | <h1>Module HowTo - Account profiles<br> | ||
|  | </h1> | ||
|  | <div style="text-align: left;"><br> | ||
|  | Account profiles make it easy to set default values for new accounts | ||
|  | and even to reset an existing account to default values.<br> | ||
|  | Your module should provide the possibility to define default values for | ||
|  | all attributes which do not differ for each account.<br> | ||
|  | </div> | ||
|  | <div style="text-align: left;"><br> | ||
|  | <h2>1. Defining possible profile options<br> | ||
|  | </h2> | ||
|  | The first step to account profiles is defining the attributes for which | ||
|  | the user can set default values. You will also have to define the type | ||
|  | (text, checkbox, ...) of the profile options.<br> | ||
|  | The profile editor then will display a fieldset for each module | ||
|  | containing its profile options.<br> | ||
|  | <br> | ||
|  | The profile options are specified with <span style="font-weight: bold;">get_profileOptions()</span> | ||
|  | or <span style="font-weight: bold;">meta['profile_options']</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;">inetOrgPerson</span> | ||
|  | module has only two attributes which may be set to a default value: job | ||
|  | title and employee type.<br> | ||
|  | The other attributes are account specific and not useful as profile | ||
|  | options.<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;">    /**<br> | ||
|  |     * Returns meta data that is interpreted by parent | ||
|  | class<br> | ||
|  |     *<br> | ||
|  |     * @return array array with meta data<br> | ||
|  |     */<br> | ||
|  |     <span style="font-weight: bold;">function</span> | ||
|  | get_metaData() {<br> | ||
|  |         $return = array();<br> | ||
|  |         // profile elements<br> | ||
|  |         $return[<span | ||
|  |  style="color: rgb(255, 0, 0);">'profile_options'</span>] = array(<br> | ||
|  |             array(<br> | ||
|  |             | ||
|  |     0 => array('kind' => 'text', 'text' => | ||
|  | _('Job title') . ":"),<br> | ||
|  |             | ||
|  |     1 => array('kind' => 'input', 'name' => | ||
|  | 'inetOrgPerson_title', 'type' => 'text', 'size' => '30', | ||
|  | 'maxlength' => '255'),<br> | ||
|  |             | ||
|  |     2 => array('kind' => 'help', 'value' => | ||
|  | 'title')),<br> | ||
|  |             array(<br> | ||
|  |             | ||
|  |     0 => array('kind' => 'text', 'text' => | ||
|  | _('Employee type') . ":"),<br> | ||
|  |             | ||
|  |     1 => array('kind' => 'input', 'name' => | ||
|  | 'inetOrgPerson_employeeType', 'type' => 'text', 'size' => '30', | ||
|  | 'maxlength' => '255'),<br> | ||
|  |             | ||
|  |     2 => array('kind' => 'help', 'value' => | ||
|  | 'employeeType'))<br> | ||
|  |         );<br> | ||
|  |         [...]<br> | ||
|  |       </td> | ||
|  |     </tr> | ||
|  |   </tbody> | ||
|  | </table> | ||
|  | <br> | ||
|  | This defines two text boxes in the profile editor, one for the job | ||
|  | title and one for the employee type.<br> | ||
|  | Your profile options should also provide a help link if the description | ||
|  | of the input element might be not enough.<br> | ||
|  | <br> | ||
|  | <br> | ||
|  | <h2>2. Checking user input</h2> | ||
|  | Probably you also want to check if the input data is syntactically | ||
|  | correct.<br> | ||
|  | The <span style="font-style: italic;">baseModule</span> already | ||
|  | provides different checks which can be activated with <span | ||
|  |  style="font-style: italic;">meta data</span>. However you can also do | ||
|  | the checking in the module.<br> | ||
|  | Implementing the function <span style="font-weight: bold;">check_profileOptions()</span> | ||
|  | in your module will allow you to do the checks yourself. Basic checks | ||
|  | can be defined with <span style="font-weight: bold;">meta['profile_checks']</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;">inetOrgPerson</span> module only | ||
|  | needs some regular expression checks on the input. This can be done by | ||
|  | the <span style="font-style: italic;">baseModule</span>.<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;">    /**<br> | ||
|  |     * Returns meta data that is interpreted by parent | ||
|  | class<br> | ||
|  |     *<br> | ||
|  |     * @return array array with meta data<br> | ||
|  |     */<br> | ||
|  |     <span style="font-weight: bold;">function</span> | ||
|  | get_metaData() {<br> | ||
|  |         $return = array();<br> | ||
|  |         // profile checks<br> | ||
|  |         $return[<span | ||
|  |  style="color: rgb(255, 0, 0);">'profile_checks'</span>][<span | ||
|  |  style="color: rgb(255, 0, 0);">'inetOrgPerson_title'</span>] = array(<br> | ||
|  |             'type' => | ||
|  | 'ext_preg',<br> | ||
|  |             'regex' => | ||
|  | 'title',<br> | ||
|  |            | ||
|  |  'error_message' => $this->messages['title'][0]);<br> | ||
|  |         $return[<span | ||
|  |  style="color: rgb(255, 0, 0);">'profile_checks'</span>][<span | ||
|  |  style="color: rgb(255, 0, 0);">'inetOrgPerson_employeeType'</span>] = | ||
|  | array(<br> | ||
|  |             'type' => | ||
|  | 'ext_preg',<br> | ||
|  |             'regex' => | ||
|  | 'employeeType',<br> | ||
|  |            | ||
|  |  'error_message' => $this->messages['employeeType'][0]);<br> | ||
|  |         [...]<br> | ||
|  |       </td> | ||
|  |     </tr> | ||
|  |   </tbody> | ||
|  | </table> | ||
|  | <br> | ||
|  | The type <span style="font-weight: bold;">"ext_preg"</span> means that | ||
|  | the <span style="font-style: italic;">baseModule</span> will use the <span | ||
|  |  style="font-style: italic;">get_preg()</span> function in <span | ||
|  |  style="font-style: italic;">lib/account.inc</span> for the syntax | ||
|  | check. This function already contains regular expressions for the most | ||
|  | common cases.<br> | ||
|  | <br> | ||
|  | <br> | ||
|  | <h2>3. Loading an account profile</h2> | ||
|  | When an account profile is loaded the modules have to check what values | ||
|  | they need for their internal data structures.<br> | ||
|  | The <span style="font-style: italic;">baseModule</span> already | ||
|  | provides the possibility to store profile values directly as LDAP | ||
|  | attributes in <span style="font-style: italic;">$this->attributes</span>. | ||
|  | This is done by defining profile-attribute mappings in <span | ||
|  |  style="font-weight: bold;">meta['profile_mappings']</span>.<br> | ||
|  | If you have other values than LDAP attributes or need some post | ||
|  | processing you can implement the function <span | ||
|  |  style="font-weight: bold;">load_profile()</span> in your module.<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;">inetLocalMailRecipient</span> | ||
|  | module only | ||
|  | needs a static mapping. This can be done by | ||
|  | the <span style="font-style: italic;">baseModule</span>.<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;">    /**<br> | ||
|  |     * Returns meta data that is interpreted by parent | ||
|  | class<br> | ||
|  |     *<br> | ||
|  |     * @return array array with meta data<br> | ||
|  |     */<br> | ||
|  |     <span style="font-weight: bold;">function</span> | ||
|  | get_metaData() {<br> | ||
|  |         $return = array();<br> | ||
|  |         // profile mappings<br> | ||
|  |         $return[<span | ||
|  |  style="color: rgb(255, 0, 0);">'profile_mappings'</span>] = array(<br> | ||
|  |            | ||
|  |  'inetLocalMailRecipient_host' => 'mailHost'<br> | ||
|  |         );<br> | ||
|  |         [...]<br> | ||
|  |       </td> | ||
|  |     </tr> | ||
|  |   </tbody> | ||
|  | </table> | ||
|  | <br> | ||
|  | In this example the profile option "inetLocalMailRecipient_host" is | ||
|  | stored as LDAP attribute "mailHost".<br> | ||
|  | <br> | ||
|  | <br> | ||
|  | <span style="font-weight: bold;"></span> | ||
|  | <h2><span style="font-weight: bold;"></span></h2> | ||
|  | </div> | ||
|  | </div> | ||
|  | 
 | ||
|  | <p align="center"> | ||
|  | <script type="text/javascript"><!-- | ||
|  | google_ad_client = "pub-4179059556107138"; | ||
|  | google_alternate_ad_url = "http://lam.sourceforge.net/google_adsense_script.html"; | ||
|  | google_ad_width = 728; | ||
|  | google_ad_height = 90; | ||
|  | google_ad_format = "728x90_as"; | ||
|  | google_ad_type = "text_image"; | ||
|  | google_ad_channel =""; | ||
|  | google_page_url = document.location; | ||
|  | google_color_border = "EEEEEE"; | ||
|  | google_color_bg = "FFFFFF"; | ||
|  | google_color_link = "0000FF"; | ||
|  | google_color_url = "008000"; | ||
|  | google_color_text = "000000"; | ||
|  | //--></script> | ||
|  | <script type="text/javascript" | ||
|  |   src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> | ||
|  | </script> | ||
|  | </p> | ||
|  | 
 | ||
|  | </body> | ||
|  | </html> |