This replaces SetError() and direct field access.
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/web/admin/UserDetails.pl | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/testbot/web/admin/UserDetails.pl b/testbot/web/admin/UserDetails.pl index 833a36d14f..da8cebf2f1 100644 --- a/testbot/web/admin/UserDetails.pl +++ b/testbot/web/admin/UserDetails.pl @@ -88,10 +88,10 @@ sub OnItemAction($$$) return 1 if ($self->{User}->Roles->HasItem($Item->Name));
$self->{User}->AddRole($Item); - my $ErrMessage = $self->{User}->Roles->Save(); + my ($_ErrKey, $ErrProperty, $ErrMessage) = $self->{User}->Roles->Save(); if (defined $ErrMessage) { - $self->{EnclosingPage}->SetError(undef, $ErrMessage); + $self->{EnclosingPage}->AddError($ErrMessage, $ErrProperty); return 0; } NotifyAdministrator("New administrator user: $self->{UserName}", @@ -100,13 +100,12 @@ sub OnItemAction($$$) } if ($self->{RW} and $Action eq "Remove role") { - my $UserRole = $self->{User}->Roles->GetItem($Item->Name); + my $Roles = $self->{User}->Roles; + my $UserRole = $Roles->GetItem($Item->Name); return 1 if (!$UserRole);
- my $ErrMessage = $self->{User}->Roles->DeleteItem($UserRole); - if (defined $ErrMessage) + if ($self->{EnclosingPage}->AddError($Roles->DeleteItem($UserRole))) { - $self->{EnclosingPage}->SetError(undef, $ErrMessage); return 0; } NotifyAdministrator("Removed an administrator: $self->{UserName}", @@ -114,7 +113,7 @@ sub OnItemAction($$$) return 1; }
- $self->{EnclosingPage}->SetError(undef, "No per-Item action defined for $Action"); + $self->{EnclosingPage}->AddError("No per-Item action defined for $Action"); return 0; }
@@ -194,8 +193,7 @@ sub OnApprove($) my ($self) = @_;
return !1 if (!$self->Save()); - $self->{ErrMessage} = $self->{Item}->Approve(); - return !1 if (defined $self->{ErrMessage}); + return !1 if ($self->AddError($self->{Item}->Approve())); exit($self->RedirectToParent()); }
@@ -204,8 +202,12 @@ sub OnReject($) my ($self) = @_;
$self->{Item}->Status('deleted'); - ($self->{ErrField}, $self->{ErrMessage}) = $self->{Item}->Save(); - return !1 if (defined $self->{ErrMessage}); + my ($ErrProperty, $ErrMessage) = $self->{Item}->Save(); + if (defined $ErrMessage) + { + $self->AddError($ErrMessage, $ErrProperty); + return !1; + } # Forcefully log out that user by deleting his web sessions DeleteSessions($self->{Item}); exit($self->RedirectToParent());