/[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 27 by dpavlin, Mon Mar 17 21:30:59 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 virtual;
26    
27            column sn =>
28                    is virtual,
29                    label is _('Prezime'),
30                    is mandatory;
31    
32            column givenName =>
33                    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            column loginShell =>
302                    label is _('shell');
303    
304            column uidNumber =>
305                    label is _('uid'),
306                    type is 'int';
307    
308            column gidNumber =>
309                    label is _('gid');
310                    type is 'int';
311    
312            column homeDirectory =>
313                    label is _('home');
314    
315  };  };
316    
317    # we don't use following mixing because it wants to send notificaitons on e-mail address change
318    #use Jifty::Plugin::User::Mixin::Model::User;
319    use Jifty::Plugin::Authentication::Password::Mixin::Model::User;
320    #use Jifty::Plugin::OpenID::Mixin::Model::User;
321    use Jifty::Plugin::ActorMetadata::Mixin::Model::ActorMetadata; # created_by, created_on, updated_on
322    
323  # Your model-specific methods go here.  # Your model-specific methods go here.
324    
325    =head2 before_create
326    
327    Implement virtual columns, for now put mail from ldap into email row
328    
329    =cut
330    
331    =for later
332    
333    sub before_create {
334            my ($self, $attr) = @_;
335            if ( ! $attr->{'email'} ) {
336                    warn "push mail to email";
337                    $attr->{'email'} = $attr->{'mail'};
338            }
339    }
340    
341    =cut
342    
343    =head2 email
344    
345    Accessor for compatibility with Jifty mixins
346    
347    =cut
348    
349    sub email {
350            my $self = shift;
351            return $self->__value('mail');
352    }
353    
354    sub email_confirmed { 1 };
355    
356    =head2 validate_telephoneNumber
357    
358    =cut
359    
360    sub validate_telephoneNumber {
361            my ( $self, $value ) = @_;
362    
363            return ( 0, _('Telephone number invalid') ) if $value !~ m/^(\+?385)?[\d\s-]+$/;
364    
365            return ( 1, 'OK' );
366    }
367    
368    =head2 canonicalize_hrEduPersonExpireDate
369    
370    Support NONE as 2042-12-30
371    
372    =cut
373    
374    sub canonicalize_hrEduPersonExpireDate {
375            my ( $self, $value ) = @_;
376    
377            if ( $value eq 'NONE' ) {
378                    $self->log->warn("fixed hrEduPersonExpireDate");
379                    $value = '2042-12-30';
380            }
381    
382            return $value;
383    }
384    
385    =head2 current_user_can
386    
387    =cut
388    
389    sub current_user_can {
390            # FIXME no security for now :-)
391            return 1;
392    }
393    
394  1;  1;
395    

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

  ViewVC Help
Powered by ViewVC 1.1.26