Ver código fonte

! Post moderation is no longer controlled by core features. Oh, and some housecleaning.

Signed-off-by: Peter Spicer <[email protected]>
Peter Spicer 10 anos atrás
pai
commit
498389f656

+ 1 - 1
Sources/Admin.php

@@ -319,7 +319,7 @@ function AdminMain()
 						'index' => array($txt['permissions_groups'], 'manage_permissions'),
 						'board' => array($txt['permissions_boards'], 'manage_permissions'),
 						'profiles' => array($txt['permissions_profiles'], 'manage_permissions'),
-						'postmod' => array($txt['permissions_post_moderation'], 'manage_permissions', 'enabled' => $modSettings['postmod_active']),
+						'postmod' => array($txt['permissions_post_moderation'], 'manage_permissions'),
 						'settings' => array($txt['settings'], 'admin_forum'),
 					),
 				),

+ 3 - 3
Sources/Load.php

@@ -172,8 +172,8 @@ function reloadSettings()
 			display_loadavg_error();
 	}
 
-	// Is post moderation alive and well?
-	$modSettings['postmod_active'] = isset($modSettings['admin_features']) ? in_array('pm', explode(',', $modSettings['admin_features'])) : true;
+	// Is post moderation alive and well? Everywhere else assumes this has been defined, so let's make sure it is.
+	$modSettings['postmod_active'] = !empty($modSettings['postmod_active']);
 
 	// Here to justify the name of this function. :P
 	// It should be added to the install and upgrade scripts.
@@ -1797,7 +1797,7 @@ function loadTheme($id_theme = 0, $initialize = true)
 		$modSettings['memberCount'] = $modSettings['totalMembers'];
 
 	// This allows us to change the way things look for the admin.
-	$context['admin_features'] = isset($modSettings['admin_features']) ? explode(',', $modSettings['admin_features']) : array('k,w,pm');
+	$context['admin_features'] = isset($modSettings['admin_features']) ? explode(',', $modSettings['admin_features']) : array('k,w');
 
 	// Default JS variables for use in every theme
 	$context['javascript_vars'] = array(

+ 61 - 36
Sources/ManagePermissions.php

@@ -39,7 +39,7 @@ function ModifyPermissions()
 		'modify2' => array('ModifyMembergroup2', 'manage_permissions'),
 		'quick' => array('SetQuickGroups', 'manage_permissions'),
 		'quickboard' => array('SetQuickBoards', 'manage_permissions'),
-		'postmod' => array('ModifyPostModeration', 'manage_permissions', 'disabled' => !in_array('pm', $context['admin_features'])),
+		'postmod' => array('ModifyPostModeration', 'manage_permissions'),
 		'profiles' => array('EditPermissionProfiles', 'manage_permissions'),
 		'settings' => array('GeneralPermissionSettings', 'admin_forum'),
 	);
