Cleaning up admin interface.
This commit is contained in:
parent
fbd8093ae0
commit
ed6901a0ef
7 changed files with 172 additions and 131 deletions
|
|
@ -17,6 +17,7 @@ use WebGUI::DateTime;
|
|||
use WebGUI::HTMLForm;
|
||||
use WebGUI::Icon;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Operation::Shared;
|
||||
use WebGUI::Paginator;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
|
|
@ -25,150 +26,151 @@ use WebGUI::URL;
|
|||
use WebGUI::Utility;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(&www_deleteGroup &www_deleteGroupConfirm &www_editGroup &www_editGroupSave &www_listGroups);
|
||||
our @EXPORT = qw(&www_manageUsersInGroup &www_deleteGroup &www_deleteGroupConfirm &www_editGroup
|
||||
&www_editGroupSave &www_listGroups);
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _submenu {
|
||||
my ($output, %menu);
|
||||
tie %menu, 'Tie::IxHash';
|
||||
$menu{WebGUI::URL::page('op=editGroup&gid=new')} = WebGUI::International::get(90);
|
||||
unless ($session{form}{op} eq "listGroups"
|
||||
|| $session{form}{gid} eq "new"
|
||||
|| $session{form}{op} eq "deleteGroupConfirm") {
|
||||
$menu{WebGUI::URL::page("op=editGroup&gid=".$session{form}{gid})} = WebGUI::International::get(753);
|
||||
$menu{WebGUI::URL::page("op=manageUsersInGroup&gid=".$session{form}{gid})} = WebGUI::International::get(754);
|
||||
$menu{WebGUI::URL::page("op=deleteGroup&gid=".$session{form}{gid})} = WebGUI::International::get(755);
|
||||
}
|
||||
$menu{WebGUI::URL::page("op=listGroups")} = WebGUI::International::get(756);
|
||||
return menuWrapper($_[0],\%menu);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteGroup {
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
my ($output);
|
||||
if ($session{form}{gid} < 26) {
|
||||
return WebGUI::Privilege::vitalComponent();
|
||||
} elsif (WebGUI::Privilege::isInGroup(3)) {
|
||||
$output .= helpIcon(15);
|
||||
$output .= '<h1>'.WebGUI::International::get(42).'</h1>';
|
||||
$output .= WebGUI::International::get(86).'<p>';
|
||||
$output .= '<div align="center"><a href="'.
|
||||
WebGUI::URL::page('op=deleteGroupConfirm&gid='.$session{form}{gid}).
|
||||
'">'.WebGUI::International::get(44).'</a>';
|
||||
$output .= ' <a href="'.WebGUI::URL::page('op=listGroups').'">'.
|
||||
WebGUI::International::get(45).'</a></div>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
}
|
||||
return WebGUI::Privilege::vitalComponent() if ($session{form}{gid} < 26);
|
||||
$output .= helpIcon(15);
|
||||
$output .= '<h1>'.WebGUI::International::get(42).'</h1>';
|
||||
$output .= WebGUI::International::get(86).'<p>';
|
||||
$output .= '<div align="center"><a href="'.WebGUI::URL::page('op=deleteGroupConfirm&gid='.$session{form}{gid}).
|
||||
'">'.WebGUI::International::get(44).'</a>';
|
||||
$output .= ' <a href="'.WebGUI::URL::page('op=listGroups').'">'
|
||||
.WebGUI::International::get(45).'</a></div>';
|
||||
return _submenu($output);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteGroupConfirm {
|
||||
if ($session{form}{gid} < 26) {
|
||||
return WebGUI::Privilege::vitalComponent();
|
||||
} elsif (WebGUI::Privilege::isInGroup(3)) {
|
||||
WebGUI::SQL->write("delete from groups where groupId=$session{form}{gid}");
|
||||
WebGUI::SQL->write("delete from groupings where groupId=$session{form}{gid}");
|
||||
return www_listGroups();
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
}
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
return WebGUI::Privilege::vitalComponent() if ($session{form}{gid} < 26);
|
||||
WebGUI::SQL->write("delete from groups where groupId=$session{form}{gid}");
|
||||
WebGUI::SQL->write("delete from groupings where groupId=$session{form}{gid}");
|
||||
return www_listGroups();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editGroup {
|
||||
my ($output, $sth, %group, %hash, $f);
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
my ($output, %group, $f);
|
||||
tie %group, 'Tie::CPHash';
|
||||
tie %hash, 'Tie::CPHash';
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
if ($session{form}{gid} eq "new") {
|
||||
$group{expireAfter} = 314496000;
|
||||
$group{karmaThreshold} = 1000000000;
|
||||
} else {
|
||||
%group = WebGUI::SQL->quickHash("select * from groups where groupId=$session{form}{gid}");
|
||||
}
|
||||
$output .= helpIcon(17);
|
||||
$output .= '<h1>'.WebGUI::International::get(87).'</h1>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->hidden("op","editGroupSave");
|
||||
$f->hidden("gid",$session{form}{gid});
|
||||
$f->readOnly($session{form}{gid},WebGUI::International::get(379));
|
||||
$f->text("groupName",WebGUI::International::get(84),$group{groupName});
|
||||
$f->textarea("description",WebGUI::International::get(85),$group{description});
|
||||
$f->interval("expireAfter",WebGUI::International::get(367),
|
||||
WebGUI::DateTime::secondsToInterval($group{expireAfter}));
|
||||
if ($session{setting}{useKarma}) {
|
||||
$f->integer("karmaThreshold",WebGUI::International::get(538),$group{karmaThreshold});
|
||||
} else {
|
||||
$f->hidden("karmaThreshold",$group{karmaThreshold});
|
||||
}
|
||||
$f->submit;
|
||||
$output .= $f->print;
|
||||
unless ($session{form}{gid} eq "new") {
|
||||
$output .= '<h1>'.WebGUI::International::get(88).'</h1>';
|
||||
$output .= '<table><tr><td class="tableHeader"> </td>
|
||||
<td class="tableHeader">'.WebGUI::International::get(50).'</td>
|
||||
<td class="tableHeader">'.WebGUI::International::get(369).'</td></tr>';
|
||||
$sth = WebGUI::SQL->read("select users.username,users.userId,groupings.expireDate
|
||||
from groupings,users where groupings.groupId=$session{form}{gid} and groupings.userId=users.userId
|
||||
order by users.username");
|
||||
while (%hash = $sth->hash) {
|
||||
$output .= '<tr><td>'
|
||||
.deleteIcon('op=deleteGrouping&uid='.$hash{userId}.'&gid='.$session{form}{gid})
|
||||
.editIcon('op=editGrouping&uid='.$hash{userId}.'&gid='.$session{form}{gid})
|
||||
.'</td>';
|
||||
$output .= '<td class="tableData"><a href="'.WebGUI::URL::page('op=editUser&uid='.$hash{userId}).'">'
|
||||
.$hash{username}.'</a></td>';
|
||||
$output .= '<td class="tableData">'.epochToHuman($hash{expireDate},"%z").'</td></tr>';
|
||||
}
|
||||
$sth->finish;
|
||||
$output .= '</table>';
|
||||
}
|
||||
} else {
|
||||
$output = WebGUI::Privilege::adminOnly();
|
||||
}
|
||||
return $output;
|
||||
if ($session{form}{gid} eq "new") {
|
||||
$group{expireAfter} = 314496000;
|
||||
$group{karmaThreshold} = 1000000000;
|
||||
} else {
|
||||
%group = WebGUI::SQL->quickHash("select * from groups where groupId=$session{form}{gid}");
|
||||
}
|
||||
$output .= helpIcon(17);
|
||||
$output .= '<h1>'.WebGUI::International::get(87).'</h1>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->hidden("op","editGroupSave");
|
||||
$f->hidden("gid",$session{form}{gid});
|
||||
$f->readOnly($session{form}{gid},WebGUI::International::get(379));
|
||||
$f->text("groupName",WebGUI::International::get(84),$group{groupName});
|
||||
$f->textarea("description",WebGUI::International::get(85),$group{description});
|
||||
$f->interval("expireAfter",WebGUI::International::get(367), WebGUI::DateTime::secondsToInterval($group{expireAfter}));
|
||||
if ($session{setting}{useKarma}) {
|
||||
$f->integer("karmaThreshold",WebGUI::International::get(538),$group{karmaThreshold});
|
||||
} else {
|
||||
$f->hidden("karmaThreshold",$group{karmaThreshold});
|
||||
}
|
||||
$f->submit;
|
||||
$output .= $f->print;
|
||||
return _submenu($output);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editGroupSave {
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
if ($session{form}{gid} eq "new") {
|
||||
$session{form}{gid} = getNextId("groupId");
|
||||
WebGUI::SQL->write("insert into groups (groupId) values ($session{form}{gid})");
|
||||
}
|
||||
WebGUI::SQL->write("update groups set groupName=".quote($session{form}{groupName}).",
|
||||
description=".quote($session{form}{description}).",
|
||||
expireAfter='".WebGUI::DateTime::intervalToSeconds($session{form}{expireAfter_interval},
|
||||
$session{form}{expireAfter_units})."',
|
||||
karmaThreshold='$session{form}{karmaThreshold}'
|
||||
where groupId=".$session{form}{gid});
|
||||
return www_listGroups();
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
}
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
if ($session{form}{gid} eq "new") {
|
||||
$session{form}{gid} = getNextId("groupId");
|
||||
WebGUI::SQL->write("insert into groups (groupId) values ($session{form}{gid})");
|
||||
}
|
||||
WebGUI::SQL->write("update groups set groupName=".quote($session{form}{groupName}).",
|
||||
description=".quote($session{form}{description}).",
|
||||
expireAfter='".WebGUI::DateTime::intervalToSeconds($session{form}{expireAfter_interval},
|
||||
$session{form}{expireAfter_units})."',
|
||||
karmaThreshold='$session{form}{karmaThreshold}'
|
||||
where groupId=".$session{form}{gid});
|
||||
return www_listGroups();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_listGroups {
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
my ($output, $p, $sth, @data, @row, $i, $userCount);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
$output = helpIcon(10);
|
||||
$output .= '<h1>'.WebGUI::International::get(89).'</h1>';
|
||||
$output .= '<div align="center"><a href="'.WebGUI::URL::page('op=editGroup&gid=new').'">'.WebGUI::International::get(90).'</a></div>';
|
||||
$sth = WebGUI::SQL->read("select groupId,groupName,description from groups
|
||||
where groupId<>1 and groupId<>2 and groupId<>7 order by groupName");
|
||||
while (@data = $sth->array) {
|
||||
$row[$i] = '<tr><td valign="top" class="tableData">'
|
||||
.deleteIcon('op=deleteGroup&gid='.$data[0])
|
||||
.editIcon('op=editGroup&gid='.$data[0])
|
||||
.'</td>';
|
||||
$row[$i] .= '<td valign="top" class="tableData">'.$data[1].'</td>';
|
||||
$row[$i] .= '<td valign="top" class="tableData">'.$data[2].'</td>';
|
||||
($userCount) = WebGUI::SQL->quickArray("select count(*) from groupings where groupId=$data[0]");
|
||||
$row[$i] .= '<td valign="top" class="tableData">'.$userCount.'</td></tr>';
|
||||
$row[$i] .= '</tr>';
|
||||
$i++;
|
||||
}
|
||||
$sth->finish;
|
||||
$p = WebGUI::Paginator->new(WebGUI::URL::page('op=listGroups'),\@row);
|
||||
$output .= '<table border=1 cellpadding=5 cellspacing=0 align="center">';
|
||||
$output .= '<tr><td></td><td class="tableHeader">'.WebGUI::International::get(84).'</td><td class="tableHeader">'
|
||||
.WebGUI::International::get(85).'</td><td class="tableHeader">'
|
||||
.WebGUI::International::get(748).'</td></tr>';
|
||||
$output .= $p->getPage($session{form}{pn});
|
||||
$output .= '</table>';
|
||||
$output .= $p->getBarTraditional($session{form}{pn});
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
$output = helpIcon(10);
|
||||
$output .= '<h1>'.WebGUI::International::get(89).'</h1>';
|
||||
$sth = WebGUI::SQL->read("select groupId,groupName,description from groups
|
||||
where groupId<>1 and groupId<>2 and groupId<>7 order by groupName");
|
||||
while (@data = $sth->array) {
|
||||
$row[$i] = '<tr>';
|
||||
$row[$i] .= '<td valign="top" class="tableData"><a href="'
|
||||
.WebGUI::URL::page('op=editGroup&gid='.$data[0]).'">'.$data[1].'</td>';
|
||||
$row[$i] .= '<td valign="top" class="tableData">'.$data[2].'</td>';
|
||||
($userCount) = WebGUI::SQL->quickArray("select count(*) from groupings where groupId=$data[0]");
|
||||
$row[$i] .= '<td valign="top" class="tableData">'.$userCount.'</td></tr>';
|
||||
$row[$i] .= '</tr>';
|
||||
$i++;
|
||||
}
|
||||
$sth->finish;
|
||||
$p = WebGUI::Paginator->new(WebGUI::URL::page('op=listGroups'),\@row);
|
||||
$output .= '<table border=1 cellpadding=5 cellspacing=0 align="center">';
|
||||
$output .= '<tr><td class="tableHeader">'.WebGUI::International::get(84).'</td><td class="tableHeader">'
|
||||
.WebGUI::International::get(85).'</td><td class="tableHeader">'
|
||||
.WebGUI::International::get(748).'</td></tr>';
|
||||
$output .= $p->getPage($session{form}{pn});
|
||||
$output .= '</table>';
|
||||
$output .= $p->getBarTraditional($session{form}{pn});
|
||||
return _submenu($output);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_manageUsersInGroup {
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
my ($output, $sth, %hash);
|
||||
tie %hash, 'Tie::CPHash';
|
||||
$output = '<h1>'.WebGUI::International::get(88).'</h1>';
|
||||
$output .= '<table align="center" border="1" cellpadding="2" cellspacing="0"><tr><td class="tableHeader"> </td>
|
||||
<td class="tableHeader">'.WebGUI::International::get(50).'</td>
|
||||
<td class="tableHeader">'.WebGUI::International::get(369).'</td></tr>';
|
||||
$sth = WebGUI::SQL->read("select users.username,users.userId,groupings.expireDate
|
||||
from groupings,users where groupings.groupId=$session{form}{gid} and groupings.userId=users.userId
|
||||
order by users.username");
|
||||
while (%hash = $sth->hash) {
|
||||
$output .= '<tr><td>'
|
||||
.deleteIcon('op=deleteGrouping&uid='.$hash{userId}.'&gid='.$session{form}{gid})
|
||||
.editIcon('op=editGrouping&uid='.$hash{userId}.'&gid='.$session{form}{gid})
|
||||
.'</td>';
|
||||
$output .= '<td class="tableData"><a href="'.WebGUI::URL::page('op=editUser&uid='.$hash{userId}).'">'
|
||||
.$hash{username}.'</a></td>';
|
||||
$output .= '<td class="tableData">'.epochToHuman($hash{expireDate},"%z").'</td></tr>';
|
||||
}
|
||||
$sth->finish;
|
||||
$output .= '</table>';
|
||||
return _submenu($output);
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
|
|
|||
38
lib/WebGUI/Operation/Shared.pm
Normal file
38
lib/WebGUI/Operation/Shared.pm
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
package WebGUI::Operation::Shared;
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2002 Plain Black LLC.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use Exporter;
|
||||
use strict;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(&menuWrapper);
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub menuWrapper {
|
||||
my ($output, $key);
|
||||
$output = '<table width="100%" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr><td width="70%" class="tableData" valign="top">';
|
||||
$output .= $_[0];
|
||||
$output .= '</td><td width="30%" class="tableMenu" valign="top">';
|
||||
foreach $key (keys %{$_[1]}) {
|
||||
$output .= '<li><a href="'.$key.'">'.$_[1]->{$key}.'</a>';
|
||||
}
|
||||
$output .= '<li><a href="'.WebGUI::URL::page().'">'.WebGUI::International::get(493).'</a>';
|
||||
$output .= '</td></tr></table>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
@ -30,15 +30,21 @@ use WebGUI::Utility;
|
|||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(&www_editUserKarma &www_editUserKarmaSave &www_editUserGroup &www_editUserProfile &www_editUserProfileSave &www_addUserToGroupSave &www_deleteGrouping &www_editGrouping &www_editGroupingSave &www_becomeUser &www_addUser &www_addUserSave &www_deleteUser &www_deleteUserConfirm &www_editUser &www_editUserSave &www_listUsers);
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _submenu {
|
||||
my ($output, %menu);
|
||||
tie %menu, 'Tie::IxHash';
|
||||
$menu{WebGUI::URL::page("op=addUser")} = WebGUI::International::get(169);
|
||||
unless ($session{form}{op} eq "listUsers" || $session{form}{op} eq "addUser" || $session{form}{op} eq "deleteUserConfirm") {
|
||||
unless ($session{form}{op} eq "listUsers"
|
||||
|| $session{form}{op} eq "addUser"
|
||||
|| $session{form}{op} eq "deleteUserConfirm") {
|
||||
$menu{WebGUI::URL::page("op=editUser&uid=".$session{form}{uid})} = WebGUI::International::get(457);
|
||||
$menu{WebGUI::URL::page("op=editUserGroup&uid=".$session{form}{uid})} = WebGUI::International::get(458);
|
||||
$menu{WebGUI::URL::page("op=editUserProfile&uid=".$session{form}{uid})} = WebGUI::International::get(459);
|
||||
$menu{WebGUI::URL::page('op=viewProfile&uid='.$session{form}{uid})} = WebGUI::International::get(752);
|
||||
$menu{WebGUI::URL::page('op=becomeUser&uid='.$session{form}{uid})} = WebGUI::International::get(751);
|
||||
$menu{WebGUI::URL::page('op=deleteUser&uid='.$session{form}{uid})} = WebGUI::International::get(750);
|
||||
if ($session{setting}{useKarma}) {
|
||||
$menu{WebGUI::URL::page("op=editUserKarma&uid=".$session{form}{uid})} = WebGUI::International::get(555);
|
||||
}
|
||||
|
|
@ -141,12 +147,11 @@ sub www_deleteUser {
|
|||
$output .= helpIcon(7);
|
||||
$output .= '<h1>'.WebGUI::International::get(42).'</h1>';
|
||||
$output .= WebGUI::International::get(167).'<p>';
|
||||
$output .= '<div align="center"><a href="'.
|
||||
WebGUI::URL::page('op=deleteUserConfirm&uid='.$session{form}{uid}).
|
||||
$output .= '<div align="center"><a href="'.WebGUI::URL::page('op=deleteUserConfirm&uid='.$session{form}{uid}).
|
||||
'">'.WebGUI::International::get(44).'</a>';
|
||||
$output .= ' <a href="'.WebGUI::URL::page('op=listUsers').'">'.
|
||||
WebGUI::International::get(45).'</a></div>';
|
||||
return $output;
|
||||
return _submenu($output);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -384,12 +389,8 @@ sub www_listUsers {
|
|||
}
|
||||
$sth = WebGUI::SQL->read("select * from users $search order by users.username");
|
||||
while (%data = $sth->hash) {
|
||||
$row[$i] = '<tr class="tableData"><td>'
|
||||
.deleteIcon('op=deleteUser&uid='.$data{userId})
|
||||
.editIcon('op=editUser&uid='.$data{userId})
|
||||
.becomeIcon('op=becomeUser&uid='.$data{userId});
|
||||
$row[$i] .= '</td>';
|
||||
$row[$i] .= '<td><a href="'.WebGUI::URL::page('op=viewProfile&uid='.$data{userId})
|
||||
$row[$i] = '<tr class="tableData">';
|
||||
$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>';
|
||||
|
|
@ -399,7 +400,7 @@ sub www_listUsers {
|
|||
$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"></td>
|
||||
$output .= '<tr>
|
||||
<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>';
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 969 B |
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 606 B |
Loading…
Add table
Add a link
Reference in a new issue