nullify score button
This commit is contained in:
parent
a62ed8f5eb
commit
23cc49592d
@ -43,10 +43,11 @@ class NumericScore implements Extension {
|
||||
if(!$user->is_anonymous()) {
|
||||
$image_id = int_escape($_POST['image_id']);
|
||||
$char = $_POST['vote'];
|
||||
$score = 0;
|
||||
$score = null;
|
||||
if($char == "up") $score = 1;
|
||||
else if($char == "null") $score = 0;
|
||||
else if($char == "down") $score = -1;
|
||||
if($score != 0) send_event(new NumericScoreSetEvent($image_id, $user, $score));
|
||||
if(!is_null($score)) send_event(new NumericScoreSetEvent($image_id, $user, $score));
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/$image_id"));
|
||||
}
|
||||
@ -135,9 +136,11 @@ class NumericScore implements Extension {
|
||||
$database->Execute(
|
||||
"DELETE FROM numeric_score_votes WHERE image_id=? AND user_id=?",
|
||||
array($image_id, $user_id));
|
||||
$database->Execute(
|
||||
"INSERT INTO numeric_score_votes(image_id, user_id, score) VALUES(?, ?, ?)",
|
||||
array($image_id, $user_id, $score));
|
||||
if($score != 0) {
|
||||
$database->Execute(
|
||||
"INSERT INTO numeric_score_votes(image_id, user_id, score) VALUES(?, ?, ?)",
|
||||
array($image_id, $user_id, $score));
|
||||
}
|
||||
$database->Execute(
|
||||
"UPDATE images SET numeric_score=(SELECT SUM(score) FROM numeric_score_votes WHERE image_id=?) WHERE id=?",
|
||||
array($image_id, $image_id));
|
||||
|
@ -14,7 +14,13 @@ class NumericScoreTheme extends Themelet {
|
||||
<input type='submit' value='Vote Up'>
|
||||
</form>
|
||||
|
||||
<p><form action='".make_link("numeric_score_vote")."' method='POST'>
|
||||
<form action='".make_link("numeric_score_vote")."' method='POST'>
|
||||
<input type='hidden' name='image_id' value='$i_image_id'>
|
||||
<input type='hidden' name='vote' value='null'>
|
||||
<input type='submit' value='Remove Vote'>
|
||||
</form>
|
||||
|
||||
<form action='".make_link("numeric_score_vote")."' method='POST'>
|
||||
<input type='hidden' name='image_id' value='$i_image_id'>
|
||||
<input type='hidden' name='vote' value='down'>
|
||||
<input type='submit' value='Vote Down'>
|
||||
|
Loading…
x
Reference in New Issue
Block a user