Bläddra i källkod

! A few more tweaks related to moving topics...

Signed-off-by: Michael Eshom <[email protected]>
Michael Eshom 10 år sedan
förälder
incheckning
d3ba61003a
2 ändrade filer med 40 tillägg och 2 borttagningar
  1. 22 0
      Sources/Display.php
  2. 18 2
      Sources/MessageIndex.php

+ 22 - 0
Sources/Display.php

@@ -1089,6 +1089,28 @@ function Display()
 	foreach ($anyown_permissions as $contextual => $perm)
 		$context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own'));
 
+	// Move is a bit tricky now...
+	if ($user_info['is_admin'])
+		$context['can_move_any'] = $context['can_move_own'] = true;
+	if (!$user_info['is_admin'])
+	{
+		// We'll use this in a minute
+		$boards_allowed = boardsAllowedTo(array('move_any', 'move_own'));
+
+		// Boards other than this one where you can move_any or move_own 
+		$other_boards_move_any = array_diff($boards_allowed['move_any'], array($board));
+		$other_boards_move_own = array_diff($boards_allowed['move_own'], array($board));
+
+		// How many boards can you do this on besides this one?
+		$context['can_move_any'] = !empty($other_boards_move_any);
+		$context['can_move_own'] = !empty($other_boards_move_own);
+
+		/* You can't move this unless:
+			You have move_any on at least one other board OR
+			You started the topic and have move_own on at least one other board*/
+		$context['move'] &= $context['can_move_any'] || ($context['topic_starter_id'] == $user_info['id'] && $context['can_move_own']);
+	}
+
 	// Cleanup all the permissions with extra stuff...
 	$context['can_mark_notify'] &= !$context['user']['is_guest'];
 	$context['calendar_post'] &= !empty($modSettings['cal_enabled']);

+ 18 - 2
Sources/MessageIndex.php

@@ -629,6 +629,22 @@ function MessageIndex()
 		// Can we restore topics?
 		$context['can_restore'] = allowedTo('move_any') && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $board;
 
+		if ($user_info['is_admin'])
+			$context['can_move_any'] = $context['can_move_own'] = true;
+		else
+		{
+			// We'll use this in a minute
+			$boards_allowed = boardsAllowedTo(array('move_any', 'move_own'));
+			
+			// Boards other than this one where you can move_any or move_own 
+			$other_boards_move_any = array_diff($boards_allowed['move_any'], array($board));
+			$other_boards_move_own = array_diff($boards_allowed['move_own'], array($board));
+			
+			// How many boards can you do this on besides this one?
+			$context['can_move_any'] = !empty($other_boards_move_any);
+			$context['can_move_own'] = !empty($other_boards_move_own);
+		}
+
 		// Set permissions for all the topics.
 		foreach ($context['topics'] as $t => $topic)
 		{
@@ -636,13 +652,13 @@ function MessageIndex()
 			$context['topics'][$t]['quick_mod'] = array(
 				'lock' => allowedTo('lock_any') || ($started && allowedTo('lock_own')),
 				'sticky' => allowedTo('make_sticky'),
-				'move' => allowedTo('move_any') || ($started && allowedTo('move_own')),
+				'move' => (allowedTo('move_any') && $context['can_move_any']) || ($started && allowedTo('move_own') && ($context['can_move_own'] || $context['can_move_any'])),
 				'modify' => allowedTo('modify_any') || ($started && allowedTo('modify_own')),
 				'remove' => allowedTo('remove_any') || ($started && allowedTo('remove_own')),
 				'approve' => $context['can_approve'] && $topic['unapproved_posts']
 			);
 			$context['can_lock'] |= ($started && allowedTo('lock_own'));
-			$context['can_move'] |= ($started && allowedTo('move_own'));
+			$context['can_move'] |= ($started && allowedTo('move_own') && ($context['can_move_own'] || $context['can_move_any']));
 			$context['can_remove'] |= ($started && allowedTo('remove_own'));
 		}