--- lib/A3C/Model/User.pm 2008/03/18 19:22:30 33 +++ lib/A3C/Model/Person.pm 2008/05/15 19:18:45 121 @@ -1,21 +1,29 @@ use strict; use warnings; -package A3C::Model::User; +=head1 WARNING + +B since application is using L + +=cut + +package A3C::Model::Person; use Jifty::DBI::Schema; +use A3C::AAIEduHr; + use utf8; use A3C::Record schema { column uid => - label is ('uid'), + label is _('UID'), is indexed, is mandatory, is distinct; column hrEduPersonUniqueID => - label is ('hrEduPersonUniqueID'), + label is _('hr Edu Person Unique ID'), is indexed, is distinct, is mandatory; @@ -36,6 +44,7 @@ type is 'text', is mandatory, label is _('Email address'), default is '', + is indexed, is immutable, is distinct; @@ -64,7 +73,7 @@ column hrEduPersonUniqueNumber => # is mandatory, - label is _('JMBG'); + label is _('Unique number'); column hrEduPersonDateOfBirth => type is 'date', @@ -73,7 +82,8 @@ filters are 'Jifty::DBI::Filter::Date'; column hrEduPersonGender => - label is _('Spol'); + label is _('Spol'), + valid are [ { display => 'Nepoznato', value => 0 }, A3C::AAIEduHr->vocabulary('hrEdu002') ]; column jpegPhoto => label is _('Slika'); @@ -88,108 +98,55 @@ label is _('Tip administratora'), valid are [ '', 'AS', 'AI', 'AR', 'AHU' ]; + column hrEduPersonHomeOrg => + label is _('Oznaka matične ustanove'), + hint is 'CARNet', + is mandatory; + column hrEduPersonProfessionalStatus => label is _('Stručni status'), - valid are [ - '', - 'NKV', - 'PKV', - 'KV', - 'VKV', - 'SSS', - 'VS', - 'VSS', - 'VŠS', - 'MR', - 'DR', - ], + valid are [ '', A3C::AAIEduHr->vocabulary('hrEdu001'), 'VŠS' ], default is ''; column hrEduPersonAcademicStatus => label is _('Zvanje'), - valid are [ - '', - 'knjižničar', - 'viši knjižničar', - 'korepetitor', - 'viši korepetitor', - 'lektor', - 'viši lektor', - 'stručni suradnik', - 'asistent visoke škole', - 'profesor visoke škole', - 'mlađi asistent', - 'znanstveni novak', - 'znanstveni asistent', - 'znanstveni suradnik', - 'predavač', - 'viši predavač', - 'asistent', - 'asistent - predavač', - 'viši asistent', - 'docent', - 'izvanredni profesor', - 'redoviti profesor', - 'znanstveni savjetnik', - 'viši znanstveni suradnik', - ], + valid are [ '', A3C::AAIEduHr->vocabulary('hrEdu002') ], default is ''; column hrEduPersonScienceArea => label is _('Područje znanosti'), - valid are [ - '', - 'Tehničke znanosti', - 'Prirodne znanosti', - 'Humanističke znanosti', - 'Društvene znanosti', - 'Biotehničke znanosti', - 'Biomedicina i zdravstvo', - ], + valid are [ '', A3C::AAIEduHr->vocabulary('hrEdu007') ], default is ''; - column organization => - refers_to A3C::Model::Organization by 'id', - is mandatory; + column 'o' => + is indexed; + + column 'l'; + column 'postalAddress'; + column 'postalCode'; + column 'street'; + +# column organization => +# refers_to A3C::Model::Organization by 'id', +# is mandatory; column hrEduPersonAffiliation => label is _('Povezanost s ustanovom'), is mandatory, - valid are [ - 'učenik', - 'student', - 'djelatnik', - 'vanjski suradnik', - 'korisnik usluge', - 'gost', - ], + valid are A3C::AAIEduHr->vocabulary('hrEdu004'), default is 'korisnik usluge'; column hrEduPersonPrimaryAffiliation => label is _('Temeljna povezanost s ustanovom'); is mandatory, - valid are [ - 'učenik', - 'student', - 'djelatnik', - 'vanjski suradnik', - 'korisnik usluge', - 'gost', - ], + valid are A3C::AAIEduHr->vocabulary('hrEdu004'), default is 'korisnik usluge'; column hrEduPersonStudentCategory => label is 'Vrsta studenta', valid are [ '', - 'osnovnoškolac', - 'srednjoškolac', - 'student stručnog studija', - 'preddiplomac', - 'postdiplomac', - 'dodiplomac', - 'pauzira godinu', - 'prekid studija', + A3C::AAIEduHr->vocabulary('hrEdu010'), ], default is ''; @@ -202,39 +159,14 @@ column hrEduPersonTitle => label is 'Položaj u ustanovi', - valid are [ # FIXME reorder - '', - 'dekan', - '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', - ], + valid are [ '', A3C::AAIEduHr->vocabulary('hrEdu003') ], default is ''; column hrEduPersonRole => label is 'Uloga u ustanovi', valid are [ '', - 'administrator imenika', - 'CARNet koordinator', - 'CARNet sistem inženjer', - 'ICT koordinator', - 'ISVU koordinator', - 'kontakt za sigurnosna pitanja', - 'MS koordinator', + A3C::AAIEduHr->vocabulary('hrEdu006'), 'MATICA operater', 'MATICA urednik', ], @@ -242,14 +174,7 @@ column hrEduPersonStaffCategory => label is 'Vrsta posla u ustanovi', - valid are [ - 'administrativno osoblje', - 'ICT podrška', - 'istraživači', - 'nastavno osoblje', - 'osoblje knjižnice', - 'tehničko osoblje', - ]; + valid are [ '', A3C::AAIEduHr->vocabulary('hrEdu005') ]; column hrEduPersonGroupMember => label is 'Pripadnost grupi', @@ -275,18 +200,18 @@ label is _('Oznaka privatnosti'); column loginShell => - label is _('shell'); + label is _('login shell'); column uidNumber => - label is _('uid'), + label is _('uid number'), type is 'int'; column gidNumber => - label is _('gid'); + label is _('gid number'); type is 'int'; column homeDirectory => - label is _('home'); + label is _('home directory'); }; @@ -324,11 +249,20 @@ sub email { my $self = shift; - return $self->__value('mail'); + return $self->mail; } sub email_confirmed { 1 }; +=head2 name + +=cut + +sub name { + my $self = shift; + return $self->cn . ' <' . $self->mail . '>'; +} + =head2 validate_telephoneNumber =cut @@ -341,6 +275,46 @@ return ( 1, 'OK' ); } +=head2 hrEduPersonUniqueNumber + +Check if JMBG is valid + +=cut + +sub validate_hrEduPersonUniqueNumber { + my ( $self, $value ) = @_; + + if ( $value =~ m/^JMBG:\s+(\d+)$/ ) { + + my $jmbg = $1; + + return ( 0, _('JMBG must have 13 digits') ) unless length($jmbg) == 13; + + sub digit_at { + my ($jmbg,$pos) = @_; + return ord(substr($jmbg,$pos,1)) - ord('0'); + } + + my $sum; + my $fact = 7; + + foreach my $i ( 0 .. 11 ) { + my $c = digit_at( $jmbg, $i ); + $sum += $c * $fact; +# warn "## $c * $fact => $sum\n"; + $fact--; + $fact = 7 if $fact == 1; + } + + my $ost = $sum % 11; + $ost = 11 - $ost if $ost > 1; + + return ( 0, _("JMBG is invalid") ) if $ost != digit_at( $jmbg, 12 ); + } + + return ( 1, 'OK' ); +} + =head2 canonicalize_hrEduPersonExpireDate Support NONE as 2042-12-30 @@ -358,14 +332,7 @@ return $value; } -=head2 current_user_can - -=cut - -sub current_user_can { - # FIXME no security for now :-) - return 1; -} +use A3C::DefaultACL; 1;