Initial revision
This commit is contained in:
parent
bb66c11a6a
commit
01e11d7871
41 changed files with 5420 additions and 3155 deletions
|
|
@ -15,7 +15,7 @@ use Exporter;
|
|||
use strict;
|
||||
use Tie::CPHash;
|
||||
use WebGUI::DateTime;
|
||||
use WebGUI::Form;
|
||||
use WebGUI::HTMLForm;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Paginator;
|
||||
use WebGUI::Privilege;
|
||||
|
|
@ -23,41 +23,48 @@ use WebGUI::Session;
|
|||
use WebGUI::Shortcut;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::URL;
|
||||
use WebGUI::User;
|
||||
use WebGUI::Utility;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(&www_editUserGroupSave &www_deleteGrouping &www_editGrouping &www_editGroupingSave &www_becomeUser &www_addUser &www_addUserSave &www_deleteUser &www_deleteUserConfirm &www_editUser &www_editUserSave &www_listUsers);
|
||||
our @EXPORT = qw(&www_editUserGroup &www_editUserProfile &www_editUserProfileSave &www_editUserGroupSave &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>';
|
||||
$output .= '<li><a href="'.WebGUI::URL::page("op=listUsers").'">'.WebGUI::International::get(456).'</a>';
|
||||
$output .= '</td></tr></table>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addUser {
|
||||
my ($output, %hash, @array);
|
||||
my ($output, %hash, $f);
|
||||
tie %hash, 'Tie::IxHash';
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
$output .= helpLink(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>';
|
||||
}
|
||||
$output .= formHeader();
|
||||
$output .= WebGUI::Form::hidden("op","addUserSave");
|
||||
$output .= '<table>';
|
||||
$output .= tableFormRow(WebGUI::International::get(50),WebGUI::Form::text("username",20,35,$session{form}{username}));
|
||||
$output .= tableFormRow(WebGUI::International::get(51),WebGUI::Form::password("identifier",20,35,$session{form}{username}));
|
||||
$f->hidden("op","addUserSave");
|
||||
$f->text("username",WebGUI::International::get(50),$session{form}{username});
|
||||
$f->password("identifier",WebGUI::International::get(51));
|
||||
%hash = ('WebGUI'=>'WebGUI', 'LDAP'=>'LDAP');
|
||||
$array[0] = $session{setting}{authMethod};
|
||||
$output .= tableFormRow(WebGUI::International::get(164),WebGUI::Form::selectList("authMethod",\%hash, \@array));
|
||||
$output .= tableFormRow(WebGUI::International::get(165),WebGUI::Form::text("ldapURL",20,2048,$session{setting}{ldapURL}));
|
||||
$output .= tableFormRow(WebGUI::International::get(166),WebGUI::Form::text("connectDN",20,255,$session{form}{connectDN}));
|
||||
$output .= tableFormRow(WebGUI::International::get(56),WebGUI::Form::text("email",20,255,$session{form}{email}));
|
||||
%hash = WebGUI::SQL->buildHash("select groupId,groupName from groups where groupName<>'Reserved' order by groupName");
|
||||
$array[0] = 2;
|
||||
$output .= tableFormRow(WebGUI::International::get(89),WebGUI::Form::selectList("groups",\%hash,\@array,5,1));
|
||||
%hash = WebGUI::SQL->buildHash("select distinct(language) from international");
|
||||
$array[0] = "English";
|
||||
$output .= tableFormRow(WebGUI::International::get(304),WebGUI::Form::selectList("language",\%hash,\@array));
|
||||
$output .= formSave();
|
||||
$output .= '</table>';
|
||||
$output .= '</form> ';
|
||||
$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});
|
||||
$f->group("groups",WebGUI::International::get(89),[2],5,1);
|
||||
$f->submit;
|
||||
$output .= $f->print;
|
||||
} else {
|
||||
$output = WebGUI::Privilege::adminOnly();
|
||||
}
|
||||
|
|
@ -66,20 +73,22 @@ sub www_addUser {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addUserSave {
|
||||
my ($output, @groups, $uid, $gid, $encryptedPassword, $expireAfter);
|
||||
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});
|
||||
$uid = getNextId("userId");
|
||||
WebGUI::SQL->write("insert into users (userId,username,identifier,email,authMethod,ldapURL,connectDN,language) values ($uid, ".quote($session{form}{username}).", ".quote($encryptedPassword).", ".quote($session{form}{email}).", ".quote($session{form}{authMethod}).", ".quote($session{form}{ldapURL}).", ".quote($session{form}{connectDN}).", ".quote($session{form}{language}).")");
|
||||
$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');
|
||||
foreach $gid (@groups) {
|
||||
($expireAfter) = WebGUI::SQL->quickArray("select expireAfter from groups where groupId=$gid");
|
||||
WebGUI::SQL->write("insert into groupings values ($gid, $uid, ".(time()+$expireAfter).")");
|
||||
}
|
||||
$output = www_listUsers();
|
||||
$u->addToGroups(\@groups);
|
||||
$session{form}{uid}=$u->userId;
|
||||
$output = www_editUser();
|
||||
} else {
|
||||
$output = www_addUser();
|
||||
}
|
||||
|
|
@ -104,8 +113,10 @@ sub www_becomeUser {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteGrouping {
|
||||
my ($u);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
WebGUI::SQL->write("delete from groupings where groupId=$session{form}{gid} and userId=$session{form}{uid}");
|
||||
$u = WebGUI::User->new($session{form}{uid});
|
||||
$u->deleteFromGroups([$session{form}{gid}]);
|
||||
return www_editUser();
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
|
|
@ -134,11 +145,12 @@ sub www_deleteUser {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteUserConfirm {
|
||||
my ($u);
|
||||
if ($session{form}{uid} < 26) {
|
||||
return WebGUI::Privilege::vitalComponent();
|
||||
} elsif (WebGUI::Privilege::isInGroup(3)) {
|
||||
WebGUI::SQL->write("delete from users where userId=$session{form}{uid}");
|
||||
WebGUI::SQL->write("delete from groupings where userId=$session{form}{uid}");
|
||||
$u = WebGUI::User->new($session{form}{uid});
|
||||
$u->delete;
|
||||
return www_listUsers();
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
|
|
@ -147,23 +159,22 @@ sub www_deleteUserConfirm {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editGrouping {
|
||||
my ($output, $username, $group, $expireDate);
|
||||
my ($output, $username, $group, $expireDate, $f);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
$output .= '<h1>'.WebGUI::International::get(370).'</h1>';
|
||||
$output .= formHeader();
|
||||
$output .= WebGUI::Form::hidden("op","editGroupingSave");
|
||||
$output .= WebGUI::Form::hidden("uid",$session{form}{uid});
|
||||
$output .= WebGUI::Form::hidden("gid",$session{form}{gid});
|
||||
$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}");
|
||||
$output .= '<table>';
|
||||
$output .= tableFormRow(WebGUI::International::get(50),$username);
|
||||
$output .= tableFormRow(WebGUI::International::get(84),$group);
|
||||
$output .= tableFormRow(WebGUI::International::get(369),WebGUI::Form::text("expireDate",20,30,epochToSet($expireDate),1));
|
||||
$output .= formSave();
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
$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();
|
||||
}
|
||||
|
|
@ -173,7 +184,7 @@ sub www_editGrouping {
|
|||
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_editUser();
|
||||
return www_editUserGroup();
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
}
|
||||
|
|
@ -181,89 +192,30 @@ sub www_editGroupingSave {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editUser {
|
||||
my ($output, %user, %hash, @array, %gender, $sth, %data);
|
||||
tie %user, 'Tie::CPHash';
|
||||
tie %hash, 'Tie::CPHash';
|
||||
my ($output, $f, $u, %data);
|
||||
tie %data, 'Tie::IxHash';
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
%gender = ('neuter'=>WebGUI::International::get(403),'male'=>WebGUI::International::get(339),'female'=>WebGUI::International::get(340));
|
||||
%user = WebGUI::SQL->quickHash("select * from users where userId=$session{form}{uid}");
|
||||
$output .= '<table><tr><td valign="top">';
|
||||
$u = WebGUI::User->new($session{form}{uid});
|
||||
$output .= helpLink(5);
|
||||
$output .= '<h1>'.WebGUI::International::get(168).'</h1>';
|
||||
if ($session{form}{op} eq "editUserSave") {
|
||||
$output .= '<ul><li>'.WebGUI::International::get(77).' '.$session{form}{username}.'Too or '.$session{form}{username}.'02</ul>';
|
||||
}
|
||||
$output .= formHeader();
|
||||
$output .= WebGUI::Form::hidden("op","editUserSave");
|
||||
$output .= WebGUI::Form::hidden("uid",$session{form}{uid});
|
||||
$output .= '<table>';
|
||||
$output .= tableFormRow(WebGUI::International::get(378),$session{form}{uid});
|
||||
$output .= tableFormRow(WebGUI::International::get(50),WebGUI::Form::text("username",20,35,$user{username}));
|
||||
$output .= tableFormRow(WebGUI::International::get(51),WebGUI::Form::password("identifier",20,35,"password"));
|
||||
$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(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');
|
||||
$array[0] = $user{authMethod};
|
||||
$output .= tableFormRow(WebGUI::International::get(164),WebGUI::Form::selectList("authMethod",\%data,\@array));
|
||||
$output .= tableFormRow(WebGUI::International::get(165),WebGUI::Form::text("ldapURL",20,2048,$user{ldapURL}));
|
||||
$output .= tableFormRow(WebGUI::International::get(166),WebGUI::Form::text("connectDN",20,255,$user{connectDN}));
|
||||
$output .= tableFormRow(WebGUI::International::get(56),WebGUI::Form::text("email",20,255,$user{email}));
|
||||
%data = WebGUI::SQL->buildHash("select distinct(language) from international");
|
||||
@array = [];
|
||||
$array[0] = $user{language};
|
||||
$output .= tableFormRow(WebGUI::International::get(304),WebGUI::Form::selectList("language",\%data,\@array));
|
||||
$output .= tableFormRow(WebGUI::International::get(314),WebGUI::Form::text("firstName",20,50,$user{firstName}));
|
||||
$output .= tableFormRow(WebGUI::International::get(315),WebGUI::Form::text("middleName",20,50,$user{middleName}));
|
||||
$output .= tableFormRow(WebGUI::International::get(316),WebGUI::Form::text("lastName",20,50,$user{lastName}));
|
||||
$output .= tableFormRow(WebGUI::International::get(317),WebGUI::Form::text("icq",20,30,$user{icq}));
|
||||
$output .= tableFormRow(WebGUI::International::get(318),WebGUI::Form::text("aim",20,30,$user{aim}));
|
||||
$output .= tableFormRow(WebGUI::International::get(319),WebGUI::Form::text("msnIM",20,30,$user{msnIM}));
|
||||
$output .= tableFormRow(WebGUI::International::get(320),WebGUI::Form::text("yahooIM",20,30,$user{yahooIM}));
|
||||
$output .= tableFormRow(WebGUI::International::get(321),WebGUI::Form::text("cellPhone",20,30,$user{cellPhone}));
|
||||
$output .= tableFormRow(WebGUI::International::get(322),WebGUI::Form::text("pager",20,30,$user{pager}));
|
||||
$output .= tableFormRow(WebGUI::International::get(323),WebGUI::Form::text("homeAddress",20,128,$user{homeAddress}));
|
||||
$output .= tableFormRow(WebGUI::International::get(324),WebGUI::Form::text("homeCity",20,30,$user{homeCity}));
|
||||
$output .= tableFormRow(WebGUI::International::get(325),WebGUI::Form::text("homeState",20,30,$user{homeState}));
|
||||
$output .= tableFormRow(WebGUI::International::get(326),WebGUI::Form::text("homeZip",20,15,$user{homeZip}));
|
||||
$output .= tableFormRow(WebGUI::International::get(327),WebGUI::Form::text("homeCountry",20,30,$user{homeCountry}));
|
||||
$output .= tableFormRow(WebGUI::International::get(328),WebGUI::Form::text("homePhone",20,30,$user{homePhone}));
|
||||
$output .= tableFormRow(WebGUI::International::get(329),WebGUI::Form::text("workAddress",20,128,$user{workAddress}));
|
||||
$output .= tableFormRow(WebGUI::International::get(330),WebGUI::Form::text("workCity",20,30,$user{workCity}));
|
||||
$output .= tableFormRow(WebGUI::International::get(331),WebGUI::Form::text("workState",20,30,$user{workState}));
|
||||
$output .= tableFormRow(WebGUI::International::get(332),WebGUI::Form::text("workZip",20,15,$user{workZip}));
|
||||
$output .= tableFormRow(WebGUI::International::get(333),WebGUI::Form::text("workCountry",20,30,$user{workCountry}));
|
||||
$output .= tableFormRow(WebGUI::International::get(334),WebGUI::Form::text("workPhone",20,30,$user{workPhone}));
|
||||
@array = ($user{gender});
|
||||
$output .= tableFormRow(WebGUI::International::get(335),WebGUI::Form::selectList("gender",\%gender,\@array));
|
||||
$output .= tableFormRow(WebGUI::International::get(336),WebGUI::Form::text("birthdate",20,30,$user{birthdate}));
|
||||
$output .= tableFormRow(WebGUI::International::get(337),WebGUI::Form::text("homepage",20,2048,$user{homepage}));
|
||||
$output .= formSave();
|
||||
$output .= '</table>';
|
||||
$output .= '</form>';
|
||||
$output .= '</td><td> </td><td class="formDescription" valign="top">';
|
||||
$output .= '<h1>'.WebGUI::International::get(372).'</h1>';
|
||||
$output .= formHeader();
|
||||
$output .= WebGUI::Form::hidden("op","editUserGroupSave");
|
||||
$output .= WebGUI::Form::hidden("uid",$session{form}{uid});
|
||||
%data = WebGUI::SQL->buildHash("select groupId,groupName from groups where groupName<>'Reserved' order by groupName");
|
||||
@array = WebGUI::SQL->buildArray("select groupId from groupings where userId=$session{form}{uid}");
|
||||
$output .= WebGUI::Form::selectList("groups",\%data,\@array,5,1);
|
||||
$output .= '<br>'.WebGUI::Form::submit(WebGUI::International::get(62));
|
||||
$output .= '<p>'.WebGUI::International::get(373).'<p></form>';
|
||||
$output .= '<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><a href="'.WebGUI::URL::page('op=deleteGrouping&uid='.
|
||||
$session{form}{uid}.'&gid='.$hash{groupId}).'"><img src="'.
|
||||
$session{setting}{lib}.'/delete.gif" border=0></a><a href="'.
|
||||
WebGUI::URL::page('op=editGrouping&uid='.$session{form}{uid}.
|
||||
'&gid='.$hash{groupId}).'"><img src="'.$session{setting}{lib}.
|
||||
'/edit.gif" border=0></a></td>';
|
||||
$output .= '<td class="tableData">'.$hash{groupName}.'</td>';
|
||||
$output .= '<td class="tableData">'.epochToHuman($hash{expireDate},"%M/%D/%y").'</td></tr>';
|
||||
}
|
||||
$sth->finish;
|
||||
$output .= '</table>';
|
||||
$output .= '</td></tr></table>';
|
||||
$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();
|
||||
}
|
||||
|
|
@ -272,7 +224,7 @@ sub www_editUser {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editUserSave {
|
||||
my ($error, $uid, $encryptedPassword, $passwordStatement);
|
||||
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}));
|
||||
|
|
@ -282,7 +234,12 @@ sub www_editUserSave {
|
|||
$passwordStatement = ', identifier='.quote($encryptedPassword);
|
||||
}
|
||||
$encryptedPassword = Digest::MD5::md5_base64($session{form}{identifier1});
|
||||
WebGUI::SQL->write("update users set username=".quote($session{form}{username}).$passwordStatement.", authMethod=".quote($session{form}{authMethod}).", ldapURL=".quote($session{form}{ldapURL}).", connectDN=".quote($session{form}{connectDN}).", email=".quote($session{form}{email}).", language=".quote($session{form}{language}).", firstName=".quote($session{form}{firstName}).", middleName=".quote($session{form}{middleName}).", lastName=".quote($session{form}{lastName}).", icq=".quote($session{form}{icq}).", aim=".quote($session{form}{aim}).", msnIM=".quote($session{form}{msnIM}).", yahooIM=".quote($session{form}{yahooIM}).", homeAddress=".quote($session{form}{homeAddress}).", homeCity=".quote($session{form}{homeCity}).", homeState=".quote($session{form}{homeState}).", homeZip=".quote($session{form}{homeZip}).", homeCountry=".quote($session{form}{homeCountry}).", homePhone=".quote($session{form}{homePhone}).", workAddress=".quote($session{form}{workAddress}).", workCity=".quote($session{form}{workCity}).", workState=".quote($session{form}{workState}).", workZip=".quote($session{form}{workZip}).", workCountry=".quote($session{form}{workCountry}).", workPhone=".quote($session{form}{workPhone}).", cellPhone=".quote($session{form}{cellPhone}).", pager=".quote($session{form}{pager}).", gender=".quote($session{form}{gender}).", birthdate=".quote($session{form}{birthdate}).", homepage=".quote($session{form}{homepage})." where userId=".$session{form}{uid});
|
||||
$u = WebGUI::User->new($session{form}{uid});
|
||||
$u->username($session{form}{username});
|
||||
$u->identifier($encryptedPassword);
|
||||
$u->authMethod($session{form}{authMethod});
|
||||
$u->connectDN($session{form}{connectDN});
|
||||
$u->ldapURL($session{form}{ldapURL});
|
||||
return www_listUsers();
|
||||
} else {
|
||||
return www_editUser();
|
||||
|
|
@ -292,6 +249,45 @@ sub www_editUserSave {
|
|||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editUserGroup {
|
||||
my ($output, $f, @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","editUserGroupSave");
|
||||
$f->hidden("uid",$session{form}{uid});
|
||||
@array = WebGUI::SQL->buildArray("select groupId from groupings where userId=$session{form}{uid}");
|
||||
$f->group("groups",WebGUI::International::get(89),\@array,8,1);
|
||||
$f->submit;
|
||||
$f->readOnly(WebGUI::International::get(373));
|
||||
$output .= $f->print;
|
||||
$output .= '<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><a href="'.WebGUI::URL::page('op=deleteGrouping&uid='.
|
||||
$session{form}{uid}.'&gid='.$hash{groupId}).'"><img src="'.
|
||||
$session{setting}{lib}.'/delete.gif" border=0></a><a href="'.
|
||||
WebGUI::URL::page('op=editGrouping&uid='.$session{form}{uid}.
|
||||
'&gid='.$hash{groupId}).'"><img src="'.$session{setting}{lib}.
|
||||
'/edit.gif" border=0></a></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();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editUserGroupSave {
|
||||
my (@groups, $gid, $expireAfter);
|
||||
|
|
@ -302,7 +298,75 @@ sub www_editUserGroupSave {
|
|||
($expireAfter) = WebGUI::SQL->quickArray("select expireAfter from groups where groupId=$gid");
|
||||
WebGUI::SQL->write("insert into groupings values ($gid, $session{form}{uid}, ".(time()+$expireAfter).")");
|
||||
}
|
||||
return www_editUser();
|
||||
return www_editUserGroup();
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editUserProfile {
|
||||
my ($output, $f, $a, %data, $method, $values, $category, $label, $default, $previousCategory);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
$output .= '<h1>'.WebGUI::International::get(455).'</h1>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->hidden("op","editUserProfileSave");
|
||||
$f->hidden("uid",$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 ($session{user}{$data{fieldName}}) {
|
||||
$default = [$session{user}{$data{fieldName}}];
|
||||
} else {
|
||||
$default = eval $data{dataDefault};
|
||||
}
|
||||
$f->select($data{fieldName},$values,$label,$default);
|
||||
} else {
|
||||
$default = $session{form}{$data{fieldName}}
|
||||
|| $session{user}{$data{fieldName}}
|
||||
|| eval $data{dataDefault};
|
||||
$f->$method($data{fieldName},$label,$default);
|
||||
}
|
||||
$previousCategory = $category;
|
||||
}
|
||||
$a->finish;
|
||||
$f->submit;
|
||||
$output .= $f->print;
|
||||
$output = _subMenu($output);
|
||||
} else {
|
||||
$output .= WebGUI::Privilege::adminOnly();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editUserProfileSave {
|
||||
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();
|
||||
}
|
||||
|
|
@ -310,7 +374,8 @@ sub www_editUserGroupSave {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_listUsers {
|
||||
my ($output, $sth, @data, @row, $p, $i, $search);
|
||||
my ($output, $sth, %data, @row, $p, $i, $search);
|
||||
tie %data, 'Tie::CPHash';
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
$output = helpLink(8);
|
||||
$output .= '<h1>'.WebGUI::International::get(149).'</h1>';
|
||||
|
|
@ -322,27 +387,32 @@ sub www_listUsers {
|
|||
$output .= WebGUI::Form::submit(WebGUI::International::get(170));
|
||||
$output .= '</td></form></tr></table><p>';
|
||||
if ($session{form}{keyword} ne "") {
|
||||
$search = " and (username like '%".$session{form}{keyword}."%' or email like '%".$session{form}{keyword}."%') ";
|
||||
$search = " where (users.username like '%".$session{form}{keyword}."%') ";
|
||||
}
|
||||
$sth = WebGUI::SQL->read("select userId,username,email from users where username<>'Reserved' $search order by username");
|
||||
while (@data = $sth->array) {
|
||||
$sth = WebGUI::SQL->read("select * from users $search order by users.username");
|
||||
while (%data = $sth->hash) {
|
||||
$row[$i] = '<tr class="tableData"><td>';
|
||||
$row[$i] .= '<a href="'.WebGUI::URL::page('op=deleteUser&uid='.$data[0]).
|
||||
$row[$i] .= '<a href="'.WebGUI::URL::page('op=deleteUser&uid='.$data{userId}).
|
||||
'"><img src="'.$session{setting}{lib}.'/delete.gif" border=0></a>';
|
||||
$row[$i] .= '<a href="'.WebGUI::URL::page('op=editUser&uid='.$data[0]).
|
||||
$row[$i] .= '<a href="'.WebGUI::URL::page('op=editUser&uid='.$data{userId}).
|
||||
'"><img src="'.$session{setting}{lib}.'/edit.gif" border=0></a>';
|
||||
$row[$i] .= '<a href="'.WebGUI::URL::page('op=becomeUser&uid='.$data[0]).
|
||||
$row[$i] .= '<a href="'.WebGUI::URL::page('op=becomeUser&uid='.$data{userId}).
|
||||
'"><img src="'.$session{setting}{lib}.'/become.gif" border=0></a>';
|
||||
$row[$i] .= '</td>';
|
||||
$row[$i] .= '<td><a href="'.WebGUI::URL::page('op=viewProfile&uid='.$data[0])
|
||||
.'">'.$data[1].'</a></td>';
|
||||
#$row[$i] .= '<td>'.$data[1].'</td>';
|
||||
$row[$i] .= '<td><a href="mailto:'.$data[2].'">'.$data[2].'</a></td></tr>';
|
||||
$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'),\@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>
|
||||
<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});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue