/[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

Annotation of /lib/A3C/Model/Person.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 77 - (hide annotations)
Fri Apr 11 22:02:09 2008 UTC (16 years ago) by dpavlin
File size: 8074 byte(s)
added few columns, fixed labels
1 dpavlin 2 use strict;
2     use warnings;
3    
4 dpavlin 66 package A3C::Model::Person;
5 dpavlin 2 use Jifty::DBI::Schema;
6    
7 dpavlin 14 use utf8;
8    
9 dpavlin 11 use A3C::Record schema {
10 dpavlin 2
11 dpavlin 16 column uid =>
12 dpavlin 77 label is _('UID'),
13 dpavlin 16 is indexed,
14     is mandatory,
15     is distinct;
16    
17     column hrEduPersonUniqueID =>
18 dpavlin 77 label is _('hr Edu Person Unique ID'),
19 dpavlin 16 is indexed,
20 dpavlin 18 is distinct,
21 dpavlin 4 is mandatory;
22    
23     column cn =>
24 dpavlin 21 label is _('Ime i prezime'),
25 dpavlin 29 is mandatory;
26 dpavlin 4
27     column sn =>
28     label is _('Prezime'),
29     is mandatory;
30    
31     column givenName =>
32     label is _('Ime'),
33     is mandatory;
34    
35 dpavlin 16 column mail =>
36 dpavlin 4 type is 'text',
37     is mandatory,
38 dpavlin 18 label is _('Email address'), default is '',
39 dpavlin 73 is indexed,
40 dpavlin 18 is immutable,
41     is distinct;
42 dpavlin 4
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 dpavlin 10 # is mandatory,
68 dpavlin 35 label is _('Unique number');
69 dpavlin 4
70     column hrEduPersonDateOfBirth =>
71     type is 'date',
72 dpavlin 15 render as 'date',
73 dpavlin 16 label is _('Datum rođenja'),
74     filters are 'Jifty::DBI::Filter::Date';
75 dpavlin 4
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 dpavlin 15 valid are [ '', 'AS', 'AI', 'AR', 'AHU' ];
91 dpavlin 4
92 dpavlin 42 column hrEduPersonHomeOrg =>
93     label is _('Oznaka matične ustanove'),
94     hint is 'CARNet',
95     is mandatory;
96    
97 dpavlin 4 column hrEduPersonProfessionalStatus =>
98     label is _('Stručni status'),
99 dpavlin 15 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 dpavlin 4
114     column hrEduPersonAcademicStatus =>
115     label is _('Zvanje'),
116 dpavlin 15 valid are [
117     '',
118 dpavlin 4 'knjižničar',
119 dpavlin 15 'viši knjižničar',
120 dpavlin 4 'korepetitor',
121 dpavlin 15 'viši korepetitor',
122 dpavlin 4 'lektor',
123 dpavlin 15 'viši lektor',
124     'stručni suradnik',
125     'asistent visoke škole',
126     'profesor visoke škole',
127 dpavlin 4 'mlađi asistent',
128 dpavlin 15 'znanstveni novak',
129     'znanstveni asistent',
130     'znanstveni suradnik',
131 dpavlin 4 'predavač',
132 dpavlin 15 'viši predavač',
133     'asistent',
134     'asistent - predavač',
135     'viši asistent',
136     'docent',
137     'izvanredni profesor',
138 dpavlin 4 'redoviti profesor',
139 dpavlin 15 'znanstveni savjetnik',
140 dpavlin 4 'viši znanstveni suradnik',
141 dpavlin 15 ],
142     default is '';
143 dpavlin 4
144     column hrEduPersonScienceArea =>
145     label is _('Područje znanosti'),
146 dpavlin 15 valid are [
147     '',
148 dpavlin 4 'Tehničke znanosti',
149     'Prirodne znanosti',
150     'Humanističke znanosti',
151     'Društvene znanosti',
152     'Biotehničke znanosti',
153     'Biomedicina i zdravstvo',
154 dpavlin 15 ],
155     default is '';
156 dpavlin 4
157 dpavlin 77 column 'o' =>
158     is indexed;
159    
160 dpavlin 45 column 'l';
161     column 'postalAddress';
162 dpavlin 77 column 'postalCode';
163     column 'street';
164 dpavlin 45
165 dpavlin 42 # column organization =>
166     # refers_to A3C::Model::Organization by 'id',
167     # is mandatory;
168 dpavlin 32
169 dpavlin 4 column hrEduPersonAffiliation =>
170     label is _('Povezanost s ustanovom'),
171     is mandatory,
172 dpavlin 15 valid are [
173     'učenik',
174     'student',
175 dpavlin 4 'djelatnik',
176 dpavlin 15 'vanjski suradnik',
177     'korisnik usluge',
178 dpavlin 4 'gost',
179 dpavlin 15 ],
180     default is 'korisnik usluge';
181 dpavlin 4
182     column hrEduPersonPrimaryAffiliation =>
183     label is _('Temeljna povezanost s ustanovom');
184     is mandatory,
185 dpavlin 15 valid are [
186     'učenik',
187     'student',
188 dpavlin 4 'djelatnik',
189 dpavlin 15 'vanjski suradnik',
190     'korisnik usluge',
191 dpavlin 4 'gost',
192 dpavlin 15 ],
193     default is 'korisnik usluge';
194 dpavlin 4
195     column hrEduPersonStudentCategory =>
196     label is 'Vrsta studenta',
197 dpavlin 15 valid are [
198     '',
199     'osnovnoškolac',
200     'srednjoškolac',
201     'student stručnog studija',
202     'preddiplomac',
203     'postdiplomac',
204 dpavlin 4 'dodiplomac',
205     'pauzira godinu',
206     'prekid studija',
207 dpavlin 15 ],
208     default is '';
209 dpavlin 4
210     column hrEduPersonExpireDate =>
211     label is _('Datum isteka temeljne povezanosti'),
212     type is 'date',
213 dpavlin 15 render as 'date',
214 dpavlin 4 is mandatory,
215 dpavlin 16 filters are 'Jifty::DBI::Filter::Date';
216 dpavlin 4
217     column hrEduPersonTitle =>
218     label is 'Položaj u ustanovi',
219 dpavlin 15 valid are [ # FIXME reorder
220     '',
221 dpavlin 4 '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 dpavlin 15 ],
239     default is '';
240 dpavlin 4
241     column hrEduPersonRole =>
242     label is 'Uloga u ustanovi',
243 dpavlin 15 valid are [
244     '',
245 dpavlin 4 '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 dpavlin 15 ],
255     default is '';
256 dpavlin 4
257     column hrEduPersonStaffCategory =>
258     label is 'Vrsta posla u ustanovi',
259 dpavlin 15 valid are [
260 dpavlin 4 '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 dpavlin 12 label is _('Kućna poštanska adresa'),
280     render as 'textarea';
281 dpavlin 4
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 dpavlin 23 column loginShell =>
292 dpavlin 45 label is _('login shell');
293 dpavlin 23
294     column uidNumber =>
295 dpavlin 45 label is _('uid number'),
296 dpavlin 23 type is 'int';
297    
298     column gidNumber =>
299 dpavlin 45 label is _('gid number');
300 dpavlin 23 type is 'int';
301    
302     column homeDirectory =>
303 dpavlin 45 label is _('home directory');
304 dpavlin 23
305 dpavlin 2 };
306    
307 dpavlin 18 # 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 dpavlin 4 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 dpavlin 2 # Your model-specific methods go here.
314    
315 dpavlin 18 =head2 before_create
316 dpavlin 16
317 dpavlin 18 Implement virtual columns, for now put mail from ldap into email row
318 dpavlin 16
319     =cut
320    
321 dpavlin 18 =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 dpavlin 16 }
330    
331 dpavlin 18 =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 dpavlin 73 return $self->mail;
342 dpavlin 18 }
343    
344     sub email_confirmed { 1 };
345    
346 dpavlin 45 =head2 name
347    
348     =cut
349    
350     sub name {
351     my $self = shift;
352 dpavlin 73 return $self->cn . ' <' . $self->mail . '>';
353 dpavlin 45 }
354    
355 dpavlin 4 =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 dpavlin 38 =head2 hrEduPersonUniqueNumber
368 dpavlin 35
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 dpavlin 16 =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 dpavlin 33 if ( lc($value) eq 'none' ) {
417 dpavlin 16 $self->log->warn("fixed hrEduPersonExpireDate");
418     $value = '2042-12-30';
419     }
420    
421     return $value;
422     }
423    
424 dpavlin 70 use A3C::DefaultACL;
425 dpavlin 16
426 dpavlin 2 1;
427    

  ViewVC Help
Powered by ViewVC 1.1.26