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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.2  
changed lines
  Added in v.29

  ViewVC Help
Powered by ViewVC 1.1.26