- Timestamp:
- 12/31/15 14:31:46 (9 years ago)
- Location:
- trunk/LATMOS-Accounts
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Employment.pm
r1576 r1577 285 285 286 286 my %changes; 287 foreach (qw( endEmployment endStrictEmployment endCurrentEmployment endLastEmployment )) { 287 my @employmentDate = qw( endEmployment endStrictEmployment endCurrentEmployment endLastEmployment ); 288 foreach (@employmentDate) { 288 289 my $old = $user->_get_attributes($_) || ''; 289 290 my $new = $user->_get_attributes("_$_") || ''; … … 295 296 # If there is no current employment we try to find any to not let expire 296 297 # unset 297 my $endemploy = $currentemployment 298 ? $user->_get_attributes('_endEmployment') 299 : $user->_get_attributes('_endLastEmployment'); 300 my $nextexpire = str2time($endemploy || '1970-01-01T00:00:00'); 301 302 if ($expire != $nextexpire) { 303 $changes{expire} = $endemploy; 298 299 my $expireOn = $self->base->config('expireOn') || ''; 300 if (!grep { $_ eq $expireOn } (@employmentDate, '', 'never')) { 301 $self->base->log(LA_ERR, "expireOn set to invalid parameter %s, using endEmployment instead", $expireOn); 302 $expireOn = 'endEmployment'; 303 } 304 305 if ($expireOn ne 'never') { 306 my $endemploy = $currentemployment 307 ? $user->_get_attributes("_$expireOn") 308 : $user->_get_attributes('_endLastEmployment'); 309 my $nextexpire = str2time($endemploy || '1970-01-01T00:00:00'); 310 311 if ($expire != $nextexpire) { 312 $changes{expire} = $endemploy; 313 } 304 314 } 305 315 306 316 if (keys %changes) { 307 317 $user->ReportChange('Update', 'Update %s to match employment', join(', ', sort keys %changes)); 308 $user->ReportChange('Update', 'Expire update to %s to match employment', ($ endemploy|| '(none)'))318 $user->ReportChange('Update', 'Expire update to %s to match employment', ($changes{expire} || '(none)')) 309 319 if (exists($changes{expire})); 310 320 $user->set_fields(%changes); -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm
r1570 r1577 1104 1104 }; 1105 1105 1106 foreach (qw(expire contratType managerContact company endcircuit department)) { 1107 $attrs->{$_}{ro} = sub { 1108 1109 my $setting = $base->config('employment_lock_user') || 'any'; 1110 1111 for ($setting) { 1112 /^always$/ and return 1; 1113 /^never$/ and return 0; 1114 1115 !$_[0] and return 1; 1116 1117 /^any$/i and return $_[0]->listEmployment ? 1 : 0; 1118 /^active/i and do { 1119 return $_[0]->_get_c_field('currentEmployment') 1120 ? 1 1121 : $_[0]->_get_c_field('nextEmployment') ? 1 : 0; 1122 }; 1123 /(\S+)=(\S+)/ and do { 1124 my $attr = $_[0]->_get_c_field($1); 1125 if (defined($attr)) { 1126 if ($2 eq '*') { 1127 return 1; 1128 } elsif($2 eq $attr) { 1129 return 1; 1130 } else { 1131 return 0; 1132 } 1106 my $employmentro = sub { 1107 my $setting = $base->config('employment_lock_user') || 'any'; 1108 1109 for ($setting) { 1110 /^always$/ and return 1; 1111 /^never$/ and return 0; 1112 1113 !$_[0] and return 1; 1114 1115 /^any$/i and return $_[0]->listEmployment ? 1 : 0; 1116 /^active/i and do { 1117 return $_[0]->_get_c_field('currentEmployment') 1118 ? 1 1119 : $_[0]->_get_c_field('nextEmployment') ? 1 : 0; 1120 }; 1121 /(\S+)=(\S+)/ and do { 1122 my $attr = $_[0]->_get_c_field($1); 1123 if (defined($attr)) { 1124 if ($2 eq '*') { 1125 return 1; 1126 } elsif($2 eq $attr) { 1127 return 1; 1133 1128 } else { 1134 1129 return 0; 1135 1130 } 1136 }; 1137 } 1138 return $_[0]->listEmployment ? 1 : 0; # default is any! 1139 }; 1131 } else { 1132 return 0; 1133 } 1134 }; 1135 } 1136 return $_[0]->listEmployment ? 1 : 0; # default is any! 1137 }; 1138 1139 foreach (qw(contratType managerContact company endcircuit department)) { 1140 $attrs->{$_}{ro} = $employmentro; 1140 1141 } 1142 1143 $attrs->{expire}{ro} = sub { 1144 my $expireOn = $base->config('expireOn') || ''; 1145 if ($expireOn eq 'never') { 1146 return 0; 1147 } 1148 1149 $employmentro->($_[0]); 1150 }; 1141 1151 1142 1152 $class->SUPER::_get_attr_schema($base, $attrs) -
trunk/LATMOS-Accounts/man/man8/latmos-accounts-base-sql.pod
r1576 r1577 150 150 The end of the employment matching current date. 151 151 152 =head3 Account Expiration 153 154 When using employment, account expiration are set to match employment. By 155 default the expiration is set to C<endEmployment> value. 156 157 This behaviour can be changed by setting C<expireOn> parameter into base 158 definition: 159 160 =over 4 161 162 =item any of endCurrentEmployment, endEmployment, endStrictEmployment, endLastEmployment 163 164 =item never 165 166 The expire date is left unchanged and must managed manually. 167 168 =back 169 152 170 =head2 Group AutoMemberFilter 153 171
Note: See TracChangeset
for help on using the changeset viewer.