move user search to user extension, and search by ID

git-svn-id: file:///home/shish/svn/shimmie2/trunk@719 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
shish 2008-02-16 03:14:38 +00:00
parent 86f805a088
commit c828ce5cfe
3 changed files with 21 additions and 13 deletions

View File

@ -98,17 +98,6 @@ class Index extends Extension {
$val = parse_shorthand_int($matches[3]);
$event->set_querylet(new Querylet("AND (images.$col $cmp $val)"));
}
else if(preg_match("/(poster|user)=(.*)/i", $event->term, $matches)) {
global $database;
$user = $database->get_user_by_name($matches[2]);
if(!is_null($user)) {
$user_id = $user->id;
}
else {
$user_id = -1;
}
$event->set_querylet(new Querylet("AND (images.owner_id = $user_id)"));
}
else if(preg_match("/hash=([0-9a-fA-F]*)/i", $event->term, $matches)) {
$hash = strtolower($matches[2]);
$event->set_querylet(new Querylet("AND (images.hash = '$hash')"));

View File

@ -157,6 +157,25 @@ class UserPage extends Extension {
if(is_a($event, 'UserCreationEvent')) {
if($this->check_user_creation($event)) $this->create_user($event);
}
if(is_a($event, 'SearchTermParseEvent')) {
$matches = array();
if(preg_match("/(poster|user)=(.*)/i", $event->term, $matches)) {
global $database;
$user = $database->get_user_by_name($matches[2]);
if(!is_null($user)) {
$user_id = $user->id;
}
else {
$user_id = -1;
}
$event->set_querylet(new Querylet("AND (images.owner_id = $user_id)"));
}
else if(preg_match("/(poster|user)_id=([0-9]+)/i", $event->term, $matches)) {
$user_id = int_escape($matches[2]);
$event->set_querylet(new Querylet("AND (images.owner_id = $user_id)"));
}
}
}
// }}}
// Things done *with* the user {{{

View File

@ -132,8 +132,8 @@ class UserPageTheme extends Themelet {
$h_image_rate = sprintf("%3.1f", ($i_image_count / $i_days_old2));
$h_comment_rate = sprintf("%3.1f", ($i_comment_count / $i_days_old2));
$u_name = url_escape($duser->name);
$images_link = make_link("post/list/user=$u_name/1");
$u_id = url_escape($duser->id);
$images_link = make_link("post/list/user_id=$u_id/1");
return "
Join date: $h_join_date ($i_days_old days old)