Browse Source

Merge pull request #1086 from Arantor/release-2.1

! Phasing out moderator preferences and instead just allowing them to co...
Arantor 10 years ago
parent
commit
6c42012bc5

+ 11 - 50
Sources/ModerationCenter.php

@@ -227,7 +227,7 @@ function ModerationMain($dont_call = false)
  */
 function ModerationHome()
 {
-	global $txt, $context, $scripturl, $modSettings, $user_info, $user_settings;
+	global $txt, $context, $scripturl, $modSettings, $user_info, $user_settings, $options;
 
 	loadTemplate('ModerationCenter');
 	loadJavascriptFile('admin.js', array('default_theme' => true), 'admin.js');
@@ -249,23 +249,17 @@ function ModerationHome()
 		$valid_blocks['w'] = 'WatchedUsers';
 	}
 
-	if (empty($user_settings['mod_prefs']))
-		$user_blocks = 'n' . ($context['can_moderate_boards'] ? 'wr' : '') . ($context['can_moderate_groups'] ? 'g' : '');
-	else
-		list (, $user_blocks) = explode('|', $user_settings['mod_prefs']);
-
-	$user_blocks = str_split($user_blocks);
+	call_integration_hook('integrate_mod_centre_blocks', array(&$valid_blocks));
 
 	$context['mod_blocks'] = array();
 	foreach ($valid_blocks as $k => $block)
 	{
-		if (in_array($k, $user_blocks))
-		{
-			$block = 'ModBlock' . $block;
-			if (function_exists($block))
-				$context['mod_blocks'][] = $block();
-		}
+		$block = 'ModBlock' . $block;
+		if (function_exists($block))
+			$context['mod_blocks'][] = $block();
 	}
+
+	$context['admin_prefs'] = !empty($options['admin_preferences']) ? unserialize($options['admin_preferences']) : array();
 }
 
 /**
@@ -2128,28 +2122,9 @@ function ModerationSettings()
 		'description' => $txt['mc_prefs_desc']
 	);
 
-	// What blocks can this user see?
-	$context['homepage_blocks'] = array();
-
-	if ($context['can_moderate_groups'])
-		$context['homepage_blocks']['g'] = $txt['mc_group_requests'];
-	if ($context['can_moderate_boards'])
-	{
-		$context['homepage_blocks']['r'] = $txt['mc_reported_posts'];
-		$context['homepage_blocks']['w'] = $txt['mc_watched_users'];
-	}
-
-	// Does the user have any settings yet?
-	if (empty($user_settings['mod_prefs']))
-	{
-		$mod_blocks = 'n' . ($context['can_moderate_boards'] ? 'wr' : '') . ($context['can_moderate_groups'] ? 'g' : '');
-		$pref_binary = 5;
-		$show_reports = 0;
-	}
-	else
-	{
-		list ($show_reports, $mod_blocks, $pref_binary) = explode('|', $user_settings['mod_prefs']);
-	}
+	$mod_blocks = '';
+	$pref_binary = 5;
+	$show_reports = 0;
 
 	// Are we saving?
 	if (isset($_POST['save']))
@@ -2164,21 +2139,9 @@ function ModerationSettings()
 				x = Show report count on forum header.
 				ABCD = Block indexes to show on moderation main page.
 				yyy = Integer with the following bit status:
-					- yyy & 1 = Always notify on reports.
-					- yyy & 2 = Notify on reports for moderators only.
 					- yyy & 4 = Notify about posts awaiting approval.
 		*/
 
-		// Do blocks first!
-		$mod_blocks = '';
-		if (!empty($_POST['mod_homepage']))
-			foreach ($_POST['mod_homepage'] as $k => $v)
-			{
-				// Make sure they can add this...
-				if (isset($context['homepage_blocks'][$k]))
-					$mod_blocks .= $k;
-			}
-
 		// Now check other options!
 		$pref_binary = 0;
 
@@ -2186,15 +2149,13 @@ function ModerationSettings()
 			$pref_binary |= 4;
 
 		// Put it all together.
-		$mod_prefs = '0|' . $mod_blocks . '|' . $pref_binary;
+		$mod_prefs = '0||' . $pref_binary;
 		updateMemberData($user_info['id'], array('mod_prefs' => $mod_prefs));
 	}
 
 	// What blocks does the user currently have selected?
 	$context['mod_settings'] = array(
-		'notify_report' => $pref_binary & 2 ? 1 : ($pref_binary & 1 ? 2 : 0),
 		'notify_approval' => $pref_binary & 4,
-		'user_blocks' => str_split($mod_blocks),
 	);
 
 	createToken('mod-set');

+ 110 - 22
Themes/default/ModerationCenter.template.php

@@ -50,10 +50,11 @@ function template_group_requests_block()
 	echo '
 		<div class="cat_bar">
 			<h3 class="catbg">
