Code Duplication    Length = 19-30 lines in 2 locations

Sources/RemoveTopic.php 1 location

@@ 1202-1220 (lines=19) @@
1199
			list ($count_posts) = $smcFunc['db_fetch_row']($request2);
1200
			$smcFunc['db_free_result']($request2);
1201
1202
			if (empty($count_posts))
1203
			{
1204
				// Lets get the members that need their post count restored.
1205
				$request2 = $smcFunc['db_query']('', '
1206
					SELECT id_member, COUNT(id_msg) AS post_count
1207
					FROM {db_prefix}messages
1208
					WHERE id_topic = {int:topic}
1209
						AND approved = {int:is_approved}
1210
					GROUP BY id_member',
1211
					array(
1212
						'topic' => $row['id_topic'],
1213
						'is_approved' => 1,
1214
					)
1215
				);
1216
1217
				while ($member = $smcFunc['db_fetch_assoc']($request2))
1218
					updateMemberData($member['id_member'], array('posts' => 'posts + ' . $member['post_count']));
1219
				$smcFunc['db_free_result']($request2);
1220
			}
1221
1222
			// Log it.
1223
			logAction('restore_topic', array('topic' => $row['id_topic'], 'board' => $row['id_board'], 'board_to' => $row['id_previous_board']));

Sources/ManageMaintenance.php 1 location

@@ 1808-1837 (lines=30) @@
1805
		)
1806
	) !== false;
1807
1808
	if ($createTemporary)
1809
	{
1810
		// outer join the members table on the temporary table finding the members that have a post count but no posts in the message table
1811
		$request = $smcFunc['db_query']('', '
1812
			SELECT mem.id_member, mem.posts
1813
			FROM {db_prefix}members AS mem
1814
			LEFT OUTER JOIN {db_prefix}tmp_maint_recountposts AS res
1815
			ON res.id_member = mem.id_member
1816
			WHERE res.id_member IS null
1817
				AND mem.posts != {int:zero}',
1818
			array(
1819
				'zero' => 0,
1820
			)
1821
		);
1822
1823
		// set the post count to zero for any delinquents we may have found
1824
		while ($row = $smcFunc['db_fetch_assoc']($request))
1825
		{
1826
			$smcFunc['db_query']('', '
1827
				UPDATE {db_prefix}members
1828
				SET posts = {int:zero}
1829
				WHERE id_member = {int:row}',
1830
				array(
1831
					'row' => $row['id_member'],
1832
					'zero' => 0,
1833
				)
1834
			);
1835
		}
1836
		$smcFunc['db_free_result']($request);
1837
	}
1838
1839
	// all done
1840
	unset($_SESSION['total_members']);