Converted user manager to use new pagination and scratch systems. Cleaned up some unnecessary code introduced by the new user status search.
This commit is contained in:
parent
d9c0f17145
commit
4bd546b81d
2 changed files with 42 additions and 51 deletions
|
|
@ -956,10 +956,9 @@ INSERT INTO template VALUES (3,'Ordered List','<tmpl_if displayTitle>\r\n <h1
|
|||
INSERT INTO template VALUES (4,'Descriptive','<tmpl_if displayTitle>\r\n <h1><tmpl_var title></h1>\r\n</tmpl_if>\r\n\r\n<tmpl_if description>\r\n <tmpl_var description><p/>\r\n</tmpl_if>\r\n\r\n<tmpl_if session.var.adminOn>\r\n <a href=\"<tmpl_var addlink.url>\"><tmpl_var addlink.label></a><p />\r\n</tmpl_if>\r\n\r\n<tmpl_loop link_loop>\r\n <tmpl_if session.var.adminOn>\r\n <tmpl_var link.controls> <br />\r\n </tmpl_if>\r\n\r\n <a href=\"<tmpl_var link.url\"\r\n <tmpl_if link.newwindow>\r\n target=\"_blank\"\r\n </tmpl_if>\r\n ><span class=\"linkTitle\"><tmpl_var link.name></span></a>\r\n\r\n <tmpl_if link.description>\r\n - <tmpl_var link.description>\r\n </tmpl_if>\r\n <p />\r\n</tmpl_loop>\r\n','LinkList');
|
||||
insert into settings (name, value) values ('snippetsPreviewLength', 30);
|
||||
alter table users add column status enum('Active','Deactivated','Selfdestructed') not null default 'Active';
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (822,1,'WebGUI','Search users within selected status.', 1038433447);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (821,1,'WebGUI','Any', 1038432387);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (820,1,'WebGUI','Your account is not activated. Therefore you cannot log in until it\'s activated, which only can be done by the admin.', 1038431645);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (819,1,'WebGUI','Selfdestructed', 1038431323);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (819,1,'WebGUI','Self-Deactivated', 1038431323);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (818,1,'WebGUI','Deactivated', 1038431300);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (817,1,'WebGUI','Active', 1038431287);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (816,1,'WebGUI','Status', 1038431169);
|
||||
|
|
|
|||
|
|
@ -72,11 +72,14 @@ sub www_addUser {
|
|||
tie %status, 'Tie::IxHash';
|
||||
%status = (
|
||||
Active =>WebGUI::International::get(817),
|
||||
Deactivated =>WebGUI::International::get(818),
|
||||
Selfdestructed =>WebGUI::International::get(819)
|
||||
Deactivated =>WebGUI::International::get(818)
|
||||
);
|
||||
$f->select("status",\%status,WebGUI::International::get(816), ['Active']);
|
||||
|
||||
push(@array,1); #visitors
|
||||
push(@array,2); #registered users
|
||||
push(@array,7); #everyone
|
||||
$groups = WebGUI::SQL->buildHashRef("select groupId,groupName from groups where groupId not in (".join(",",@array).") order by groupName");
|
||||
$f->select("groups",$groups,WebGUI::International::get(605),[],5,1);
|
||||
%hash = map {$_ => $_} @{$session{authentication}{available}};
|
||||
$f->select("authMethod",\%hash,WebGUI::International::get(164),[$session{setting}{authMethod}]);
|
||||
|
||||
|
|
@ -86,12 +89,6 @@ sub www_addUser {
|
|||
WebGUI::ErrorHandler::fatalError("Unable to load method formAddUser on Authentication module: $_. ".$@) if($@);
|
||||
$f->raw($html);
|
||||
}
|
||||
|
||||
push(@array,1); #visitors
|
||||
push(@array,2); #registered users
|
||||
push(@array,7); #everyone
|
||||
$groups = WebGUI::SQL->buildHashRef("select groupId,groupName from groups where groupId not in (".join(",",@array).") order by groupName");
|
||||
$f->select("groups",$groups,WebGUI::International::get(605),[],5,1);
|
||||
$f->submit;
|
||||
$output .= $f->print;
|
||||
return _submenu($output);
|
||||
|
|
@ -400,64 +397,59 @@ sub www_editUserProfileSave {
|
|||
#-------------------------------------------------------------------
|
||||
sub www_listUsers {
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
my ($output, $sth, %data, $f, @row, $p, $i, $search, %status, $selectedStatus);
|
||||
tie %data, 'Tie::CPHash';
|
||||
WebGUI::Session::setScratch("userSearchKeyword",$session{form}{keyword});
|
||||
WebGUI::Session::setScratch("userSearchStatus",$session{form}{status});
|
||||
my ($output, $data, $f, $rows, $p, $search, %status, $selectedStatus);
|
||||
$output = helpIcon(8);
|
||||
$output .= '<h1>'.WebGUI::International::get(149).'</h1>';
|
||||
$output .= '<div align="center">';
|
||||
tie %status, 'Tie::IxHash';
|
||||
%status = (
|
||||
"status like '%'" => WebGUI::International::get(821),
|
||||
"status='Active'" => WebGUI::International::get(817),
|
||||
"status='Deactivated'" => WebGUI::International::get(818),
|
||||
"status='Selfdestructed'" => WebGUI::International::get(819)
|
||||
"" => WebGUI::International::get(821),
|
||||
Active => WebGUI::International::get(817),
|
||||
Deactivated => WebGUI::International::get(818),
|
||||
Selfdestructed => WebGUI::International::get(819)
|
||||
);
|
||||
$f = WebGUI::HTMLForm->new(1);
|
||||
$f->hidden("op","listUsers");
|
||||
$f->text("keyword",'',$session{form}{keyword});
|
||||
$f->text("keyword",'',$session{scratch}{userSearchKeyword});
|
||||
$f->select(
|
||||
-name => "status",
|
||||
-value => [$session{form}{status} || "status like '%'"],
|
||||
-options=> \%status
|
||||
);
|
||||
$f->submit(WebGUI::International::get(170));
|
||||
$f->readOnly(WebGUI::International::get(822));
|
||||
$f->checkbox (
|
||||
-name => "searchWithinStatus",
|
||||
-label => "searchWithinStatus",
|
||||
-checked=> $session{form}{searchWithinStatus},
|
||||
);
|
||||
$output .= $f->print;
|
||||
$output .= '</div>';
|
||||
$selectedStatus = $session{form}{status} || "status like '%'";
|
||||
if ($session{form}{keyword} ne "") {
|
||||
$selectedStatus = "status like '%'" unless ($session{form}{searchWithinStatus});
|
||||
$search = " where (users.username like '%".$session{form}{keyword}."%' and ".$selectedStatus.") ";
|
||||
} else {
|
||||
$search = " where (".$selectedStatus.") ";
|
||||
}
|
||||
$sth = WebGUI::SQL->read("select * from users $search order by users.username");
|
||||
while (%data = $sth->hash) {
|
||||
$row[$i] = '<tr class="tableData">';
|
||||
$row[$i] .= ($data{status} eq 'Active') ? '<td> </td>' : '<td>'.$data{status}.'</td>';
|
||||
$row[$i] .= '<td><a href="'.WebGUI::URL::page('op=editUser&uid='.$data{userId})
|
||||
.'">'.$data{username}.'</a></td>';
|
||||
#$row[$i] .= '<td class="tableData">'.epochToHuman($data{dateCreated},"%z").'</td>';
|
||||
#$row[$i] .= '<td class="tableData">'.epochToHuman($data{lastUpdated},"%z").'</td>';
|
||||
$row[$i] .= '</tr>';
|
||||
$i++;
|
||||
}
|
||||
$sth->finish;
|
||||
$p = WebGUI::Paginator->new(WebGUI::URL::page('op=listUsers&keyword='.$session{form}{keyword}),\@row);
|
||||
$output .= '<table border=1 cellpadding=5 cellspacing=0 align="center">';
|
||||
$output .= '<tr>
|
||||
<td class="tableHeader">'.WebGUI::International::get(816).'</td>
|
||||
<td class="tableHeader">'.WebGUI::International::get(50).'</td></tr>';
|
||||
# <td class="tableHeader">'.WebGUI::International::get(453).'</td>
|
||||
# <td class="tableHeader">'.WebGUI::International::get(454).'</td></tr>';
|
||||
$output .= $p->getPage($session{form}{pn});
|
||||
$output .= '<tr>
|
||||
<td class="tableHeader">'.WebGUI::International::get(816).'</td>
|
||||
<td class="tableHeader">'.WebGUI::International::get(50).'</td>
|
||||
<td class="tableHeader">'.WebGUI::International::get(453).'</td>
|
||||
<td class="tableHeader">'.WebGUI::International::get(454).'</td></tr>';
|
||||
if ($session{scratch}{userSearchStatus}) {
|
||||
$selectedStatus = "status='".$session{scratch}{userSearchStatus}."'";
|
||||
} else {
|
||||
$selectedStatus = "status like '%'";
|
||||
}
|
||||
if ($session{scratch}{userSearchKeyword} ne "") {
|
||||
$search = " and users.username like ".quote("%".$session{scratch}{userSearchKeyword}."%");
|
||||
}
|
||||
$p = WebGUI::Paginator->new(WebGUI::URL::page("op=listUsers"));
|
||||
$p->setDataByQuery("select userId,username,status,dateCreated,lastUpdated from users
|
||||
where $selectedStatus $search order by users.username");
|
||||
$rows = $p->getPageData;
|
||||
foreach $data (@$rows) {
|
||||
$output .= '<tr class="tableData">';
|
||||
$output .= '<td>'.$status{$data->{status}}.'</td>';
|
||||
$output .= '<td><a href="'.WebGUI::URL::page('op=editUser&uid='.$data->{userId})
|
||||
.'">'.$data->{username}.'</a></td>';
|
||||
$output .= '<td class="tableData">'.epochToHuman($data->{dateCreated},"%z").'</td>';
|
||||
$output .= '<td class="tableData">'.epochToHuman($data->{lastUpdated},"%z").'</td>';
|
||||
$output .= '</tr>';
|
||||
}
|
||||
$output .= '</table>';
|
||||
$output .= $p->getBarTraditional($session{form}{pn});
|
||||
$output .= $p->getBarTraditional;
|
||||
return _submenu($output);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue