button to remove all votes by user
This commit is contained in:
parent
1abb96159b
commit
7118e5fe40
2 changed files with 18 additions and 1 deletions
|
@ -42,6 +42,11 @@ class NumericScore implements Extension {
|
|||
}
|
||||
}
|
||||
|
||||
if($event instanceof UserPageBuildingEvent) {
|
||||
$html = $this->theme->get_nuller_html($event->display_user);
|
||||
$page->add_block(new Block("Votes", $html, "main", 60));
|
||||
}
|
||||
|
||||
if($event instanceof PageRequestEvent) {
|
||||
if($event->page_matches("numeric_score_votes")) {
|
||||
$image_id = int_escape($event->get_arg(0));
|
||||
|
@ -99,7 +104,7 @@ class NumericScore implements Extension {
|
|||
"UPDATE images SET numeric_score=(SELECT SUM(score) FROM numeric_score_votes WHERE image_id=images.id) WHERE images.id IN ?",
|
||||
array($image_ids));
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/$image_id"));
|
||||
$page->set_redirect(make_link());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,18 @@ class NumericScoreTheme extends Themelet {
|
|||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function get_nuller_html(User $duser) {
|
||||
global $user;
|
||||
$html = "
|
||||
<form action='".make_link("numeric_score/remove_votes_by")."' method='POST'>
|
||||
".$user->get_auth_html()."
|
||||
<input type='hidden' name='user_id' value='{$duser->id}'>
|
||||
<input type='submit' value='Delete all votes by this user'>
|
||||
</form>
|
||||
";
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Reference in a new issue