/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 16 - (hide annotations)
Thu Mar 13 18:07:28 2008 UTC (16 years, 1 month ago) by dpavlin
File size: 7099 byte(s)
- added uid, hrEduPersonUniqueID columns
- try to map LDAP mail into email column
- use Jifty::DBI::Filter::Date to get DateTime object from model
- hrEduPersonExpireDate support NONE as 2042-12-30

1 dpavlin 2 use strict;
2     use warnings;
3    
4 dpavlin 11 package A3C::Model::User;
5 dpavlin 2 use Jifty::DBI::Schema;
6    
7 dpavlin 14 use utf8;
8    
9 dpavlin 11 use A3C::Record schema {
10 dpavlin 2
11 dpavlin 16 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 dpavlin 4 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 dpavlin 16 column mail =>
43     type is 'virtual';
44    
45 dpavlin 4 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 dpavlin 10 # is mandatory,
79 dpavlin 4 label is _('JMBG');
80    
81     column hrEduPersonDateOfBirth =>
82     type is 'date',
83 dpavlin 15 render as 'date',
84 dpavlin 16 label is _('Datum rođenja'),
85     filters are 'Jifty::DBI::Filter::Date';
86 dpavlin 4
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 dpavlin 15 valid are [ '', 'AS', 'AI', 'AR', 'AHU' ];
102 dpavlin 4
103     column hrEduPersonProfessionalStatus =>
104     label is _('Stručni status'),
105 dpavlin 15 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 dpavlin 4
120     column hrEduPersonAcademicStatus =>
121     label is _('Zvanje'),
122 dpavlin 15 valid are [
123     '',
124 dpavlin 4 'knjižničar',
125 dpavlin 15 'viši knjižničar',
126 dpavlin 4 'korepetitor',
127 dpavlin 15 'viši korepetitor',
128 dpavlin 4 'lektor',
129 dpavlin 15 'viši lektor',
130     'stručni suradnik',
131     'asistent visoke škole',
132     'profesor visoke škole',
133 dpavlin 4 'mlađi asistent',
134 dpavlin 15 'znanstveni novak',
135     'znanstveni asistent',
136     'znanstveni suradnik',
137 dpavlin 4 'predavač',
138 dpavlin 15 'viši predavač',
139     'asistent',
140     'asistent - predavač',
141     'viši asistent',
142     'docent',
143     'izvanredni profesor',
144 dpavlin 4 'redoviti profesor',
145 dpavlin 15 'znanstveni savjetnik',
146 dpavlin 4 'viši znanstveni suradnik',
147 dpavlin 15 ],
148     default is '';
149 dpavlin 4
150     column hrEduPersonScienceArea =>
151     label is _('Područje znanosti'),
152 dpavlin 15 valid are [
153     '',
154 dpavlin 4 'Tehničke znanosti',
155     'Prirodne znanosti',
156     'Humanističke znanosti',
157     'Društvene znanosti',
158     'Biotehničke znanosti',
159     'Biomedicina i zdravstvo',
160 dpavlin 15 ],
161     default is '';
162 dpavlin 4
163     column hrEduPersonAffiliation =>
164     label is _('Povezanost s ustanovom'),
165     is mandatory,
166 dpavlin 15 valid are [
167     'učenik',
168     'student',
169 dpavlin 4 'djelatnik',
170 dpavlin 15 'vanjski suradnik',
171     'korisnik usluge',
172 dpavlin 4 'gost',
173 dpavlin 15 ],
174     default is 'korisnik usluge';
175 dpavlin 4
176     column hrEduPersonPrimaryAffiliation =>
177     label is _('Temeljna povezanost s ustanovom');
178     is mandatory,
179 dpavlin 15 valid are [
180     'učenik',
181     'student',
182 dpavlin 4 'djelatnik',
183 dpavlin 15 'vanjski suradnik',
184     'korisnik usluge',
185 dpavlin 4 'gost',
186 dpavlin 15 ],
187     default is 'korisnik usluge';
188 dpavlin 4
189     column hrEduPersonStudentCategory =>
190     label is 'Vrsta studenta',
191 dpavlin 15 valid are [
192     '',
193     'osnovnoškolac',
194     'srednjoškolac',
195     'student stručnog studija',
196     'preddiplomac',
197     'postdiplomac',
198 dpavlin 4 'dodiplomac',
199     'pauzira godinu',
200     'prekid studija',
201 dpavlin 15 ],
202     default is '';
203 dpavlin 4
204     column hrEduPersonExpireDate =>
205     label is _('Datum isteka temeljne povezanosti'),
206     type is 'date',
207 dpavlin 15 render as 'date',
208 dpavlin 4 is mandatory,
209 dpavlin 16 filters are 'Jifty::DBI::Filter::Date';
210 dpavlin 4
211     column hrEduPersonTitle =>
212     label is 'Položaj u ustanovi',
213 dpavlin 15 valid are [ # FIXME reorder
214     '',
215 dpavlin 4 '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 dpavlin 15 ],
233     default is '';
234 dpavlin 4
235     column hrEduPersonRole =>
236     label is 'Uloga u ustanovi',
237 dpavlin 15 valid are [
238     '',
239 dpavlin 4 '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 dpavlin 15 ],
249     default is '';
250 dpavlin 4
251     column hrEduPersonStaffCategory =>
252     label is 'Vrsta posla u ustanovi',
253 dpavlin 15 valid are [
254 dpavlin 4 '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 dpavlin 12 render as 'textarea',
284 dpavlin 4 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 dpavlin 12 label is _('Kućna poštanska adresa'),
300     render as 'textarea';
301 dpavlin 4
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 dpavlin 2 };
312    
313 dpavlin 4 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 dpavlin 2 # Your model-specific methods go here.
319    
320 dpavlin 16 =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 dpavlin 4 =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 dpavlin 16 =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 dpavlin 7 sub current_user_can {
365     # FIXME no security for now :-)
366     return 1;
367     }
368    
369 dpavlin 2 1;
370    

  ViewVC Help
Powered by ViewVC 1.1.26