/[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

Annotation of /lib/A3C/Model/Person.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 121 - (hide annotations)
Thu May 15 19:18:45 2008 UTC (15 years, 11 months ago) by dpavlin
File size: 6722 byte(s)
added depriciation warnings
1 dpavlin 2 use strict;
2     use warnings;
3    
4 dpavlin 121 =head1 WARNING
5    
6     B<This code is obsolete> since application is using L<A3C::Model::hrEduPerson>
7    
8     =cut
9    
10 dpavlin 66 package A3C::Model::Person;
11 dpavlin 2 use Jifty::DBI::Schema;
12    
13 dpavlin 94 use A3C::AAIEduHr;
14    
15 dpavlin 14 use utf8;
16    
17 dpavlin 11 use A3C::Record schema {
18 dpavlin 2
19 dpavlin 16 column uid =>
20 dpavlin 77 label is _('UID'),
21 dpavlin 16 is indexed,
22     is mandatory,
23     is distinct;
24    
25     column hrEduPersonUniqueID =>
26 dpavlin 77 label is _('hr Edu Person Unique ID'),
27 dpavlin 16 is indexed,
28 dpavlin 18 is distinct,
29 dpavlin 4 is mandatory;
30    
31     column cn =>
32 dpavlin 21 label is _('Ime i prezime'),
33 dpavlin 29 is mandatory;
34 dpavlin 4
35     column sn =>
36     label is _('Prezime'),
37     is mandatory;
38    
39     column givenName =>
40     label is _('Ime'),
41     is mandatory;
42    
43 dpavlin 16 column mail =>
44 dpavlin 4 type is 'text',
45     is mandatory,
46 dpavlin 18 label is _('Email address'), default is '',
47 dpavlin 73 is indexed,
48 dpavlin 18 is immutable,
49     is distinct;
50 dpavlin 4
51     column password =>
52     is unreadable,
53     label is _('Password'),
54     type is 'varchar',
55     hints is _('Your password should be at least six characters'),
56     render_as 'password',
57     # filters are 'Jifty::DBI::Filter::SaltHash',
58     is mandatory;
59    
60     column telephoneNumber =>
61     type is 'text',
62     label is _('Telefonski broj'),
63     hint is '+385 xx yyyyyy';
64    
65     column hrEduPersonExtensionNumber =>
66     label is _('Lokalni telefonski broj');
67    
68     column mobile =>
69     label is _('Broj mobilnog telefona');
70    
71     column facsimileTelephoneNumber =>
72     label is _('Fax broj');
73    
74     column hrEduPersonUniqueNumber =>
75 dpavlin 10 # is mandatory,
76 dpavlin 35 label is _('Unique number');
77 dpavlin 4
78     column hrEduPersonDateOfBirth =>
79     type is 'date',
80 dpavlin 15 render as 'date',
81 dpavlin 16 label is _('Datum rođenja'),
82     filters are 'Jifty::DBI::Filter::Date';
83 dpavlin 4
84     column hrEduPersonGender =>
85 dpavlin 94 label is _('Spol'),
86     valid are [ { display => 'Nepoznato', value => 0 }, A3C::AAIEduHr->vocabulary('hrEdu002') ];
87 dpavlin 4
88     column jpegPhoto =>
89     label is _('Slika');
90    
91     column userCertificate =>
92     label is _('Ceritifikat');
93    
94     column labeledURI =>
95     label is _('URI adresa');
96    
97     column wtAdminType =>
98     label is _('Tip administratora'),
99 dpavlin 15 valid are [ '', 'AS', 'AI', 'AR', 'AHU' ];
100 dpavlin 4
101 dpavlin 42 column hrEduPersonHomeOrg =>
102     label is _('Oznaka matične ustanove'),
103     hint is 'CARNet',
104     is mandatory;
105    
106 dpavlin 4 column hrEduPersonProfessionalStatus =>
107     label is _('Stručni status'),
108 dpavlin 94 valid are [ '', A3C::AAIEduHr->vocabulary('hrEdu001'), 'VŠS' ],
109 dpavlin 15 default is '';
110 dpavlin 4
111     column hrEduPersonAcademicStatus =>
112     label is _('Zvanje'),
113 dpavlin 94 valid are [ '', A3C::AAIEduHr->vocabulary('hrEdu002') ],
114 dpavlin 15 default is '';
115 dpavlin 4
116     column hrEduPersonScienceArea =>
117     label is _('Područje znanosti'),
118 dpavlin 94 valid are [ '', A3C::AAIEduHr->vocabulary('hrEdu007') ],
119 dpavlin 15 default is '';
120 dpavlin 4
121 dpavlin 77 column 'o' =>
122     is indexed;
123    
124 dpavlin 45 column 'l';
125     column 'postalAddress';
126 dpavlin 77 column 'postalCode';
127     column 'street';
128 dpavlin 45
129 dpavlin 42 # column organization =>
130     # refers_to A3C::Model::Organization by 'id',
131     # is mandatory;
132 dpavlin 32
133 dpavlin 4 column hrEduPersonAffiliation =>
134     label is _('Povezanost s ustanovom'),
135     is mandatory,
136 dpavlin 94 valid are A3C::AAIEduHr->vocabulary('hrEdu004'),
137 dpavlin 15 default is 'korisnik usluge';
138 dpavlin 4
139     column hrEduPersonPrimaryAffiliation =>
140     label is _('Temeljna povezanost s ustanovom');
141     is mandatory,
142 dpavlin 94 valid are A3C::AAIEduHr->vocabulary('hrEdu004'),
143 dpavlin 15 default is 'korisnik usluge';
144 dpavlin 4
145     column hrEduPersonStudentCategory =>
146     label is 'Vrsta studenta',
147 dpavlin 15 valid are [
148     '',
149 dpavlin 94 A3C::AAIEduHr->vocabulary('hrEdu010'),
150 dpavlin 15 ],
151     default is '';
152 dpavlin 4
153     column hrEduPersonExpireDate =>
154     label is _('Datum isteka temeljne povezanosti'),
155     type is 'date',
156 dpavlin 15 render as 'date',
157 dpavlin 4 is mandatory,
158 dpavlin 16 filters are 'Jifty::DBI::Filter::Date';
159 dpavlin 4
160     column hrEduPersonTitle =>
161     label is 'Položaj u ustanovi',
162 dpavlin 94 valid are [ '', A3C::AAIEduHr->vocabulary('hrEdu003') ],
163 dpavlin 15 default is '';
164 dpavlin 4
165     column hrEduPersonRole =>
166     label is 'Uloga u ustanovi',
167 dpavlin 15 valid are [
168     '',
169 dpavlin 94 A3C::AAIEduHr->vocabulary('hrEdu006'),
170 dpavlin 4 'MATICA operater',
171     'MATICA urednik',
172 dpavlin 15 ],
173     default is '';
174 dpavlin 4
175     column hrEduPersonStaffCategory =>
176     label is 'Vrsta posla u ustanovi',
177 dpavlin 94 valid are [ '', A3C::AAIEduHr->vocabulary('hrEdu005') ];
178 dpavlin 4
179     column hrEduPersonGroupMember =>
180     label is 'Pripadnost grupi',
181     hint is 'skolskagodina::razred';
182    
183     column ou =>
184     label is _('Organizacijska jedinica');
185    
186     column roomNumber =>
187     label is _('Broj sobe');
188    
189     column homePostalAddress =>
190 dpavlin 12 label is _('Kućna poštanska adresa'),
191     render as 'textarea';
192 dpavlin 4
193     column homePhone =>
194     label is _('Kućni telefonski broj');
195    
196     column hrEduPersonCommURI =>
197     label is _('Desktop uređaj');
198    
199     column hrEduPersonPrivacy =>
200     label is _('Oznaka privatnosti');
201    
202 dpavlin 23 column loginShell =>
203 dpavlin 45 label is _('login shell');
204 dpavlin 23
205     column uidNumber =>
206 dpavlin 45 label is _('uid number'),
207 dpavlin 23 type is 'int';
208    
209     column gidNumber =>
210 dpavlin 45 label is _('gid number');
211 dpavlin 23 type is 'int';
212    
213     column homeDirectory =>
214 dpavlin 45 label is _('home directory');
215 dpavlin 23
216 dpavlin 2 };
217    
218 dpavlin 18 # 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 dpavlin 4 use Jifty::Plugin::Authentication::Password::Mixin::Model::User;
221     #use Jifty::Plugin::OpenID::Mixin::Model::User;
222     use Jifty::Plugin::ActorMetadata::Mixin::Model::ActorMetadata; # created_by, created_on, updated_on
223    
224 dpavlin 2 # Your model-specific methods go here.
225    
226 dpavlin 18 =head2 before_create
227 dpavlin 16
228 dpavlin 18 Implement virtual columns, for now put mail from ldap into email row
229 dpavlin 16
230     =cut
231    
232 dpavlin 18 =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 dpavlin 16 }
241    
242 dpavlin 18 =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 dpavlin 73 return $self->mail;
253 dpavlin 18 }
254    
255     sub email_confirmed { 1 };
256    
257 dpavlin 45 =head2 name
258    
259     =cut
260    
261     sub name {
262     my $self = shift;
263 dpavlin 73 return $self->cn . ' <' . $self->mail . '>';
264 dpavlin 45 }
265    
266 dpavlin 4 =head2 validate_telephoneNumber
267    
268     =cut
269    
270     sub validate_telephoneNumber {
271     my ( $self, $value ) = @_;
272    
273     return ( 0, _('Telephone number invalid') ) if $value !~ m/^(\+?385)?[\d\s-]+$/;
274    
275     return ( 1, 'OK' );
276     }
277    
278 dpavlin 38 =head2 hrEduPersonUniqueNumber
279 dpavlin 35
280     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 dpavlin 16 =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 dpavlin 33 if ( lc($value) eq 'none' ) {
328 dpavlin 16 $self->log->warn("fixed hrEduPersonExpireDate");
329     $value = '2042-12-30';
330     }
331    
332     return $value;
333     }
334    
335 dpavlin 70 use A3C::DefaultACL;
336 dpavlin 16
337 dpavlin 2 1;
338    

  ViewVC Help
Powered by ViewVC 1.1.26