Debian Codegraph @

docs/devel/mod_config.htm

raw symbols SCIP
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html lang="en"><head><title>Module HowTo - Configuration options</title>
3
4
5 <link rel="stylesheet" type="text/css" href="style/layout.css">
6 <link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico"></head><body>
7 <h1>Module HowTo - Configuration options<br>
8 </h1>
9 <div style="text-align: left;"><br>
10 There might be situations where you want to give the user the
11 possibility to make general settings which are not useful to place on
12 the account detail pages or profile editor.<br>
13 Therefore LAM allows the modules to define their own configuration
14 options. E.g. the <span style="font-style: italic;">posixAccount</span>
15 module uses this to define the ranges for the UIDs.<br>
16 LAM will display your configuration options only if the user also
17 selected your module.<br>
18 </div>
19 <div style="text-align: left;"><br>
20 <h2>1. Defining configuration options<br>
21 </h2>
22 First you have to define what options you want to offer the user. LAM
23 will display all options in one fieldset for each module. Please notice
24 that there will be no separation on account types if you module is
25 suitable for different account types.<br>
26 <br>
27 The configuration options are specified with <span style="font-weight: bold;">get_configOptions()</span>
28 or <span style="font-weight: bold;">meta['config_options']</span>.<br>
29 <br>
30 <span style="font-weight: bold; text-decoration: underline;">Example:</span><br style="font-weight: bold; text-decoration: underline;">
31 <br>
32 The <span style="font-style: italic;">posixGroup</span> module offers several configuration options including the min/maximum values for GIDs.<br>
33 <br>
34 <div class="mod-code">
35 &nbsp;&nbsp;&nbsp; * Returns meta data that is interpreted by parent
36 class<br>
37 &nbsp;&nbsp;&nbsp; *<br>
38 &nbsp;&nbsp;&nbsp; * @return array array with meta data<br>
39 &nbsp;&nbsp;&nbsp; */<br>
40 &nbsp;&nbsp;&nbsp;<span style="font-weight: bold;"> function</span>
41 get_metaData() {<br>
42 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $return = array();<br>
43 &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; // configuration options<br>
44 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $configContainer = new htmlTable();<br>
45 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $configContainer-&gt;addElement(new htmlSubTitle(_("Groups")), true);<br>
46 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $minGidInput = new
47 htmlTableExtendedInputField(_('Minimum GID number'),
48 'posixGroup_minGID', null, 'minMaxGID');<br>
49 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $minGidInput-&gt;setRequired(true);<br>
50 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $configContainer-&gt;addElement($minGidInput, true);<br>
51 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $maxGidInput = new
52 htmlTableExtendedInputField(_('Maximum GID number'),
53 'posixGroup_maxGID', null, 'minMaxGID');<br>
54 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $maxGidInput-&gt;setRequired(true);<br>
55 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $configContainer-&gt;addElement($maxGidInput, true);<br>
56 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $return[<span style="color: red;">'config_options'</span>][<span style="color: red;">'group'</span>] = $configContainer;<br>
57 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [...]<br>
58 </div>
59 <br>
60 The min/maximum GID numbers are defined with simple text boxes.<br><br>
61 <h2>2. Checking user input</h2>
62 Probably you also want to check if the input data is syntactically
63 correct.<br>
64 The <span style="font-style: italic;">baseModule</span> already
65 provides different checks which can be activated with <span style="font-style: italic;">meta data</span>. However you can also do
66 the checking in the module.<br>
67 Implementing the function <span style="font-weight: bold;">check_configOptions()</span>
68 in your module will allow you to do the checks yourself. Basic checks
69 can be defined with <span style="font-weight: bold;">meta['config_checks']</span>.<br>
70 <br>
71 <span style="font-weight: bold; text-decoration: underline;">Example:</span><br style="font-weight: bold; text-decoration: underline;">
72 <br>
73 The <span style="font-style: italic;">posixGroup</span> module only
74 needs to check if the GID numbers are correct. The password hash type
75 needs not to be checked as it is a selection.<br>
76 <br>
77 <div class="mod-code">
78 &nbsp;&nbsp;&nbsp; * Returns meta data that is interpreted by parent
79 class<br>
80 &nbsp;&nbsp;&nbsp; *<br>
81 &nbsp;&nbsp;&nbsp; * @return array array with meta data<br>
82 &nbsp;&nbsp;&nbsp; */<br>
83 &nbsp;&nbsp;&nbsp;<span style="font-weight: bold;"> function</span>
84 get_metaData() {<br>
85 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $return = array();<br>
86 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // configuration checks<br>
87 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;$return[<span style="color: rgb(255, 0, 0);">'config_checks'</span>][<span style="color: rgb(255, 0, 0);">'group'</span>]['posixGroup_minGID'] =
88 array (<br>
89 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;'type' =&gt;
90 'ext_preg',<br>
91 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;'regex' =&gt;
92 'digit',<br>
93 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;'required'
94 =&gt; true,<br>
95 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
96 &nbsp;'required_message' =&gt; $this-&gt;messages['gidNumber'][5],<br>
97 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
98 &nbsp;'error_message' =&gt; $this-&gt;messages['gidNumber'][5]);<br>
99 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;$return[<span style="color: rgb(255, 0, 0);">'config_checks'</span>][<span style="color: rgb(255, 0, 0);">'group'</span>]['posixGroup_maxGID'] =
100 array (<br>
101 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;'type' =&gt;
102 'ext_preg',<br>
103 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;'regex' =&gt;
104 'digit',<br>
105 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;'required'
106 =&gt; true,<br>
107 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
108 &nbsp;'required_message' =&gt; $this-&gt;messages['gidNumber'][6],<br>
109 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
110 &nbsp;'error_message' =&gt; $this-&gt;messages['gidNumber'][6]);<br>
111 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;$return[<span style="color: rgb(255, 0, 0);">'config_checks'</span>][<span style="color: rgb(255, 0, 0);">'group'</span>]['cmpGID'] = array (<br>
112 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;'type' =&gt;
113 'int_greater',<br>
114 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;'cmp_name1'
115 =&gt; 'posixGroup_maxGID',<br>
116 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;'cmp_name2'
117 =&gt; 'posixGroup_minGID',<br>
118 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
119 &nbsp;'error_message' =&gt; $this-&gt;messages['gidNumber'][7]);<br>
120 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [...]<br>
121 </div>
122 <br>
123 The type <span style="font-weight: bold;">"ext_preg"</span> means that
124 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
125 check. This function already contains regular expressions for the most
126 common cases.<br>
127 To check if the minimum GID is smaller than the maximum GID we define a
128 check for the nonexistent option "cmpGID" and define it as optional.
129 This will do the comparison check.<br>
130 <br>
131 <br>
132 </div>
133 </body></html>