Browse Source

Merge pull request #1465 from Oldiesmann/release-2.1

! Remove the 'who can view warning status' setting in favor of permissio...
Michael Eshom 10 years ago
parent
commit
24fa1cd892

+ 1 - 0
Sources/Admin.php

@@ -322,6 +322,7 @@ function AdminMain()
 					'function' => 'ModifyWarningSettings',
 					'icon' => 'warning.png',
 					'inactive' => $modSettings['warning_settings'][0] == 0,
+					'permission' => array('admin_forum'),
 				),
 				'ban' => array(
 					'label' => $txt['ban_title'],

+ 5 - 1
Sources/Display.php

@@ -1080,6 +1080,7 @@ function Display()
 		'can_remove_poll' => 'poll_remove',
 		'can_reply' => 'post_reply',
 		'can_reply_unapproved' => 'post_unapproved_replies',
+		'can_view_warning' => 'profile_warning',
 	);
 	foreach ($anyown_permissions as $contextual => $perm)
 		$context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own'));
@@ -1302,9 +1303,12 @@ function prepareDisplayContext($reset = false)
 	}
 	else
 	{
+		// Define this here to make things a bit more readable
+		$can_view_warning = $context['user']['can_mod'] || allowedTo('view_warning_any') || ($message['id_member'] == $user_info['id'] && allowedTo('view_warning_own'));
+		
 		$memberContext[$message['id_member']]['can_view_profile'] = allowedTo('profile_view') || ($message['id_member'] == $user_info['id'] && !$user_info['is_guest']);
 		$memberContext[$message['id_member']]['is_topic_starter'] = $message['id_member'] == $context['topic_starter_id'];
-		$memberContext[$message['id_member']]['can_see_warning'] = !isset($context['disabled_fields']['warning_status']) && $memberContext[$message['id_member']]['warning_status'] && ($context['user']['can_mod'] || (!$user_info['is_guest'] && !empty($modSettings['warning_show']) && ($modSettings['warning_show'] > 1 || $message['id_member'] == $user_info['id'])));
+		$memberContext[$message['id_member']]['can_see_warning'] = !isset($context['disabled_fields']['warning_status']) && $memberContext[$message['id_member']]['warning_status'] && $can_view_warning;
 	}
 
 	$memberContext[$message['id_member']]['ip'] = $message['poster_ip'];

+ 5 - 0
Sources/ManagePermissions.php

@@ -1457,6 +1457,7 @@ function loadAllPermissions()
 			'profile_displayed_name' => array(true, 'profile_account'),
 			'profile_password' => array(true, 'profile_account'),
 			'profile_remove' => array(true, 'profile_account'),
+			'view_warning' => array(true, 'profile_account'),
 		),
 		'board' => array(
 			'moderate_board' => array(false, 'general_board'),
@@ -1516,7 +1517,10 @@ function loadAllPermissions()
 		$hiddenPermissions[] = 'calendar_edit';
 	}
 	if ($modSettings['warning_settings'][0] == 0)
+	{
 		$hiddenPermissions[] = 'issue_warning';
+		$hiddenPermissions[] = 'view_warning';
+	}
 	if (empty($modSettings['karmaMode']))
 		$hiddenPermissions[] = 'karma_edit';
 
@@ -2204,6 +2208,7 @@ function loadIllegalGuestPermissions()
 		'profile_signature',
 		'profile_title',
 		'profile_upload_avatar',
+		'profile_warning',
 		'remove',
 		'report_any',
 		'report_user',

+ 1 - 1
Sources/ManageSettings.php

@@ -352,7 +352,7 @@ function ModifyWarningSettings($return_config = false)
 				array('int', 'warning_mute', 'subtext' => $txt['setting_warning_mute_note']),
 				'rem1' => array('int', 'user_limit', 'subtext' => $txt['setting_user_limit_note']),
 				'rem2' => array('int', 'warning_decrement', 'subtext' => $txt['setting_warning_decrement_note']),
