Browse Source

Unapprove posts buttom from SeleePy's Post Unapproval mod

Signed-off-by: emanuele <[email protected]>
emanuele 13 years ago
parent
commit
469d6ce6d9

+ 1 - 0
Sources/Display.php

@@ -1255,6 +1255,7 @@ function prepareDisplayContext($reset = false)
 		'can_unapprove' => $message['approved'] && $context['can_approve'],
 		'can_modify' => (!$context['is_locked'] || allowedTo('moderate_board')) && (allowedTo('modify_any') || (allowedTo('modify_replies') && $context['user']['started']) || (allowedTo('modify_own') && $message['id_member'] == $user_info['id'] && (empty($modSettings['edit_disable_time']) || !$message['approved'] || $message['poster_time'] + $modSettings['edit_disable_time'] * 60 > time()))),
 		'can_remove' => allowedTo('delete_any') || (allowedTo('delete_replies') && $context['user']['started']) || (allowedTo('delete_own') && $message['id_member'] == $user_info['id'] && (empty($modSettings['edit_disable_time']) || $message['poster_time'] + $modSettings['edit_disable_time'] * 60 > time())),
+		'can_unapprove' => $message['approved'] && $context['can_approve'],
 		'can_see_ip' => allowedTo('moderate_forum') || ($message['id_member'] == $user_info['id'] && !empty($user_info['id'])),
 	);
 

+ 8 - 1
Sources/Post.php

@@ -175,7 +175,7 @@ function Post()
 	$context['can_quote'] = empty($modSettings['disabledBBC']) || !in_array('quote', explode(',', $modSettings['disabledBBC']));
 
 	// Generally don't show the approval box... (Assume we want things approved)
-	$context['show_approval'] = false;
+	$context['show_approval'] = allowedTo('approve_posts') && $context['becomes_approved'] ? 2 : (allowedTo('approve_posts') ? 1 : 0);
 
 	// An array to hold all the attachments for this topic.
 	$context['current_attachments'] = array();
@@ -1705,6 +1705,13 @@ function Post2()
 		}
 	}
 
+	// Incase we want to override
+	if (allowedTo('approve_posts'))
+	{
+		$becomesApproved = !isset($_REQUEST['approve']) || !empty($_REQUEST['approve']) ? 1 : 0;
+		$approve_has_changed = isset($row['approved']) ? $row['approved'] != $becomesApproved : false;
+	}
+
 	// If the poster is a guest evaluate the legality of name and email.
 	if ($posterIsGuest)
 	{

+ 2 - 2
Themes/default/Display.template.php

@@ -399,9 +399,9 @@ function template_main()
 								<ul class="reset smalltext quickbuttons">';
 
 		// Maybe we can approve it, maybe we should?
-		if ($message['can_approve'])
+		if ($message['can_approve'] || $message['can_unapprove'])
 			echo '
-									<li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"  class="approve_button">', $txt['approve'], '</a></li>';
+									<li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"  class="', $message['can_unapprove'] ? 'un' : '', 'approve_button">', $txt['approve'], '</a></li>';
 
 		// Can they reply? Have they turned on quick reply?
 		if ($context['can_quote'] && !empty($options['display_quick_reply']))

+ 3 - 0
Themes/default/css/index.css

@@ -1882,6 +1882,9 @@ ul.quickbuttons li a.reply_all_button {
 ul.quickbuttons li a.notify_button {
 	background: url(../images/theme/quickbuttons.png) no-repeat 0 -210px;
 }
+ul.quickbuttons li a.unapprove_button {
+	background: url(../images/theme/quickbuttons.png) no-repeat 0 -230px;
+}
 ul.quickbuttons li.inline_mod_check {
 	margin: 0 0 0 5px;
 }

BIN
Themes/default/images/theme/quickbuttons.png


+ 1 - 0
Themes/default/languages/index.english.php

@@ -131,6 +131,7 @@ $txt['reply_quote'] = 'Reply with quote';
 $txt['reply'] = 'Reply';
 $txt['reply_noun'] = 'Reply';
 $txt['approve'] = 'Approve';
+$txt['unapprove'] = 'Unapprove';
 $txt['approve_all'] = 'approve all';
 $txt['awaiting_approval'] = 'Awaiting Approval';
 $txt['attach_awaiting_approve'] = 'Attachments awaiting approval';