/[A3C]/lib/A3C/Model/User.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /lib/A3C/Model/User.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 18 - (show annotations)
Thu Mar 13 19:26:56 2008 UTC (16 years ago) by dpavlin
File size: 7299 byte(s)
remove Jifty::Plugin::User::Mixin::Model::User and
implement it ourselfs, with few tweaks for other
mixins (email* accessors)

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

  ViewVC Help
Powered by ViewVC 1.1.26