-				array('select', 'warning_show', 'subtext' => $txt['setting_warning_show_note'], array($txt['setting_warning_show_mods'], $txt['setting_warning_show_user'], $txt['setting_warning_show_all'])),
+				array('permissions', 'view_warning'),
 		);
 
 	call_integration_hook('integrate_warning_settings', array(&$config_vars));

+ 2 - 2
Sources/Profile-View.php

@@ -33,9 +33,9 @@ function summary($memID)
 		'can_send_email' => allowedTo('send_email_to_members'),
 		'can_have_buddy' => allowedTo('profile_identity_own') && !empty($modSettings['enable_buddylist']),
 		'can_issue_warning' => allowedTo('issue_warning') && $modSettings['warning_settings'][0] == 1,
+		'can_view_warning' => (allowedTo('moderate_forum') || allowedTo('issue_warning') || allowedTo('view_warning_any') || ($context['user']['is_owner'] && allowedTo('view_warning_own')) && $modSettings['warning_settings'][0] === 1)
 	);
 	$context['member'] = &$memberContext[$memID];
-	$context['can_view_warning'] = (allowedTo('issue_warning') && !$context['user']['is_owner']) || (!empty($modSettings['warning_show']) && ($modSettings['warning_show'] > 1 || $context['user']['is_owner']));
 
 	// Set a canonical URL for this page.
 	$context['canonical_url'] = $scripturl . '?action=profile;u=' . $memID;
@@ -2729,7 +2729,7 @@ function viewWarning($memID)
 	global $modSettings, $context, $sourcedir, $txt, $scripturl;
 
 	// Firstly, can we actually even be here?
-	if (!allowedTo('issue_warning') && (empty($modSettings['warning_show']) || ($modSettings['warning_show'] == 1 && !$context['user']['is_owner'])))
+	if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum'))
 		fatal_lang_error('no_access', false);
 
 	// Make sure things which are disabled stay disabled.

+ 3 - 3
Sources/Profile.php

@@ -185,13 +185,13 @@ function ModifyProfile($post_errors = array())
 				),
 				'viewwarning' => array(
 					'label' => $txt['profile_view_warnings'],
-					'enabled' => $modSettings['warning_settings'][0] == 1 && $cur_profile['warning'] && (!empty($modSettings['warning_show']) && ($context['user']['is_owner'] || $modSettings['warning_show'] == 2)),
+					'enabled' => $modSettings['warning_settings'][0] == 1 && $cur_profile['warning'],
 					'file' => 'Profile-View.php',
 					'function' => 'viewWarning',
 					'icon' => 'warning.png',
 					'permission' => array(
-						'own' => 'is_not_guest', // @todo this needs to be a view-own warning
-						'any' => 'issue_warning',
+						'own' => array('profile_warning_own', 'profile_warning_any', 'issue_warning', 'moderate_forum'),
+						'any' => array('profile_warning_any', 'issue_warning', 'moderate_forum'),
 					),
 				),
 			),

+ 4 - 0
Themes/default/languages/ManagePermissions.english.php

@@ -182,6 +182,10 @@ $txt['permissionname_profile_remove'] = 'Delete account';
 $txt['permissionhelp_profile_remove'] = 'This permission allows a user to delete his account, when set to \'Own Account\'.';
 $txt['permissionname_profile_remove_own'] = 'Own account';
 $txt['permissionname_profile_remove_any'] = 'Any account';
+$txt['permissionname_view_warning'] = 'View warning status';
+$txt['permissionname_view_warning_own'] = 'Own account';
+$txt['permissionname_view_warning_any'] = 'Any account';
+$txt['permissionhelp_view_warning'] = 'Allows users to view their own warning status and history (\'Own account\') or that of any user (\'Any account\')';
 
 $txt['permissionname_report_user'] = 'Report users\' profiles';
 $txt['permissionhelp_report_user'] = 'This permission will allow members to report other users\' profiles to the admins to alert them of spam or other inappropriate content in the profile.';