Debian Codegraph @

docs/devel/mod_selfService.htm

raw symbols SCIP
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html lang="en"><head><title>Module HowTo - Self-service</title>
3
4
5
6
7 <link rel="stylesheet" type="text/css" href="style/layout.css">
8 <link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico"></head><body>
9 <div style="text-align: center;">
10 <h1>Module HowTo - Self-service<br>
11 </h1>
12 <div style="text-align: left;"><br>
13 Self-service is a LAM Pro feature. It allows your users to manage their own data (e.g. telephone numbers).<br>
14 <br>
15 </div>
16 <div style="text-align: left;">First you need to implement the function <span style="font-weight: bold;">getSelfServiceFields()</span> or use <span style="font-weight: bold;">meta['selfServiceFieldSettings']</span>. Each field
17 has an ID and a descriptive name that will be displayed on the self
18 service page.<br>
19 Your input fields may also be defined as read-only in the self-service
20 profile editor. If your fields supports read-only then use
21 canSelfServiceFieldBeReadOnly() or <span style="font-weight: bold;">meta['selfServiceReadOnlyFields']</span>.<br>
22 <br>
23 <span style="font-weight: bold; text-decoration: underline;">Example:</span><br style="font-weight: bold; text-decoration: underline;">
24 <br>
25 The <span style="font-style: italic;">inetOrgPerson</span> module
26 provides lots of possible input fields for the self-service.<br>
27 <br>
28 <div class="mod-code">
29 &nbsp;&nbsp;&nbsp; * Returns meta data that is interpreted by parent
30 class<br>
31 &nbsp;&nbsp;&nbsp; *<br>
32 &nbsp;&nbsp;&nbsp; * @return array array with meta data<br>
33 &nbsp;&nbsp;&nbsp; */<br>
34 &nbsp;&nbsp;&nbsp;<span style="font-weight: bold;"> function</span>
35 get_metaData() {<br>
36 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $return = array();<br>&nbsp;&nbsp;&nbsp;
37 &nbsp;&nbsp;&nbsp; $return['selfServiceFieldSettings'] =
38 array('firstName' =&gt; _('First name'), 'lastName' =&gt; _('Last
39 name'),<br>
40 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;'mail' =&gt;
41 _('Email address'), 'telephoneNumber' =&gt; _('Telephone number'),
42 'mobile' =&gt; _('Mobile number'),<br>
43 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;'faxNumber'
44 =&gt; _('Fax number'), 'street' =&gt; _('Street'), 'postalAddress'
45 =&gt; _('Postal address'), 'registeredAddress' =&gt; _('Registered
46 address'),<br>
47 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;'postalCode'
48 =&gt; _('Postal code'), 'postOfficeBox' =&gt; _('Post office box'),
49 'jpegPhoto' =&gt; _('Photo'),<br>
50 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;'homePhone'
51 =&gt; _('Home telephone number'), 'roomNumber' =&gt; _('Room number'),
52 'carLicense' =&gt; _('Car license'),<br>
53 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;'location'
54 =&gt; _('Location'), 'state' =&gt; _('State'), 'officeName' =&gt;
55 _('Office name'), 'businessCategory' =&gt; _('Business category'),<br>
56 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
57 &nbsp;'departmentNumber' =&gt; _('Department'), 'initials' =&gt;
58 _('Initials'), 'title' =&gt; _('Job title'), 'labeledURI' =&gt; _('Web
59 site'),<br>
60 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;'userCertificate' =&gt; _('User certificates'));<br>
61 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // possible self-service read-only fields<br>
62 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;
63 &nbsp;$return['selfServiceReadOnlyFields'] = array('firstName',
64 'lastName', 'mail', 'telephoneNumber', 'mobile', 'faxNumber', 'street',<br>
65 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
66 &nbsp;'postalAddress', 'registeredAddress', 'postalCode',
67 'postOfficeBox', 'jpegPhoto', 'homePhone', 'roomNumber', 'carLicense',<br>
68 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;'location',
69 'state', 'officeName', 'businessCategory', 'departmentNumber',
70 'initials', 'title', 'labeledURI', 'userCertificate');<br>
71 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [...]<br>
72 </div>
73 <br>
74 <br>
75 In very rare cases you need to specify self-service search attributes.
76 These are used to identify the user inside LDAP. Common examples are
77 "uid" or "mail".<br>
78 <br>
79 <span style="font-weight: bold; text-decoration: underline;">Example:</span><br style="font-weight: bold; text-decoration: underline;">
80
81 <br>
82
83 The <span style="font-style: italic;">inetOrgPerson</span> module specifies several search attributes.<br>
84
85 <br>
86
87 <div class="mod-code">
88 &nbsp;&nbsp;&nbsp; * Returns meta data that is interpreted by parent
89 class<br>
90 &nbsp;&nbsp;&nbsp; *<br>
91 &nbsp;&nbsp;&nbsp; * @return array array with meta data<br>
92 &nbsp;&nbsp;&nbsp; */<br>
93 &nbsp;&nbsp;&nbsp;<span style="font-weight: bold;"> function</span>
94 get_metaData() {<br>
95 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $return = array();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // self-service search attributes<br>
96 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;
97 &nbsp;$return['selfServiceSearchAttributes'] = array('uid', 'mail',
98 'cn', 'surname', 'givenName', 'employeeNumber');<br>
99 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [...]<br>
100 </div>
101
102 <br>
103
104 <br>
105
106 The HTML code for the user page is generated with the function <span style="font-weight: bold;">getSelfServiceOptions()</span>. It returns one table row for each input field.<br>
107 Please note that some fields may be defined as read-only
108 ($readOnlyFields). If $passwordChangeOnly is set then no input fields
109 other than the bind password should be displayed (you will not get any
110 attribute values).<br>
111
112
113
114 <br>
115 <span style="font-weight: bold; text-decoration: underline;">Example:</span><br style="font-weight: bold; text-decoration: underline;">
116
117
118 <br>
119
120
121 The <span style="font-style: italic;">windowsUser</span> module uses
122 the addSimpleSelfServiceTextField() function from baseModule to print
123 the text field. You may also build the table row yourself if the input
124 field is more complex.<br>
125 <br>
126
127
128 <div class="mod-code">
129 &nbsp;&nbsp;&nbsp; &nbsp;* Returns the meta HTML code for each input field.<br>
130 &nbsp;&nbsp;&nbsp; &nbsp;* format: array(&lt;field1&gt; =&gt; array(&lt;META HTML&gt;), ...)<br>
131 &nbsp;&nbsp;&nbsp; &nbsp;* It is not possible to display help links.<br>
132 &nbsp;&nbsp;&nbsp; &nbsp;*<br>
133 &nbsp;&nbsp;&nbsp; &nbsp;* @param array $fields list of active fields<br>
134 &nbsp;&nbsp;&nbsp; &nbsp;* @param array $attributes attributes of LDAP account<br>
135 &nbsp;&nbsp;&nbsp; &nbsp;* @param boolean $passwordChangeOnly indicates
136 that the user is only allowed to change his password and no LDAP
137 content is readable<br>
138 &nbsp;&nbsp;&nbsp; &nbsp;* @param array $readOnlyFields list of read-only fields<br>
139 &nbsp;&nbsp;&nbsp; &nbsp;* @return array list of meta HTML elements (field name =&gt; htmlTableRow)<br>
140 &nbsp;&nbsp;&nbsp; &nbsp;*/<br>
141 &nbsp;&nbsp;&nbsp; function getSelfServiceOptions($fields, $attributes, $passwordChangeOnly, $readOnlyFields) {<br>
142 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $return = array();<br>
143 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ($passwordChangeOnly) {<br>
144 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return
145 $return; // only password fields as long no LDAP content can be read<br>
146 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
147 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
148 $this-&gt;addSimpleSelfServiceTextField($return,
149 'physicalDeliveryOfficeName', _('Office name'), $fields, $attributes,
150 $readOnlyFields);<br>
151 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [...]<br>
152 </div>
153
154
155 <br>
156
157
158 <br>
159 Of course, the user input should also be validated before making any LDAP changes. This is done in <span style="font-weight: bold;">checkSelfServiceOptions()</span>.<br>
160 The return value includes any error messages to display and also all LDAP operations.<br>
161 Please note that some fields may be defined as read-only
162 ($readOnlyFields). If $passwordChangeOnly is set then no input fields
163 other than the bind
164 password should be displayed (you will not get any attribute values).<br>
165
166
167
168
169 <br>
170 <span style="font-weight: bold; text-decoration: underline;">Example:</span><br style="font-weight: bold; text-decoration: underline;">
171
172
173
174 <br>
175 The <span style="font-style: italic;">inetOrgPerson</span> module has a field for the user's first name.<br>
176 <br>
177
178
179
180 <div class="mod-code">
181 &nbsp;&nbsp;&nbsp; &nbsp;* Checks if all input values are correct and returns the LDAP attributes which should be changed.<br>
182 &nbsp;&nbsp;&nbsp; &nbsp;* &lt;br&gt;Return values:<br>
183 &nbsp;&nbsp;&nbsp; &nbsp;* &lt;br&gt;messages: array of parameters to create status messages<br>
184 &nbsp;&nbsp;&nbsp; &nbsp;* &lt;br&gt;add: array of attributes to add<br>
185 &nbsp;&nbsp;&nbsp; &nbsp;* &lt;br&gt;del: array of attributes to remove<br>
186 &nbsp;&nbsp;&nbsp; &nbsp;* &lt;br&gt;mod: array of attributes to modify<br>
187 &nbsp;&nbsp;&nbsp; &nbsp;* &lt;br&gt;info: array of values with
188 informational value (e.g. to be used later by pre/postModify actions)<br>
189 &nbsp;&nbsp;&nbsp; &nbsp;* <br>
190 &nbsp;&nbsp;&nbsp; &nbsp;* Calling this method does not require the existence of an enclosing {@link accountContainer}.<br>
191 &nbsp;&nbsp;&nbsp; &nbsp;*<br>
192 &nbsp;&nbsp;&nbsp; &nbsp;* @param string $fields input fields<br>
193 &nbsp;&nbsp;&nbsp; &nbsp;* @param array $attributes LDAP attributes<br>
194 &nbsp;&nbsp;&nbsp; &nbsp;* @param boolean $passwordChangeOnly indicates
195 that the user is only allowed to change his password and no LDAP
196 content is readable<br>
197 &nbsp;&nbsp;&nbsp; &nbsp;* @param array $readOnlyFields list of read-only fields<br>
198 &nbsp;&nbsp;&nbsp; &nbsp;* @return array messages and attributes
199 (array('messages' =&gt; array(), 'add' =&gt; array('mail' =&gt;
200 array('[email protected]')), 'del' =&gt; array(), 'mod' =&gt; array(),
201 'info' =&gt; array()))<br>
202 &nbsp;&nbsp;&nbsp; &nbsp;*/<br>
203 &nbsp;&nbsp;&nbsp; function checkSelfServiceOptions($fields, $attributes, $passwordChangeOnly, $readOnlyFields) {<br>
204 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $return = array('messages' =&gt;
205 array(), 'add' =&gt; array(), 'del' =&gt; array(), 'mod' =&gt; array(),
206 'info' =&gt; array());<br>
207 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ($passwordChangeOnly) {<br>
208 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return $return; // skip processing if only a password change is done<br>
209 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
210 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $attributeNames = array(); // list of attributes which should be checked for modification<br>
211 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $attributesNew = $attributes;<br>
212 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // first name<br>
213 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (in_array('firstName', $fields) &amp;&amp; !in_array('firstName', $readOnlyFields)) {<br>
214 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $attributeNames[] = 'givenName';<br>
215 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if
216 (isset($_POST['inetOrgPerson_firstName']) &amp;&amp;
217 ($_POST['inetOrgPerson_firstName'] != '')) {<br>
218 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
219 &nbsp;&nbsp;&nbsp; if (!get_preg($_POST['inetOrgPerson_firstName'],
220 'realname')) $return['messages'][] = $this-&gt;messages['givenName'][0];<br>
221 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
222 &nbsp;&nbsp;&nbsp; else $attributesNew['givenName'][0] =
223 $_POST['inetOrgPerson_firstName'];<br>
224 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
225 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; elseif
226 (isset($attributes['givenName'])) unset($attributesNew['givenName']);<br>
227 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
228 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [...]<br>
229 </div>
230 <br>
231 <br>
232 The self-service also supports configuration settings for each module. See <span style="font-weight: bold;">getSelfServiceSettings() </span>or <span style="font-weight: bold;">meta['selfServiceSettings'] </span>to specify the options.<br>
233 You can validate the input with <span style="font-weight: bold;">checkSelfServiceSettings()</span>.<br>
234 Self-service configuration settings are displayed on a separate tab in the self-service profile editor.<br>
235 <br>
236 </div>
237 </div>
238 </body></html>