Changeset 1947 for trunk/LATMOS-Accounts/lib
- Timestamp:
- 02/14/17 19:37:35 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm
r1945 r1947 1530 1530 my ($self) = @_; 1531 1531 1532 my $currentempl oyment= $self->get_attributes('currentEmployment') || '';1532 my $currentempl = $self->get_attributes('currentEmployment') || ''; 1533 1533 1534 1534 $self->base->log( 1535 1535 LA_DEBUG, 1536 1536 "Applying Employement %s to user %s", 1537 $currentempl oyment ? $currentemployment->id :'(none)',1537 $currentempl || '(none)', 1538 1538 $self->id 1539 1539 ); 1540 1540 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 } 1560 1558 } 1561 1559 } 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; 1574 1574 } 1575 1575 } else { 1576 return 1; 1577 } 1576 return $self->_resetEmployment; 1577 } 1578 1578 1579 } 1579 1580 … … 1599 1600 } 1600 1601 } 1601 if ($self->set_fields(%changes)) { 1602 if (!%changes) { 1603 return 1 1604 } elsif ($self->set_fields(%changes)) { 1602 1605 $self->base->log(LA_NOTICE, "Updating user %s to match unemployment", $self->id); 1603 1606 $self->ReportChange('Update', 'Update %s to match unemployment', join(', ', sort keys %changes));
Note: See TracChangeset
for help on using the changeset viewer.