8 |
|
|
9 |
use A3C::Record schema { |
use A3C::Record schema { |
10 |
|
|
11 |
column name => |
column uid => |
12 |
type is 'text', |
label is ('uid'), |
13 |
label is _('Ime'), |
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; |
is mandatory; |
22 |
|
|
23 |
column cn => |
column cn => |
24 |
label is _('Ime'), |
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 |
|
|
35 |
column email => |
column mail => |
36 |
type is 'text', |
type is 'text', |
37 |
is mandatory, |
is mandatory, |
38 |
label is _('Email address'), default is '', is immutable, is distinct; |
label is _('Email address'), default is '', |
39 |
|
is immutable, |
40 |
column email_confirmed => |
is distinct; |
|
label is _('Email address confirmed?'), |
|
|
type is 'boolean'; |
|
41 |
|
|
42 |
column password => |
column password => |
43 |
is unreadable, |
is unreadable, |
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', |
71 |
render as 'date', |
render as 'date', |
72 |
label is _('Datum rođenja'); |
label is _('Datum rođenja'), |
73 |
|
filters are 'Jifty::DBI::Filter::Date'; |
74 |
|
|
75 |
column hrEduPersonGender => |
column hrEduPersonGender => |
76 |
label is _('Spol'); |
label is _('Spol'); |
148 |
], |
], |
149 |
default is ''; |
default is ''; |
150 |
|
|
151 |
|
column organization => |
152 |
|
refers_to A3C::Model::Organization by 'id', |
153 |
|
is mandatory; |
154 |
|
|
155 |
column hrEduPersonAffiliation => |
column hrEduPersonAffiliation => |
156 |
label is _('Povezanost s ustanovom'), |
label is _('Povezanost s ustanovom'), |
157 |
is mandatory, |
is mandatory, |
198 |
type is 'date', |
type is 'date', |
199 |
render as 'date', |
render as 'date', |
200 |
is mandatory, |
is mandatory, |
201 |
|
filters are 'Jifty::DBI::Filter::Date'; |
202 |
|
|
203 |
column hrEduPersonTitle => |
column hrEduPersonTitle => |
204 |
label is 'Položaj u ustanovi', |
label is 'Položaj u ustanovi', |
255 |
label is 'Pripadnost grupi', |
label is 'Pripadnost grupi', |
256 |
hint is 'skolskagodina::razred'; |
hint is 'skolskagodina::razred'; |
257 |
|
|
|
column o => |
|
|
label is _('Naziv matične ustanove'), |
|
|
is mandatory; |
|
|
|
|
|
column hrEduPersonHomeOrg => |
|
|
label is _('Oznaka matične ustanove'), |
|
|
hint is 'CARNet', |
|
|
is mandatory; |
|
|
|
|
258 |
column ou => |
column ou => |
259 |
label is _('Organizacijska jedinica'); |
label is _('Organizacijska jedinica'); |
260 |
|
|
261 |
column roomNumber => |
column roomNumber => |
262 |
label is _('Broj sobe'); |
label is _('Broj sobe'); |
263 |
|
|
|
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'); |
|
|
|
|
264 |
column homePostalAddress => |
column homePostalAddress => |
265 |
label is _('Kućna poštanska adresa'), |
label is _('Kućna poštanska adresa'), |
266 |
render as 'textarea'; |
render as 'textarea'; |
274 |
column hrEduPersonPrivacy => |
column hrEduPersonPrivacy => |
275 |
label is _('Oznaka privatnosti'); |
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 |
use Jifty::Plugin::User::Mixin::Model::User; |
# 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; |
use Jifty::Plugin::Authentication::Password::Mixin::Model::User; |
296 |
#use Jifty::Plugin::OpenID::Mixin::Model::User; |
#use Jifty::Plugin::OpenID::Mixin::Model::User; |
297 |
use Jifty::Plugin::ActorMetadata::Mixin::Model::ActorMetadata; # created_by, created_on, updated_on |
use Jifty::Plugin::ActorMetadata::Mixin::Model::ActorMetadata; # created_by, created_on, updated_on |
298 |
|
|
299 |
# Your model-specific methods go here. |
# 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 |
=head2 validate_telephoneNumber |
333 |
|
|
334 |
=cut |
=cut |
341 |
return ( 1, 'OK' ); |
return ( 1, 'OK' ); |
342 |
} |
} |
343 |
|
|
344 |
|
=head 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 { |
sub current_user_can { |
406 |
# FIXME no security for now :-) |
# FIXME no security for now :-) |
407 |
return 1; |
return 1; |