瀏覽代碼

Merge pull request #1198 from Arantor/release-2.1

Buglet zapping
Arantor 11 年之前
父節點
當前提交
d8e78cc8a3

+ 8 - 2
Sources/ManageMembergroups.php

@@ -610,7 +610,10 @@ function DeleteMembergroup()
 	checkSession('get');
 
 	require_once($sourcedir . '/Subs-Membergroups.php');
-	deleteMembergroups((int) $_REQUEST['group']);
+	$result = deleteMembergroups((int) $_REQUEST['group']);
+	// Need to throw a warning if it went wrong, but this is the only one we have a message for...
+	if ($result === 'group_cannot_delete_sub')
+		fatal_lang_error('membergroups_cannot_delete_paid', false);
 
 	// Go back to the membergroup index.
 	redirectexit('action=admin;area=membergroups;');
@@ -680,7 +683,10 @@ function EditMembergroup()
 		validateToken('admin-mmg');
 
 		require_once($sourcedir . '/Subs-Membergroups.php');
-		deleteMembergroups($_REQUEST['group']);
+		$result = deleteMembergroups($_REQUEST['group']);
+		// Need to throw a warning if it went wrong, but this is the only one we have a message for...
+		if ($result === 'group_cannot_delete_sub')
+			fatal_lang_error('membergroups_cannot_delete_paid', false);
 
 		redirectexit('action=admin;area=membergroups;');
 	}

+ 6 - 0
Sources/Profile-View.php

@@ -113,6 +113,12 @@ function summary($memID)
 
 		// Should we show a custom message?
 		$context['activate_message'] = isset($txt['account_activate_method_' . $context['member']['is_activated'] % 10]) ? $txt['account_activate_method_' . $context['member']['is_activated'] % 10] : $txt['account_not_activated'];
+
+		// If they can be approved, we need to set up a token for them.
+		$context['token_check'] = 'profile-aa' . $memID;
+		createToken($context['token_check'], 'get');
+
+		$context['activate_link'] = $scripturl . '?action=profile;save;area=activateaccount;u=' . $context['id_member'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';' . $context[$context['token_check'] . '_token_var'] . '=' . $context[$context['token_check'] . '_token'];
 	}
 
 	// Is the signature even enabled on this forum?

+ 1 - 0
Sources/Profile.php

@@ -378,6 +378,7 @@ function ModifyProfile($post_errors = array())
 					'icon' => 'regcenter.png',
 					'sc' => 'get',
 					'token' => 'profile-aa%u',
+					'token_type' => 'get',
 					'permission' => array(
 						'own' => array(),
 						'any' => array('moderate_forum'),

+ 29 - 3
Sources/Subs-Membergroups.php

@@ -24,11 +24,11 @@ if (!defined('SMF'))
  * Deletes the permissions linked to the membergroup.
  * Takes members out of the deleted membergroups.
  * @param array $groups
- * @return boolean
+ * @return mixed bool true for success, otherwise an identifier as to reason for failure
  */
 function deleteMembergroups($groups)
 {
-	global $sourcedir, $smcFunc, $modSettings;
+	global $sourcedir, $smcFunc, $modSettings, $txt;
 
 	// Make sure it's an array.
 	if (!is_array($groups))
@@ -64,7 +64,33 @@ function deleteMembergroups($groups)
 	// Make sure they don't delete protected groups!
 	$groups = array_diff($groups, array_unique($protected_groups));
 	if (empty($groups))
-		return false;
+		return 'no_group_found';
+
+	// Make sure they don't try to delete a group attached to a paid subscription.
+	$subscriptions = array();
+	$request = $smcFunc['db_query']('', '
+		SELECT id_subscribe, name, id_group, add_groups
+		FROM {db_prefix}subscriptions
+		ORDER BY name');
+	while ($row = $smcFunc['db_fetch_assoc']($request))
+	{
+		if (in_array($row['id_group'], $groups))
+			$subscriptions[] = $row['name'];
+		else
+		{
+			$add_groups = explode(',', $row['add_groups']);
+			if (count(array_intersect($add_groups, $groups)) != 0)
+				$subscriptions[] = $row['name'];
+		}
+	}
+	$smcFunc['db_free_result']($request);
+	if (!empty($subscriptions))
+	{
+		// Uh oh. But before we return, we need to update a language string because we want the names of the groups.
+		loadLanguage('ManageMembers');
+		$txt['membergroups_cannot_delete_paid'] = sprintf($txt['membergroups_cannot_delete_paid'], implode(', ', $subscriptions));
+		return 'group_cannot_delete_sub';
+	}
 
 	// Log the deletion.
 	$request = $smcFunc['db_query']('', '

+ 1 - 1
Themes/default/Profile.template.php

@@ -324,7 +324,7 @@ function template_summary()
 		// If the person looking at the summary has permission, and the account isn't activated, give the viewer the ability to do it themselves.
 		if (!empty($context['activate_message']))
 			echo '
-					<dt class="clear"><span class="alert">', $context['activate_message'], '</span>&nbsp;(<a href="' . $scripturl . '?action=profile;save;area=activateaccount;u=' . $context['id_member'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '"', ($context['activate_type'] == 4 ? ' onclick="return confirm(\'' . $txt['profileConfirm'] . '\');"' : ''), '>', $context['activate_link_text'], '</a>)</dt>';
+					<dt class="clear"><span class="alert">', $context['activate_message'], '</span>&nbsp;(<a href="', $context['activate_link'], '"', ($context['activate_type'] == 4 ? ' onclick="return confirm(\'' . $txt['profileConfirm'] . '\');"' : ''), '>', $context['activate_link_text'], '</a>)</dt>';
 
 		// If the current member is banned, show a message and possibly a link to the ban.
 		if (!empty($context['member']['bans']))

+ 2 - 0
Themes/default/languages/ManageMembers.english.php

@@ -25,6 +25,8 @@ $txt['membergroups_new_as_copy'] = 'based off of';
 $txt['membergroups_new_copy_none'] = '(none)';
 $txt['membergroups_can_edit_later'] = 'You can edit them later.';
 
+$txt['membergroups_cannot_delete_paid'] = 'This group cannot be deleted, it is currently in use by the following paid subscription(s): %1$s';
+
 $txt['membergroups_edit_group'] = 'Edit Membergroup';
 $txt['membergroups_edit_name'] = 'Group name';
 $txt['membergroups_edit_inherit_permissions'] = 'Inherit Permissions';

+ 2 - 2
Themes/default/languages/ModerationCenter.english.php

@@ -41,8 +41,8 @@ $txt['mc_reportedp_none_found'] = 'No Reports Found';
 $txt['mc_reportedp_details'] = 'Details';
 $txt['mc_reportedp_close'] = 'Close';
 $txt['mc_reportedp_open'] = 'Open';
-$txt['mc_reportedp_ignore'] = 'Ignore';
-$txt['mc_reportedp_unignore'] = 'Un-Ignore';
+$txt['mc_reportedp_ignore'] = 'Disregard';
+$txt['mc_reportedp_unignore'] = 'Undo Disregard';
 $txt['mc_reportedp_delete'] = 'Delete message';
 $txt['mc_reportedp_delete_confirm'] = 'Are you sure you wish to delete this message?';
 $txt['mc_reportedp_ban'] = 'Ban this user';