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; |
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 |
|
|
64 |
|
|
65 |
column hrEduPersonUniqueNumber => |
column hrEduPersonUniqueNumber => |
66 |
# is mandatory, |
# is mandatory, |
67 |
label is _('JMBG'); |
label is _('Unique number'); |
68 |
|
|
69 |
column hrEduPersonDateOfBirth => |
column hrEduPersonDateOfBirth => |
70 |
type is 'date', |
type is 'date', |
88 |
label is _('Tip administratora'), |
label is _('Tip administratora'), |
89 |
valid are [ '', 'AS', 'AI', 'AR', 'AHU' ]; |
valid are [ '', 'AS', 'AI', 'AR', 'AHU' ]; |
90 |
|
|
91 |
|
column hrEduPersonHomeOrg => |
92 |
|
label is _('Oznaka matične ustanove'), |
93 |
|
hint is 'CARNet', |
94 |
|
is mandatory; |
95 |
|
|
96 |
column hrEduPersonProfessionalStatus => |
column hrEduPersonProfessionalStatus => |
97 |
label is _('Stručni status'), |
label is _('Stručni status'), |
98 |
valid are [ |
valid are [ |
153 |
], |
], |
154 |
default is ''; |
default is ''; |
155 |
|
|
156 |
|
column 'o'; |
157 |
|
column 'l'; |
158 |
|
column 'postalAddress'; |
159 |
|
|
160 |
|
# column organization => |
161 |
|
# refers_to A3C::Model::Organization by 'id', |
162 |
|
# is mandatory; |
163 |
|
|
164 |
column hrEduPersonAffiliation => |
column hrEduPersonAffiliation => |
165 |
label is _('Povezanost s ustanovom'), |
label is _('Povezanost s ustanovom'), |
166 |
is mandatory, |
is mandatory, |
264 |
label is 'Pripadnost grupi', |
label is 'Pripadnost grupi', |
265 |
hint is 'skolskagodina::razred'; |
hint is 'skolskagodina::razred'; |
266 |
|
|
|
column o => |
|
|
label is _('Naziv matične ustanove'), |
|
|
is mandatory; |
|
|
|
|
|
column hrEduPersonHomeOrg => |
|
|
label is _('Oznaka matične ustanove'), |
|
|
hint is 'CARNet', |
|
|
is mandatory; |
|
|
|
|
267 |
column ou => |
column ou => |
268 |
label is _('Organizacijska jedinica'); |
label is _('Organizacijska jedinica'); |
269 |
|
|
270 |
column roomNumber => |
column roomNumber => |
271 |
label is _('Broj sobe'); |
label is _('Broj sobe'); |
272 |
|
|
|
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'); |
|
|
|
|
273 |
column homePostalAddress => |
column homePostalAddress => |
274 |
label is _('Kućna poštanska adresa'), |
label is _('Kućna poštanska adresa'), |
275 |
render as 'textarea'; |
render as 'textarea'; |
283 |
column hrEduPersonPrivacy => |
column hrEduPersonPrivacy => |
284 |
label is _('Oznaka privatnosti'); |
label is _('Oznaka privatnosti'); |
285 |
|
|
286 |
|
column loginShell => |
287 |
|
label is _('login shell'); |
288 |
|
|
289 |
|
column uidNumber => |
290 |
|
label is _('uid number'), |
291 |
|
type is 'int'; |
292 |
|
|
293 |
|
column gidNumber => |
294 |
|
label is _('gid number'); |
295 |
|
type is 'int'; |
296 |
|
|
297 |
|
column homeDirectory => |
298 |
|
label is _('home directory'); |
299 |
|
|
300 |
}; |
}; |
301 |
|
|
302 |
# we don't use following mixing because it wants to send notificaitons on e-mail address change |
# we don't use following mixing because it wants to send notificaitons on e-mail address change |
338 |
|
|
339 |
sub email_confirmed { 1 }; |
sub email_confirmed { 1 }; |
340 |
|
|
341 |
|
=head2 name |
342 |
|
|
343 |
|
=cut |
344 |
|
|
345 |
|
sub name { |
346 |
|
my $self = shift; |
347 |
|
return $self->__value('cn') . ' <' . $self->__value('mail') . '>'; |
348 |
|
} |
349 |
|
|
350 |
=head2 validate_telephoneNumber |
=head2 validate_telephoneNumber |
351 |
|
|
352 |
=cut |
=cut |
359 |
return ( 1, 'OK' ); |
return ( 1, 'OK' ); |
360 |
} |
} |
361 |
|
|
362 |
|
=head2 hrEduPersonUniqueNumber |
363 |
|
|
364 |
|
Check if JMBG is valid |
365 |
|
|
366 |
|
=cut |
367 |
|
|
368 |
|
sub validate_hrEduPersonUniqueNumber { |
369 |
|
my ( $self, $value ) = @_; |
370 |
|
|
371 |
|
if ( $value =~ m/^JMBG:\s+(\d+)$/ ) { |
372 |
|
|
373 |
|
my $jmbg = $1; |
374 |
|
|
375 |
|
return ( 0, _('JMBG must have 13 digits') ) unless length($jmbg) == 13; |
376 |
|
|
377 |
|
sub digit_at { |
378 |
|
my ($jmbg,$pos) = @_; |
379 |
|
return ord(substr($jmbg,$pos,1)) - ord('0'); |
380 |
|
} |
381 |
|
|
382 |
|
my $sum; |
383 |
|
my $fact = 7; |
384 |
|
|
385 |
|
foreach my $i ( 0 .. 11 ) { |
386 |
|
my $c = digit_at( $jmbg, $i ); |
387 |
|
$sum += $c * $fact; |
388 |
|
# warn "## $c * $fact => $sum\n"; |
389 |
|
$fact--; |
390 |
|
$fact = 7 if $fact == 1; |
391 |
|
} |
392 |
|
|
393 |
|
my $ost = $sum % 11; |
394 |
|
$ost = 11 - $ost if $ost > 1; |
395 |
|
|
396 |
|
return ( 0, _("JMBG is invalid") ) if $ost != digit_at( $jmbg, 12 ); |
397 |
|
} |
398 |
|
|
399 |
|
return ( 1, 'OK' ); |
400 |
|
} |
401 |
|
|
402 |
=head2 canonicalize_hrEduPersonExpireDate |
=head2 canonicalize_hrEduPersonExpireDate |
403 |
|
|
404 |
Support NONE as 2042-12-30 |
Support NONE as 2042-12-30 |
408 |
sub canonicalize_hrEduPersonExpireDate { |
sub canonicalize_hrEduPersonExpireDate { |
409 |
my ( $self, $value ) = @_; |
my ( $self, $value ) = @_; |
410 |
|
|
411 |
if ( $value eq 'NONE' ) { |
if ( lc($value) eq 'none' ) { |
412 |
$self->log->warn("fixed hrEduPersonExpireDate"); |
$self->log->warn("fixed hrEduPersonExpireDate"); |
413 |
$value = '2042-12-30'; |
$value = '2042-12-30'; |
414 |
} |
} |
416 |
return $value; |
return $value; |
417 |
} |
} |
418 |
|
|
419 |
=head2 current_user_can |
use A3C::DefaultACL; |
|
|
|
|
=cut |
|
|
|
|
|
sub current_user_can { |
|
|
# FIXME no security for now :-) |
|
|
return 1; |
|
|
} |
|
420 |
|
|
421 |
1; |
1; |
422 |
|
|