Page 1 of 1

phpbb points for posting

Posted: Sat Apr 09, 2022 10:10 am
by Stevyn
phpbb points for posting

this is just a quick hack but it works. it could be refined of course.

on custom profile create a text field called points

edit:

Code: Select all

includes/functions_posting.php
find the "Submit Post" section, we will read the points from user DB and add 50 and update the DB. if user does a reply we give them 25 points

about line 1758:

Code: Select all

///////////////////
         $userPoints  = "";
	$sql="SELECT pf_points FROM phpbb_profile_fields_data WHERE user_id = {$user->data['user_id']}";
        $result = $db->sql_query($sql);
       $row = $db->sql_fetchrow($result);
      $userPoints = $row['pf_points'];
      $userPoints = $userPoints + 50;
      $sql = "UPDATE phpbb_profile_fields_data SET pf_points = \"$userPoints\" WHERE user_id= {$user->data['user_id']}";
  $db->sql_query($sql);
/////////////
			if ($post_visibility == ITEM_APPROVED)
			{
				$sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_approved = forum_topics_approved + 1';
				$sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts_approved = forum_posts_approved + 1';
			}
			else if ($post_visibility == ITEM_UNAPPROVED)
			{
				$sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_unapproved = forum_topics_unapproved + 1';
				$sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts_unapproved = forum_posts_unapproved + 1';
			}
			else if ($post_visibility == ITEM_DELETED)
			{
				$sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_softdeleted = forum_topics_softdeleted + 1';
				$sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts_softdeleted = forum_posts_softdeleted + 1';
			}
		break;

		case 'reply':
			$sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_view_time = ' . $current_time . ',
				topic_bumped = 0,
				topic_bumper = 0' .
				(($post_visibility == ITEM_APPROVED) ? ', topic_posts_approved = topic_posts_approved + 1' : '') .
				(($post_visibility == ITEM_UNAPPROVED) ? ', topic_posts_unapproved = topic_posts_unapproved + 1' : '') .
				(($post_visibility == ITEM_DELETED) ? ', topic_posts_softdeleted = topic_posts_softdeleted + 1' : '') .
				((!empty($data_ary['attachment_data']) || (isset($data_ary['topic_attachment']) && $data_ary['topic_attachment'])) ? ', topic_attachment = 1' : '');

			$sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = $current_time" . (($auth->acl_get('f_postcount', $data_ary['forum_id']) && $post_visibility == ITEM_APPROVED) ? ', user_posts = user_posts + 1' : '');

///////////////////
     $userPoints ="";
	$sql="SELECT pf_points FROM phpbb_profile_fields_data WHERE user_id = {$user->data['user_id']}";
        $result = $db->sql_query($sql);
       $row = $db->sql_fetchrow($result);
      $userPoints = $row['pf_points'];
      $userPoints = $userPoints + 25;
      $sql = "UPDATE phpbb_profile_fields_data SET pf_points = \"$userPoints\" WHERE user_id= {$user->data['user_id']}";
  $db->sql_query($sql);
/////////////


			if ($post_visibility == ITEM_APPROVED)
			{
				$sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts_approved = forum_posts_approved + 1';
			}
			else if ($post_visibility == ITEM_UNAPPROVED)
			{
				$sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts_unapproved = forum_posts_unapproved + 1';
			}
			else if ($post_visibility == ITEM_DELETED)
			{
				$sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts_softdeleted = forum_posts_softdeleted + 1';
			}
		break;