1 |
use strict; |
2 |
use warnings; |
3 |
|
4 |
package A3C::Model::User; |
5 |
use Jifty::DBI::Schema; |
6 |
|
7 |
use utf8; |
8 |
|
9 |
use A3C::Record schema { |
10 |
|
11 |
column uid => |
12 |
label is ('uid'), |
13 |
is indexed, |
14 |
is mandatory, |
15 |
is distinct; |
16 |
|
17 |
column hrEduPersonUniqueID => |
18 |
label is ('hrEduPersonUniqueID'), |
19 |
is indexed, |
20 |
is mandatory, |
21 |
is distinct; |
22 |
|
23 |
column name => |
24 |
type is 'text', |
25 |
label is _('Ime'), |
26 |
is mandatory; |
27 |
|
28 |
column cn => |
29 |
label is _('Ime'), |
30 |
type is 'virtual'; |
31 |
|
32 |
column sn => |
33 |
type is 'virtual', |
34 |
label is _('Prezime'), |
35 |
is mandatory; |
36 |
|
37 |
column givenName => |
38 |
type is 'virtual', |
39 |
label is _('Ime'), |
40 |
is mandatory; |
41 |
|
42 |
column mail => |
43 |
type is 'virtual'; |
44 |
|
45 |
column email => |
46 |
type is 'text', |
47 |
is mandatory, |
48 |
label is _('Email address'), default is '', is immutable, is distinct; |
49 |
|
50 |
column email_confirmed => |
51 |
label is _('Email address confirmed?'), |
52 |
type is 'boolean'; |
53 |
|
54 |
column password => |
55 |
is unreadable, |
56 |
label is _('Password'), |
57 |
type is 'varchar', |
58 |
hints is _('Your password should be at least six characters'), |
59 |
render_as 'password', |
60 |
# filters are 'Jifty::DBI::Filter::SaltHash', |
61 |
is mandatory; |
62 |
|
63 |
column telephoneNumber => |
64 |
type is 'text', |
65 |
label is _('Telefonski broj'), |
66 |
hint is '+385 xx yyyyyy'; |
67 |
|
68 |
column hrEduPersonExtensionNumber => |
69 |
label is _('Lokalni telefonski broj'); |
70 |
|
71 |
column mobile => |
72 |
label is _('Broj mobilnog telefona'); |
73 |
|
74 |
column facsimileTelephoneNumber => |
75 |
label is _('Fax broj'); |
76 |
|
77 |
column hrEduPersonUniqueNumber => |
78 |
# is mandatory, |
79 |
label is _('JMBG'); |
80 |
|
81 |
column hrEduPersonDateOfBirth => |
82 |
type is 'date', |
83 |
render as 'date', |
84 |
label is _('Datum rođenja'), |
85 |
filters are 'Jifty::DBI::Filter::Date'; |
86 |
|
87 |
column hrEduPersonGender => |
88 |
label is _('Spol'); |
89 |
|
90 |
column jpegPhoto => |
91 |
label is _('Slika'); |
92 |
|
93 |
column userCertificate => |
94 |
label is _('Ceritifikat'); |
95 |
|
96 |
column labeledURI => |
97 |
label is _('URI adresa'); |
98 |
|
99 |
column wtAdminType => |
100 |
label is _('Tip administratora'), |
101 |
valid are [ '', 'AS', 'AI', 'AR', 'AHU' ]; |
102 |
|
103 |
column hrEduPersonProfessionalStatus => |
104 |
label is _('Stručni status'), |
105 |
valid are [ |
106 |
'', |
107 |
'NKV', |
108 |
'PKV', |
109 |
'KV', |
110 |
'VKV', |
111 |
'SSS', |
112 |
'VS', |
113 |
'VSS', |
114 |
'VŠS', |
115 |
'MR', |
116 |
'DR', |
117 |
], |
118 |
default is ''; |
119 |
|
120 |
column hrEduPersonAcademicStatus => |
121 |
label is _('Zvanje'), |
122 |
valid are [ |
123 |
'', |
124 |
'knjižničar', |
125 |
'viši knjižničar', |
126 |
'korepetitor', |
127 |
'viši korepetitor', |
128 |
'lektor', |
129 |
'viši lektor', |
130 |
'stručni suradnik', |
131 |
'asistent visoke škole', |
132 |
'profesor visoke škole', |
133 |
'mlađi asistent', |
134 |
'znanstveni novak', |
135 |
'znanstveni asistent', |
136 |
'znanstveni suradnik', |
137 |
'predavač', |
138 |
'viši predavač', |
139 |
'asistent', |
140 |
'asistent - predavač', |
141 |
'viši asistent', |
142 |
'docent', |
143 |
'izvanredni profesor', |
144 |
'redoviti profesor', |
145 |
'znanstveni savjetnik', |
146 |
'viši znanstveni suradnik', |
147 |
], |
148 |
default is ''; |
149 |
|
150 |
column hrEduPersonScienceArea => |
151 |
label is _('Područje znanosti'), |
152 |
valid are [ |
153 |
'', |
154 |
'Tehničke znanosti', |
155 |
'Prirodne znanosti', |
156 |
'Humanističke znanosti', |
157 |
'Društvene znanosti', |
158 |
'Biotehničke znanosti', |
159 |
'Biomedicina i zdravstvo', |
160 |
], |
161 |
default is ''; |
162 |
|
163 |
column hrEduPersonAffiliation => |
164 |
label is _('Povezanost s ustanovom'), |
165 |
is mandatory, |
166 |
valid are [ |
167 |
'učenik', |
168 |
'student', |
169 |
'djelatnik', |
170 |
'vanjski suradnik', |
171 |
'korisnik usluge', |
172 |
'gost', |
173 |
], |
174 |
default is 'korisnik usluge'; |
175 |
|
176 |
column hrEduPersonPrimaryAffiliation => |
177 |
label is _('Temeljna povezanost s ustanovom'); |
178 |
is mandatory, |
179 |
valid are [ |
180 |
'učenik', |
181 |
'student', |
182 |
'djelatnik', |
183 |
'vanjski suradnik', |
184 |
'korisnik usluge', |
185 |
'gost', |
186 |
], |
187 |
default is 'korisnik usluge'; |
188 |
|
189 |
column hrEduPersonStudentCategory => |
190 |
label is 'Vrsta studenta', |
191 |
valid are [ |
192 |
'', |
193 |
'osnovnoškolac', |
194 |
'srednjoškolac', |
195 |
'student stručnog studija', |
196 |
'preddiplomac', |
197 |
'postdiplomac', |
198 |
'dodiplomac', |
199 |
'pauzira godinu', |
200 |
'prekid studija', |
201 |
], |
202 |
default is ''; |
203 |
|
204 |
column hrEduPersonExpireDate => |
205 |
label is _('Datum isteka temeljne povezanosti'), |
206 |
type is 'date', |
207 |
render as 'date', |
208 |
is mandatory, |
209 |
filters are 'Jifty::DBI::Filter::Date'; |
210 |
|
211 |
column hrEduPersonTitle => |
212 |
label is 'Položaj u ustanovi', |
213 |
valid are [ # FIXME reorder |
214 |
'', |
215 |
'dekan', |
216 |
'direktor', |
217 |
'pomoćnik ravnatelja', |
218 |
'predstojnik zavoda', |
219 |
'pročelnik katedre', |
220 |
'pročelnik odsjeka', |
221 |
'pročelnik sveučilišnog odjela', |
222 |
'prodekan', |
223 |
'prorektor', |
224 |
'ravnatelj', |
225 |
'rektor', |
226 |
'voditelj laboratorija', |
227 |
'voditelj odjela', |
228 |
'voditelj organizacijske jedini', |
229 |
'voditelj projekta', |
230 |
'zamjenik pročelnika sveučilišn', |
231 |
'zamjenik ravnatelja', |
232 |
], |
233 |
default is ''; |
234 |
|
235 |
column hrEduPersonRole => |
236 |
label is 'Uloga u ustanovi', |
237 |
valid are [ |
238 |
'', |
239 |
'administrator imenika', |
240 |
'CARNet koordinator', |
241 |
'CARNet sistem inženjer', |
242 |
'ICT koordinator', |
243 |
'ISVU koordinator', |
244 |
'kontakt za sigurnosna pitanja', |
245 |
'MS koordinator', |
246 |
'MATICA operater', |
247 |
'MATICA urednik', |
248 |
], |
249 |
default is ''; |
250 |
|
251 |
column hrEduPersonStaffCategory => |
252 |
label is 'Vrsta posla u ustanovi', |
253 |
valid are [ |
254 |
'administrativno osoblje', |
255 |
'ICT podrška', |
256 |
'istraživači', |
257 |
'nastavno osoblje', |
258 |
'osoblje knjižnice', |
259 |
'tehničko osoblje', |
260 |
]; |
261 |
|
262 |
column hrEduPersonGroupMember => |
263 |
label is 'Pripadnost grupi', |
264 |
hint is 'skolskagodina::razred'; |
265 |
|
266 |
column o => |
267 |
label is _('Naziv matične ustanove'), |
268 |
is mandatory; |
269 |
|
270 |
column hrEduPersonHomeOrg => |
271 |
label is _('Oznaka matične ustanove'), |
272 |
hint is 'CARNet', |
273 |
is mandatory; |
274 |
|
275 |
column ou => |
276 |
label is _('Organizacijska jedinica'); |
277 |
|
278 |
column roomNumber => |
279 |
label is _('Broj sobe'); |
280 |
|
281 |
column postalAddress => |
282 |
label is _('Poštanska adresa'), |
283 |
render as 'textarea', |
284 |
is mandatory; |
285 |
|
286 |
column l => |
287 |
label is _('Mjesto'), |
288 |
hist is 'Zagreb', |
289 |
is mandatory; |
290 |
|
291 |
column postalCode => |
292 |
label is _('Poštanski broj'), |
293 |
hint is 'HR-10000'; |
294 |
|
295 |
column street => |
296 |
label is _('Ulica i kućni broj'); |
297 |
|
298 |
column homePostalAddress => |
299 |
label is _('Kućna poštanska adresa'), |
300 |
render as 'textarea'; |
301 |
|
302 |
column homePhone => |
303 |
label is _('Kućni telefonski broj'); |
304 |
|
305 |
column hrEduPersonCommURI => |
306 |
label is _('Desktop uređaj'); |
307 |
|
308 |
column hrEduPersonPrivacy => |
309 |
label is _('Oznaka privatnosti'); |
310 |
|
311 |
}; |
312 |
|
313 |
use Jifty::Plugin::User::Mixin::Model::User; |
314 |
use Jifty::Plugin::Authentication::Password::Mixin::Model::User; |
315 |
#use Jifty::Plugin::OpenID::Mixin::Model::User; |
316 |
use Jifty::Plugin::ActorMetadata::Mixin::Model::ActorMetadata; # created_by, created_on, updated_on |
317 |
|
318 |
# Your model-specific methods go here. |
319 |
|
320 |
=head2 set_mail |
321 |
|
322 |
Put mail from ldap into email row |
323 |
|
324 |
=cut |
325 |
|
326 |
sub set_mail { |
327 |
my ($self,$v) = @_; |
328 |
$self->set_email( $v ); |
329 |
} |
330 |
|
331 |
=head2 validate_telephoneNumber |
332 |
|
333 |
=cut |
334 |
|
335 |
sub validate_telephoneNumber { |
336 |
my ( $self, $value ) = @_; |
337 |
|
338 |
return ( 0, _('Telephone number invalid') ) if $value !~ m/^(\+?385)?[\d\s-]+$/; |
339 |
|
340 |
return ( 1, 'OK' ); |
341 |
} |
342 |
|
343 |
=head2 canonicalize_hrEduPersonExpireDate |
344 |
|
345 |
Support NONE as 2042-12-30 |
346 |
|
347 |
=cut |
348 |
|
349 |
sub canonicalize_hrEduPersonExpireDate { |
350 |
my ( $self, $value ) = @_; |
351 |
|
352 |
if ( $value eq 'NONE' ) { |
353 |
$self->log->warn("fixed hrEduPersonExpireDate"); |
354 |
$value = '2042-12-30'; |
355 |
} |
356 |
|
357 |
return $value; |
358 |
} |
359 |
|
360 |
=head2 current_user_can |
361 |
|
362 |
=cut |
363 |
|
364 |
sub current_user_can { |
365 |
# FIXME no security for now :-) |
366 |
return 1; |
367 |
} |
368 |
|
369 |
1; |
370 |
|