Ignore:
Timestamp:
03/20/15 12:31:05 (9 years ago)
Author:
nanardon
Message:

review the way chanages are report, make it more general

File:
1 edited

Legend:

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

    r1278 r1286  
    128128    my ($self) = @_; 
    129129    $self->{_id} 
     130} 
     131 
     132 
     133=head2 Iid 
     134 
     135Return internal id if different from Id 
     136 
     137=cut 
     138 
     139sub Iid { 
     140    my ($self) = @_; 
     141    $self->id 
    130142} 
    131143 
     
    368380            return 0; 
    369381        }; 
    370         $res += ($attribute->set($cdata{$cfield}) || 0); 
    371  
    372     } 
    373     $res 
     382    } 
     383 
     384    my %updated = (); 
     385    foreach my $cfield (keys %cdata) { 
     386        my $attribute = $self->attribute($cfield) or do { 
     387            $self->base->log(LA_ERR, 
     388                "Cannot set unsupported attribute %s to %s (%s)", 
     389                $cfield, $self->id, $self->type 
     390            ); 
     391            return; 
     392        }; 
     393        if ($attribute->set($cdata{$cfield})) { 
     394            $updated{$cfield} = $attribute->{notify}; 
     395        } 
     396    } 
     397     
     398    if (keys %updated) { 
     399        $self->ReportChange('Update', 'Attributes %s where updated', join(', ', sort keys %updated)); 
     400        foreach (sort keys %updated) { 
     401            $self->ReportChange('Attributes', '%s set to %s', $_,  
     402                (ref $cdata{$_} 
     403                    ? join(', ', @{ $cdata{$_} }) 
     404                    : $cdata{$_}) || '(none)') 
     405                if ($updated{$_}); 
     406        } 
     407    } 
     408    return scalar(keys %updated); 
    374409} 
    375410 
     
    390425    my ($self, $clear_pass) = @_; 
    391426    if ($self->base->check_acl($self, 'userPassword', 'w')) { 
    392         return $self->_set_password($clear_pass); 
     427        if ($self->_set_password($clear_pass)) { 
     428             $self->ReportChange('Password', 'user password has changed'); 
     429             return 1; 
     430        } else { 
     431            return; 
     432        } 
    393433    } else { 
    394434        $self->base->log(LA_ERROR, "Permission denied for %s to change its password", 
     
    623663} 
    624664 
     665=head2 ReportChange($changetype, $message, @args) 
     666 
     667Possible per database way to log changes 
     668 
     669=cut 
     670 
     671sub ReportChange { 
     672    my ($self, $changetype, $message, @args) = @_; 
     673 
     674    $self->base->ReportChange( 
     675        $self->type, 
     676        $self->id, 
     677        $self->Iid, 
     678        $changetype, $message, @args 
     679    ) 
     680} 
     681 
    6256821; 
    626683 
Note: See TracChangeset for help on using the changeset viewer.