/[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 121 by dpavlin, Thu May 15 19:18:45 2008 UTC
# Line 1  Line 1 
1  use strict;  use strict;
2  use warnings;  use warnings;
3    
4  package CAdmin::Model::User;  =head1 WARNING
5    
6    B<This code is obsolete> since application is using L<A3C::Model::hrEduPerson>
7    
8    =cut
9    
10    package A3C::Model::Person;
11  use Jifty::DBI::Schema;  use Jifty::DBI::Schema;
12    
13  use CAdmin::Record schema {  use A3C::AAIEduHr;
14    
15          column name =>  use utf8;
16                  type is 'text',  
17                  label is _('Ime'),  use A3C::Record schema {
18    
19            column uid =>
20                    label is _('UID'),
21                    is indexed,
22                    is mandatory,
23                    is distinct;
24    
25            column hrEduPersonUniqueID =>
26                    label is _('hr Edu Person Unique ID'),
27                    is indexed,
28                    is distinct,
29                  is mandatory;                  is mandatory;
30    
31          column cn =>          column cn =>
32                  label is _('Ime'),                  label is _('Ime i prezime'),
33                  type is 'virtual';                  is mandatory;
34    
35          column sn =>          column sn =>
                 type is 'virtual',  
36                  label is _('Prezime'),                  label is _('Prezime'),
37                  is mandatory;                  is mandatory;
38    
39          column givenName =>          column givenName =>
                 type is 'virtual',  
40                  label is _('Ime'),                  label is _('Ime'),
41                  is mandatory;                  is mandatory;
42    
43          column email =>          column mail =>
44                  type is 'text',                  type is 'text',
45                  is mandatory,                  is mandatory,
46                  label is _('Email address'), default is '', is immutable, is distinct;                  label is _('Email address'), default is '',
47                    is indexed,
48          column email_confirmed =>                  is immutable,
49                  label is _('Email address confirmed?'),                  is distinct;
                 type is 'boolean';  
50    
51          column password =>          column password =>
52                  is unreadable,                  is unreadable,
# Line 59  use CAdmin::Record schema { Line 73  use CAdmin::Record schema {
73    
74          column hrEduPersonUniqueNumber =>          column hrEduPersonUniqueNumber =>
75  #               is mandatory,  #               is mandatory,
76                  label is _('JMBG');                  label is _('Unique number');
77    
78          column hrEduPersonDateOfBirth =>          column hrEduPersonDateOfBirth =>
79                  type is 'date',                  type is 'date',
80                  label is _('Datum rođenja');                  render as 'date',
81                    label is _('Datum rođenja'),
82                    filters are 'Jifty::DBI::Filter::Date';
83    
84          column hrEduPersonGender =>          column hrEduPersonGender =>
85                  label is _('Spol');                  label is _('Spol'),
86                    valid are [ { display => 'Nepoznato', value => 0 }, A3C::AAIEduHr->vocabulary('hrEdu002') ];
87    
88          column jpegPhoto =>          column jpegPhoto =>
89                  label is _('Slika');                  label is _('Slika');
# Line 79  use CAdmin::Record schema { Line 96  use CAdmin::Record schema {
96                    
97          column wtAdminType =>          column wtAdminType =>
98                  label is _('Tip administratora'),                  label is _('Tip administratora'),
99                  available are qw( AS AI AR AHU );                  valid are [ '', 'AS', 'AI', 'AR', 'AHU' ];
100    
101            column hrEduPersonHomeOrg =>
102                    label is _('Oznaka matične ustanove'),
103                    hint is 'CARNet',
104                    is mandatory;
105    
106          column hrEduPersonProfessionalStatus =>          column hrEduPersonProfessionalStatus =>
107                  label is _('Stručni status'),                  label is _('Stručni status'),
108                  available are qw( DR KV MR NKV PKV SSS VKV VS VSS VŠS );                  valid are [ '', A3C::AAIEduHr->vocabulary('hrEdu001'), 'VŠS' ],
109                    default is '';
110    
111          column hrEduPersonAcademicStatus =>          column hrEduPersonAcademicStatus =>
112                  label is _('Zvanje'),                  label is _('Zvanje'),
113                  available are [                  valid are [ '', A3C::AAIEduHr->vocabulary('hrEdu002') ],
114                          'asistent',                  default is '';
                         'asistent - predavač',  
                         'asistent visoke škole',  
                         'docent',  
                         'izvanredni profesor',  
                         'knjižničar',  
                         'korepetitor',  
                         'lektor',  
                         'mlađi asistent',  
                         'predavač',  
                         'profesor visoke škole',  
                         'redoviti profesor',  
                         'stručni suradnik',  
                         'viši asistent',  
                         'viši knjižničar',  
                         'viši korepetitor',  
                         'viši lektor',  
                         'viši predavač',  
                         'viši znanstveni suradnik',  
                         'znanstveni asistent',  
                         'znanstveni novak',  
                         'znanstveni savjetnik',  
                         'znanstveni suradnik',  
                 ];  
115    
116          column hrEduPersonScienceArea =>          column hrEduPersonScienceArea =>
117                  label is _('Područje znanosti'),                  label is _('Područje znanosti'),
118                  available are [                  valid are [ '', A3C::AAIEduHr->vocabulary('hrEdu007') ],
119                          'Tehničke znanosti',                  default is '';
120                          'Prirodne znanosti',  
121                          'Humanističke znanosti',          column 'o' =>
122                          'Društvene znanosti',                  is indexed;
123                          'Biotehničke znanosti',  
124                          'Biomedicina i zdravstvo',          column 'l';
125                  ];          column 'postalAddress';
126            column 'postalCode';
127            column 'street';
128    
129    #       column organization =>
130    #               refers_to A3C::Model::Organization by 'id',
131    #               is mandatory;
132    
133          column hrEduPersonAffiliation =>          column hrEduPersonAffiliation =>
134                  label is _('Povezanost s ustanovom'),                  label is _('Povezanost s ustanovom'),
135                  is mandatory,                  is mandatory,
136                  available are [                  valid are A3C::AAIEduHr->vocabulary('hrEdu004'),
137                          'djelatnik',                  default is 'korisnik usluge';
                         'gost',  
                         'korisnik usluge',  
                         'student',  
                         'učenik',  
                         'vanjski suradnik',  
                 ];  
138    
139          column hrEduPersonPrimaryAffiliation =>          column hrEduPersonPrimaryAffiliation =>
140                  label is _('Temeljna povezanost s ustanovom');                  label is _('Temeljna povezanost s ustanovom');
141                  is mandatory,                  is mandatory,
142                  available are [                  valid are A3C::AAIEduHr->vocabulary('hrEdu004'),
143                          'djelatnik',                  default is 'korisnik usluge';
                         'gost',  
                         'korisnik usluge',  
                         'student',  
                         'učenik',  
                         'vanjski suradnik',  
                 ];  
144    
145          column hrEduPersonStudentCategory =>          column hrEduPersonStudentCategory =>
146                  label is 'Vrsta studenta',                  label is 'Vrsta studenta',
147                  available are [                  valid are [
148                          'dodiplomac',                          '',
149                          'osnovnoškolac',                          A3C::AAIEduHr->vocabulary('hrEdu010'),
150                          'pauzira godinu',                  ],
151                          'postdiplomac',                  default is '';
                         'preddiplomac',  
                         'prekid studija',  
                         'srednjoškolac',  
                         'student stručnog studija',  
                 ];  
152    
153          column hrEduPersonExpireDate =>          column hrEduPersonExpireDate =>
154                  label is _('Datum isteka temeljne povezanosti'),                  label is _('Datum isteka temeljne povezanosti'),
155                  type is 'date',                  type is 'date',
156                  hint is 'dd.mm.gggg',                  render as 'date',
157                  is mandatory,                  is mandatory,
158                    filters are 'Jifty::DBI::Filter::Date';
159    
160          column hrEduPersonTitle =>          column hrEduPersonTitle =>
161                  label is 'Položaj u ustanovi',                  label is 'Položaj u ustanovi',
162                  available are [                  valid are [ '', A3C::AAIEduHr->vocabulary('hrEdu003') ],
163                          'dekan',                  default is '';
                         'direktor',  
                         'pomoćnik ravnatelja',  
                         'predstojnik zavoda',  
                         'pročelnik katedre',  
                         'pročelnik odsjeka',  
                         'pročelnik sveučilišnog odjela',  
                         'prodekan',  
                         'prorektor',  
                         'ravnatelj',  
                         'rektor',  
                         'voditelj laboratorija',  
                         'voditelj odjela',  
                         'voditelj organizacijske jedini',  
                         'voditelj projekta',  
                         'zamjenik pročelnika sveučilišn',  
                         'zamjenik ravnatelja',  
                 ];  
164    
165          column hrEduPersonRole =>          column hrEduPersonRole =>
166                  label is 'Uloga u ustanovi',                  label is 'Uloga u ustanovi',
167                  available are [                  valid are [
168                          'administrator imenika',                          '',
169                          'CARNet koordinator',                          A3C::AAIEduHr->vocabulary('hrEdu006'),
                         'CARNet sistem inženjer',  
                         'ICT koordinator',  
                         'ISVU koordinator',  
                         'kontakt za sigurnosna pitanja',  
                         'MS koordinator',  
170                          'MATICA operater',                          'MATICA operater',
171                          'MATICA urednik',                          'MATICA urednik',
172                  ];                  ],
173                    default is '';
174    
175          column hrEduPersonStaffCategory =>          column hrEduPersonStaffCategory =>
176                  label is 'Vrsta posla u ustanovi',                  label is 'Vrsta posla u ustanovi',
177                  available are [                  valid are [ '', A3C::AAIEduHr->vocabulary('hrEdu005') ];
                         'administrativno osoblje',  
                         'ICT podrška',  
                         'istraživači',  
                         'nastavno osoblje',  
                         'osoblje knjižnice',  
                         'tehničko osoblje',  
                 ];  
178    
179          column hrEduPersonGroupMember =>          column hrEduPersonGroupMember =>
180                  label is 'Pripadnost grupi',                  label is 'Pripadnost grupi',
181                  hint is 'skolskagodina::razred';                  hint is 'skolskagodina::razred';
182    
         column o =>  
                 label is _('Naziv matične ustanove'),  
                 is mandatory;  
           
         column hrEduPersonHomeOrg =>  
                 label is _('Oznaka matične ustanove'),  
                 hint is 'CARNet',  
                 is mandatory;  
   
183          column ou =>          column ou =>
184                  label is _('Organizacijska jedinica');                  label is _('Organizacijska jedinica');
185                    
186          column roomNumber =>          column roomNumber =>
187                  label is _('Broj sobe');                  label is _('Broj sobe');
188    
         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');  
           
189          column homePostalAddress =>          column homePostalAddress =>
190                  label is _('Kućna poštanska adresa');                  label is _('Kućna poštanska adresa'),
191                    render as 'textarea';
192                    
193          column homePhone =>          column homePhone =>
194                  label is _('Kućni telefonski broj');                  label is _('Kućni telefonski broj');
# Line 261  use CAdmin::Record schema { Line 199  use CAdmin::Record schema {
199          column hrEduPersonPrivacy =>          column hrEduPersonPrivacy =>
200                  label is _('Oznaka privatnosti');                  label is _('Oznaka privatnosti');
201    
202            column loginShell =>
203                    label is _('login shell');
204    
205            column uidNumber =>
206                    label is _('uid number'),
207                    type is 'int';
208    
209            column gidNumber =>
210                    label is _('gid number');
211                    type is 'int';
212    
213            column homeDirectory =>
214                    label is _('home directory');
215    
216  };  };
217    
218  use Jifty::Plugin::User::Mixin::Model::User;  # we don't use following mixing because it wants to send notificaitons on e-mail address change
219    #use Jifty::Plugin::User::Mixin::Model::User;
220  use Jifty::Plugin::Authentication::Password::Mixin::Model::User;  use Jifty::Plugin::Authentication::Password::Mixin::Model::User;
221  #use Jifty::Plugin::OpenID::Mixin::Model::User;  #use Jifty::Plugin::OpenID::Mixin::Model::User;
222  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
223    
224  # Your model-specific methods go here.  # Your model-specific methods go here.
225    
226    =head2 before_create
227    
228    Implement virtual columns, for now put mail from ldap into email row
229    
230    =cut
231    
232    =for later
233    
234    sub before_create {
235            my ($self, $attr) = @_;
236            if ( ! $attr->{'email'} ) {
237                    warn "push mail to email";
238                    $attr->{'email'} = $attr->{'mail'};
239            }
240    }
241    
242    =cut
243    
244    =head2 email
245    
246    Accessor for compatibility with Jifty mixins
247    
248    =cut
249    
250    sub email {
251            my $self = shift;
252            return $self->mail;
253    }
254    
255    sub email_confirmed { 1 };
256    
257    =head2 name
258    
259    =cut
260    
261    sub name {
262            my $self = shift;
263            return $self->cn . ' <' . $self->mail . '>';
264    }
265    
266  =head2 validate_telephoneNumber  =head2 validate_telephoneNumber
267    
268  =cut  =cut
# Line 282  sub validate_telephoneNumber { Line 275  sub validate_telephoneNumber {
275          return ( 1, 'OK' );          return ( 1, 'OK' );
276  }  }
277    
278  sub current_user_can {  =head2 hrEduPersonUniqueNumber
279          # FIXME no security for now :-)  
280          return 1;  Check if JMBG is valid
281    
282    =cut
283    
284    sub validate_hrEduPersonUniqueNumber {
285            my ( $self, $value ) = @_;
286    
287            if ( $value =~ m/^JMBG:\s+(\d+)$/ ) {
288    
289                    my $jmbg = $1;
290    
291                    return ( 0, _('JMBG must have 13 digits') ) unless length($jmbg) == 13;
292    
293                    sub digit_at {
294                            my ($jmbg,$pos) = @_;
295                            return ord(substr($jmbg,$pos,1)) - ord('0');
296                    }
297    
298                    my $sum;
299                    my $fact = 7;
300    
301                    foreach my $i ( 0 .. 11 ) {
302                            my $c = digit_at( $jmbg, $i );
303                            $sum += $c * $fact;
304    #                       warn "## $c * $fact => $sum\n";
305                            $fact--;
306                            $fact = 7 if $fact == 1;
307                    }
308    
309                    my $ost = $sum % 11;
310                    $ost = 11 - $ost if $ost > 1;
311    
312                    return ( 0, _("JMBG is invalid") ) if $ost != digit_at( $jmbg, 12 );
313            }
314    
315            return ( 1, 'OK' );
316  }  }
317    
318    =head2 canonicalize_hrEduPersonExpireDate
319    
320    Support NONE as 2042-12-30
321    
322    =cut
323    
324    sub canonicalize_hrEduPersonExpireDate {
325            my ( $self, $value ) = @_;
326    
327            if ( lc($value) eq 'none' ) {
328                    $self->log->warn("fixed hrEduPersonExpireDate");
329                    $value = '2042-12-30';
330            }
331    
332            return $value;
333    }
334    
335    use A3C::DefaultACL;
336    
337  1;  1;
338    

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

  ViewVC Help
Powered by ViewVC 1.1.26