$bounty_description, ':thread_id' => self::$data['thread_id'] ] ); } else { $bounty_points = form_sanitizer(isset($_POST['bounty_points']) ? $_POST['bounty_points'] : 0, $default, 'bounty_points'); $point_bal = fusion_get_userdata('user_reputation') - $bounty_points; $user_id = fusion_get_userdata('user_id'); dbquery('UPDATE '.DB_USERS.' SET user_reputation=:point_balance WHERE user_id=:my_id', [ ':point_balance' => $point_bal, ':my_id' => $user_id ]); $bounty_arr = [ 'thread_id' => self::$data['thread_id'], 'thread_bounty' => $bounty_points, 'thread_bounty_user' => fusion_get_userdata('user_id'), 'thread_bounty_description' => $bounty_description, 'thread_bounty_start' => TIME, ]; dbquery_insert(DB_FORUM_THREADS, $bounty_arr, 'update'); } redirect(FORUM.'postify.php?post=bounty&error=0&forum_id='.self::$data['forum_id'].'&thread_id='.self::$data['thread_id']); } } if ($edit) { $bounty_description = self::$data['thread_bounty_description']; } $bounty_field['openform'] = openform('set_bountyfrm', 'post', FUSION_REQUEST, ['class' => 'spacer-xs']); $bounty_field['closeform'] = closeform(); $bounty_field['bounty_description'] = form_textarea('bounty_description', $locale['forum_2016'], $bounty_description, ['type' => 'bbcode']); $bounty_field['bounty_select'] = (!$edit ? form_select('bounty_points', $locale['forum_2017'], $bounty_points, ['options' => $points]) : ''); $bounty_field['bounty_button'] = form_button('save_bounty', $locale['forum_2018'], $locale['forum_2018'], ['class' => 'btn-primary']); $info = [ 'title' => $locale['forum_2014'], 'description' => $locale['forum_2000'].self::$data['thread_subject'], 'field' => $bounty_field ]; display_forum_bountyform($info); } else { redirect(FORUM.'index.php'); } } public function award_bounty() { // via postify if (self::get_bounty_permissions('can_award_bounty')) { if (isset(self::$post_data['post_items'][$_GET['post_id']])) { $post_data = self::$post_data['post_items'][$_GET['post_id']]; if ($post_data['post_author'] !== fusion_get_userdata('user_id')) { // give the user the points. dbquery("UPDATE ".DB_USERS." SET user_reputation=user_reputation+:points WHERE user_id=:user_id", [ ':points' => self::$data['thread_bounty'], ':user_id' => $post_data['post_author'], ] ); // log the points change $d = [ 'post_id' => $post_data['post_id'], 'thread_id' => $post_data['thread_id'], 'forum_id' => $post_data['forum_id'], 'points_gain' => self::$data['thread_bounty'], 'voter_id' => fusion_get_userdata('user_id'), 'user_id' => $post_data['post_author'], ]; dbquery_insert(DB_FORUM_USER_REP, $d, 'save'); $title = self::$locale['forum_4105']; $message = strtr(self::$locale['forum_4106'], ['{%thread_link%}' => "[url=".fusion_get_settings('siteurl')."infusions/forum/viewthread.php?thread_id=".self::$data['thread_id']."]".self::$data['thread_subject']."[/url]"]); send_pm($post_data['post_author'], 0, $title, stripinput($message)); dbquery("UPDATE ".DB_FORUM_THREADS." SET thread_bounty=:bounty, thread_bounty_description=:desc, thread_bounty_user=:user, thread_bounty_start=:start WHERE thread_id=:thread_id", [ ':bounty' => 0, ':desc' => '', ':user' => 0, ':start' => 0, ':thread_id' => $post_data['thread_id'] ]); redirect(FORUM.'postify.php?post=award&error=0&forum_id='.$post_data['forum_id'].'&thread_id='.$post_data['thread_id'].'&post_id='.$post_data['post_id']); } redirect(FORUM.'postify.php?post=award&error=7&forum_id='.$post_data['forum_id'].'&thread_id='.$post_data['thread_id'].'&post_id='.$post_data['post_id']); } } } // What happens when bounty ends? public function display_bounty() { $html = ''; if (self::$data['thread_bounty']) { $user = fusion_get_user(self::$data['thread_bounty_user']); $html = "
".self::$data['thread_bounty_description']."\n
"; $html .= "