/[A3C]/lib/A3C/Model/User.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /lib/A3C/Model/User.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 23 - (show annotations)
Mon Mar 17 13:02:50 2008 UTC (16 years ago) by dpavlin
File size: 7568 byte(s)
added few more columns to match ldap

1 use strict;
2 use warnings;
3
4 package A3C::Model::User;
5 use Jifty::DBI::Schema;
6
7 use utf8;
8
9 use A3C::Record schema {
10
11 column uid =>
12 label is ('uid'),
13 is indexed,
14 is mandatory,
15 is distinct;
16
17 column hrEduPersonUniqueID =>
18 label is ('hrEduPersonUniqueID'),
19 is indexed,
20 is distinct,
21 is mandatory;
22
23 column cn =>
24 label is _('Ime i prezime'),
25 type is 'virtual';
26
27 column sn =>
28 type is 'virtual',
29 label is _('Prezime'),
30 is mandatory;
31
32 column givenName =>
33 type is 'virtual',
34 label is _('Ime'),
35 is mandatory;
36
37 column mail =>
38 type is 'text',
39 is mandatory,
40 label is _('Email address'), default is '',
41 is immutable,
42 is distinct;
43
44 column password =>
45 is unreadable,
46 label is _('Password'),
47 type is 'varchar',
48 hints is _('Your password should be at least six characters'),
49 render_as 'password',
50 # filters are 'Jifty::DBI::Filter::SaltHash',
51 is mandatory;
52
53 column telephoneNumber =>
54 type is 'text',
55 label is _('Telefonski broj'),
56 hint is '+385 xx yyyyyy';
57
58 column hrEduPersonExtensionNumber =>
59 label is _('Lokalni telefonski broj');
60
61 column mobile =>
62 label is _('Broj mobilnog telefona');
63
64 column facsimileTelephoneNumber =>
65 label is _('Fax broj');
66
67 column hrEduPersonUniqueNumber =>
68 # is mandatory,
69 label is _('JMBG');
70
71 column hrEduPersonDateOfBirth =>
72 type is 'date',
73 render as 'date',
74 label is _('Datum rođenja'),
75 filters are 'Jifty::DBI::Filter::Date';
76
77 column hrEduPersonGender =>
78 label is _('Spol');
79
80 column jpegPhoto =>
81 label is _('Slika');
82
83 column userCertificate =>
84 label is _('Ceritifikat');
85
86 column labeledURI =>
87 label is _('URI adresa');
88
89 column wtAdminType =>
90 label is _('Tip administratora'),
91 valid are [ '', 'AS', 'AI', 'AR', 'AHU' ];
92
93 column hrEduPersonProfessionalStatus =>
94 label is _('Stručni status'),
95 valid are [
96 '',
97 'NKV',
98 'PKV',
99 'KV',
100 'VKV',
101 'SSS',
102 'VS',
103 'VSS',
104 'VŠS',
105 'MR',
106 'DR',
107 ],
108 default is '';
109
110 column hrEduPersonAcademicStatus =>
111 label is _('Zvanje'),
112 valid are [
113 '',
114 'knjižničar',
115 'viši knjižničar',
116 'korepetitor',
117 'viši korepetitor',
118 'lektor',
119 'viši lektor',
120 'stručni suradnik',
121 'asistent visoke škole',
122 'profesor visoke škole',
123 'mlađi asistent',
124 'znanstveni novak',
125 'znanstveni asistent',
126 'znanstveni suradnik',
127 'predavač',
128 'viši predavač',
129 'asistent',
130 'asistent - predavač',
131 'viši asistent',
132 'docent',
133 'izvanredni profesor',
134 'redoviti profesor',
135 'znanstveni savjetnik',
136 'viši znanstveni suradnik',
137 ],
138 default is '';
139
140 column hrEduPersonScienceArea =>
141 label is _('Područje znanosti'),
142 valid are [
143 '',
144 'Tehničke znanosti',
145 'Prirodne znanosti',
146 'Humanističke znanosti',
147 'Društvene znanosti',
148 'Biotehničke znanosti',
149 'Biomedicina i zdravstvo',
150 ],
151 default is '';
152
153 column hrEduPersonAffiliation =>
154 label is _('Povezanost s ustanovom'),
155 is mandatory,
156 valid are [
157 'učenik',
158 'student',
159 'djelatnik',
160 'vanjski suradnik',
161 'korisnik usluge',
162 'gost',
163 ],
164 default is 'korisnik usluge';
165
166 column hrEduPersonPrimaryAffiliation =>
167 label is _('Temeljna povezanost s ustanovom');
168 is mandatory,
169 valid are [
170 'učenik',
171 'student',
172 'djelatnik',
173 'vanjski suradnik',
174 'korisnik usluge',
175 'gost',
176 ],
177 default is 'korisnik usluge';
178
179 column hrEduPersonStudentCategory =>
180 label is 'Vrsta studenta',
181 valid are [
182 '',
183 'osnovnoškolac',
184 'srednjoškolac',
185 'student stručnog studija',
186 'preddiplomac',
187 'postdiplomac',
188 'dodiplomac',
189 'pauzira godinu',
190 'prekid studija',
191 ],
192 default is '';
193
194 column hrEduPersonExpireDate =>
195 label is _('Datum isteka temeljne povezanosti'),
196 type is 'date',
197 render as 'date',
198 is mandatory,
199 filters are 'Jifty::DBI::Filter::Date';
200
201 column hrEduPersonTitle =>
202 label is 'Položaj u ustanovi',
203 valid are [ # FIXME reorder
204 '',
205 'dekan',
206 'direktor',
207 'pomoćnik ravnatelja',
208 'predstojnik zavoda',
209 'pročelnik katedre',
210 'pročelnik odsjeka',
211 'pročelnik sveučilišnog odjela',
212 'prodekan',
213 'prorektor',
214 'ravnatelj',
215 'rektor',
216 'voditelj laboratorija',
217 'voditelj odjela',
218 'voditelj organizacijske jedini',
219 'voditelj projekta',
220 'zamjenik pročelnika sveučilišn',
221 'zamjenik ravnatelja',
222 ],
223 default is '';
224
225 column hrEduPersonRole =>
226 label is 'Uloga u ustanovi',
227 valid are [
228 '',
229 'administrator imenika',
230 'CARNet koordinator',
231 'CARNet sistem inženjer',
232 'ICT koordinator',
233 'ISVU koordinator',
234 'kontakt za sigurnosna pitanja',
235 'MS koordinator',
236 'MATICA operater',
237 'MATICA urednik',
238 ],
239 default is '';
240
241 column hrEduPersonStaffCategory =>
242 label is 'Vrsta posla u ustanovi',
243 valid are [
244 'administrativno osoblje',
245 'ICT podrška',
246 'istraživači',
247 'nastavno osoblje',
248 'osoblje knjižnice',
249 'tehničko osoblje',
250 ];
251
252 column hrEduPersonGroupMember =>
253 label is 'Pripadnost grupi',
254 hint is 'skolskagodina::razred';
255
256 column o =>
257 label is _('Naziv matične ustanove'),
258 is mandatory;
259
260 column hrEduPersonHomeOrg =>
261 label is _('Oznaka matične ustanove'),
262 hint is 'CARNet',
263 is mandatory;
264
265 column ou =>
266 label is _('Organizacijska jedinica');
267
268 column roomNumber =>
269 label is _('Broj sobe');
270
271 column postalAddress =>
272 label is _('Poštanska adresa'),
273 render as 'textarea',
274 is mandatory;
275
276 column l =>
277 label is _('Mjesto'),
278 hist is 'Zagreb',
279 is mandatory;
280
281 column postalCode =>
282 label is _('Poštanski broj'),
283 hint is 'HR-10000';
284
285 column street =>
286 label is _('Ulica i kućni broj');
287
288 column homePostalAddress =>
289 label is _('Kućna poštanska adresa'),
290 render as 'textarea';
291
292 column homePhone =>
293 label is _('Kućni telefonski broj');
294
295 column hrEduPersonCommURI =>
296 label is _('Desktop uređaj');
297
298 column hrEduPersonPrivacy =>
299 label is _('Oznaka privatnosti');
300
301 column loginShell =>
302 label is _('shell');
303
304 column uidNumber =>
305 label is _('uid'),
306 type is 'int';
307
308 column gidNumber =>
309 label is _('gid');
310 type is 'int';
311
312 column homeDirectory =>
313 label is _('home');
314
315 column objectClass =>
316 type is 'virtual';
317
318 };
319
320 # we don't use following mixing because it wants to send notificaitons on e-mail address change
321 #use Jifty::Plugin::User::Mixin::Model::User;
322 use Jifty::Plugin::Authentication::Password::Mixin::Model::User;
323 #use Jifty::Plugin::OpenID::Mixin::Model::User;
324 use Jifty::Plugin::ActorMetadata::Mixin::Model::ActorMetadata; # created_by, created_on, updated_on
325
326 # Your model-specific methods go here.
327
328 =head2 before_create
329
330 Implement virtual columns, for now put mail from ldap into email row
331
332 =cut
333
334 =for later
335
336 sub before_create {
337 my ($self, $attr) = @_;
338 if ( ! $attr->{'email'} ) {
339 warn "push mail to email";
340 $attr->{'email'} = $attr->{'mail'};
341 }
342 }
343
344 =cut
345
346 =head2 email
347
348 Accessor for compatibility with Jifty mixins
349
350 =cut
351
352 sub email {
353 my $self = shift;
354 return $self->__value('mail');
355 }
356
357 sub email_confirmed { 1 };
358
359 =head2 validate_telephoneNumber
360
361 =cut
362
363 sub validate_telephoneNumber {
364 my ( $self, $value ) = @_;
365
366 return ( 0, _('Telephone number invalid') ) if $value !~ m/^(\+?385)?[\d\s-]+$/;
367
368 return ( 1, 'OK' );
369 }
370
371 =head2 canonicalize_hrEduPersonExpireDate
372
373 Support NONE as 2042-12-30
374
375 =cut
376
377 sub canonicalize_hrEduPersonExpireDate {
378 my ( $self, $value ) = @_;
379
380 if ( $value eq 'NONE' ) {
381 $self->log->warn("fixed hrEduPersonExpireDate");
382 $value = '2042-12-30';
383 }
384
385 return $value;
386 }
387
388 =head2 current_user_can
389
390 =cut
391
392 sub current_user_can {
393 # FIXME no security for now :-)
394 return 1;
395 }
396
397 1;
398

  ViewVC Help
Powered by ViewVC 1.1.26