@@ -2282,7 +2282,7 @@ function loadIllegalGuestPermissions()
  */
 function ModifyPostModeration()
 {
-	global $context, $txt, $smcFunc, $modSettings;
+	global $context, $txt, $smcFunc, $modSettings, $sourcedir;
 
 	// Just in case.
 	checkSession('get');
@@ -2370,47 +2370,73 @@ function ModifyPostModeration()
 	{
 		validateToken('admin-mppm');
 
-		// Start by deleting all the permissions relevant.
-		$smcFunc['db_query']('', '
-			DELETE FROM {db_prefix}board_permissions
-			WHERE id_profile = {int:current_profile}
-				AND permission IN ({array_string:permissions})
-				AND id_group IN ({array_int:profile_group_list})',
-			array(
-				'profile_group_list' => array_keys($context['profile_groups']),
-				'current_profile' => $context['current_profile'],
-				'permissions' => $all_permissions,
-			)
-		);
-
-		// Do it group by group.
-		$new_permissions = array();
-		foreach ($context['profile_groups'] as $id => $group)
+		// First, are we saving a new value for enabled post moderation?
+		$new_setting = !empty($_POST['postmod_active']);
+		if ($new_setting != $modSettings['postmod_active'])
 		{
-			foreach ($mappings as $index => $data)
+			if ($new_setting)
 			{
-				if (isset($_POST[$index][$group['id']]))
+				// Turning it on. This seems easy enough.
+				updateSettings(array('postmod_active' => 1));
+			}
+			else
+			{
+				// Turning it off. Not so straightforward. We have to turn off warnings to moderation level, and make everything approved.
+				updateSettings(array(
+					'postmod_active' => 0,
+					'warning_moderate' => 0,
+				));
+				
+				require_once($sourcedir . '/PostModeration.php');
+				approveAllData();
+			}
+		}
+		elseif ($modSettings['postmod_active'])
+		{
+			// We're not saving a new setting - and if it's still enabled we have more work to do.
+
+			// Start by deleting all the permissions relevant.
+			$smcFunc['db_query']('', '
+				DELETE FROM {db_prefix}board_permissions
+				WHERE id_profile = {int:current_profile}
+					AND permission IN ({array_string:permissions})
+					AND id_group IN ({array_int:profile_group_list})',
+				array(
+					'profile_group_list' => array_keys($context['profile_groups']),
+					'current_profile' => $context['current_profile'],
+					'permissions' => $all_permissions,
+				)
+			);
+
+			// Do it group by group.
+			$new_permissions = array();
+			foreach ($context['profile_groups'] as $id => $group)
+			{
+				foreach ($mappings as $index => $data)
 				{
-					if ($_POST[$index][$group['id']] == 'allow')
+					if (isset($_POST[$index][$group['id']]))
 					{
-						// Give them both sets for fun.
-						$new_permissions[] = array($context['current_profile'], $group['id'], $data[0], 1);
-						$new_permissions[] = array($context['current_profile'], $group['id'], $data[1], 1);
+						if ($_POST[$index][$group['id']] == 'allow')
+						{
+							// Give them both sets for fun.
+							$new_permissions[] = array($context['current_profile'], $group['id'], $data[0], 1);
+							$new_permissions[] = array($context['current_profile'], $group['id'], $data[1], 1);
+						}
+						elseif ($_POST[$index][$group['id']] == 'moderate')
+							$new_permissions[] = array($context['current_profile'], $group['id'], $data[1], 1);
 					}
-					elseif ($_POST[$index][$group['id']] == 'moderate')
-						$new_permissions[] = array($context['current_profile'], $group['id'], $data[1], 1);
 				}
 			}
-		}
 
-		// Insert new permissions.
-		if (!empty($new_permissions))
-			$smcFunc['db_insert']('',
-				'{db_prefix}board_permissions',
-				array('id_profile' => 'int', 'id_group' => 'int', 'permission' => 'string', 'add_deny' => 'int'),
-				$new_permissions,
-				array('id_profile', 'id_group', 'permission')
-			);
+			// Insert new permissions.
+			if (!empty($new_permissions))
+				$smcFunc['db_insert']('',
+					'{db_prefix}board_permissions',
+					array('id_profile' => 'int', 'id_group' => 'int', 'permission' => 'string', 'add_deny' => 'int'),
+					$new_permissions,
+					array('id_profile', 'id_group', 'permission')
+				);
+		}
 	}
 
 	// Now get all the permissions!
@@ -2451,7 +2477,6 @@ function ModifyPostModeration()
 	$smcFunc['db_free_result']($request);
 
 	createToken('admin-mppm');
-
 }
 
 ?>

+ 0 - 18
Sources/ManageSettings.php

@@ -192,24 +192,6 @@ function ModifyCoreFeatures($return_config = false)
 				'karmaMode' => 2,
 			),
 		),