-				<a href="', $scripturl, '?action=groups;sa=requests">', $txt['mc_group_requests'], '</a>
+				<span id="group_requests_toggle" class="', !empty($context['admin_prefs']['mcgr']) ? 'toggle_down' : 'toggle_up', ' floatright" style="display: none;"></span>
+				<a href="', $scripturl, '?action=groups;sa=requests" id="group_requests_link">', $txt['mc_group_requests'], '</a>
 			</h3>
 		</div>
-		<div class="windowbg">
+		<div class="windowbg" id="group_requests_panel">
 			<div class="content modbox">
 				<ul class="reset">';
 
@@ -73,21 +74,54 @@ function template_group_requests_block()
 		echo '
 				</ul>
 			</div>
-		</div>';
+		</div>
+		
+	<script type="text/javascript"><!-- // --><![CDATA[
+		var oGroupRequestsPanelToggle = new smc_Toggle({
+			bToggleEnabled: true,
+			bCurrentlyCollapsed: ', !empty($context['admin_prefs']['mcgr']) ? 'true' : 'false', ',
+			aSwappableContainers: [
+				\'group_requests_panel\'
+			],
+			aSwapImages: [
+				{
+					sId: \'group_requests_toggle\',
+					altExpanded: ', JavaScriptEscape($txt['hide']), ',
+					altCollapsed: ', JavaScriptEscape($txt['show']), '
+				}
+			],
+			aSwapLinks: [
+				{
+					sId: \'group_requests_link\',
+					msgExpanded: ', JavaScriptEscape($txt['mc_group_requests']), ',
+					msgCollapsed: ', JavaScriptEscape($txt['mc_group_requests']), '
+				}
+			],
+			oThemeOptions: {
+				bUseThemeSettings: true,
+				sOptionName: \'admin_preferences\',
+				sSessionVar: smf_session_var,
+				sSessionId: smf_session_id,
+				sThemeId: \'1\',
+				sAdditionalVars: \';admin_key=mcgr\'
+			}
+		});
+	// ]]></script>';
 }
 
 // A block to show the current top reported posts.
 function template_reported_posts_block()
 {
-	global $options, $context, $txt, $scripturl;
+	global $context, $txt, $scripturl;
 
 	echo '
 		<div class="cat_bar">
 			<h3 class="catbg">
-				<a href="', $scripturl, '?action=moderate;area=reports">', $txt['mc_recent_reports'], '</a>
+				<span id="reported_posts_toggle" class="', !empty($context['admin_prefs']['mcrp']) ? 'toggle_down' : 'toggle_up', ' floatright" style="display: none;"></span>
+				<a href="', $scripturl, '?action=moderate;area=reports" id="reported_posts_link">', $txt['mc_recent_reports'], '</a>
 			</h3>
 		</div>
-		<div class="windowbg">
+		<div class="windowbg" id="reported_posts_panel">
 			<div class="content modbox">
 				<ul class="reset">';
 
@@ -107,7 +141,39 @@ function template_reported_posts_block()
 		echo '
 				</ul>
 			</div>
-		</div>';
+		</div>
+		
+	<script type="text/javascript"><!-- // --><![CDATA[
+		var oReportedPostsPanelToggle = new smc_Toggle({
+			bToggleEnabled: true,
+			bCurrentlyCollapsed: ', !empty($context['admin_prefs']['mcrp']) ? 'true' : 'false', ',
+			aSwappableContainers: [
+				\'reported_posts_panel\'
+			],
+			aSwapImages: [
+				{
+					sId: \'reported_posts_toggle\',
+					altExpanded: ', JavaScriptEscape($txt['hide']), ',
+					altCollapsed: ', JavaScriptEscape($txt['show']), '
+				}
+			],
+			aSwapLinks: [
+				{
+					sId: \'reported_posts_link\',
+					msgExpanded: ', JavaScriptEscape($txt['mc_recent_reports']), ',
+					msgCollapsed: ', JavaScriptEscape($txt['mc_recent_reports']), '
+				}
+			],
+			oThemeOptions: {
+				bUseThemeSettings: true,
+				sOptionName: \'admin_preferences\',
+				sSessionVar: smf_session_var,
+				sSessionId: smf_session_id,
+				sThemeId: \'1\',
+				sAdditionalVars: \';admin_key=mcrp\'
+			}
+		});
+	// ]]></script>';
 }
 
 function template_watched_users()
@@ -117,10 +183,11 @@ function template_watched_users()
 	echo '
 		<div class="cat_bar">
 			<h3 class="catbg">
