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 A3C::AAIEduHr; |
8 |
|
|
9 |
use utf8; |
use utf8; |
10 |
|
|
11 |
use A3C::Record schema { |
use A3C::Record schema { |
12 |
|
|
13 |
column uid => |
column uid => |
14 |
label is ('uid'), |
label is _('UID'), |
15 |
is indexed, |
is indexed, |
16 |
is mandatory, |
is mandatory, |
17 |
is distinct; |
is distinct; |
18 |
|
|
19 |
column hrEduPersonUniqueID => |
column hrEduPersonUniqueID => |
20 |
label is ('hrEduPersonUniqueID'), |
label is _('hr Edu Person Unique ID'), |
21 |
is indexed, |
is indexed, |
22 |
is distinct, |
is distinct, |
23 |
is mandatory; |
is mandatory; |
24 |
|
|
25 |
column cn => |
column cn => |
26 |
label is _('Ime i prezime'), |
label is _('Ime i prezime'), |
27 |
type is 'virtual'; |
is mandatory; |
28 |
|
|
29 |
column sn => |
column sn => |
|
type is 'virtual', |
|
30 |
label is _('Prezime'), |
label is _('Prezime'), |
31 |
is mandatory; |
is mandatory; |
32 |
|
|
33 |
column givenName => |
column givenName => |
|
type is 'virtual', |
|
34 |
label is _('Ime'), |
label is _('Ime'), |
35 |
is mandatory; |
is mandatory; |
36 |
|
|
38 |
type is 'text', |
type is 'text', |
39 |
is mandatory, |
is mandatory, |
40 |
label is _('Email address'), default is '', |
label is _('Email address'), default is '', |
41 |
|
is indexed, |
42 |
is immutable, |
is immutable, |
43 |
is distinct; |
is distinct; |
44 |
|
|
67 |
|
|
68 |
column hrEduPersonUniqueNumber => |
column hrEduPersonUniqueNumber => |
69 |
# is mandatory, |
# is mandatory, |
70 |
label is _('JMBG'); |
label is _('Unique number'); |
71 |
|
|
72 |
column hrEduPersonDateOfBirth => |
column hrEduPersonDateOfBirth => |
73 |
type is 'date', |
type is 'date', |
76 |
filters are 'Jifty::DBI::Filter::Date'; |
filters are 'Jifty::DBI::Filter::Date'; |
77 |
|
|
78 |
column hrEduPersonGender => |
column hrEduPersonGender => |
79 |
label is _('Spol'); |
label is _('Spol'), |
80 |
|
valid are [ { display => 'Nepoznato', value => 0 }, A3C::AAIEduHr->vocabulary('hrEdu002') ]; |
81 |
|
|
82 |
column jpegPhoto => |
column jpegPhoto => |
83 |
label is _('Slika'); |
label is _('Slika'); |
92 |
label is _('Tip administratora'), |
label is _('Tip administratora'), |
93 |
valid are [ '', 'AS', 'AI', 'AR', 'AHU' ]; |
valid are [ '', 'AS', 'AI', 'AR', 'AHU' ]; |
94 |
|
|
95 |
|
column hrEduPersonHomeOrg => |
96 |
|
label is _('Oznaka matične ustanove'), |
97 |
|
hint is 'CARNet', |
98 |
|
is mandatory; |
99 |
|
|
100 |
column hrEduPersonProfessionalStatus => |
column hrEduPersonProfessionalStatus => |
101 |
label is _('Stručni status'), |
label is _('Stručni status'), |
102 |
valid are [ |
valid are [ '', A3C::AAIEduHr->vocabulary('hrEdu001'), 'VŠS' ], |
|
'', |
|
|
'NKV', |
|
|
'PKV', |
|
|
'KV', |
|
|
'VKV', |
|
|
'SSS', |
|
|
'VS', |
|
|
'VSS', |
|
|
'VŠS', |
|
|
'MR', |
|
|
'DR', |
|
|
], |
|
103 |
default is ''; |
default is ''; |
104 |
|
|
105 |
column hrEduPersonAcademicStatus => |
column hrEduPersonAcademicStatus => |
106 |
label is _('Zvanje'), |
label is _('Zvanje'), |
107 |
valid are [ |
valid are [ '', A3C::AAIEduHr->vocabulary('hrEdu002') ], |
|
'', |
|
|
'knjižničar', |
|
|
'viši knjižničar', |
|
|
'korepetitor', |
|
|
'viši korepetitor', |
|
|
'lektor', |
|
|
'viši lektor', |
|
|
'stručni suradnik', |
|
|
'asistent visoke škole', |
|
|
'profesor visoke škole', |
|
|
'mlađi asistent', |
|
|
'znanstveni novak', |
|
|
'znanstveni asistent', |
|
|
'znanstveni suradnik', |
|
|
'predavač', |
|
|
'viši predavač', |
|
|
'asistent', |
|
|
'asistent - predavač', |
|
|
'viši asistent', |
|
|
'docent', |
|
|
'izvanredni profesor', |
|
|
'redoviti profesor', |
|
|
'znanstveni savjetnik', |
|
|
'viši znanstveni suradnik', |
|
|
], |
|
108 |
default is ''; |
default is ''; |
109 |
|
|
110 |
column hrEduPersonScienceArea => |
column hrEduPersonScienceArea => |
111 |
label is _('Područje znanosti'), |
label is _('Područje znanosti'), |
112 |
valid are [ |
valid are [ '', A3C::AAIEduHr->vocabulary('hrEdu007') ], |
|
'', |
|
|
'Tehničke znanosti', |
|
|
'Prirodne znanosti', |
|
|
'Humanističke znanosti', |
|
|
'Društvene znanosti', |
|
|
'Biotehničke znanosti', |
|
|
'Biomedicina i zdravstvo', |
|
|
], |
|
113 |
default is ''; |
default is ''; |
114 |
|
|
115 |
|
column 'o' => |
116 |
|
is indexed; |
117 |
|
|
118 |
|
column 'l'; |
119 |
|
column 'postalAddress'; |
120 |
|
column 'postalCode'; |
121 |
|
column 'street'; |
122 |
|
|
123 |
|
# column organization => |
124 |
|
# refers_to A3C::Model::Organization by 'id', |
125 |
|
# is mandatory; |
126 |
|
|
127 |
column hrEduPersonAffiliation => |
column hrEduPersonAffiliation => |
128 |
label is _('Povezanost s ustanovom'), |
label is _('Povezanost s ustanovom'), |
129 |
is mandatory, |
is mandatory, |
130 |
valid are [ |
valid are A3C::AAIEduHr->vocabulary('hrEdu004'), |
|
'učenik', |
|
|
'student', |
|
|
'djelatnik', |
|
|
'vanjski suradnik', |
|
|
'korisnik usluge', |
|
|
'gost', |
|
|
], |
|
131 |
default is 'korisnik usluge'; |
default is 'korisnik usluge'; |
132 |
|
|
133 |
column hrEduPersonPrimaryAffiliation => |
column hrEduPersonPrimaryAffiliation => |
134 |
label is _('Temeljna povezanost s ustanovom'); |
label is _('Temeljna povezanost s ustanovom'); |
135 |
is mandatory, |
is mandatory, |
136 |
valid are [ |
valid are A3C::AAIEduHr->vocabulary('hrEdu004'), |
|
'učenik', |
|
|
'student', |
|
|
'djelatnik', |
|
|
'vanjski suradnik', |
|
|
'korisnik usluge', |
|
|
'gost', |
|
|
], |
|
137 |
default is 'korisnik usluge'; |
default is 'korisnik usluge'; |
138 |
|
|
139 |
column hrEduPersonStudentCategory => |
column hrEduPersonStudentCategory => |
140 |
label is 'Vrsta studenta', |
label is 'Vrsta studenta', |
141 |
valid are [ |
valid are [ |
142 |
'', |
'', |
143 |
'osnovnoškolac', |
A3C::AAIEduHr->vocabulary('hrEdu010'), |
|
'srednjoškolac', |
|
|
'student stručnog studija', |
|
|
'preddiplomac', |
|
|
'postdiplomac', |
|
|
'dodiplomac', |
|
|
'pauzira godinu', |
|
|
'prekid studija', |
|
144 |
], |
], |
145 |
default is ''; |
default is ''; |
146 |
|
|
153 |
|
|
154 |
column hrEduPersonTitle => |
column hrEduPersonTitle => |
155 |
label is 'Položaj u ustanovi', |
label is 'Položaj u ustanovi', |
156 |
valid are [ # FIXME reorder |
valid are [ '', A3C::AAIEduHr->vocabulary('hrEdu003') ], |
|
'', |
|
|
'dekan', |
|
|
'direktor', |
|
|
'pomoćnik ravnatelja', |
|
|
'predstojnik zavoda', |
|
|
'pročelnik katedre', |
|
|
'pročelnik odsjeka', |
|
|
'pročelnik sveučilišnog odjela', |
|
|
'prodekan', |
|
|
'prorektor', |
|
|
'ravnatelj', |
|
|
'rektor', |
|
|
'voditelj laboratorija', |
|
|
'voditelj odjela', |
|
|
'voditelj organizacijske jedini', |
|
|
'voditelj projekta', |
|
|
'zamjenik pročelnika sveučilišn', |
|
|
'zamjenik ravnatelja', |
|
|
], |
|
157 |
default is ''; |
default is ''; |
158 |
|
|
159 |
column hrEduPersonRole => |
column hrEduPersonRole => |
160 |
label is 'Uloga u ustanovi', |
label is 'Uloga u ustanovi', |
161 |
valid are [ |
valid are [ |
162 |
'', |
'', |
163 |
'administrator imenika', |
A3C::AAIEduHr->vocabulary('hrEdu006'), |
|
'CARNet koordinator', |
|
|
'CARNet sistem inženjer', |
|
|
'ICT koordinator', |
|
|
'ISVU koordinator', |
|
|
'kontakt za sigurnosna pitanja', |
|
|
'MS koordinator', |
|
164 |
'MATICA operater', |
'MATICA operater', |
165 |
'MATICA urednik', |
'MATICA urednik', |
166 |
], |
], |
168 |
|
|
169 |
column hrEduPersonStaffCategory => |
column hrEduPersonStaffCategory => |
170 |
label is 'Vrsta posla u ustanovi', |
label is 'Vrsta posla u ustanovi', |
171 |
valid are [ |
valid are [ '', A3C::AAIEduHr->vocabulary('hrEdu005') ]; |
|
'administrativno osoblje', |
|
|
'ICT podrška', |
|
|
'istraživači', |
|
|
'nastavno osoblje', |
|
|
'osoblje knjižnice', |
|
|
'tehničko osoblje', |
|
|
]; |
|
172 |
|
|
173 |
column hrEduPersonGroupMember => |
column hrEduPersonGroupMember => |
174 |
label is 'Pripadnost grupi', |
label is 'Pripadnost grupi', |
175 |
hint is 'skolskagodina::razred'; |
hint is 'skolskagodina::razred'; |
176 |
|
|
|
column o => |
|
|
label is _('Naziv matične ustanove'), |
|
|
is mandatory; |
|
|
|
|
|
column hrEduPersonHomeOrg => |
|
|
label is _('Oznaka matične ustanove'), |
|
|
hint is 'CARNet', |
|
|
is mandatory; |
|
|
|
|
177 |
column ou => |
column ou => |
178 |
label is _('Organizacijska jedinica'); |
label is _('Organizacijska jedinica'); |
179 |
|
|
180 |
column roomNumber => |
column roomNumber => |
181 |
label is _('Broj sobe'); |
label is _('Broj sobe'); |
182 |
|
|
|
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'); |
|
|
|
|
183 |
column homePostalAddress => |
column homePostalAddress => |
184 |
label is _('Kućna poštanska adresa'), |
label is _('Kućna poštanska adresa'), |
185 |
render as 'textarea'; |
render as 'textarea'; |
194 |
label is _('Oznaka privatnosti'); |
label is _('Oznaka privatnosti'); |
195 |
|
|
196 |
column loginShell => |
column loginShell => |
197 |
label is _('shell'); |
label is _('login shell'); |
198 |
|
|
199 |
column uidNumber => |
column uidNumber => |
200 |
label is _('uid'), |
label is _('uid number'), |
201 |
type is 'int'; |
type is 'int'; |
202 |
|
|
203 |
column gidNumber => |
column gidNumber => |
204 |
label is _('gid'); |
label is _('gid number'); |
205 |
type is 'int'; |
type is 'int'; |
206 |
|
|
207 |
column homeDirectory => |
column homeDirectory => |
208 |
label is _('home'); |
label is _('home directory'); |
|
|
|
|
column objectClass => |
|
|
type is 'virtual'; |
|
209 |
|
|
210 |
}; |
}; |
211 |
|
|
243 |
|
|
244 |
sub email { |
sub email { |
245 |
my $self = shift; |
my $self = shift; |
246 |
return $self->__value('mail'); |
return $self->mail; |
247 |
} |
} |
248 |
|
|
249 |
sub email_confirmed { 1 }; |
sub email_confirmed { 1 }; |
250 |
|
|
251 |
|
=head2 name |
252 |
|
|
253 |
|
=cut |
254 |
|
|
255 |
|
sub name { |
256 |
|
my $self = shift; |
257 |
|
return $self->cn . ' <' . $self->mail . '>'; |
258 |
|
} |
259 |
|
|
260 |
=head2 validate_telephoneNumber |
=head2 validate_telephoneNumber |
261 |
|
|
262 |
=cut |
=cut |
269 |
return ( 1, 'OK' ); |
return ( 1, 'OK' ); |
270 |
} |
} |
271 |
|
|
272 |
|
=head2 hrEduPersonUniqueNumber |
273 |
|
|
274 |
|
Check if JMBG is valid |
275 |
|
|
276 |
|
=cut |
277 |
|
|
278 |
|
sub validate_hrEduPersonUniqueNumber { |
279 |
|
my ( $self, $value ) = @_; |
280 |
|
|
281 |
|
if ( $value =~ m/^JMBG:\s+(\d+)$/ ) { |
282 |
|
|
283 |
|
my $jmbg = $1; |
284 |
|
|
285 |
|
return ( 0, _('JMBG must have 13 digits') ) unless length($jmbg) == 13; |
286 |
|
|
287 |
|
sub digit_at { |
288 |
|
my ($jmbg,$pos) = @_; |
289 |
|
return ord(substr($jmbg,$pos,1)) - ord('0'); |
290 |
|
} |
291 |
|
|
292 |
|
my $sum; |
293 |
|
my $fact = 7; |
294 |
|
|
295 |
|
foreach my $i ( 0 .. 11 ) { |
296 |
|
my $c = digit_at( $jmbg, $i ); |
297 |
|
$sum += $c * $fact; |
298 |
|
# warn "## $c * $fact => $sum\n"; |
299 |
|
$fact--; |
300 |
|
$fact = 7 if $fact == 1; |
301 |
|
} |
302 |
|
|
303 |
|
my $ost = $sum % 11; |
304 |
|
$ost = 11 - $ost if $ost > 1; |
305 |
|
|
306 |
|
return ( 0, _("JMBG is invalid") ) if $ost != digit_at( $jmbg, 12 ); |
307 |
|
} |
308 |
|
|
309 |
|
return ( 1, 'OK' ); |
310 |
|
} |
311 |
|
|
312 |
=head2 canonicalize_hrEduPersonExpireDate |
=head2 canonicalize_hrEduPersonExpireDate |
313 |
|
|
314 |
Support NONE as 2042-12-30 |
Support NONE as 2042-12-30 |
318 |
sub canonicalize_hrEduPersonExpireDate { |
sub canonicalize_hrEduPersonExpireDate { |
319 |
my ( $self, $value ) = @_; |
my ( $self, $value ) = @_; |
320 |
|
|
321 |
if ( $value eq 'NONE' ) { |
if ( lc($value) eq 'none' ) { |
322 |
$self->log->warn("fixed hrEduPersonExpireDate"); |
$self->log->warn("fixed hrEduPersonExpireDate"); |
323 |
$value = '2042-12-30'; |
$value = '2042-12-30'; |
324 |
} |
} |
326 |
return $value; |
return $value; |
327 |
} |
} |
328 |
|
|
329 |
=head2 current_user_can |
use A3C::DefaultACL; |
|
|
|
|
=cut |
|
|
|
|
|
sub current_user_can { |
|
|
# FIXME no security for now :-) |
|
|
return 1; |
|
|
} |
|
330 |
|
|
331 |
1; |
1; |
332 |
|
|