/[A3C]/lib/A3C/Model/Person.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/Person.pm

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

lib/CAdmin/Model/User.pm revision 10 by dpavlin, Thu Mar 13 14:08:41 2008 UTC lib/A3C/Model/Person.pm revision 77 by dpavlin, Fri Apr 11 22:02:09 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::Person;
5  use Jifty::DBI::Schema;  use Jifty::DBI::Schema;
6    
7  use CAdmin::Record schema {  use utf8;
8    
9          column name =>  use A3C::Record schema {
10                  type is 'text',  
11                  label is _('Ime'),          column uid =>
12                    label is _('UID'),
13                    is indexed,
14                    is mandatory,
15                    is distinct;
16    
17            column hrEduPersonUniqueID =>
18                    label is _('hr Edu Person Unique ID'),
19                    is indexed,
20                    is distinct,
21                  is mandatory;                  is mandatory;
22    
23          column cn =>          column cn =>
24                  label is _('Ime'),                  label is _('Ime i prezime'),
25                  type is 'virtual';                  is mandatory;
26    
27          column sn =>          column sn =>
                 type is 'virtual',  
28                  label is _('Prezime'),                  label is _('Prezime'),
29                  is mandatory;                  is mandatory;
30    
31          column givenName =>          column givenName =>
                 type is 'virtual',  
32                  label is _('Ime'),                  label is _('Ime'),
33                  is mandatory;                  is mandatory;
34    
35          column email =>          column mail =>
36                  type is 'text',                  type is 'text',
37                  is mandatory,                  is mandatory,
38                  label is _('Email address'), default is '', is immutable, is distinct;                  label is _('Email address'), default is '',
39                    is indexed,
40          column email_confirmed =>                  is immutable,
41                  label is _('Email address confirmed?'),                  is distinct;
                 type is 'boolean';  
42    
43          column password =>          column password =>
44                  is unreadable,                  is unreadable,
# Line 59  use CAdmin::Record schema { Line 65  use CAdmin::Record schema {
65    
66          column hrEduPersonUniqueNumber =>          column hrEduPersonUniqueNumber =>
67  #               is mandatory,  #               is mandatory,
68                  label is _('JMBG');                  label is _('Unique number');
69    
70          column hrEduPersonDateOfBirth =>          column hrEduPersonDateOfBirth =>
71                  type is 'date',                  type is 'date',
72                  label is _('Datum rođenja');                  render as 'date',
73                    label is _('Datum rođenja'),
74                    filters are 'Jifty::DBI::Filter::Date';
75    
76          column hrEduPersonGender =>          column hrEduPersonGender =>
77                  label is _('Spol');                  label is _('Spol');
# Line 79  use CAdmin::Record schema { Line 87  use CAdmin::Record schema {
87                    
88          column wtAdminType =>          column wtAdminType =>
89                  label is _('Tip administratora'),                  label is _('Tip administratora'),
90                  available are qw( AS AI AR AHU );                  valid are [ '', 'AS', 'AI', 'AR', 'AHU' ];
91    
92            column hrEduPersonHomeOrg =>
93                    label is _('Oznaka matične ustanove'),
94                    hint is 'CARNet',
95                    is mandatory;
96    
97          column hrEduPersonProfessionalStatus =>          column hrEduPersonProfessionalStatus =>
98                  label is _('Stručni status'),                  label is _('Stručni status'),
99                  available are qw( DR KV MR NKV PKV SSS VKV VS VSS VŠS );                  valid are [
100                            '',
101                            'NKV',
102                            'PKV',
103                            'KV',
104                            'VKV',
105                            'SSS',
106                            'VS',
107                            'VSS',
108                            'VŠS',
109                            'MR',
110                            'DR',
111                    ],
112                    default is '';
113    
114          column hrEduPersonAcademicStatus =>          column hrEduPersonAcademicStatus =>
115                  label is _('Zvanje'),                  label is _('Zvanje'),
116                  available are [                  valid are [
117                          'asistent',                          '',
                         'asistent - predavač',  
                         'asistent visoke škole',  
                         'docent',  
                         'izvanredni profesor',  
118                          'knjižničar',                          'knjižničar',
119                            'viši knjižničar',
120                          'korepetitor',                          'korepetitor',
121                            'viši korepetitor',
122                          'lektor',                          'lektor',
123                            'viši lektor',
124                            'stručni suradnik',
125                            'asistent visoke škole',
126                            'profesor visoke škole',
127                          'mlađi asistent',                          'mlađi asistent',
128                            'znanstveni novak',
129                            'znanstveni asistent',
130                            'znanstveni suradnik',
131                          'predavač',                          'predavač',
                         'profesor visoke škole',  
                         'redoviti profesor',  
                         'stručni suradnik',  
                         'viši asistent',  
                         'viši knjižničar',  
                         'viši korepetitor',  
                         'viši lektor',  
132                          'viši predavač',                          'viši predavač',
133                          'viši znanstveni suradnik',                          'asistent',
134                          'znanstveni asistent',                          'asistent - predavač',
135                          'znanstveni novak',                          'viši asistent',
136                            'docent',
137                            'izvanredni profesor',
138                            'redoviti profesor',
139                          'znanstveni savjetnik',                          'znanstveni savjetnik',
140                          'znanstveni suradnik',                          'viši znanstveni suradnik',
141                  ];                  ],
142                    default is '';
143    
144          column hrEduPersonScienceArea =>          column hrEduPersonScienceArea =>
145                  label is _('Područje znanosti'),                  label is _('Područje znanosti'),
146                  available are [                  valid are [
147                            '',
148                          'Tehničke znanosti',                          'Tehničke znanosti',
149                          'Prirodne znanosti',                          'Prirodne znanosti',
150                          'Humanističke znanosti',                          'Humanističke znanosti',
151                          'Društvene znanosti',                          'Društvene znanosti',
152                          'Biotehničke znanosti',                          'Biotehničke znanosti',
153                          'Biomedicina i zdravstvo',                          'Biomedicina i zdravstvo',
154                  ];                  ],
155                    default is '';
156    
157            column 'o' =>
158                    is indexed;
159    
160            column 'l';
161            column 'postalAddress';
162            column 'postalCode';
163            column 'street';
164    
165    #       column organization =>
166    #               refers_to A3C::Model::Organization by 'id',
167    #               is mandatory;
168    
169          column hrEduPersonAffiliation =>          column hrEduPersonAffiliation =>
170                  label is _('Povezanost s ustanovom'),                  label is _('Povezanost s ustanovom'),
171                  is mandatory,                  is mandatory,
172                  available are [                  valid are [
                         'djelatnik',  
                         'gost',  
                         'korisnik usluge',  
                         'student',  
173                          'učenik',                          'učenik',
174                            'student',
175                            'djelatnik',
176                          'vanjski suradnik',                          'vanjski suradnik',
177                  ];                          'korisnik usluge',
178                            'gost',
179                    ],
180                    default is 'korisnik usluge';
181    
182          column hrEduPersonPrimaryAffiliation =>          column hrEduPersonPrimaryAffiliation =>
183                  label is _('Temeljna povezanost s ustanovom');                  label is _('Temeljna povezanost s ustanovom');
184                  is mandatory,                  is mandatory,
185                  available are [                  valid are [
                         'djelatnik',  
                         'gost',  
                         'korisnik usluge',  
                         'student',  
186                          'učenik',                          'učenik',
187                            'student',
188                            'djelatnik',
189                          'vanjski suradnik',                          'vanjski suradnik',
190                  ];                          'korisnik usluge',
191                            'gost',
192                    ],
193                    default is 'korisnik usluge';
194    
195          column hrEduPersonStudentCategory =>          column hrEduPersonStudentCategory =>
196                  label is 'Vrsta studenta',                  label is 'Vrsta studenta',
197                  available are [                  valid are [
198                          'dodiplomac',                          '',
199                          'osnovnoškolac',                          'osnovnoškolac',
                         'pauzira godinu',  
                         'postdiplomac',  
                         'preddiplomac',  
                         'prekid studija',  
200                          'srednjoškolac',                          'srednjoškolac',
201                          'student stručnog studija',                          'student stručnog studija',
202                  ];                          'preddiplomac',
203                            'postdiplomac',
204                            'dodiplomac',
205                            'pauzira godinu',
206                            'prekid studija',
207                    ],
208                    default is '';
209    
210          column hrEduPersonExpireDate =>          column hrEduPersonExpireDate =>
211                  label is _('Datum isteka temeljne povezanosti'),                  label is _('Datum isteka temeljne povezanosti'),
212                  type is 'date',                  type is 'date',
213                  hint is 'dd.mm.gggg',                  render as 'date',
214                  is mandatory,                  is mandatory,
215                    filters are 'Jifty::DBI::Filter::Date';
216    
217          column hrEduPersonTitle =>          column hrEduPersonTitle =>
218                  label is 'Položaj u ustanovi',                  label is 'Položaj u ustanovi',
219                  available are [                  valid are [     # FIXME reorder
220                            '',
221                          'dekan',                          'dekan',
222                          'direktor',                          'direktor',
223                          'pomoćnik ravnatelja',                          'pomoćnik ravnatelja',
# Line 187  use CAdmin::Record schema { Line 235  use CAdmin::Record schema {
235                          'voditelj projekta',                          'voditelj projekta',
236                          'zamjenik pročelnika sveučilišn',                          'zamjenik pročelnika sveučilišn',
237                          'zamjenik ravnatelja',                          'zamjenik ravnatelja',
238                  ];                  ],
239                    default is '';
240    
241          column hrEduPersonRole =>          column hrEduPersonRole =>
242                  label is 'Uloga u ustanovi',                  label is 'Uloga u ustanovi',
243                  available are [                  valid are [
244                            '',
245                          'administrator imenika',                          'administrator imenika',
246                          'CARNet koordinator',                          'CARNet koordinator',
247                          'CARNet sistem inženjer',                          'CARNet sistem inženjer',
# Line 201  use CAdmin::Record schema { Line 251  use CAdmin::Record schema {
251                          'MS koordinator',                          'MS koordinator',
252                          'MATICA operater',                          'MATICA operater',
253                          'MATICA urednik',                          'MATICA urednik',
254                  ];                  ],
255                    default is '';
256    
257          column hrEduPersonStaffCategory =>          column hrEduPersonStaffCategory =>
258                  label is 'Vrsta posla u ustanovi',                  label is 'Vrsta posla u ustanovi',
259                  available are [                  valid are [
260                          'administrativno osoblje',                          'administrativno osoblje',
261                          'ICT podrška',                          'ICT podrška',
262                          'istraživači',                          'istraživači',
# Line 218  use CAdmin::Record schema { Line 269  use CAdmin::Record schema {
269                  label is 'Pripadnost grupi',                  label is 'Pripadnost grupi',
270                  hint is 'skolskagodina::razred';                  hint is 'skolskagodina::razred';
271    
         column o =>  
                 label is _('Naziv matične ustanove'),  
                 is mandatory;  
           
         column hrEduPersonHomeOrg =>  
                 label is _('Oznaka matične ustanove'),  
                 hint is 'CARNet',  
                 is mandatory;  
   
272          column ou =>          column ou =>
273                  label is _('Organizacijska jedinica');                  label is _('Organizacijska jedinica');
274                    
275          column roomNumber =>          column roomNumber =>
276                  label is _('Broj sobe');                  label is _('Broj sobe');
277    
         column postalAddress =>  
                 label is _('Poštanska adresa'),  
                 is mandatory;  
           
         column l =>  
                 label is _('Mjesto'),  
                 hist is 'Zagreb',  
                 is mandatory;  
   
         column postalCode =>  
                 label is _('Poštanski broj'),  
                 hint is 'HR-10000';  
   
         column street =>  
                 label is _('Ulica i kućni broj');  
           
278          column homePostalAddress =>          column homePostalAddress =>
279                  label is _('Kućna poštanska adresa');                  label is _('Kućna poštanska adresa'),
280                    render as 'textarea';
281                    
282          column homePhone =>          column homePhone =>
283                  label is _('Kućni telefonski broj');                  label is _('Kućni telefonski broj');
# Line 261  use CAdmin::Record schema { Line 288  use CAdmin::Record schema {
288          column hrEduPersonPrivacy =>          column hrEduPersonPrivacy =>
289                  label is _('Oznaka privatnosti');                  label is _('Oznaka privatnosti');
290    
291            column loginShell =>
292                    label is _('login shell');
293    
294            column uidNumber =>
295                    label is _('uid number'),
296                    type is 'int';
297    
298            column gidNumber =>
299                    label is _('gid number');
300                    type is 'int';
301    
302            column homeDirectory =>
303                    label is _('home directory');
304    
305  };  };
306    
307  use Jifty::Plugin::User::Mixin::Model::User;  # we don't use following mixing because it wants to send notificaitons on e-mail address change
308    #use Jifty::Plugin::User::Mixin::Model::User;
309  use Jifty::Plugin::Authentication::Password::Mixin::Model::User;  use Jifty::Plugin::Authentication::Password::Mixin::Model::User;
310  #use Jifty::Plugin::OpenID::Mixin::Model::User;  #use Jifty::Plugin::OpenID::Mixin::Model::User;
311  use Jifty::Plugin::ActorMetadata::Mixin::Model::ActorMetadata; # created_by, created_on, updated_on  use Jifty::Plugin::ActorMetadata::Mixin::Model::ActorMetadata; # created_by, created_on, updated_on
312    
313  # Your model-specific methods go here.  # Your model-specific methods go here.
314    
315    =head2 before_create
316    
317    Implement virtual columns, for now put mail from ldap into email row
318    
319    =cut
320    
321    =for later
322    
323    sub before_create {
324            my ($self, $attr) = @_;
325            if ( ! $attr->{'email'} ) {
326                    warn "push mail to email";
327                    $attr->{'email'} = $attr->{'mail'};
328            }
329    }
330    
331    =cut
332    
333    =head2 email
334    
335    Accessor for compatibility with Jifty mixins
336    
337    =cut
338    
339    sub email {
340            my $self = shift;
341            return $self->mail;
342    }
343    
344    sub email_confirmed { 1 };
345    
346    =head2 name
347    
348    =cut
349    
350    sub name {
351            my $self = shift;
352            return $self->cn . ' <' . $self->mail . '>';
353    }
354    
355  =head2 validate_telephoneNumber  =head2 validate_telephoneNumber
356    
357  =cut  =cut
# Line 282  sub validate_telephoneNumber { Line 364  sub validate_telephoneNumber {
364          return ( 1, 'OK' );          return ( 1, 'OK' );
365  }  }
366    
367  sub current_user_can {  =head2 hrEduPersonUniqueNumber
368          # FIXME no security for now :-)  
369          return 1;  Check if JMBG is valid
370    
371    =cut
372    
373    sub validate_hrEduPersonUniqueNumber {
374            my ( $self, $value ) = @_;
375    
376            if ( $value =~ m/^JMBG:\s+(\d+)$/ ) {
377    
378                    my $jmbg = $1;
379    
380                    return ( 0, _('JMBG must have 13 digits') ) unless length($jmbg) == 13;
381    
382                    sub digit_at {
383                            my ($jmbg,$pos) = @_;
384                            return ord(substr($jmbg,$pos,1)) - ord('0');
385                    }
386    
387                    my $sum;
388                    my $fact = 7;
389    
390                    foreach my $i ( 0 .. 11 ) {
391                            my $c = digit_at( $jmbg, $i );
392                            $sum += $c * $fact;
393    #                       warn "## $c * $fact => $sum\n";
394                            $fact--;
395                            $fact = 7 if $fact == 1;
396                    }
397    
398                    my $ost = $sum % 11;
399                    $ost = 11 - $ost if $ost > 1;
400    
401                    return ( 0, _("JMBG is invalid") ) if $ost != digit_at( $jmbg, 12 );
402            }
403    
404            return ( 1, 'OK' );
405  }  }
406    
407    =head2 canonicalize_hrEduPersonExpireDate
408    
409    Support NONE as 2042-12-30
410    
411    =cut
412    
413    sub canonicalize_hrEduPersonExpireDate {
414            my ( $self, $value ) = @_;
415    
416            if ( lc($value) eq 'none' ) {
417                    $self->log->warn("fixed hrEduPersonExpireDate");
418                    $value = '2042-12-30';
419            }
420    
421            return $value;
422    }
423    
424    use A3C::DefaultACL;
425    
426  1;  1;
427    

Legend:
Removed from v.10  
changed lines
  Added in v.77

  ViewVC Help
Powered by ViewVC 1.1.26