--- lib/A3C/Model/User.pm 2008/03/13 16:34:47 12 +++ lib/A3C/Model/User.pm 2008/03/17 13:02:50 23 @@ -4,15 +4,24 @@ package A3C::Model::User; use Jifty::DBI::Schema; +use utf8; + use A3C::Record schema { - column name => - type is 'text', - label is _('Ime'), + column uid => + label is ('uid'), + is indexed, + is mandatory, + is distinct; + + column hrEduPersonUniqueID => + label is ('hrEduPersonUniqueID'), + is indexed, + is distinct, is mandatory; column cn => - label is _('Ime'), + label is _('Ime i prezime'), type is 'virtual'; column sn => @@ -25,14 +34,12 @@ label is _('Ime'), is mandatory; - column email => + column mail => type is 'text', is mandatory, - label is _('Email address'), default is '', is immutable, is distinct; - - column email_confirmed => - label is _('Email address confirmed?'), - type is 'boolean'; + label is _('Email address'), default is '', + is immutable, + is distinct; column password => is unreadable, @@ -63,7 +70,9 @@ column hrEduPersonDateOfBirth => type is 'date', - label is _('Datum rođenja'); + render as 'date', + label is _('Datum rođenja'), + filters are 'Jifty::DBI::Filter::Date'; column hrEduPersonGender => label is _('Spol'); @@ -79,97 +88,120 @@ column wtAdminType => label is _('Tip administratora'), - available are qw( AS AI AR AHU ); + valid are [ '', 'AS', 'AI', 'AR', 'AHU' ]; column hrEduPersonProfessionalStatus => label is _('Stručni status'), - available are qw( DR KV MR NKV PKV SSS VKV VS VSS VŠS ); + valid are [ + '', + 'NKV', + 'PKV', + 'KV', + 'VKV', + 'SSS', + 'VS', + 'VSS', + 'VŠS', + 'MR', + 'DR', + ], + default is ''; column hrEduPersonAcademicStatus => label is _('Zvanje'), - available are [ - 'asistent', - 'asistent - predavač', - 'asistent visoke škole', - 'docent', - 'izvanredni profesor', + 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č', - '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', + 'asistent', + 'asistent - predavač', + 'viši asistent', + 'docent', + 'izvanredni profesor', + 'redoviti profesor', 'znanstveni savjetnik', - 'znanstveni suradnik', - ]; + 'viši znanstveni suradnik', + ], + default is ''; column hrEduPersonScienceArea => label is _('Područje znanosti'), - available are [ + valid are [ + '', 'Tehničke znanosti', 'Prirodne znanosti', 'Humanističke znanosti', 'Društvene znanosti', 'Biotehničke znanosti', 'Biomedicina i zdravstvo', - ]; + ], + default is ''; column hrEduPersonAffiliation => label is _('Povezanost s ustanovom'), is mandatory, - available are [ - 'djelatnik', - 'gost', - 'korisnik usluge', - 'student', + valid are [ 'učenik', + 'student', + 'djelatnik', 'vanjski suradnik', - ]; + 'korisnik usluge', + 'gost', + ], + default is 'korisnik usluge'; column hrEduPersonPrimaryAffiliation => label is _('Temeljna povezanost s ustanovom'); is mandatory, - available are [ - 'djelatnik', - 'gost', - 'korisnik usluge', - 'student', + valid are [ 'učenik', + 'student', + 'djelatnik', 'vanjski suradnik', - ]; + 'korisnik usluge', + 'gost', + ], + default is 'korisnik usluge'; column hrEduPersonStudentCategory => label is 'Vrsta studenta', - available are [ - 'dodiplomac', + valid are [ + '', 'osnovnoškolac', - 'pauzira godinu', - 'postdiplomac', - 'preddiplomac', - 'prekid studija', 'srednjoškolac', 'student stručnog studija', - ]; + 'preddiplomac', + 'postdiplomac', + 'dodiplomac', + 'pauzira godinu', + 'prekid studija', + ], + default is ''; column hrEduPersonExpireDate => label is _('Datum isteka temeljne povezanosti'), type is 'date', - hint is 'dd.mm.gggg', + render as 'date', is mandatory, + filters are 'Jifty::DBI::Filter::Date'; column hrEduPersonTitle => label is 'Položaj u ustanovi', - available are [ + valid are [ # FIXME reorder + '', 'dekan', 'direktor', 'pomoćnik ravnatelja', @@ -187,11 +219,13 @@ 'voditelj projekta', 'zamjenik pročelnika sveučilišn', 'zamjenik ravnatelja', - ]; + ], + default is ''; column hrEduPersonRole => label is 'Uloga u ustanovi', - available are [ + valid are [ + '', 'administrator imenika', 'CARNet koordinator', 'CARNet sistem inženjer', @@ -201,11 +235,12 @@ 'MS koordinator', 'MATICA operater', 'MATICA urednik', - ]; + ], + default is ''; column hrEduPersonStaffCategory => label is 'Vrsta posla u ustanovi', - available are [ + valid are [ 'administrativno osoblje', 'ICT podrška', 'istraživači', @@ -263,15 +298,64 @@ column hrEduPersonPrivacy => label is _('Oznaka privatnosti'); + column loginShell => + label is _('shell'); + + column uidNumber => + label is _('uid'), + type is 'int'; + + column gidNumber => + label is _('gid'); + type is 'int'; + + column homeDirectory => + label is _('home'); + + column objectClass => + type is 'virtual'; + }; -use Jifty::Plugin::User::Mixin::Model::User; +# we don't use following mixing because it wants to send notificaitons on e-mail address change +#use Jifty::Plugin::User::Mixin::Model::User; use Jifty::Plugin::Authentication::Password::Mixin::Model::User; #use Jifty::Plugin::OpenID::Mixin::Model::User; use Jifty::Plugin::ActorMetadata::Mixin::Model::ActorMetadata; # created_by, created_on, updated_on # Your model-specific methods go here. +=head2 before_create + +Implement virtual columns, for now put mail from ldap into email row + +=cut + +=for later + +sub before_create { + my ($self, $attr) = @_; + if ( ! $attr->{'email'} ) { + warn "push mail to email"; + $attr->{'email'} = $attr->{'mail'}; + } +} + +=cut + +=head2 email + +Accessor for compatibility with Jifty mixins + +=cut + +sub email { + my $self = shift; + return $self->__value('mail'); +} + +sub email_confirmed { 1 }; + =head2 validate_telephoneNumber =cut @@ -284,6 +368,27 @@ return ( 1, 'OK' ); } +=head2 canonicalize_hrEduPersonExpireDate + +Support NONE as 2042-12-30 + +=cut + +sub canonicalize_hrEduPersonExpireDate { + my ( $self, $value ) = @_; + + if ( $value eq 'NONE' ) { + $self->log->warn("fixed hrEduPersonExpireDate"); + $value = '2042-12-30'; + } + + return $value; +} + +=head2 current_user_can + +=cut + sub current_user_can { # FIXME no security for now :-) return 1;