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

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