Massive code cleanup.

This commit is contained in:
JT Smith 2002-05-29 20:23:56 +00:00
parent 5ce80419a7
commit 0cf392469c
13 changed files with 147 additions and 202 deletions

View file

@ -14,51 +14,18 @@ use Exporter;
use strict;
use Tie::CPHash;
use WebGUI::DateTime;
use WebGUI::Form;
use WebGUI::HTMLForm;
use WebGUI::Icon;
use WebGUI::International;
use WebGUI::Paginator;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::Shortcut;
use WebGUI::SQL;
use WebGUI::URL;
use WebGUI::Utility;
our @ISA = qw(Exporter);
our @EXPORT = qw(&www_addGroup &www_addGroupSave &www_deleteGroup &www_deleteGroupConfirm &www_editGroup &www_editGroupSave &www_listGroups);
#-------------------------------------------------------------------
sub www_addGroup {
my ($output);
if (WebGUI::Privilege::isInGroup(3)) {
$output .= helpLink(17);
$output .= '<h1>'.WebGUI::International::get(83).'</h1>';
$output .= formHeader();
$output .= WebGUI::Form::hidden("op","addGroupSave");
$output .= '<table>';
$output .= tableFormRow(WebGUI::International::get(84),WebGUI::Form::text("groupName",20,30));
$output .= tableFormRow(WebGUI::International::get(85),WebGUI::Form::textArea("description",''));
$output .= tableFormRow(WebGUI::International::get(367),WebGUI::Form::text("expireAfter",20,30,314496000));
$output .= formSave();
$output .= '</table>';
$output .= '</form> ';
} else {
$output = WebGUI::Privilege::adminOnly();
}
return $output;
}
#-------------------------------------------------------------------
sub www_addGroupSave {
my ($output);
if ($session{var}{sessionId}) {
WebGUI::SQL->write("insert into groups values (".getNextId("groupId").", ".quote($session{form}{groupName}).", ".quote($session{form}{description}).", '$session{form}{expireAfter}')");
$output = www_listGroups();
} else {
$output = WebGUI::Privilege::adminOnly();
}
return $output;
}
our @EXPORT = qw(&www_deleteGroup &www_deleteGroupConfirm &www_editGroup &www_editGroupSave &www_listGroups);
#-------------------------------------------------------------------
sub www_deleteGroup {
@ -66,7 +33,7 @@ sub www_deleteGroup {
if ($session{form}{gid} < 26) {
return WebGUI::Privilege::vitalComponent();
} elsif (WebGUI::Privilege::isInGroup(3)) {
$output .= helpLink(15);
$output .= helpIcon(15);
$output .= '<h1>'.WebGUI::International::get(42).'</h1>';
$output .= WebGUI::International::get(86).'<p>';
$output .= '<div align="center"><a href="'.
@ -95,40 +62,46 @@ sub www_deleteGroupConfirm {
#-------------------------------------------------------------------
sub www_editGroup {
my ($output, $sth, %group, %hash);
my ($output, $sth, %group, %hash, $f);
tie %group, 'Tie::CPHash';
tie %hash, 'Tie::CPHash';
if (WebGUI::Privilege::isInGroup(3)) {
%group = WebGUI::SQL->quickHash("select * from groups where groupId=$session{form}{gid}");
$output .= helpLink(17);
if ($session{form}{gid} eq "new") {
$group{expireAfter} = 314496000;
} else {
%group = WebGUI::SQL->quickHash("select * from groups where groupId=$session{form}{gid}");
}
$output .= helpIcon(17);
$output .= '<h1>'.WebGUI::International::get(87).'</h1>';
$output .= formHeader();
$output .= WebGUI::Form::hidden("op","editGroupSave");
$output .= WebGUI::Form::hidden("gid",$session{form}{gid});
$output .= '<table>';
$output .= tableFormRow(WebGUI::International::get(379),$session{form}{gid});
$output .= tableFormRow(WebGUI::International::get(84),WebGUI::Form::text("groupName",20,30,$group{groupName}));
$output .= tableFormRow(WebGUI::International::get(85),WebGUI::Form::textArea("description",$group{description}));
$output .= tableFormRow(WebGUI::International::get(367),WebGUI::Form::text("expireAfter",20,30,$group{expireAfter}));
$output .= formSave();
$output .= '</table>';
$output .= '</form> ';
$output .= '<h1>'.WebGUI::International::get(88).'</h1>';
$output .= '<table><tr><td class="tableHeader">&nbsp;</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><a href="'.
WebGUI::URL::page('op=deleteGrouping&uid='.$hash{userId}.'&gid='.$session{form}{gid})
.'"><img src="'.$session{setting}{lib}.'/delete.gif" border=0></a><a href="'.
WebGUI::URL::page('op=editGrouping&uid='.$hash{userId}.'&gid='.$session{form}{gid})
.'"><img src="'.$session{setting}{lib}.'/edit.gif" border=0></a></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},"%M/%D/%y").'</td></tr>';
}
$sth->finish;
$output .= '</table>';
$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->integer("expireAfter",WebGUI::International::get(367),$group{expireAfter});
$f->submit;
$output .= $f->print;
unless ($session{form}{gid} eq "new") {
$output .= '<h1>'.WebGUI::International::get(88).'</h1>';
$output .= '<table><tr><td class="tableHeader">&nbsp;</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();
}
@ -138,7 +111,13 @@ sub www_editGroup {
#-------------------------------------------------------------------
sub www_editGroupSave {
if (WebGUI::Privilege::isInGroup(3)) {
WebGUI::SQL->write("update groups set groupName=".quote($session{form}{groupName}).", description=".quote($session{form}{description}).", expireAfter='$session{form}{expireAfter}' where groupId=".$session{form}{gid});
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='$session{form}{expireAfter}'
where groupId=".$session{form}{gid});
return www_listGroups();
} else {
return WebGUI::Privilege::adminOnly();
@ -149,10 +128,9 @@ sub www_editGroupSave {
sub www_listGroups {
my ($output, $p, $sth, @data, @row, $i);
if (WebGUI::Privilege::isInGroup(3)) {
$output = helpLink(10);
$output = helpIcon(10);
$output .= '<h1>'.WebGUI::International::get(89).'</h1>';
$output .= '<div align="center"><a href="'.WebGUI::URL::page('op=addGroup').
'">'.WebGUI::International::get(90).'</a></div>';
$output .= '<div align="center"><a href="'.WebGUI::URL::page('op=editGroup&gid=new').'">'.WebGUI::International::get(90).'</a></div>';
$output .= '<table border=1 cellpadding=5 cellspacing=0 align="center">';
$sth = WebGUI::SQL->read("select groupId,groupName,description from groups where groupName<>'Reserved' order by groupName");
while (@data = $sth->array) {