1 |
use strict; |
use strict; |
2 |
use warnings; |
use warnings; |
3 |
|
|
4 |
package A3C::Model::User; |
package A3C::Model::Person; |
5 |
use Jifty::DBI::Schema; |
use Jifty::DBI::Schema; |
6 |
|
|
7 |
use utf8; |
use utf8; |
9 |
use A3C::Record schema { |
use A3C::Record schema { |
10 |
|
|
11 |
column uid => |
column uid => |
12 |
label is ('uid'), |
label is _('UID'), |
13 |
is indexed, |
is indexed, |
14 |
is mandatory, |
is mandatory, |
15 |
is distinct; |
is distinct; |
16 |
|
|
17 |
column hrEduPersonUniqueID => |
column hrEduPersonUniqueID => |
18 |
label is ('hrEduPersonUniqueID'), |
label is _('hr Edu Person Unique ID'), |
19 |
is indexed, |
is indexed, |
20 |
is distinct, |
is distinct, |
21 |
is mandatory; |
is mandatory; |
22 |
|
|
23 |
column cn => |
column cn => |
24 |
label is _('Ime i prezime'), |
label is _('Ime i prezime'), |
25 |
type is 'virtual'; |
is mandatory; |
26 |
|
|
27 |
column sn => |
column sn => |
|
type is 'virtual', |
|
28 |
label is _('Prezime'), |
label is _('Prezime'), |
29 |
is mandatory; |
is mandatory; |
30 |
|
|
31 |
column givenName => |
column givenName => |
|
type is 'virtual', |
|
32 |
label is _('Ime'), |
label is _('Ime'), |
33 |
is mandatory; |
is mandatory; |
34 |
|
|
36 |
type is 'text', |
type is 'text', |
37 |
is mandatory, |
is mandatory, |
38 |
label is _('Email address'), default is '', |
label is _('Email address'), default is '', |
39 |
|
is indexed, |
40 |
is immutable, |
is immutable, |
41 |
is distinct; |
is distinct; |
42 |
|
|
65 |
|
|
66 |
column hrEduPersonUniqueNumber => |
column hrEduPersonUniqueNumber => |
67 |
# is mandatory, |
# is mandatory, |
68 |
label is _('JMBG'); |
label is _('Unique number'); |
69 |
|
|
70 |
column hrEduPersonDateOfBirth => |
column hrEduPersonDateOfBirth => |
71 |
type is 'date', |
type is 'date', |
89 |
label is _('Tip administratora'), |
label is _('Tip administratora'), |
90 |
valid are [ '', 'AS', 'AI', 'AR', 'AHU' ]; |
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 => |
column hrEduPersonProfessionalStatus => |
98 |
label is _('Stručni status'), |
label is _('Stručni status'), |
99 |
valid are [ |
valid are [ |
154 |
], |
], |
155 |
default is ''; |
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 => |
column hrEduPersonAffiliation => |
170 |
label is _('Povezanost s ustanovom'), |
label is _('Povezanost s ustanovom'), |
171 |
is mandatory, |
is mandatory, |
269 |
label is 'Pripadnost grupi', |
label is 'Pripadnost grupi', |
270 |
hint is 'skolskagodina::razred'; |
hint is 'skolskagodina::razred'; |
271 |
|
|
|
column o => |
|
|
label is _('Naziv matične ustanove'), |
|
|
is mandatory; |
|
|
|
|
|
column hrEduPersonHomeOrg => |
|
|
label is _('Oznaka matične ustanove'), |
|
|
hint is 'CARNet', |
|
|
is mandatory; |
|
|
|
|
272 |
column ou => |
column ou => |
273 |
label is _('Organizacijska jedinica'); |
label is _('Organizacijska jedinica'); |
274 |
|
|
275 |
column roomNumber => |
column roomNumber => |
276 |
label is _('Broj sobe'); |
label is _('Broj sobe'); |
277 |
|
|
|
column postalAddress => |
|
|
label is _('Poštanska adresa'), |
|
|
render as 'textarea', |
|
|
is mandatory; |
|
|
|
|
|
column l => |
|
|
label is _('Mjesto'), |
|
|
hist is 'Zagreb', |
|
|
is mandatory; |
|
|
|
|
|
column postalCode => |
|
|
label is _('Poštanski broj'), |
|
|
hint is 'HR-10000'; |
|
|
|
|
|
column street => |
|
|
label is _('Ulica i kućni broj'); |
|
|
|
|
278 |
column homePostalAddress => |
column homePostalAddress => |
279 |
label is _('Kućna poštanska adresa'), |
label is _('Kućna poštanska adresa'), |
280 |
render as 'textarea'; |
render as 'textarea'; |
289 |
label is _('Oznaka privatnosti'); |
label is _('Oznaka privatnosti'); |
290 |
|
|
291 |
column loginShell => |
column loginShell => |
292 |
label is _('shell'); |
label is _('login shell'); |
293 |
|
|
294 |
column uidNumber => |
column uidNumber => |
295 |
label is _('uid'), |
label is _('uid number'), |
296 |
type is 'int'; |
type is 'int'; |
297 |
|
|
298 |
column gidNumber => |
column gidNumber => |
299 |
label is _('gid'); |
label is _('gid number'); |
300 |
type is 'int'; |
type is 'int'; |
301 |
|
|
302 |
column homeDirectory => |
column homeDirectory => |
303 |
label is _('home'); |
label is _('home directory'); |
304 |
|
|
305 |
}; |
}; |
306 |
|
|
338 |
|
|
339 |
sub email { |
sub email { |
340 |
my $self = shift; |
my $self = shift; |
341 |
return $self->__value('mail'); |
return $self->mail; |
342 |
} |
} |
343 |
|
|
344 |
sub email_confirmed { 1 }; |
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 |
=head2 validate_telephoneNumber |
356 |
|
|
357 |
=cut |
=cut |
364 |
return ( 1, 'OK' ); |
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 |
=head2 canonicalize_hrEduPersonExpireDate |
408 |
|
|
409 |
Support NONE as 2042-12-30 |
Support NONE as 2042-12-30 |
413 |
sub canonicalize_hrEduPersonExpireDate { |
sub canonicalize_hrEduPersonExpireDate { |
414 |
my ( $self, $value ) = @_; |
my ( $self, $value ) = @_; |
415 |
|
|
416 |
if ( $value eq 'NONE' ) { |
if ( lc($value) eq 'none' ) { |
417 |
$self->log->warn("fixed hrEduPersonExpireDate"); |
$self->log->warn("fixed hrEduPersonExpireDate"); |
418 |
$value = '2042-12-30'; |
$value = '2042-12-30'; |
419 |
} |
} |
421 |
return $value; |
return $value; |
422 |
} |
} |
423 |
|
|
424 |
=head2 current_user_can |
use A3C::DefaultACL; |
|
|
|
|
=cut |
|
|
|
|
|
sub current_user_can { |
|
|
# FIXME no security for now :-) |
|
|
return 1; |
|
|
} |
|
425 |
|
|
426 |
1; |
1; |
427 |
|
|