/[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/A3C/Model/User.pm revision 33 by dpavlin, Tue Mar 18 19:22:30 2008 UTC lib/A3C/Model/Person.pm revision 73 by dpavlin, Fri Apr 11 15:49:50 2008 UTC
# Line 1  Line 1 
1  use strict;  use strict;
2  use warnings;  use warnings;
3    
4  package A3C::Model::User;  package A3C::Model::Person;
5  use Jifty::DBI::Schema;  use Jifty::DBI::Schema;
6    
7  use utf8;  use utf8;
# Line 36  use A3C::Record schema { Line 36  use A3C::Record schema {
36                  type is 'text',                  type is 'text',
37                  is mandatory,                  is mandatory,
38                  label is _('Email address'), default is '',                  label is _('Email address'), default is '',
39                    is indexed,
40                  is immutable,                  is immutable,
41                  is distinct;                  is distinct;
42    
# Line 64  use A3C::Record schema { Line 65  use A3C::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',
# Line 88  use A3C::Record schema { Line 89  use A3C::Record schema {
89                  label is _('Tip administratora'),                  label is _('Tip administratora'),
90                  valid are [ '', '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                  valid are [                  valid are [
# Line 148  use A3C::Record schema { Line 154  use A3C::Record schema {
154                  ],                  ],
155                  default is '';                  default is '';
156    
157          column organization =>          column 'o';
158                  refers_to A3C::Model::Organization by 'id',          column 'l';
159                  is mandatory;          column 'postalAddress';
160    
161    #       column organization =>
162    #               refers_to A3C::Model::Organization by 'id',
163    #               is mandatory;
164    
165          column hrEduPersonAffiliation =>          column hrEduPersonAffiliation =>
166                  label is _('Povezanost s ustanovom'),                  label is _('Povezanost s ustanovom'),
# Line 275  use A3C::Record schema { Line 285  use A3C::Record schema {
285                  label is _('Oznaka privatnosti');                  label is _('Oznaka privatnosti');
286    
287          column loginShell =>          column loginShell =>
288                  label is _('shell');                  label is _('login shell');
289    
290          column uidNumber =>          column uidNumber =>
291                  label is _('uid'),                  label is _('uid number'),
292                  type is 'int';                  type is 'int';
293    
294          column gidNumber =>          column gidNumber =>
295                  label is _('gid');                  label is _('gid number');
296                  type is 'int';                  type is 'int';
297    
298          column homeDirectory =>          column homeDirectory =>
299                  label is _('home');                  label is _('home directory');
300    
301  };  };
302    
# Line 324  Accessor for compatibility with Jifty mi Line 334  Accessor for compatibility with Jifty mi
334    
335  sub email {  sub email {
336          my $self = shift;          my $self = shift;
337          return $self->__value('mail');          return $self->mail;
338  }  }
339    
340  sub email_confirmed { 1 };  sub email_confirmed { 1 };
341    
342    =head2 name
343    
344    =cut
345    
346    sub name {
347            my $self = shift;
348            return $self->cn . ' <' . $self->mail . '>';
349    }
350    
351  =head2 validate_telephoneNumber  =head2 validate_telephoneNumber
352    
353  =cut  =cut
# Line 341  sub validate_telephoneNumber { Line 360  sub validate_telephoneNumber {
360          return ( 1, 'OK' );          return ( 1, 'OK' );
361  }  }
362    
363    =head2 hrEduPersonUniqueNumber
364    
365    Check if JMBG is valid
366    
367    =cut
368    
369    sub validate_hrEduPersonUniqueNumber {
370            my ( $self, $value ) = @_;
371    
372            if ( $value =~ m/^JMBG:\s+(\d+)$/ ) {
373    
374                    my $jmbg = $1;
375    
376                    return ( 0, _('JMBG must have 13 digits') ) unless length($jmbg) == 13;
377    
378                    sub digit_at {
379                            my ($jmbg,$pos) = @_;
380                            return ord(substr($jmbg,$pos,1)) - ord('0');
381                    }
382    
383                    my $sum;
384                    my $fact = 7;
385    
386                    foreach my $i ( 0 .. 11 ) {
387                            my $c = digit_at( $jmbg, $i );
388                            $sum += $c * $fact;
389    #                       warn "## $c * $fact => $sum\n";
390                            $fact--;
391                            $fact = 7 if $fact == 1;
392                    }
393    
394                    my $ost = $sum % 11;
395                    $ost = 11 - $ost if $ost > 1;
396    
397                    return ( 0, _("JMBG is invalid") ) if $ost != digit_at( $jmbg, 12 );
398            }
399    
400            return ( 1, 'OK' );
401    }
402    
403  =head2 canonicalize_hrEduPersonExpireDate  =head2 canonicalize_hrEduPersonExpireDate
404    
405  Support NONE as 2042-12-30  Support NONE as 2042-12-30
# Line 358  sub canonicalize_hrEduPersonExpireDate { Line 417  sub canonicalize_hrEduPersonExpireDate {
417          return $value;          return $value;
418  }  }
419    
420  =head2 current_user_can  use A3C::DefaultACL;
   
 =cut  
   
 sub current_user_can {  
         # FIXME no security for now :-)  
         return 1;  
 }  
421    
422  1;  1;
423    

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

  ViewVC Help
Powered by ViewVC 1.1.26