Browse Source

Work for showing open/closed reports

Signed-off-by: Suki <[email protected]>
Suki 10 years ago
parent
commit
8bef199f84
3 changed files with 24 additions and 14 deletions
  1. 0 4
      Sources/ModerationCenter.php
  2. 18 3
      Sources/ReportedPosts.php
  3. 6 7
      Sources/Subs-ReportedPosts.php

+ 0 - 4
Sources/ModerationCenter.php

@@ -127,10 +127,6 @@ function ModerationMain($dont_call = false)
 					'file' => 'ReportedPosts.php',
 					'function' => 'ReportedPosts',
 					'icon' => 'reports.png',
-					'subsections' => array(
-						'open' => array($txt['mc_reportedp_active']),
-						'closed' => array($txt['mc_reportedp_closed']),
-					),
 				),
 			),
 		),

+ 18 - 3
Sources/ReportedPosts.php

@@ -75,18 +75,33 @@ function ReportedPosts()
  */
 function ShowReports()
 {
-	global $context, $txt;
+	global $context, $txt, $scripturl;
 
 	// Put the open and closed options into tabs, because we can...
 	$context[$context['moderation_menu_name']]['tab_data'] = array(
 		'title' => $txt['mc_reported_posts'],
 		'help' => '',
 		'description' => $txt['mc_reported_posts_desc'],
+		'tabs' => array(
+			'show' => array($txt['mc_reportedp_active']),
+			'show;closed' => array($txt['mc_reportedp_closed']),
+		),
 	);
 
-	// Showing closed ones?
-	$context['view_closed'] = isset($_GET['closed']);
+	// Showing closed or open ones? regardless, turn this to an integer for better handling.
+	$context['view_closed'] = (int) isset($_GET['closed']);
+
+	// Call the right template.
 	$context['sub_template'] = 'reported_posts';
+	$context['start'] = (int) isset($_GET['start']) ? $_GET['start'] : 0;
+
+	// Before anything, we need to know just how many reports do we have.
+	$context['total_reports'] = countReports($context['view_closed']);
+
+	// So, that means we can have pagination, yes?
+	$context['page_index'] = constructPageIndex($scripturl . '?action=moderate;area=reports;sa=show' . ($context['view_closed'] ? ';closed' : ''), $context['start'], $context['total_reports'], 10);
+
+	// Get the reposts at once!
 	$context['reports'] = getReports($context['view_closed']);
 }
 

+ 6 - 7
Sources/Subs-ReportedPosts.php

@@ -76,9 +76,9 @@ function updateReport($action, $value, $report_id)
 
 function countReports($closed = 0)
 {
-	global $smcFunc, $context, $user_info;
+	global $smcFunc, $user_info;
 
-	$context['start'] = $_GET['start'];
+	$total_reports = 0;
 
 	// How many entries are we viewing?
 	$request = $smcFunc['db_query']('', '
@@ -87,14 +87,13 @@ function countReports($closed = 0)
 		WHERE lr.closed = {int:view_closed}
 			AND ' . ($user_info['mod_cache']['bq'] == '1=1' || $user_info['mod_cache']['bq'] == '0=1' ? $user_info['mod_cache']['bq'] : 'lr.' . $user_info['mod_cache']['bq']),
 		array(
-			'view_closed' => $closed,
+			'view_closed' => (int) $closed,
 		)
 	);
-	list ($context['total_reports']) = $smcFunc['db_fetch_row']($request);
+	list ($total_reports) = $smcFunc['db_fetch_row']($request);
 	$smcFunc['db_free_result']($request);
 
-	// So, that means we can page index, yes?
-	$context['page_index'] = constructPageIndex($scripturl . '?action=moderate;area=reports' . ($closed ? ';sa=closed' : ''), $context['start'], $context['total_reports'], 10);
+	return $total_reports;
 }
 
 function getReports($closed = 0)
@@ -116,7 +115,7 @@ function getReports($closed = 0)
 		ORDER BY lr.time_updated DESC
 		LIMIT ' . $context['start'] . ', 10',
 		array(
-			'view_closed' => $closed,
+			'view_closed' => (int) $closed,
 		)
 	);