/[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 33 by dpavlin, Tue Mar 18 19:22:30 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 organization =>
152                    refers_to A3C::Model::Organization by 'id',
153                    is mandatory;
154    
155            column hrEduPersonAffiliation =>
156                    label is _('Povezanost s ustanovom'),
157                    is mandatory,
158                    valid are [
159                            'učenik',
160                            'student',
161                            'djelatnik',
162                            'vanjski suradnik',
163                            'korisnik usluge',
164                            'gost',
165                    ],
166                    default is 'korisnik usluge';
167    
168            column hrEduPersonPrimaryAffiliation =>
169                    label is _('Temeljna povezanost s ustanovom');
170                    is mandatory,
171                    valid are [
172                            'učenik',
173                            'student',
174                            'djelatnik',
175                            'vanjski suradnik',
176                            'korisnik usluge',
177                            'gost',
178                    ],
179                    default is 'korisnik usluge';
180    
181            column hrEduPersonStudentCategory =>
182                    label is 'Vrsta studenta',
183                    valid are [
184                            '',
185                            'osnovnoškolac',
186                            'srednjoškolac',
187                            'student stručnog studija',
188                            'preddiplomac',
189                            'postdiplomac',
190                            'dodiplomac',
191                            'pauzira godinu',
192                            'prekid studija',
193                    ],
194                    default is '';
195    
196            column hrEduPersonExpireDate =>
197                    label is _('Datum isteka temeljne povezanosti'),
198                    type is 'date',
199                    render as 'date',
200                    is mandatory,
201                    filters are 'Jifty::DBI::Filter::Date';
202    
203            column hrEduPersonTitle =>
204                    label is 'Položaj u ustanovi',
205                    valid are [     # FIXME reorder
206                            '',
207                            'dekan',
208                            'direktor',
209                            'pomoćnik ravnatelja',
210                            'predstojnik zavoda',
211                            'pročelnik katedre',
212                            'pročelnik odsjeka',
213                            'pročelnik sveučilišnog odjela',
214                            'prodekan',
215                            'prorektor',
216                            'ravnatelj',
217                            'rektor',
218                            'voditelj laboratorija',
219                            'voditelj odjela',
220                            'voditelj organizacijske jedini',
221                            'voditelj projekta',
222                            'zamjenik pročelnika sveučilišn',
223                            'zamjenik ravnatelja',
224                    ],
225                    default is '';
226    
227            column hrEduPersonRole =>
228                    label is 'Uloga u ustanovi',
229                    valid are [
230                            '',
231                            'administrator imenika',
232                            'CARNet koordinator',
233                            'CARNet sistem inženjer',
234                            'ICT koordinator',
235                            'ISVU koordinator',
236                            'kontakt za sigurnosna pitanja',
237                            'MS koordinator',
238                            'MATICA operater',
239                            'MATICA urednik',
240                    ],
241                    default is '';
242    
243            column hrEduPersonStaffCategory =>
244                    label is 'Vrsta posla u ustanovi',
245                    valid are [
246                            'administrativno osoblje',
247                            'ICT podrška',
248                            'istraživači',
249                            'nastavno osoblje',
250                            'osoblje knjižnice',
251                            'tehničko osoblje',
252                    ];
253    
254            column hrEduPersonGroupMember =>
255                    label is 'Pripadnost grupi',
256                    hint is 'skolskagodina::razred';
257    
258            column ou =>
259                    label is _('Organizacijska jedinica');
260            
261            column roomNumber =>
262                    label is _('Broj sobe');
263    
264            column homePostalAddress =>
265                    label is _('Kućna poštanska adresa'),
266                    render as 'textarea';
267            
268            column homePhone =>
269                    label is _('Kućni telefonski broj');
270            
271            column hrEduPersonCommURI =>
272                    label is _('Desktop uređaj');
273    
274            column hrEduPersonPrivacy =>
275                    label is _('Oznaka privatnosti');
276    
277            column loginShell =>
278                    label is _('shell');
279    
280            column uidNumber =>
281                    label is _('uid'),
282                    type is 'int';
283    
284            column gidNumber =>
285                    label is _('gid');
286                    type is 'int';
287    
288            column homeDirectory =>
289                    label is _('home');
290    
291  };  };
292    
293    # we don't use following mixing because it wants to send notificaitons on e-mail address change
294    #use Jifty::Plugin::User::Mixin::Model::User;
295    use Jifty::Plugin::Authentication::Password::Mixin::Model::User;
296    #use Jifty::Plugin::OpenID::Mixin::Model::User;
297    use Jifty::Plugin::ActorMetadata::Mixin::Model::ActorMetadata; # created_by, created_on, updated_on
298    
299  # Your model-specific methods go here.  # Your model-specific methods go here.
300    
301    =head2 before_create
302    
303    Implement virtual columns, for now put mail from ldap into email row
304    
305    =cut
306    
307    =for later
308    
309    sub before_create {
310            my ($self, $attr) = @_;
311            if ( ! $attr->{'email'} ) {
312                    warn "push mail to email";
313                    $attr->{'email'} = $attr->{'mail'};
314            }
315    }
316    
317    =cut
318    
319    =head2 email
320    
321    Accessor for compatibility with Jifty mixins
322    
323    =cut
324    
325    sub email {
326            my $self = shift;
327            return $self->__value('mail');
328    }
329    
330    sub email_confirmed { 1 };
331    
332    =head2 validate_telephoneNumber
333    
334    =cut
335    
336    sub validate_telephoneNumber {
337            my ( $self, $value ) = @_;
338    
339            return ( 0, _('Telephone number invalid') ) if $value !~ m/^(\+?385)?[\d\s-]+$/;
340    
341            return ( 1, 'OK' );
342    }
343    
344    =head2 canonicalize_hrEduPersonExpireDate
345    
346    Support NONE as 2042-12-30
347    
348    =cut
349    
350    sub canonicalize_hrEduPersonExpireDate {
351            my ( $self, $value ) = @_;
352    
353            if ( lc($value) eq 'none' ) {
354                    $self->log->warn("fixed hrEduPersonExpireDate");
355                    $value = '2042-12-30';
356            }
357    
358            return $value;
359    }
360    
361    =head2 current_user_can
362    
363    =cut
364    
365    sub current_user_can {
366            # FIXME no security for now :-)
367            return 1;
368    }
369    
370  1;  1;
371    

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

  ViewVC Help
Powered by ViewVC 1.1.26