Changeset 1947


Ignore:
Timestamp:
02/14/17 19:37:35 (7 years ago)
Author:
nanardon
Message:

Fix object deref

File:
1 edited

Legend:

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

    r1945 r1947  
    15301530    my ($self) = @_; 
    15311531 
    1532     my $currentemployment = $self->get_attributes('currentEmployment') || ''; 
     1532    my $currentempl = $self->get_attributes('currentEmployment') || ''; 
    15331533 
    15341534    $self->base->log( 
    15351535        LA_DEBUG, 
    15361536        "Applying Employement %s to user %s", 
    1537         $currentemployment ? $currentemployment->id : '(none)', 
     1537        $currentempl || '(none)', 
    15381538        $self->id 
    15391539    ); 
    15401540 
    1541     if (!$currentemployment) { 
    1542         return $self->_resetEmployment; 
    1543     } 
    1544  
    1545     $self->computeEmploymentDate; 
    1546  
    1547     my %attrsets = ( 
    1548         appliedEmployement => $currentemployment->id, 
    1549     ); 
    1550     foreach my $attr (_reported_atributes(), qw(department managerContact)) { 
    1551         my $uval = $self->get_attributes($attr) || ''; 
    1552         my $cval = $currentemployment->get_attributes($attr) || ''; 
    1553  
    1554         for ($attr) { 
    1555             if ($attr eq 'managerContact') { 
    1556                 if (!$cval) { 
    1557                     my $dpmt  = $currentemployment->get_attributes('department') or last; 
    1558                     my $odmpt = $currentemployment->base->get_object('group', $dpmt) or last; 
    1559                     $cval = $odmpt->get_attributes('managedBy'); 
     1541    if (my $currentemployment = $self->base->get_object('employment', $currentempl)) { 
     1542        $self->computeEmploymentDate; 
     1543 
     1544        my %attrsets = ( 
     1545            appliedEmployement => $currentemployment->id, 
     1546        ); 
     1547        foreach my $attr (_reported_atributes(), qw(department managerContact)) { 
     1548            my $uval = $self->get_attributes($attr) || ''; 
     1549            my $cval = $currentemployment->get_attributes($attr) || ''; 
     1550 
     1551            for ($attr) { 
     1552                if ($attr eq 'managerContact') { 
     1553                    if (!$cval) { 
     1554                        my $dpmt  = $currentemployment->get_attributes('department') or last; 
     1555                        my $odmpt = $currentemployment->base->get_object('group', $dpmt) or last; 
     1556                        $cval = $odmpt->get_attributes('managedBy'); 
     1557                    } 
    15601558                } 
    15611559            } 
    1562         } 
    1563  
    1564         if ($uval ne $cval) { 
    1565             my $oattr = $currentemployment->base->attribute('self', $attr); 
    1566             $attrsets{$oattr->iname} = $cval; 
    1567         } 
    1568     } 
    1569  
    1570     if (keys %attrsets) { 
    1571         if (my $res = $self->set_fields(%attrsets)) { 
    1572             $self->ReportChange('Update', 'Attr %s updated to match Employment %s', join(', ', sort keys %attrsets), $currentemployment->id); 
    1573             return $res; 
     1560 
     1561            if ($uval ne $cval) { 
     1562                my $oattr = $currentemployment->base->attribute('self', $attr); 
     1563                $attrsets{$oattr->iname} = $cval; 
     1564            } 
     1565        } 
     1566 
     1567        if (keys %attrsets) { 
     1568            if (my $res = $self->set_fields(%attrsets)) { 
     1569                $self->ReportChange('Update', 'Attr %s updated to match Employment %s', join(', ', sort keys %attrsets), $currentemployment->id); 
     1570                return $res; 
     1571            } 
     1572        } else { 
     1573            return 1; 
    15741574        } 
    15751575    } else { 
    1576         return 1; 
    1577     } 
     1576        return $self->_resetEmployment; 
     1577    } 
     1578 
    15781579} 
    15791580 
     
    15991600        } 
    16001601    } 
    1601     if ($self->set_fields(%changes)) { 
     1602    if (!%changes) { 
     1603        return 1 
     1604    } elsif ($self->set_fields(%changes)) { 
    16021605        $self->base->log(LA_NOTICE, "Updating user %s to match unemployment", $self->id); 
    16031606        $self->ReportChange('Update', 'Update %s to match unemployment', join(', ', sort keys %changes)); 
Note: See TracChangeset for help on using the changeset viewer.