added new user search

This commit is contained in:
JT Smith 2004-07-05 15:37:27 +00:00
parent 2b63ab6878
commit 3375889a61
4 changed files with 57 additions and 12 deletions

View file

@ -50,6 +50,8 @@
- Added prepared statement handlers to WebGUI::SQL. - Added prepared statement handlers to WebGUI::SQL.
- Added transaction handlers to WebGUI::SQL. - Added transaction handlers to WebGUI::SQL.
- Added additional debugging to WebGUI::SQL. - Added additional debugging to WebGUI::SQL.
- Added a better user search mechanism, which works well even with 100,000
users.
6.0.3 6.0.3

View file

@ -140,6 +140,11 @@ gen61i18nfrom60data.pl
We also made the International API object oriented. The old procedural version We also made the International API object oriented. The old procedural version
is still intact as well. See WebGUI::International for API changes. is still intact as well. See WebGUI::International for API changes.
As a developer you can convert your translations (including English) and your
help files using a script we provide. You can find the script here:
http://www.plainblack.com/translations?wid=1552&func=viewSubmission&sid=1213
5.8 WebGUI::Session Changes 5.8 WebGUI::Session Changes
In 6.1 we changed the session API to remove functions that didn't really In 6.1 we changed the session API to remove functions that didn't really

View file

@ -468,8 +468,8 @@ sub www_listUsers {
return WebGUI::Privilege::adminOnly() unless (WebGUI::Grouping::isInGroup(3)); return WebGUI::Privilege::adminOnly() unless (WebGUI::Grouping::isInGroup(3));
WebGUI::Session::setScratch("userSearchKeyword",$session{form}{keyword}); WebGUI::Session::setScratch("userSearchKeyword",$session{form}{keyword});
WebGUI::Session::setScratch("userSearchStatus",$session{form}{status}); WebGUI::Session::setScratch("userSearchStatus",$session{form}{status});
my ($output, $data, $f, $rows, $p, $search, %status, $selectedStatus); my ($data, $rows, $p, %status, $selectedStatus);
$output = helpIcon(8); my $output = helpIcon(8);
$output .= '<h1>'.WebGUI::International::get(149).'</h1>'; $output .= '<h1>'.WebGUI::International::get(149).'</h1>';
$output .= '<div align="center">'; $output .= '<div align="center">';
tie %status, 'Tie::IxHash'; tie %status, 'Tie::IxHash';
@ -479,10 +479,27 @@ sub www_listUsers {
Deactivated => WebGUI::International::get(818), Deactivated => WebGUI::International::get(818),
Selfdestructed => WebGUI::International::get(819) Selfdestructed => WebGUI::International::get(819)
); );
$f = WebGUI::HTMLForm->new(1); my $f = WebGUI::HTMLForm->new(1);
$f->hidden("op","listUsers"); $f->hidden("op","listUsers");
$f->text("keyword",'',$session{scratch}{userSearchKeyword}); $f->hidden(
$f->select( -name=>"doit",
-value=>1
);
$f->selectList(
-name=>"modifier",
-value=>([$session{form}{modifier}] || ["contains"]),
-options=>{
startsWith=>WebGUI::International::get("starts with"),
contains=>WebGUI::International::get("contains"),
endsWith=>WebGUI::International::get("ends with")
}
);
$f->text(
-name=>"keyword",
-value=>$session{scratch}{userSearchKeyword},
-size=>15
);
$f->selectList(
-name => "status", -name => "status",
-value => [$session{form}{status} || "users.status like '%'"], -value => [$session{form}{status} || "users.status like '%'"],
-options=> \%status -options=> \%status
@ -490,6 +507,7 @@ sub www_listUsers {
$f->submit(WebGUI::International::get(170)); $f->submit(WebGUI::International::get(170));
$output .= $f->print; $output .= $f->print;
$output .= '</div>'; $output .= '</div>';
return _submenu($output) unless ($session{form}{doit});
$output .= '<table border=1 cellpadding=5 cellspacing=0 align="center">'; $output .= '<table border=1 cellpadding=5 cellspacing=0 align="center">';
$output .= '<tr> $output .= '<tr>
<td class="tableHeader">'.WebGUI::International::get(816).'</td> <td class="tableHeader">'.WebGUI::International::get(816).'</td>
@ -505,16 +523,18 @@ sub www_listUsers {
} else { } else {
$selectedStatus = "status like '%'"; $selectedStatus = "status like '%'";
} }
if ($session{scratch}{userSearchKeyword} ne "") { my $keyword = $session{scratch}{userSearchKeyword};
$search = " and (users.username like ".quote("%".$session{scratch}{userSearchKeyword}."%") if ($session{form}{modifier} eq "startsWith") {
." or email.fieldData like ".quote("%".$session{scratch}{userSearchKeyword}."%").")"; $keyword .= "%";
} elsif ($session{form}{modifier} eq "contains") {
$keyword = "%".$keyword."%";
} else {
$keyword = "%".$keyword;
} }
$p = WebGUI::Paginator->new(WebGUI::URL::page("op=listUsers")); $p = WebGUI::Paginator->new(WebGUI::URL::page("op=listUsers"));
$p->setDataByQuery("select users.userId, users.username, users.status, users.dateCreated, users.lastUpdated, $p->setDataByQuery("select users.userId, users.username, users.status, users.dateCreated, users.lastUpdated,
email.fieldData as email email.fieldData as email from users left join userProfileData email on users.userId=email.userId and email.fieldName='email'
from users left join userProfileData email on users.userId=email.userId and where $selectedStatus and (users.username like ".quote($keyword)." or email.fieldData like ".quote($keyword).") order by users.username");
email.fieldName='email'
where $selectedStatus $search order by users.username");
$rows = $p->getPageData; $rows = $p->getPageData;
foreach $data (@$rows) { foreach $data (@$rows) {
$output .= '<tr class="tableData">'; $output .= '<tr class="tableData">';

View file

@ -7118,6 +7118,24 @@ Following a guide like the above will help you get good ranking on search engine
lastUpdated => 1056151382 lastUpdated => 1056151382
}, },
'starts with' => {
message => q|Starts With|,
lastUpdated => 1089039511,
context => 'A phrase or word begins with this.'
},
'contains' => {
message => q|Contains|,
lastUpdated => 1089039511,
context => 'A phrase or word contains this.'
},
'ends with' => {
message => q|Ends With|,
lastUpdated => 1089039511,
context => q|A phrase or word ends with this.|
}
}; };
1; 1;