-				<a href="', $scripturl, '?action=moderate;area=userwatch">', $txt['mc_watched_users'], '</a>
+				<span id="watched_users_toggle" class="', !empty($context['admin_prefs']['mcwu']) ? 'toggle_down' : 'toggle_up', ' floatright" style="display: none;"></span>
+				<a href="', $scripturl, '?action=moderate;area=userwatch" id="watched_users_link">', $txt['mc_watched_users'], '</a>
 			</h3>
 		</div>
-		<div class="windowbg">
+		<div class="windowbg" id="watched_users_panel">
 			<div class="content modbox">
 				<ul class="reset">';
 
@@ -140,7 +207,39 @@ function template_watched_users()
 		echo '
 				</ul>
 			</div>
-		</div>';
+		</div>
+		
+	<script type="text/javascript"><!-- // --><![CDATA[
+		var oWatchedUsersToggle = new smc_Toggle({
+			bToggleEnabled: true,
+			bCurrentlyCollapsed: ', !empty($context['admin_prefs']['mcwu']) ? 'true' : 'false', ',
+			aSwappableContainers: [
+				\'watched_users_panel\'
+			],
+			aSwapImages: [
+				{
+					sId: \'watched_users_toggle\',
+					altExpanded: ', JavaScriptEscape($txt['hide']), ',
+					altCollapsed: ', JavaScriptEscape($txt['show']), '
+				}
+			],
+			aSwapLinks: [
+				{
+					sId: \'watched_users_link\',
+					msgExpanded: ', JavaScriptEscape($txt['mc_watched_users']), ',
+					msgCollapsed: ', JavaScriptEscape($txt['mc_watched_users']), '
+				}
+			],
+			oThemeOptions: {
+				bUseThemeSettings: true,
+				sOptionName: \'admin_preferences\',
+				sSessionVar: smf_session_var,
+				sSessionId: smf_session_id,
+				sThemeId: \'1\',
+				sAdditionalVars: \';admin_key=mcwu\'
+			}
+		});
+	// ]]></script>';
 }
 
 // Little section for making... notes.
@@ -503,18 +602,7 @@ function template_moderation_settings()
 		<form action="', $scripturl, '?action=moderate;area=settings" method="post" accept-charset="', $context['character_set'], '">
 			<div class="windowbg2">
 				<div class="content">
-					<dl class="settings">
-						<dt>
-							<strong>', $txt['mc_prefs_homepage'], ':</strong>
-						</dt>
-						<dd>';
-
-	foreach ($context['homepage_blocks'] as $k => $v)
-		echo '
-							<label for="mod_homepage_', $k, '"><input type="checkbox" id="mod_homepage_', $k, '" name="mod_homepage[', $k, ']"', in_array($k, $context['mod_settings']['user_blocks']) ? ' checked="checked"' : '', ' class="input_check" /> ', $v, '</label><br />';
-
-	echo '
-						</dd>';
+					<dl class="settings">';
 
 	if ($context['can_moderate_approvals'])
 	{

+ 1 - 5
Themes/default/languages/ModerationCenter.english.php

@@ -1,8 +1,6 @@
 <?php
 // Version: 2.1 Alpha 1; ModerationCenter
 
-global $scripturl;
-
 $txt['moderation_center'] = 'Moderation Center';
 $txt['mc_main'] = 'Main';
 $txt['mc_logs'] = 'Logs';
@@ -11,7 +9,7 @@ $txt['mc_groups'] = 'Members and groups';
 
 $txt['mc_view_groups'] = 'View Membergroups';
 
-$txt['mc_description'] = 'This is your &quot;Moderation Center&quot;. From here you can perform all the moderation actions assigned to yourself by the Administrator. This home page contains a summary of all the latest happenings in your community. You can personalize the layout by clicking <a href="' . $scripturl . '?action=moderate;area=settings">here</a>.';
+$txt['mc_description'] = 'This is your &quot;Moderation Center&quot;. From here you can perform all the moderation actions assigned to yourself by the Administrator. This home page contains a summary of all the latest happenings in your community.';
 $txt['mc_group_requests'] = 'Membergroup Requests';
 $txt['mc_unapproved_posts'] = 'Unapproved Posts';
 $txt['mc_watched_users'] = 'Recent Watched Members';
@@ -140,8 +138,6 @@ $txt['mc_warning_template_error_no_body'] = 'You must set a notification body.';
 $txt['mc_settings'] = 'Change Settings';
 $txt['mc_prefs_title'] = 'Moderation Preferences';
 $txt['mc_prefs_desc'] = 'This section allows you to set some personal preferences for moderation related activities such as email notifications.';
-$txt['mc_prefs_homepage'] = 'Items to show on moderation homepage';
-$txt['mc_prefs_latest_news'] = 'SM News';
 
 $txt['mc_prefs_notify_approval'] = 'Notify of items awaiting approval';
 $txt['mc_logoff'] = 'End Moderator Session';