/[A3C]/lib/A3C/Model/Person.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/Person.pm

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.26