Cleaning up adminstrative interface for consistency and better code.
This commit is contained in:
parent
49ccb43799
commit
fbd8093ae0
4 changed files with 331 additions and 324 deletions
|
|
@ -27,5 +27,9 @@ pageTitle varchar(255)
|
|||
);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (749,1,'WebGUI','Track page statistics?', 1036736182);
|
||||
insert into settings values ("trackPageStatistics",0);
|
||||
alter table pageStatistics add column wobjectId int;
|
||||
alter table pageStatistics add column function varchar(60);
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -220,12 +220,13 @@ sub page {
|
|||
$operationOutput = _processOperations();
|
||||
$wobjectOutput = _processFunctions();
|
||||
}
|
||||
if ($wobjectOutput eq "" && $operationOutput eq "" && $session{setting}{trackPageStatistics}) {
|
||||
if ($operationOutput eq "" && $session{setting}{trackPageStatistics}) {
|
||||
WebGUI::SQL->write("insert into pageStatistics (dateStamp, userId, username, ipAddress, userAgent, referer,
|
||||
pageId, pageTitle) values (".time().",".$session{user}{userId}.",".quote($session{user}{username}).",
|
||||
pageId, pageTitle, wobjectId, function) values (".time().",".$session{user}{userId}
|
||||
.",".quote($session{user}{username}).",
|
||||
".quote($session{env}{REMOTE_ADDR}).", ".quote($session{env}{HTTP_USER_AGENT}).",
|
||||
".quote($session{env}{HTTP_REFERER}).", ".$session{page}{pageId}.",
|
||||
".quote($session{page}{title}).")");
|
||||
".quote($session{page}{title}).", ".quote($session{form}{wid}).", ".quote($session{form}{func}).")");
|
||||
}
|
||||
if ($session{header}{mimetype} ne "text/html") {
|
||||
$httpHeader = WebGUI::Session::httpHeader();
|
||||
|
|
|
|||
|
|
@ -24,7 +24,8 @@ use WebGUI::Session;
|
|||
use WebGUI::SQL;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(&www_viewStatistics &www_killSession &www_viewLoginHistory &www_viewActiveSessions);
|
||||
our @EXPORT = qw(&www_viewPageReport &www_viewStatistics &www_viewTrafficReport &www_killSession
|
||||
&www_viewLoginHistory &www_viewActiveSessions);
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_killSession {
|
||||
|
|
@ -103,6 +104,39 @@ sub www_viewLoginHistory {
|
|||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_viewPageReport {
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
my ($output, $count, $user, $data, $sth, $page, $pageId);
|
||||
$sth = WebGUI::SQL->read("select pageTitle,pageId,userId,ipAddress,wobjectId from pageStatistics order by pageTitle,userId,ipAddress");
|
||||
while ($data = $sth->hashRef) {
|
||||
if ($data->{userId} == 1) {
|
||||
$user = $data->{ipAddress};
|
||||
} else {
|
||||
$user = $data->{userId};
|
||||
}
|
||||
$page->{$data->{pageId}}{pageTitle} = $data->{pageTitle};
|
||||
$page->{$data->{pageId}}{users}{$user}++;
|
||||
$page->{$data->{pageId}}{views}++;
|
||||
$page->{$data->{pageId}}{interact}++ if ($data->{wobjectId});
|
||||
}
|
||||
$sth->finish;
|
||||
$output = '<h1>Page Statistics</h1>';
|
||||
$output .= '<table><tr><td>Page Title</td><td>Page Views</td><td>Unique Visitors</td><td>Wobject Interactions</td></tr>';
|
||||
foreach $pageId (keys %{$page}) {
|
||||
$output .= '<tr><td>'.$page->{$pageId}{pageTitle}.'</td>';
|
||||
$output .= '<td>'.$page->{$pageId}{views}.'</td>';
|
||||
$count = 0;
|
||||
foreach (keys %{$page->{$pageId}{users}}) {
|
||||
$count++;
|
||||
}
|
||||
$output .= '<td>'.$count.'</td>';
|
||||
$output .= '<td>'.$page->{$pageId}{interact}.'</td></tr>';
|
||||
}
|
||||
$output .= '</table>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_viewStatistics {
|
||||
my ($output, $data, $header, $userAgent, $request, $response, $version, $referer);
|
||||
|
|
@ -143,7 +177,29 @@ sub www_viewStatistics {
|
|||
return $output;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_viewTrafficReport {
|
||||
return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup(3);
|
||||
my ($output, $data);
|
||||
$output = '<h1>Pages</h1>';
|
||||
($data) = WebGUI::SQL->quickArray("select count(*) from pageStatistics where dateStamp>=".(time()-2592000));
|
||||
$output .= "Last 30 days: ".$data."<br>";
|
||||
($data) = WebGUI::SQL->quickArray("select count(*) from pageStatistics where dateStamp>=".(time()-604800));
|
||||
$output .= "Last 7 days: ".$data."<br>";
|
||||
($data) = WebGUI::SQL->quickArray("select count(*) from pageStatistics where dateStamp>=".(time()-86400));
|
||||
$output .= "Last 24 hours: ".$data."<br>";
|
||||
$output .= '<h1>Visitors</h1>';
|
||||
($data) = WebGUI::SQL->quickArray("select count(*) from pageStatistics where dateStamp>=".(time()-2592000)
|
||||
." group by ipAddress,userId");
|
||||
$output .= "Last 30 days: ".$data."<br>";
|
||||
($data) = WebGUI::SQL->quickArray("select count(*) from pageStatistics where dateStamp>=".(time()-604800)
|
||||
." group by ipAddress,userId");
|
||||
$output .= "Last 7 days: ".$data."<br>";
|
||||
($data) = WebGUI::SQL->quickArray("select count(*) from pageStatistics where dateStamp>=".(time()-86400)
|
||||
." group by ipAddress,userId");
|
||||
$output .= "Last 24 hours: ".$data."<br>";
|
||||
return $output;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,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;
|
||||
|
|
@ -30,129 +31,113 @@ 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);
|
||||
$output = '<table width="100%"><tr><td class="tableData" valign="top">';
|
||||
$output .= $_[0];
|
||||
$output .= '</td><td class="tableMenu" valign="top">';
|
||||
$output .= '<li><a href="'.WebGUI::URL::page("op=addUser").'">'.WebGUI::International::get(169).'</a>';
|
||||
$output .= '<li><a href="'.WebGUI::URL::page("op=editUser&uid=".$session{form}{uid}).'">'.WebGUI::International::get(457).'</a>';
|
||||
$output .= '<li><a href="'.WebGUI::URL::page("op=editUserGroup&uid=".$session{form}{uid}).'">'.WebGUI::International::get(458).'</a>';
|
||||
$output .= '<li><a href="'.WebGUI::URL::page("op=editUserProfile&uid=".$session{form}{uid}).'">'.WebGUI::International::get(459).'</a>';
|
||||
if ($session{setting}{useKarma}) {
|
||||
$output .= '<li><a href="'.WebGUI::URL::page("op=editUserKarma&uid=".$session{form}{uid}).'">'.WebGUI::International::get(555).'</a>';
|
||||
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") {
|
||||
$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);
|
||||
if ($session{setting}{useKarma}) {
|
||||
$menu{WebGUI::URL::page("op=editUserKarma&uid=".$session{form}{uid})} = WebGUI::International::get(555);
|
||||
}
|
||||
}
|
||||
$output .= '<li><a href="'.WebGUI::URL::page("op=listUsers").'">'.WebGUI::International::get(456).'</a>';
|
||||
$output .= '<li><a href="'.WebGUI::URL::page().'">'.WebGUI::International::get(493).'</a>';
|
||||
$output .= '</td></tr></table>';
|
||||
return $output;
|
||||
$menu{WebGUI::URL::page("op=listUsers")} = WebGUI::International::get(456);
|
||||
return menuWrapper($_[0],\%menu);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addUser {
|
||||
my (@array, $output, $groups, %hash, $f);
|
||||
tie %hash, 'Tie::IxHash';
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
$output .= helpIcon(5);
|
||||
$output .= '<h1>'.WebGUI::International::get(163).'</h1>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
if ($session{form}{op} eq "addUserSave") {
|
||||
$output .= '<ul><li>'.WebGUI::International::get(77).' '.$session{form}{username}.'Too or '.$session{form}{username}.'02</ul>';
|
||||
}
|
||||
$f->hidden("op","addUserSave");
|
||||
$f->text("username",WebGUI::International::get(50),$session{form}{username});
|
||||
$f->password("identifier",WebGUI::International::get(51));
|
||||
$f->email("email",WebGUI::International::get(56));
|
||||
%hash = ('WebGUI'=>'WebGUI', 'LDAP'=>'LDAP');
|
||||
$f->select("authMethod",\%hash,WebGUI::International::get(164),[$session{setting}{authMethod}]);
|
||||
$f->url("ldapURL",WebGUI::International::get(165),$session{setting}{ldapURL});
|
||||
$f->text("connectDN",WebGUI::International::get(166),$session{form}{connectDN});
|
||||
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;
|
||||
} else {
|
||||
$output = WebGUI::Privilege::adminOnly();
|
||||
}
|
||||
return $output;
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
$output .= helpIcon(5);
|
||||
$output .= '<h1>'.WebGUI::International::get(163).'</h1>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
if ($session{form}{op} eq "addUserSave") {
|
||||
$output .= '<ul><li>'.WebGUI::International::get(77).' '.$session{form}{username}.'Too or '.$session{form}{username}.'02</ul>';
|
||||
}
|
||||
$f->hidden("op","addUserSave");
|
||||
$f->text("username",WebGUI::International::get(50),$session{form}{username});
|
||||
$f->password("identifier",WebGUI::International::get(51));
|
||||
$f->email("email",WebGUI::International::get(56));
|
||||
%hash = ('WebGUI'=>'WebGUI', 'LDAP'=>'LDAP');
|
||||
$f->select("authMethod",\%hash,WebGUI::International::get(164),[$session{setting}{authMethod}]);
|
||||
$f->url("ldapURL",WebGUI::International::get(165),$session{setting}{ldapURL});
|
||||
$f->text("connectDN",WebGUI::International::get(166),$session{form}{connectDN});
|
||||
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);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addUserSave {
|
||||
my ($output, @groups, $uid, $u, $gid, $encryptedPassword, $expireAfter);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
($uid) = WebGUI::SQL->quickArray("select userId from users where username=".quote($session{form}{username}));
|
||||
unless ($uid) {
|
||||
$encryptedPassword = Digest::MD5::md5_base64($session{form}{identifier});
|
||||
$u = WebGUI::User->new("new");
|
||||
$u->username($session{form}{username});
|
||||
$u->identifier($encryptedPassword);
|
||||
$u->connectDN($session{form}{connectDN});
|
||||
$u->ldapURL($session{form}{ldapURL});
|
||||
$u->authMethod($session{form}{authMethod});
|
||||
@groups = $session{cgi}->param('groups');
|
||||
$u->addToGroups(\@groups);
|
||||
$u->profileField("email",$session{form}{email});
|
||||
$session{form}{uid}=$u->userId;
|
||||
$output = www_editUser();
|
||||
} else {
|
||||
$output = www_addUser();
|
||||
}
|
||||
} else {
|
||||
$output = WebGUI::Privilege::adminOnly();
|
||||
}
|
||||
return $output;
|
||||
my (@groups, $uid, $u, $gid, $encryptedPassword, $expireAfter);
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
($uid) = WebGUI::SQL->quickArray("select userId from users where username=".quote($session{form}{username}));
|
||||
unless ($uid) {
|
||||
$encryptedPassword = Digest::MD5::md5_base64($session{form}{identifier});
|
||||
$u = WebGUI::User->new("new");
|
||||
$u->username($session{form}{username});
|
||||
$u->identifier($encryptedPassword);
|
||||
$u->connectDN($session{form}{connectDN});
|
||||
$u->ldapURL($session{form}{ldapURL});
|
||||
$u->authMethod($session{form}{authMethod});
|
||||
@groups = $session{cgi}->param('groups');
|
||||
$u->addToGroups(\@groups);
|
||||
$u->profileField("email",$session{form}{email});
|
||||
$session{form}{uid}=$u->userId;
|
||||
return www_editUser();
|
||||
} else {
|
||||
$session{form}{op} = "addUser";
|
||||
return www_addUser();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addUserToGroupSave {
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
my (@groups, $u);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
@groups = $session{cgi}->param('groups');
|
||||
$u = WebGUI::User->new($session{form}{uid});
|
||||
$u->addToGroups(\@groups);
|
||||
return www_editUserGroup();
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
}
|
||||
@groups = $session{cgi}->param('groups');
|
||||
$u = WebGUI::User->new($session{form}{uid});
|
||||
$u->addToGroups(\@groups);
|
||||
return www_editUserGroup();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_becomeUser {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
WebGUI::Session::end($session{var}{sessionId});
|
||||
WebGUI::Session::start($session{form}{uid});
|
||||
$output = "";
|
||||
} else {
|
||||
$output = WebGUI::Privilege::adminOnly();
|
||||
}
|
||||
return $output;
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
WebGUI::Session::end($session{var}{sessionId});
|
||||
WebGUI::Session::start($session{form}{uid});
|
||||
return "";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteGrouping {
|
||||
my ($u);
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
if (($session{user}{userId} == $session{form}{uid} || $session{form}{uid} == 3) && $session{form}{gid} == 3) {
|
||||
return WebGUI::Privilege::vitalComponent();
|
||||
} elsif (WebGUI::Privilege::isInGroup(3)) {
|
||||
} else {
|
||||
$u = WebGUI::User->new($session{form}{uid});
|
||||
$u->deleteFromGroups([$session{form}{gid}]);
|
||||
return www_editUserGroup();
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteUser {
|
||||
my ($output);
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
if ($session{form}{uid} < 26) {
|
||||
return WebGUI::Privilege::vitalComponent();
|
||||
} elsif (WebGUI::Privilege::isInGroup(3)) {
|
||||
} else {
|
||||
$output .= helpIcon(7);
|
||||
$output .= '<h1>'.WebGUI::International::get(42).'</h1>';
|
||||
$output .= WebGUI::International::get(167).'<p>';
|
||||
|
|
@ -162,306 +147,267 @@ sub www_deleteUser {
|
|||
$output .= ' <a href="'.WebGUI::URL::page('op=listUsers').'">'.
|
||||
WebGUI::International::get(45).'</a></div>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteUserConfirm {
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
my ($u);
|
||||
if ($session{form}{uid} < 26) {
|
||||
return WebGUI::Privilege::vitalComponent();
|
||||
} elsif (WebGUI::Privilege::isInGroup(3)) {
|
||||
} else {
|
||||
$u = WebGUI::User->new($session{form}{uid});
|
||||
$u->delete;
|
||||
return www_listUsers();
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editGrouping {
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
my ($output, $username, $group, $expireDate, $f);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
$output .= '<h1>'.WebGUI::International::get(370).'</h1>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->hidden("op","editGroupingSave");
|
||||
$f->hidden("uid",$session{form}{uid});
|
||||
$f->hidden("gid",$session{form}{gid});
|
||||
($username) = WebGUI::SQL->quickArray("select username from users where userId=$session{form}{uid}");
|
||||
($group) = WebGUI::SQL->quickArray("select groupName from groups where groupId=$session{form}{gid}");
|
||||
($expireDate) = WebGUI::SQL->quickArray("select expireDate from groupings where groupId=$session{form}{gid} and userId=$session{form}{uid}");
|
||||
$f->readOnly($username,WebGUI::International::get(50));
|
||||
$f->readOnly($group,WebGUI::International::get(84));
|
||||
$f->date("expireDate",WebGUI::International::get(369),$expireDate);
|
||||
$f->submit;
|
||||
$output .= $f->print;
|
||||
return _subMenu($output);
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
}
|
||||
$output .= '<h1>'.WebGUI::International::get(370).'</h1>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->hidden("op","editGroupingSave");
|
||||
$f->hidden("uid",$session{form}{uid});
|
||||
$f->hidden("gid",$session{form}{gid});
|
||||
($username) = WebGUI::SQL->quickArray("select username from users where userId=$session{form}{uid}");
|
||||
($group) = WebGUI::SQL->quickArray("select groupName from groups where groupId=$session{form}{gid}");
|
||||
($expireDate) = WebGUI::SQL->quickArray("select expireDate from groupings where groupId=$session{form}{gid} and userId=$session{form}{uid}");
|
||||
$f->readOnly($username,WebGUI::International::get(50));
|
||||
$f->readOnly($group,WebGUI::International::get(84));
|
||||
$f->date("expireDate",WebGUI::International::get(369),$expireDate);
|
||||
$f->submit;
|
||||
$output .= $f->print;
|
||||
return _submenu($output);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editGroupingSave {
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
WebGUI::SQL->write("update groupings set expireDate=".setToEpoch($session{form}{expireDate})." where groupId=$session{form}{gid} and userId=$session{form}{uid}");
|
||||
return www_editUserGroup();
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
}
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
WebGUI::SQL->write("update groupings set expireDate=".setToEpoch($session{form}{expireDate})." where groupId=$session{form}{gid} and userId=$session{form}{uid}");
|
||||
return www_editUserGroup();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editUser {
|
||||
my ($output, $f, $u, %data);
|
||||
tie %data, 'Tie::IxHash';
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
$u = WebGUI::User->new($session{form}{uid});
|
||||
$output .= helpIcon(5);
|
||||
$output .= '<h1>'.WebGUI::International::get(168).'</h1>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->hidden("op","editUserSave");
|
||||
$f->hidden("uid",$session{form}{uid});
|
||||
$f->readOnly($session{form}{uid},WebGUI::International::get(378));
|
||||
$f->readOnly($u->karma,WebGUI::International::get(537)) if ($session{setting}{useKarma});
|
||||
$f->readOnly(epochToHuman($u->dateCreated,"%z"),WebGUI::International::get(453));
|
||||
$f->readOnly(epochToHuman($u->lastUpdated,"%z"),WebGUI::International::get(454));
|
||||
$f->text("username",WebGUI::International::get(50),$u->username);
|
||||
$f->password("identifier",WebGUI::International::get(51),"password");
|
||||
%data = ('WebGUI'=>'WebGUI', 'LDAP'=>'LDAP');
|
||||
$f->select("authMethod",\%data,WebGUI::International::get(164),[$u->authMethod]);
|
||||
$f->url("ldapURL",WebGUI::International::get(165),$u->ldapURL);
|
||||
$f->text("connectDN",WebGUI::International::get(166),$u->connectDN);
|
||||
$f->submit;
|
||||
$output .= $f->print;
|
||||
$output = _subMenu($output);
|
||||
} else {
|
||||
$output = WebGUI::Privilege::adminOnly();
|
||||
}
|
||||
return $output;
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
my ($output, $f, $u);
|
||||
$u = WebGUI::User->new($session{form}{uid});
|
||||
$output .= helpIcon(5);
|
||||
$output .= '<h1>'.WebGUI::International::get(168).'</h1>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->hidden("op","editUserSave");
|
||||
$f->hidden("uid",$session{form}{uid});
|
||||
$f->readOnly($session{form}{uid},WebGUI::International::get(378));
|
||||
$f->readOnly($u->karma,WebGUI::International::get(537)) if ($session{setting}{useKarma});
|
||||
$f->readOnly(epochToHuman($u->dateCreated,"%z"),WebGUI::International::get(453));
|
||||
$f->readOnly(epochToHuman($u->lastUpdated,"%z"),WebGUI::International::get(454));
|
||||
$f->text("username",WebGUI::International::get(50),$u->username);
|
||||
$f->password("identifier",WebGUI::International::get(51),"password");
|
||||
$f->select(
|
||||
-name=>"authMethod",
|
||||
-options=>{
|
||||
'WebGUI'=>'WebGUI',
|
||||
'LDAP'=>'LDAP'
|
||||
},
|
||||
-label=>WebGUI::International::get(164),
|
||||
-value=>[$u->authMethod]
|
||||
);
|
||||
$f->url("ldapURL",WebGUI::International::get(165),$u->ldapURL);
|
||||
$f->text("connectDN",WebGUI::International::get(166),$u->connectDN);
|
||||
$f->submit;
|
||||
$output .= $f->print;
|
||||
return _submenu($output);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editUserSave {
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
my ($error, $uid, $u, $encryptedPassword, $passwordStatement);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
($uid) = WebGUI::SQL->quickArray("select userId from users where username=".
|
||||
quote($session{form}{username}));
|
||||
if ($uid == $session{form}{uid} || $uid < 1) {
|
||||
$u = WebGUI::User->new($session{form}{uid});
|
||||
if ($session{form}{identifier} ne "password") {
|
||||
$encryptedPassword = Digest::MD5::md5_base64($session{form}{identifier});
|
||||
$u->identifier($encryptedPassword);
|
||||
}
|
||||
$u->username($session{form}{username});
|
||||
$u->authMethod($session{form}{authMethod});
|
||||
$u->connectDN($session{form}{connectDN});
|
||||
$u->ldapURL($session{form}{ldapURL});
|
||||
} else {
|
||||
$error = '<ul><li>'.WebGUI::International::get(77).' '.$session{form}{username}.'Too or '.$session{form}{username}.'02</ul>';
|
||||
}
|
||||
return $error.www_editUser();
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
}
|
||||
($uid) = WebGUI::SQL->quickArray("select userId from users where username=".quote($session{form}{username}));
|
||||
if ($uid == $session{form}{uid} || $uid < 1) {
|
||||
$u = WebGUI::User->new($session{form}{uid});
|
||||
if ($session{form}{identifier} ne "password") {
|
||||
$encryptedPassword = Digest::MD5::md5_base64($session{form}{identifier});
|
||||
$u->identifier($encryptedPassword);
|
||||
}
|
||||
$u->username($session{form}{username});
|
||||
$u->authMethod($session{form}{authMethod});
|
||||
$u->connectDN($session{form}{connectDN});
|
||||
$u->ldapURL($session{form}{ldapURL});
|
||||
} else {
|
||||
$error = '<ul><li>'.WebGUI::International::get(77).' '.$session{form}{username}.'Too or '.$session{form}{username}.'02</ul>';
|
||||
}
|
||||
return $error.www_editUser();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editUserGroup {
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
my ($output, $f, $groups, @array, $sth, %hash);
|
||||
tie %hash, 'Tie::CPHash';
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
$output .= '<h1>'.WebGUI::International::get(372).'</h1>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->hidden("op","addUserToGroupSave");
|
||||
$f->hidden("uid",$session{form}{uid});
|
||||
@array = WebGUI::SQL->buildArray("select groupId from groupings where userId=$session{form}{uid}");
|
||||
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;
|
||||
$output .= '<p><table><tr><td class="tableHeader">'.WebGUI::International::get(89).
|
||||
'</td><td class="tableHeader">'.WebGUI::International::get(84).
|
||||
'</td><td class="tableHeader">'.WebGUI::International::get(369).'</td></tr>';
|
||||
$sth = WebGUI::SQL->read("select groups.groupId,groups.groupName,groupings.expireDate
|
||||
from groupings,groups where groupings.groupId=groups.groupId and
|
||||
groupings.userId=$session{form}{uid} order by groups.groupName");
|
||||
while (%hash = $sth->hash) {
|
||||
$output .= '<tr><td>'
|
||||
.deleteIcon('op=deleteGrouping&uid='.$session{form}{uid}.'&gid='.$hash{groupId})
|
||||
.editIcon('op=editGrouping&uid='.$session{form}{uid}.'&gid='.$hash{groupId})
|
||||
.'</td>';
|
||||
$output .= '<td class="tableData">'.$hash{groupName}.'</td>';
|
||||
$output .= '<td class="tableData">'.epochToHuman($hash{expireDate},"%z").'</td></tr>';
|
||||
}
|
||||
$sth->finish;
|
||||
$output .= '</table>';
|
||||
$output = _subMenu($output);
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
$output .= '<h1>'.WebGUI::International::get(372).'</h1>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->hidden("op","addUserToGroupSave");
|
||||
$f->hidden("uid",$session{form}{uid});
|
||||
@array = WebGUI::SQL->buildArray("select groupId from groupings where userId=$session{form}{uid}");
|
||||
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;
|
||||
$output .= '<p><table><tr><td class="tableHeader">'.WebGUI::International::get(89).
|
||||
'</td><td class="tableHeader">'.WebGUI::International::get(84).
|
||||
'</td><td class="tableHeader">'.WebGUI::International::get(369).'</td></tr>';
|
||||
$sth = WebGUI::SQL->read("select groups.groupId,groups.groupName,groupings.expireDate
|
||||
from groupings,groups where groupings.groupId=groups.groupId and
|
||||
groupings.userId=$session{form}{uid} order by groups.groupName");
|
||||
while (%hash = $sth->hash) {
|
||||
$output .= '<tr><td>'
|
||||
.deleteIcon('op=deleteGrouping&uid='.$session{form}{uid}.'&gid='.$hash{groupId})
|
||||
.editIcon('op=editGrouping&uid='.$session{form}{uid}.'&gid='.$hash{groupId})
|
||||
.'</td>';
|
||||
$output .= '<td class="tableData">'.$hash{groupName}.'</td>';
|
||||
$output .= '<td class="tableData">'.epochToHuman($hash{expireDate},"%z").'</td></tr>';
|
||||
}
|
||||
return $output;
|
||||
$sth->finish;
|
||||
$output .= '</table>';
|
||||
return _submenu($output);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editUserKarma {
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
my ($output, $f, $a, %user, %data, $method, $values, $category, $label, $default, $previousCategory);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
$output = helpIcon(36);
|
||||
$output .= '<h1>'.WebGUI::International::get(558).'</h1>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->hidden("op","editUserKarmaSave");
|
||||
$f->hidden("uid",$session{form}{uid});
|
||||
$f->integer("amount",WebGUI::International::get(556));
|
||||
$f->text("description",WebGUI::International::get(557));
|
||||
$f->submit;
|
||||
$output .= $f->print;
|
||||
$output = _subMenu($output);
|
||||
} else {
|
||||
$output .= WebGUI::Privilege::adminOnly();
|
||||
}
|
||||
return $output;
|
||||
$output = helpIcon(36);
|
||||
$output .= '<h1>'.WebGUI::International::get(558).'</h1>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->hidden("op","editUserKarmaSave");
|
||||
$f->hidden("uid",$session{form}{uid});
|
||||
$f->integer("amount",WebGUI::International::get(556));
|
||||
$f->text("description",WebGUI::International::get(557));
|
||||
$f->submit;
|
||||
$output .= $f->print;
|
||||
return _submenu($output);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editUserKarmaSave {
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
my ($u);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
$u = WebGUI::User->new($session{form}{uid});
|
||||
$u->karma($session{form}{amount},$session{user}{username}." (".$session{user}{userId}.")",$session{form}{description});
|
||||
return www_editUser();
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
}
|
||||
$u = WebGUI::User->new($session{form}{uid});
|
||||
$u->karma($session{form}{amount},$session{user}{username}." (".$session{user}{userId}.")",$session{form}{description});
|
||||
return www_editUser();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editUserProfile {
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
my ($output, $f, $a, %user, %data, $method, $values, $category, $label, $default, $previousCategory);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
$output = helpIcon(32);
|
||||
$output .= '<h1>'.WebGUI::International::get(455).'</h1>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->hidden("op","editUserProfileSave");
|
||||
$f->hidden("uid",$session{form}{uid});
|
||||
%user = WebGUI::SQL->buildHash("select fieldName,fieldData from userProfileData where userId=$session{form}{uid}");
|
||||
$a = WebGUI::SQL->read("select * from userProfileField,userProfileCategory
|
||||
where userProfileField.profileCategoryId=userProfileCategory.profileCategoryId
|
||||
order by userProfileCategory.sequenceNumber,userProfileField.sequenceNumber");
|
||||
while(%data = $a->hash) {
|
||||
$category = eval $data{categoryName};
|
||||
if ($category ne $previousCategory) {
|
||||
$f->raw('<tr><td colspan="2" class="tableHeader">'.$category.'</td></tr>');
|
||||
}
|
||||
$values = eval $data{dataValues};
|
||||
$method = $data{dataType};
|
||||
$label = eval $data{fieldLabel};
|
||||
if ($method eq "select") {
|
||||
# note: this big if statement doesn't look elegant, but doing regular
|
||||
# ORs caused problems with the array reference.
|
||||
if ($session{form}{$data{fieldName}}) {
|
||||
$default = [$session{form}{$data{fieldName}}];
|
||||
} elsif ($user{$data{fieldName}} && (defined($values->{$user{$data{fieldName}}}))) {
|
||||
$default = [$user{$data{fieldName}}];
|
||||
} else {
|
||||
$default = eval $data{dataDefault};
|
||||
}
|
||||
$f->select($data{fieldName},$values,$label,$default);
|
||||
} else {
|
||||
$default = $session{form}{$data{fieldName}}
|
||||
|| $user{$data{fieldName}}
|
||||
|| eval $data{dataDefault};
|
||||
$f->$method($data{fieldName},$label,$default);
|
||||
}
|
||||
$previousCategory = $category;
|
||||
$output = helpIcon(32);
|
||||
$output .= '<h1>'.WebGUI::International::get(455).'</h1>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->hidden("op","editUserProfileSave");
|
||||
$f->hidden("uid",$session{form}{uid});
|
||||
%user = WebGUI::SQL->buildHash("select fieldName,fieldData from userProfileData where userId=$session{form}{uid}");
|
||||
$a = WebGUI::SQL->read("select * from userProfileField,userProfileCategory
|
||||
where userProfileField.profileCategoryId=userProfileCategory.profileCategoryId
|
||||
order by userProfileCategory.sequenceNumber,userProfileField.sequenceNumber");
|
||||
while(%data = $a->hash) {
|
||||
$category = eval $data{categoryName};
|
||||
if ($category ne $previousCategory) {
|
||||
$f->raw('<tr><td colspan="2" class="tableHeader">'.$category.'</td></tr>');
|
||||
}
|
||||
$a->finish;
|
||||
$f->submit;
|
||||
$output .= $f->print;
|
||||
$output = _subMenu($output);
|
||||
} else {
|
||||
$output .= WebGUI::Privilege::adminOnly();
|
||||
$values = eval $data{dataValues};
|
||||
$method = $data{dataType};
|
||||
$label = eval $data{fieldLabel};
|
||||
if ($method eq "select") {
|
||||
# note: this big if statement doesn't look elegant, but doing regular
|
||||
# ORs caused problems with the array reference.
|
||||
if ($session{form}{$data{fieldName}}) {
|
||||
$default = [$session{form}{$data{fieldName}}];
|
||||
} elsif ($user{$data{fieldName}} && (defined($values->{$user{$data{fieldName}}}))) {
|
||||
$default = [$user{$data{fieldName}}];
|
||||
} else {
|
||||
$default = eval $data{dataDefault};
|
||||
}
|
||||
$f->select($data{fieldName},$values,$label,$default);
|
||||
} else {
|
||||
$default = $session{form}{$data{fieldName}} || $user{$data{fieldName}} || eval $data{dataDefault};
|
||||
$f->$method($data{fieldName},$label,$default);
|
||||
}
|
||||
$previousCategory = $category;
|
||||
}
|
||||
return $output;
|
||||
$a->finish;
|
||||
$f->submit;
|
||||
$output .= $f->print;
|
||||
return _submenu($output);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editUserProfileSave {
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
my ($a, %field, $u);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
tie %field, 'Tie::CPHash';
|
||||
$u = WebGUI::User->new($session{form}{uid});
|
||||
$a = WebGUI::SQL->read("select * from userProfileField");
|
||||
while (%field = $a->hash) {
|
||||
if ($field{fieldType} eq "date") {
|
||||
$session{form}{$field{fieldName}} = setToEpoch($session{form}{$field{fieldName}});
|
||||
}
|
||||
$u->profileField($field{fieldName},$session{form}{$field{fieldName}}) if (exists $session{form}{$field{fieldName}});
|
||||
}
|
||||
$a->finish;
|
||||
return www_editUserProfile();
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
}
|
||||
tie %field, 'Tie::CPHash';
|
||||
$u = WebGUI::User->new($session{form}{uid});
|
||||
$a = WebGUI::SQL->read("select * from userProfileField");
|
||||
while (%field = $a->hash) {
|
||||
if ($field{fieldType} eq "date") {
|
||||
$session{form}{$field{fieldName}} = setToEpoch($session{form}{$field{fieldName}});
|
||||
}
|
||||
$u->profileField($field{fieldName},$session{form}{$field{fieldName}}) if (exists $session{form}{$field{fieldName}});
|
||||
}
|
||||
$a->finish;
|
||||
return www_editUserProfile();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_listUsers {
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
my ($output, $sth, %data, $f, @row, $p, $i, $search);
|
||||
tie %data, 'Tie::CPHash';
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
$output = helpIcon(8);
|
||||
$output .= '<h1>'.WebGUI::International::get(149).'</h1>';
|
||||
$output .= '<table class="tableData" align="center" width="75%"><tr><td>';
|
||||
$output .= '<a href="'.WebGUI::URL::page('op=addUser').'">'.WebGUI::International::get(169).'</a>';
|
||||
$output .= '</td>';
|
||||
$f = WebGUI::HTMLForm->new(1);
|
||||
$f->raw('<td align="right">');
|
||||
$f->hidden("op","listUsers");
|
||||
$f->text("keyword",'',$session{form}{keyword});
|
||||
$f->submit(WebGUI::International::get(170));
|
||||
$f->raw('</td>');
|
||||
$output .= $f->print;
|
||||
$output .= '</tr></table><p>';
|
||||
if ($session{form}{keyword} ne "") {
|
||||
$search = " where (users.username like '%".$session{form}{keyword}."%') ";
|
||||
}
|
||||
$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})
|
||||
.'">'.$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"></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 .= '</table>';
|
||||
$output .= $p->getBarTraditional($session{form}{pn});
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
}
|
||||
$output = helpIcon(8);
|
||||
$output .= '<h1>'.WebGUI::International::get(149).'</h1>';
|
||||
$output .= '<div align="center">';
|
||||
$f = WebGUI::HTMLForm->new(1);
|
||||
$f->hidden("op","listUsers");
|
||||
$f->text("keyword",'',$session{form}{keyword});
|
||||
$f->submit(WebGUI::International::get(170));
|
||||
$output .= $f->print;
|
||||
$output .= '</div>';
|
||||
if ($session{form}{keyword} ne "") {
|
||||
$search = " where (users.username like '%".$session{form}{keyword}."%') ";
|
||||
}
|
||||
$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})
|
||||
.'">'.$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"></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 .= '</table>';
|
||||
$output .= $p->getBarTraditional($session{form}{pn});
|
||||
return _submenu($output);
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue