Browse Source

Forum post badges

spaghetti 8 years ago
parent
commit
e88ab80774
2 changed files with 30 additions and 0 deletions
  1. 15
    0
      sections/forums/take_new_thread.php
  2. 15
    0
      sections/forums/take_reply.php

+ 15
- 0
sections/forums/take_new_thread.php View File

@@ -117,6 +117,21 @@ if (isset($_POST['subscribe'])) {
117 117
   Subscriptions::subscribe($TopicID);
118 118
 }
119 119
 
120
+//Award a badge if necessary
121
+$DB->query("
122
+	SELECT COUNT(ID)
123
+	FROM forums_posts
124
+	WHERE AuthorID = '$LoggedUser[ID]'");
125
+list($UserPosts) = $DB->next_record(MYSQLI_NUM, false);
126
+foreach (AUTOMATED_BADGE_IDS['Posts'] AS $Count => $Badge) {
127
+	if ((int) $UserPosts > $Count) {
128
+		$Success = Badges::award_badge($LoggedUser['ID'], $Badge);
129
+		if ($Success) {
130
+			Misc::send_pm($LoggedUser['ID'], 0, 'You have received a badge!', "You have received a badge for making ".$Count." forum posts.\n\nIt can be enabled from your user settings.");
131
+		}
132
+	}
133
+}
134
+
120 135
 if (!$NoPoll) { // god, I hate double negatives...
121 136
   $DB->query("
122 137
     INSERT INTO forums_polls

+ 15
- 0
sections/forums/take_reply.php View File

@@ -262,6 +262,21 @@ if ($ThreadInfo['LastPostAuthorID'] == $LoggedUser['ID'] && ((!check_perms('site
262 262
 
263 263
   //Increment this now to make sure we redirect to the correct page
264 264
   $ThreadInfo['Posts']++;
265
+
266
+	//Award a badge if necessary
267
+	$DB->query("
268
+		SELECT COUNT(ID)
269
+		FROM forums_posts
270
+		WHERE AuthorID = '$LoggedUser[ID]'");
271
+	list($UserPosts) = $DB->next_record(MYSQLI_NUM, false);
272
+	foreach (AUTOMATED_BADGE_IDS['Posts'] AS $Count => $Badge) {
273
+		if ((int) $UserPosts > $Count) {
274
+			$Success = Badges::award_badge($LoggedUser['ID'], $Badge);
275
+			if ($Success) {
276
+				Misc::send_pm($LoggedUser['ID'], 0, 'You have received a badge!', "You have received a badge for making ".$Count." forum posts.\n\nIt can be enabled from your user settings.");
277
+			}
278
+		}
279
+	}
265 280
 }
266 281
 
267 282
 Subscriptions::flush_subscriptions('forums', $TopicID);

Loading…
Cancel
Save