Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/web/admin/UsersList.pl | 62 ++++++++++++++++------------------ 1 file changed, 29 insertions(+), 33 deletions(-)
diff --git a/testbot/web/admin/UsersList.pl b/testbot/web/admin/UsersList.pl index ae514e901..08ae5bffb 100644 --- a/testbot/web/admin/UsersList.pl +++ b/testbot/web/admin/UsersList.pl @@ -2,7 +2,7 @@ # User list page # # Copyright 2009 Ge van Geldorp -# Copyright 2013 Francois Gouget +# Copyright 2013, 2022 Francois Gouget # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -20,45 +20,35 @@
use strict;
-package UsersListPage; +package UsersBlock;
-use ObjectModel::CGI::CollectionPage; -our @ISA = qw(ObjectModel::CGI::CollectionPage); +use ObjectModel::CGI::CollectionBlock; +our @ISA = qw(ObjectModel::CGI::CollectionBlock);
use URI::Escape; use WineTestBot::CGI::Sessions; use WineTestBot::Config; -use WineTestBot::Users; - - -sub _initialize($$$) -{ - my ($self, $Request, $RequiredRole) = @_;
- $self->SUPER::_initialize($Request, $RequiredRole, CreateUsers()); -}
-sub SortKeys($$$) +sub Create($$) { - my ($self, $CollectionBlock, $Keys) = @_; + my ($Collection, $EnclosingPage) = @_;
- my @SortedKeys = sort { $a cmp $b } @$Keys; - return @SortedKeys; + return UsersBlock->new($Collection, $EnclosingPage); }
-sub DisplayProperty($$$) +sub DisplayProperty($$) { - my ($self, $CollectionBlock, $PropertyDescriptor) = @_; + my ($self, $PropertyDescriptor) = @_;
my $PropertyName = $PropertyDescriptor->GetName(); - return $PropertyName eq "Name" || $PropertyName eq "EMail" || $PropertyName eq "Status" || $PropertyName eq "RealName"; }
-sub GenerateDataCell($$$$$) +sub GenerateDataCell($$$$) { - my ($self, $CollectionBlock, $User, $PropertyDescriptor, $DetailsPage) = @_; + my ($self, $User, $PropertyDescriptor, $DetailsPage) = @_;
my $PropertyName = $PropertyDescriptor->GetName(); if ($PropertyName eq "Status") @@ -98,41 +88,47 @@ sub GenerateDataCell($$$$$) } else { - $self->SUPER::GenerateDataCell($CollectionBlock, $User, $PropertyDescriptor, $DetailsPage); + $self->SUPER::GenerateDataCell($User, $PropertyDescriptor, $DetailsPage); } }
-sub GetItemActions($$) +sub GetItemActions($) { - my ($self, $CollectionBlock) = @_; + my ($self) = @_;
# LDAP accounts cannot be deleted return defined $LDAPServer ? [] : ["Delete"]; }
-sub OnItemAction($$$$) +sub OnItemAction($$$) { - my ($self, $CollectionBlock, $User, $Action) = @_; + my ($self, $User, $Action) = @_;
if ($Action eq "Delete") { $User->Status('deleted'); - # Setting $self->{ErrField} is only useful on form pages - (my $_ErrProperty, $self->{ErrMessage}) = $User->Save(); - return 0 if (defined $self->{ErrMessage}); + my ($_ErrProperty, $ErrMessage) = $User->Save(); + if (defined $ErrMessage) + { + # Setting ErrField is only useful on form pages + $self->{EnclosingPage}->SetError(undef, $ErrMessage); + return 0; + }
# Forcefully log out that user by deleting the web sessions DeleteSessions($User); return 1; }
- return $self->SUPER::OnItemAction($CollectionBlock, $User, $Action); + return $self->SUPER::OnItemAction($User, $Action); }
package main;
-my $Request = shift; +use ObjectModel::CGI::SimpleCollectionPage; +use WineTestBot::Users;
-my $UsersListPage = UsersListPage->new($Request, "admin"); -$UsersListPage->GeneratePage(); +my $Request = shift; +my $Page = ObjectModel::CGI::SimpleCollectionPage->new($Request, "admin", CreateUsers(), &UsersBlock::Create); +$Page->GeneratePage();