Changeset 1524 for trunk/LATMOS-Accounts/lib
- Timestamp:
- 12/22/15 17:36:36 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm
r1522 r1524 87 87 }; 88 88 89 $class->SUPER::_get_attr_schema($base, 90 { 89 my $attrs = { 91 90 exported => { 92 91 post => sub { … … 197 196 }, 198 197 expire => { 199 ro => sub { !$_[0] and return 1; $_[0]->listEmployment ? 1 : 0 },200 198 inline => 1, 201 199 formtype => 'DATETIME', … … 203 201 }, 204 202 endcircuit => { 205 ro => sub { !$_[0] and return 1; $_[0]->listEmployment ? 1 : 0 },206 203 inline => 1, 207 204 formtype => 'DATE', … … 511 508 }, 512 509 department => { 513 ro => sub { !$_[0] and return 1; $_[0]->listEmployment ? 1 : 0 },514 510 reference => 'group', 515 511 can_values => sub { … … 519 515 }, 520 516 contratType => { 521 ro => sub { !$_[0] and return 1; $_[0]->listEmployment ? 1 : 0 },522 517 reference => 'group', 523 518 can_values => sub { … … 837 832 }, 838 833 managerContact => { 839 ro => sub { !$_[0] and return 1; $_[0]->listEmployment ? 1 : 0 },840 834 delayed => 1, 841 835 can_values => sub { … … 950 944 encryptedPassword => { }, 951 945 description => { }, 952 company => { 953 ro => sub { !$_[0] and return 1; $_[0]->listEmployment ? 1 : 0 }, 954 }, 946 company => { }, 955 947 comment => { }, 956 948 college => { }, … … 983 975 } 984 976 }, 977 nextEmployment => { 978 managed => 1, 979 ro => 1, 980 reference => 'employment', 981 get => sub { 982 my ($attr) = @_; 983 my $self = $attr->object; 984 985 my $sth = $self->base->db->prepare_cached( 986 q{ 987 select name from employment where firstday > now() and 988 (lastday is null or lastday >= now() - '1 days'::interval) and "user" = ? 989 limit 1 990 } 991 ); 992 $sth->execute($self->id); 993 my $res = $sth->fetchrow_hashref; 994 $sth->finish; 995 if ($res) { 996 return $res->{name} 997 } else { 998 return; 999 } 1000 } 1001 }, 985 1002 appliedEmployement => { 986 1003 hidden => 1, 987 1004 reference => 'employment', 988 1005 }, 989 } 990 ) 1006 }; 1007 1008 foreach (qw(expire contratType managerContact company endcircuit department)) { 1009 $attrs->{$_}{ro} = sub { 1010 1011 my $setting = $base->config('employment_lock_user') || 'any'; 1012 1013 for ($setting) { 1014 /^always$/ and return 1; 1015 /^never$/ and return 0; 1016 1017 !$_[0] and return 1; 1018 1019 /^any$/i and return $_[0]->listEmployment ? 1 : 0; 1020 /^active/i and do { 1021 return $_[0]->_get_c_field('currentEmployment') 1022 ? 1 1023 : $_[0]->_get_c_field('nextEmployment') ? 1 : 0; 1024 }; 1025 /(\S+)=(\S+)/ and do { 1026 my $attr = $_[0]->_get_c_field($1); 1027 if (defined($attr)) { 1028 if ($2 eq '*') { 1029 return 1; 1030 } elsif($2 eq $attr) { 1031 return 1; 1032 } else { 1033 return 0; 1034 } 1035 } else { 1036 return 0; 1037 } 1038 }; 1039 } 1040 return $_[0]->listEmployment ? 1 : 0; # default is any! 1041 }; 1042 } 1043 1044 $class->SUPER::_get_attr_schema($base, $attrs) 991 1045 } 992 1046
Note: See TracChangeset
for help on using the changeset viewer.