-		// pm = post moderation.
-		'pm' => array(
-			'url' => 'action=admin;area=permissions;sa=postmod',
-			'setting_callback' => create_function('$value', '
-				global $sourcedir;
-
-				// Cant use warning post moderation if disabled!
-				if (!$value)
-				{
-					require_once($sourcedir . \'/PostModeration.php\');
-					approveAllData();
-
-					return array(\'warning_moderate\' => 0);
-				}
-				else
-					return array();
-			'),
-		),
 		// w = warning.
 		'w' => array(
 			'url' => 'action=admin;area=securitysettings;sa=moderation',

+ 56 - 35
Themes/default/ManagePermissions.template.php

@@ -1071,13 +1071,26 @@ function template_postmod_permissions()
 				<h3 class="catbg">', $txt['permissions_post_moderation'], '</h3>
 			</div>';
 
-	// Got advanced permissions - if so warn!
-	if (!empty($modSettings['permission_enable_deny']))
-		echo '
+	// First, we have the bit where we can enable or disable this bad boy.
+	echo '
+			<div class="content">
+				<dl class="settings">
+					<dt>', $txt['permissions_post_moderation_enable'], '</dt>
+					<dd><input type="checkbox" name="postmod_active"', !empty($modSettings['postmod_active']) ? ' checked="checked"' : '', ' /></dd>
+				</dl>
+				<hr class="hrcolor clear" />
+			</div>';
+
+	// If we're not active, there's a bunch of stuff we don't need to show.
+	if (!empty($modSettings['postmod_active']))
+	{
+		// Got advanced permissions - if so warn!
+		if (!empty($modSettings['permission_enable_deny']))
+			echo '
 				<div class="information">', $txt['permissions_post_moderation_deny_note'], '</div>';
 
-	echo '		
-				<div "padding">
+		echo '		
+				<div class="padding">
 					<p class="smalltext" style="padding-left: 10px; float: left;">
 						<strong>', $txt['permissions_post_moderation_legend'], ':</strong><br />
 						<img src="', $settings['default_images_url'], '/admin/post_moderation_allow.png" alt="', $txt['permissions_post_moderation_allow'], '" /> - ', $txt['permissions_post_moderation_allow'], '<br />
@@ -1088,12 +1101,12 @@ function template_postmod_permissions()
 					', $txt['permissions_post_moderation_select'], ':
 					<select name="pid" onchange="document.forms.postmodForm.submit();">';
 
-	foreach ($context['profiles'] as $profile)
-		if ($profile['can_modify'])
-			echo '
+		foreach ($context['profiles'] as $profile)
+			if ($profile['can_modify'])
+				echo '
 						<option value="', $profile['id'], '" ', $profile['id'] == $context['current_profile'] ? 'selected="selected"' : '', '>', $profile['name'], '</option>';
 
-	echo '
+		echo '
 					</select>
 					<input type="submit" value="', $txt['go'], '" class="button_submit" />
 					</span>
@@ -1118,7 +1131,7 @@ function template_postmod_permissions()
 							', $txt['permissions_post_moderation_attachments'], '
 						</th>';
 		
-	echo '
+		echo '
 					</tr>
 					<tr class="titlebg">
 						<th width="30%">
@@ -1140,72 +1153,80 @@ function template_postmod_permissions()
 						<th align="center"><img src="', $settings['default_images_url'], '/admin/post_moderation_moderate.png" alt="', $txt['permissions_post_moderation_moderate'], '" title="', $txt['permissions_post_moderation_moderate'], '" /></th>
 						<th align="center"><img src="', $settings['default_images_url'], '/admin/post_moderation_deny.png" alt="', $txt['permissions_post_moderation_disallow'], '" title="', $txt['permissions_post_moderation_disallow'], '" /></th>';
 
-	echo '
+		echo '
 					</tr>
 				</thead>
 				<tbody>';
 
-	foreach ($context['profile_groups'] as $group)
-	{
-		echo '
+		foreach ($context['profile_groups'] as $group)
+		{
+			echo '
 					<tr>
 						<td width="40%" class="windowbg">
 							<span ', ($group['color'] ? 'style="color: ' . $group['color'] . '"' : ''), '>', $group['name'], '</span>';
-			if (!empty($group['children']))
-				echo '
+				if (!empty($group['children']))
+					echo '
 							<br /><span class="smalltext">', $txt['permissions_includes_inherited'], ': &quot;', implode('&quot;, &quot;', $group['children']), '&quot;</span>';
 
-			echo '
+				echo '
 						</td>
 						<td align="center" class="windowbg2"><input type="radio" name="new_topic[', $group['id'], ']" value="allow" ', $group['new_topic'] == 'allow' ? 'checked="checked"' : '', ' class="input_radio" /></td>
 						<td align="center" class="windowbg2"><input type="radio" name="new_topic[', $group['id'], ']" value="moderate" ', $group['new_topic'] == 'moderate' ? 'checked="checked"' : '', ' class="input_radio" /></td>
 						<td align="center" class="windowbg2"><input type="radio" name="new_topic[', $group['id'], ']" value="disallow" ', $group['new_topic'] == 'disallow' ? 'checked="checked"' : '', ' class="input_radio" /></td>';
 			
-			// Guests can't have "own" permissions
-			if ($group['id'] == '-1')
-			{
+				// Guests can't have "own" permissions
+				if ($group['id'] == '-1')
+				{
 				echo '
 						<td align="center" class="windowbg" colspan="3"></td>';
-			}
-			else
-			{
-				echo '
+				}
+				else
+				{
+					echo '
 						<td align="center" class="windowbg"><input type="radio" name="replies_own[', $group['id'], ']" value="allow" ', $group['replies_own'] == 'allow' ? 'checked="checked"' : '', ' class="input_radio" /></td>
 						<td align="center" class="windowbg"><input type="radio" name="replies_own[', $group['id'], ']" value="moderate" ', $group['replies_own'] == 'moderate' ? 'checked="checked"' : '', ' class="input_radio" /></td>
 						<td align="center" class="windowbg"><input type="radio" name="replies_own[', $group['id'], ']" value="disallow" ', $group['replies_own'] == 'disallow' ? 'checked="checked"' : '', ' class="input_radio" /></td>';
-			}
+				}
 			
-			echo '
+				echo '
 						<td align="center" class="windowbg2"><input type="radio" name="replies_any[', $group['id'], ']" value="allow" ', $group['replies_any'] == 'allow' ? 'checked="checked"' : '', ' class="input_radio" /></td>
 						<td align="center" class="windowbg2"><input type="radio" name="replies_any[', $group['id'], ']" value="moderate" ', $group['replies_any'] == 'moderate' ? 'checked="checked"' : '', ' class="input_radio" /></td>
 						<td align="center" class="windowbg2"><input type="radio" name="replies_any[', $group['id'], ']" value="disallow" ', $group['replies_any'] == 'disallow' ? 'checked="checked"' : '', ' class="input_radio" /></td>';
 	
-			if ($modSettings['attachmentEnable'] == 1)
-			{
-				echo '
+				if ($modSettings['attachmentEnable'] == 1)
+				{
+					echo '
 						<td align="center" class="windowbg"><input type="radio" name="attachment[', $group['id'], ']" value="allow" ', $group['attachment'] == 'allow' ? 'checked="checked"' : '', ' class="input_radio" /></td>
 						<td align="center" class="windowbg"><input type="radio" name="attachment[', $group['id'], ']" value="moderate" ', $group['attachment'] == 'moderate' ? 'checked="checked"' : '', ' class="input_radio" /></td>
 						<td align="center" class="windowbg"><input type="radio" name="attachment[', $group['id'], ']" value="disallow" ', $group['attachment'] == 'disallow' ? 'checked="checked"' : '', ' class="input_radio" /></td>';
-			}
+				}
 		
-			echo '
+				echo '
 					</tr>';
+		}
+
+		echo '
+				</tbody>
+			</table>';
 	}
 
 	echo '
-				</tbody>
-			</table>
 			<div class="righttext padding">
 				<input type="submit" name="save_changes" value="', $txt['permissions_commit'], '" class="button_submit" />
 				<input type="hidden" name="', $context['admin-mppm_token_var'], '" value="', $context['admin-mppm_token'], '" />
 			</div>
-		</form>
+		</form>';
+
+	if (!empty($modSettings['postmod_active']))
+		echo '
 		<p class="smalltext" style="padding-left: 10px;">
 			<strong>', $txt['permissions_post_moderation_legend'], ':</strong><br />
 			<img src="', $settings['default_images_url'], '/admin/post_moderation_allow.png" alt="', $txt['permissions_post_moderation_allow'], '" /> - ', $txt['permissions_post_moderation_allow'], '<br />
 			<img src="', $settings['default_images_url'], '/admin/post_moderation_moderate.png" alt="', $txt['permissions_post_moderation_moderate'], '" /> - ', $txt['permissions_post_moderation_moderate'], '<br />
 			<img src="', $settings['default_images_url'], '/admin/post_moderation_deny.png" alt="', $txt['permissions_post_moderation_disallow'], '" /> - ', $txt['permissions_post_moderation_disallow'], '
-		</p>
+		</p>';
+
+	echo '
 	</div>';
 }
 

BIN
Themes/default/images/admin/feature_ml.png


BIN
Themes/default/images/admin/feature_pm.png


+ 2 - 1
Themes/default/languages/ManagePermissions.english.php

@@ -345,7 +345,8 @@ $txt['permission_settings_enable_postgroups'] = 'Enable permissions for post cou
 // Escape any single quotes in here twice.. 'it\'s' -> 'it\\\'s'.
 $txt['permission_disable_postgroups_warning'] = 'Disabling this setting will remove permissions currently set to post count based groups.';
 
-$txt['permissions_post_moderation_desc'] = 'From this page you can easily change which groups have their posts moderated for a particular permissions profile.';
+$txt['permissions_post_moderation_desc'] = 'Post Moderation is the situation where posts are &quot;moderated&quot;, where the author and the moderation team can view posts and decide whether to permit them to be visible to other users or not. From this page you can easily change which groups have their posts moderated for a particular permissions profile.';
+$txt['permissions_post_moderation_enable'] = 'Enable Post Moderation';
 $txt['permissions_post_moderation_deny_note'] = 'Note that while you have advanced permissions enabled you cannot apply the &quot;deny&quot; permission from this page. Please edit the permissions directly if you wish to apply a deny permission.';
 $txt['permissions_post_moderation_select'] = 'Select Profile';
 $txt['permissions_post_moderation_new_topics'] = 'New Topics';

+ 0 - 6
Themes/default/languages/ManageSettings.english.php

@@ -299,12 +299,6 @@ $txt['core_settings_welcome_msg'] = 'Welcome to Your New Forum';
 $txt['core_settings_welcome_msg_desc'] = 'To get you started we suggest you select which of SMF\'s core features you want to enable. We\'d recommend only enabling with those features you need!';
 $txt['core_settings_item_k'] = 'Karma';
 $txt['core_settings_item_k_desc'] = 'Karma is a feature that shows the popularity of a member. Members, if allowed, can \'applaud\' or \'smite\' other members, which is how their popularity is calculated.';
-$txt['core_settings_item_ml'] = 'Moderation, Administration and User Logs';
-$txt['core_settings_item_ml_desc'] = 'Enable the moderation and administration logs to keep an audit trail of all the key actions taken on your forum. Also allows forum moderators to view a history of key changes a user makes to their profile.';
-$txt['core_settings_item_pm'] = 'Post Moderation';
-$txt['core_settings_item_pm_desc'] = 'Post moderation enables you to select groups and boards within which posts must be approved before they become public. Upon enabling this feature be sure to visit the permission section to set up the relevant permissions.';
-$txt['core_settings_item_ps'] = 'Paid Subscriptions';
-$txt['core_settings_item_ps_desc'] = 'Paid subscriptions allow users to pay for subscriptions to change membergroups within the forum and thus change their access rights.';
 $txt['core_settings_item_w'] = 'Warning System';
 $txt['core_settings_item_w_desc'] = 'This system allows administrators and moderators to issue warnings to users, and can automatically remove user rights as their warning level increases. To take full advantage of this system, &quot;Post Moderation&quot; should be enabled.';
 $txt['core_settings_switch_on'] = 'Click to Enable';