Changeset 1506


Ignore:
Timestamp:
12/18/15 18:35:42 (9 years ago)
Author:
nanardon
Message:

Set user's attribute read-only when employment is used

Location:
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Employment.pm

    r1504 r1506  
    142142 
    143143    if ($expire != $nextexpire) { 
    144         $user->_set_c_fields(expire => $endemploy); 
     144        $user->set_fields(expire => $endemploy); 
    145145    } 
    146146 
     
    158158 
    159159        if ($uval ne $cval) { 
    160             $attrsets{$attr} = $cval; 
     160            my $oattr = $self->base->attribute('user', $attr); 
     161            $attrsets{$oattr->iname} = $cval; 
    161162        } 
    162163    } 
    163164 
    164165    if (keys %attrsets) { 
    165         return $user->_set_c_fields(%attrsets); 
     166        return $user->set_fields(%attrsets); 
    166167    } else { 
    167168        return 1; 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm

    r1504 r1506  
    196196                monitored => 1, 
    197197            }, 
    198             expire        => { inline => 1, formtype => 'DATETIME', monitored => 1, }, 
    199             endcircuit    => { inline => 1, formtype => 'DATE',     monitored => 1, }, 
     198            expire        => { 
     199                ro => sub { !$_[0] and return 1; $_[0]->listEmployment ? 1 : 0 }, 
     200                inline => 1, 
     201                formtype => 'DATETIME', 
     202                monitored => 1, 
     203            }, 
     204            endcircuit    => { 
     205                ro => sub { !$_[0] and return 1; $_[0]->listEmployment ? 1 : 0 }, 
     206                inline => 1, 
     207                formtype => 'DATE', 
     208                monitored => 1, 
     209            }, 
    200210            endEmployment => { 
    201211                formtype => 'DATETIME', 
     
    237247                        $listold->execute($self->id); 
    238248                        my $res = $listold->fetchrow_hashref; 
    239                         $listold->finish; 
    240                         if ($res) { 
     249                        if ($res && $res->{lastday}) { 
    241250                            $end = DateTime->from_epoch(epoch => str2time($res->{lastday})); 
    242251                            $end->set_time_zone( DateTime::TimeZone->new( name => 'local' ) ); 
    243252                            $end->add(hours => 23, minutes => 59, seconds => 59); 
    244253                        } 
     254                        $listold->finish; 
    245255                    } 
    246256                    return $end ? $end->iso8601 : undef 
     
    473483            }, 
    474484            department => { 
     485                ro => sub { !$_[0] and return 1; $_[0]->listEmployment ? 1 : 0 }, 
    475486                reference => 'group', 
    476487                can_values => sub { 
     
    480491            }, 
    481492            contratType => { 
     493                ro => sub { !$_[0] and return 1; $_[0]->listEmployment ? 1 : 0 }, 
    482494                reference => 'group', 
    483495                can_values => sub { 
     
    797809            }, 
    798810            managerContact => { 
     811                ro => sub { !$_[0] and return 1; $_[0]->listEmployment ? 1 : 0 }, 
    799812                delayed => 1, 
    800813                can_values => sub { 
     
    909922            encryptedPassword => { }, 
    910923            description => { }, 
    911             company => { }, 
     924            company => { 
     925                ro => sub { !$_[0] and return 1; $_[0]->listEmployment ? 1 : 0 }, 
     926            }, 
    912927            comment => { }, 
    913928            college => { }, 
Note: See TracChangeset for help on using the changeset viewer.