Debian Codegraph @

docs/devel/mod_general.htm

raw symbols SCIP
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html lang="en"><head><title>Module HowTo - General module options</title>
3
4
5
6
7 <link rel="stylesheet" type="text/css" href="style/layout.css"><link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico"></head><body>
8
9 <div style="text-align: center;">
10 <h1>Module HowTo - General module options<br>
11 </h1>
12 <br>
13 <br>
14 <div style="text-align: left;"><br>
15 <h2>1. Account types<br>
16 </h2>
17 LAM provides multiple account types (e.g. users, groups, hosts).<span style="font-weight: bold;"><br>
18 </span>A module can manage one or more account types.<br>
19 <br>
20 The types are specified with <span style="font-weight: bold;">can_manage()</span>.<br>
21 <br>
22 <span style="font-weight: bold; text-decoration: underline;">Example:</span><br style="font-weight: bold; text-decoration: underline;">
23 <br>
24 Our <span style="font-style: italic;">ieee802Device</span>
25 module will be used only for host accounts.<br>
26 <br>
27 <div class="mod-code">
28 &nbsp;&nbsp;&nbsp; * Returns true if this module can manage accounts of the current type, otherwise false.<br>
29 &nbsp;&nbsp;&nbsp; * <br>
30 &nbsp;&nbsp;&nbsp; * @return boolean true if module fits<br>
31 &nbsp;&nbsp;&nbsp; */<br>
32 &nbsp;&nbsp;&nbsp; public function <span style="color: red;">can_manage()</span> {<br>
33 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return $this-&gt;get_scope() == 'host';<br>
34 &nbsp;&nbsp;&nbsp; }<br>
35 </div>
36 <br>
37 <br>
38 <h2>2. Base modules<br>
39 </h2>
40 In LDAP every entry needs exactly one <span style="font-style: italic;">structural
41 object class</span>. Therefore all modules which provide a <span style="font-style: italic;">structural object class</span> are marked
42 as <span style="font-weight: bold;">base module</span>.<br>
43 <br>
44 This is done with <span style="font-weight: bold;">is_base_module()</span>
45 or <span style="font-weight: bold;">meta['is_base']</span>.<br>
46 <br>
47 <span style="font-weight: bold; text-decoration: underline;">Example:</span><br style="font-weight: bold; text-decoration: underline;">
48 <br>
49 The <span style="font-style: italic;">inetOrgPerson</span>
50 module manages the structural object class "inetOrgPerson" and
51 therefore is a <span style="font-weight: bold;">base module</span>.<br>
52 If your module is not a base module you can skip the meta data for
53 this, default is <span style="font-style: italic;">false</span>.<br>
54 <br>
55 <div class="mod-code">
56 &nbsp;&nbsp;&nbsp; * Returns meta data that is interpreted by parent
57 class<br>
58 &nbsp;&nbsp;&nbsp; *<br>
59 &nbsp;&nbsp;&nbsp; * @return array array with meta data<br>
60 &nbsp;&nbsp;&nbsp; */<br>
61 &nbsp;&nbsp;&nbsp; <span style="font-weight: bold;">function</span>
62 get_metaData() {<br>
63 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $return = array();<br>
64 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // base module<br>
65 <span style="color: rgb(255, 0, 0);">&nbsp;&nbsp;&nbsp;
66 &nbsp;&nbsp;&nbsp; $return["is_base"] = true;</span><br style="color: rgb(255, 0, 0);">
67 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return $return;<br>
68 &nbsp;&nbsp;&nbsp; }<br>
69 </div>
70 <br>
71 <br>
72 <h2>3. Alias name</h2>
73 The module name is very limited, therefore every module has an <span style="font-style: italic;">alias name</span>. This <span style="font-style: italic;">alias name</span> has no limitations and
74 can be translated. It may contain special characters but make sure that
75 it does not contain HTML special characters like "&lt;".<br>
76 The <span style="font-style: italic;">alias name </span>can be the
77 same for all managed <span style="font-style: italic;">account types</span>
78 or differ for each type.<br>
79 <br>
80 The <span style="font-style: italic;">alias name</span> is specified
81 with <span style="font-weight: bold;">get_alias()</span>
82 or <span style="font-weight: bold;">meta['alias']</span>.<br>
83 <br>
84 <span style="font-weight: bold; text-decoration: underline;">Example:</span><br style="font-weight: bold; text-decoration: underline;">
85 <br>
86 Our <span style="font-style: italic;">ieee802Device</span>
87 module will get the alias MAC address.<br>
88 <br>
89 <div class="mod-code">
90 &nbsp;&nbsp;&nbsp; * Returns meta data that is interpreted by parent
91 class<br>
92 &nbsp;&nbsp;&nbsp; *<br>
93 &nbsp;&nbsp;&nbsp; * @return array array with meta data<br>
94 &nbsp;&nbsp;&nbsp; */<br>
95 &nbsp;&nbsp;&nbsp; <span style="font-weight: bold;">function</span>
96 get_metaData() {<br>
97 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $return = array();<br>
98 &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // alias name<br>
99 <span style="color: rgb(255, 0, 0);">&nbsp;&nbsp;&nbsp;
100 &nbsp;&nbsp; &nbsp;$return["alias"] = _("MAC address");</span><br style="color: rgb(255, 0, 0);">
101 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return $return;<br>
102 &nbsp;&nbsp;&nbsp; }<br>
103 </div>
104 <br>
105 <br>
106 <h2>4. Dependencies</h2>
107 Modules can depend on each other. This is useful if you need to access
108 attributes from other modules or the managed object classes of your
109 module are not structural.<br>
110 <br>
111 The dependencies are specified with <span style="font-weight: bold;">get_dependencies()</span>
112 or <span style="font-weight: bold;">meta['dependencies']</span>.<br>
113 <br>
114 <span style="font-weight: bold; text-decoration: underline;">Example:</span><br style="font-weight: bold; text-decoration: underline;">
115 <br>
116 Our <span style="font-style: italic;">ieee802Device</span>
117 module depends on the account module (because it is the only structural
118 module at this time).<br>
119 <br>
120 <div class="mod-code">
121 &nbsp;&nbsp;&nbsp; * Returns meta data that is interpreted by parent
122 class<br>
123 &nbsp;&nbsp;&nbsp; *<br>
124 &nbsp;&nbsp;&nbsp; * @return array array with meta data<br>
125 &nbsp;&nbsp;&nbsp; */<br>
126 &nbsp;&nbsp;&nbsp; <span style="font-weight: bold;">function</span>
127 get_metaData() {<br>
128 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $return = array();<br>
129 &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // module dependencies<br>
130 <span style="color: rgb(255, 0, 0);">&nbsp;&nbsp;&nbsp;
131 &nbsp;&nbsp; &nbsp;$return['dependencies'] = array('depends' =&gt;
132 array('account'), 'conflicts' =&gt; array());</span><br style="color: rgb(255, 0, 0);">
133 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return $return;<br>
134 &nbsp;&nbsp;&nbsp; }<br>
135 </div>
136 <br>
137 <br>
138 <h2>5. Messages</h2>
139 There are many situations where you will display messages to the user.
140 The modules should define such messages at a common place to make it
141 easier to modify them without searching the complete file.<br>
142 The <span style="font-style: italic;">baseModule</span> offers the $<span style="font-weight: bold;">messages</span> variable for this. It
143 should be filled by a function called <span style="font-weight: bold;">load_Messages()</span>.<br>
144 The <span style="font-style: italic;">baseModule</span> will
145 automatically check if you have implemented this function and call it
146 at construction time.<br>
147 <br>
148 <span style="font-weight: bold; text-decoration: underline;">Example:</span><br style="font-weight: bold; text-decoration: underline;">
149 <br>
150 Now let our <span style="font-style: italic;">ieee802Device</span>
151 module define a message.<br>
152 <br>
153 <div class="mod-code">
154 &nbsp;&nbsp;&nbsp; * This function fills the error message array with
155 messages<br>
156 &nbsp;&nbsp;&nbsp; */<br>
157 &nbsp;&nbsp;&nbsp; <span style="font-weight: bold;">function</span> <span style="color: rgb(255, 0, 0);">load_Messages</span>() {<br>
158 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $this-&gt;messages['mac'][0] =
159 array('ERROR', 'MAC address is invalid!');&nbsp; // third array value
160 is set dynamically<br>
161 &nbsp;&nbsp;&nbsp; }<br>
162 </div>
163 <br>
164 <br>
165 <h2>6. Managed object classes<br>
166 </h2>
167 You can tell LAM what object classes are managed by your module.<br>
168 LAM will then check the spelling of the objectClass attributes and
169 correct it automatically. This is useful if other applications (e.g.
170 smbldap-tools) also create accounts and the spelling is different.<br>
171 <br>
172 <span style="font-weight: bold; text-decoration: underline;">Example:</span><br>
173 <br>
174 The <span style="font-style: italic;">ieee802Device</span> module
175 manages one object class.<br>
176 <br>
177 <div class="mod-code">
178 &nbsp;&nbsp;&nbsp; * Returns meta data that is interpreted by parent
179 class<br>
180 &nbsp;&nbsp;&nbsp; *<br>
181 &nbsp;&nbsp;&nbsp; * @return array array with meta data<br>
182 &nbsp;&nbsp;&nbsp; */<br>
183 &nbsp;&nbsp;&nbsp; <span style="font-weight: bold;">function</span>
184 get_metaData() {<br>
185 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $return = array();<br>
186 &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // managed object classes<br>
187 <span style="color: rgb(255, 0, 0);">&nbsp;&nbsp;&nbsp;
188 &nbsp;&nbsp; &nbsp;$return['objectClasses'] = array('ieee802Device');</span><br>
189 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return $return;<br>
190 &nbsp;&nbsp;&nbsp; }<br>
191 </div>
192 <br>
193 <br>
194 <h2>7. Known LDAP aliases<br>
195 </h2>
196 LDAP attributes can have several names (e.g. "cn" and "commonName" are
197 the same). If you manage such attributes then tell LAM about the alias
198 names.<br>
199 LAM will then convert all alias names to the given attribute names
200 automatically.<br>
201 <br>
202 <span style="font-weight: bold; text-decoration: underline;">Example:</span><br>
203 <br>
204 The <span style="font-style: italic;">posixGroup</span> module manages
205 the "cn" attribute. This attribute is also known under the alias
206 "commonName".<br>
207 This way the module will never see attributes called "commonName"
208 because LAM renames them as soon as the LDAP entry is loaded.<br>
209 <br>
210 <div class="mod-code">
211 &nbsp;&nbsp;&nbsp; * Returns meta data that is interpreted by parent
212 class<br>
213 &nbsp;&nbsp;&nbsp; *<br>
214 &nbsp;&nbsp;&nbsp; * @return array array with meta data<br>
215 &nbsp;&nbsp;&nbsp; */<br>
216 &nbsp;&nbsp;&nbsp; <span style="font-weight: bold;">function</span>
217 get_metaData() {<br>
218 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $return = array();<br>
219 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // LDAP aliases<br>
220 <span style="color: rgb(255, 0, 0);">&nbsp;&nbsp;&nbsp;
221 &nbsp;&nbsp; &nbsp;$return['LDAPaliases'] = array('commonName' =&gt;
222 'cn');</span><br>
223 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return $return;<br>
224 &nbsp;&nbsp;&nbsp; }<br>
225 </div>
226 <br>
227 <br>
228 <span style="font-weight: bold;"></span>
229 </div>
230 </div>
231 <h2>8. Icon<br>
232 </h2>
233 You can specify a icon for you module. It will be displayed on the
234 account pages and other module specific places (e.g. file upload).<br>
235 The icons must be 32x32 pixels in size. The location is relative to the <span style="font-style: italic;">graphics</span> directory.<br>
236
237 <br>
238
239 <span style="font-weight: bold; text-decoration: underline;">Example:</span><br>
240
241 <br>
242
243 The <span style="font-style: italic;">posixGroup</span> module uses the "tux.png" from the graphics directory.<br>
244
245 <br>
246
247 <div class="mod-code">
248 &nbsp;&nbsp;&nbsp; * Returns meta data that is interpreted by parent
249 class<br>
250 &nbsp;&nbsp;&nbsp; *<br>
251 &nbsp;&nbsp;&nbsp; * @return array array with meta data<br>
252 &nbsp;&nbsp;&nbsp; */<br>
253 &nbsp;&nbsp;&nbsp; <span style="font-weight: bold;">function</span>
254 get_metaData() {<br>
255 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $return = array();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // icon<br>
256 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: rgb(255, 0, 0);">$return['icon'] = 'tux.png';</span><br>
257 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return $return;<br>
258 &nbsp;&nbsp;&nbsp; }<br>
259 </div>
260 <br>
261 <br>
262 </body></html>