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

  ViewVC Help
Powered by ViewVC 1.1.26