Преглед на файлове

! When adding/removing users from buddy/ignore lists, throw a message about it being saved (a la #802) but also show it couldn't be done (non specific message, hard to be accurate about why not)

Signed-off-by: Peter Spicer <[email protected]>
Peter Spicer преди 11 години
родител
ревизия
a6d5eea168
променени са 3 файла, в които са добавени 54 реда и са изтрити 0 реда
  1. 38 0
      Sources/Profile-Modify.php
  2. 14 0
      Themes/default/Profile.template.php
  3. 2 0
      Themes/default/languages/Profile.english.php

+ 38 - 0
Sources/Profile-Modify.php

@@ -1355,10 +1355,15 @@ function editBuddies($memID)
 
 		call_integration_hook('integrate_remove_buddy', array($memID));
 
+		$_SESSION['prf-save'] = $txt['could_not_remove_person'];
+
 		// Heh, I'm lazy, do it the easy way...
 		foreach ($buddiesArray as $key => $buddy)
 			if ($buddy == (int) $_GET['remove'])
+			{
 				unset($buddiesArray[$key]);
+				$_SESSION['prf-save'] = true;
+			}
 
 		// Make the changes.
 		$user_profile[$memID]['buddy_list'] = implode(',', $buddiesArray);
@@ -1386,6 +1391,7 @@ function editBuddies($memID)
 
 		call_integration_hook('integrate_add_buddies', array($memID, &$new_buddies));
 
+		$_SESSION['prf-save'] = $txt['could_not_add_person'];
 		if (!empty($new_buddies))
 		{
 			// Now find out the id_member of the buddy.
@@ -1400,6 +1406,9 @@ function editBuddies($memID)
 				)
 			);
 
+			if ($smcFunc['db_num_rows']($request) != 0)
+				$_SESSION['prf-save'] = true;
+
 			// Add the new member to the buddies array.
 			while ($row = $smcFunc['db_fetch_assoc']($request))
 				$buddiesArray[] = (int) $row['id_member'];
@@ -1448,6 +1457,16 @@ function editBuddies($memID)
 		$context['buddies'][$buddy] = $memberContext[$buddy];
 	}
 
+	if (isset($_SESSION['prf-save']))
+	{
+		if ($_SESSION['prf-save'] === true)
+			$context['saved_successful'] = true;
+		else
+			$context['saved_failed'] = $_SESSION['prf-save'];
+
+		unset($_SESSION['prf-save']);
+	}
+
 	call_integration_hook('integrate_view_buddies', array($memID));
 }
 
@@ -1472,10 +1491,15 @@ function editIgnoreList($memID)
 	{
 		checkSession('get');
 
+		$_SESSION['prf-save'] = $txt['could_not_remove_person'];
+
 		// Heh, I'm lazy, do it the easy way...
 		foreach ($ignoreArray as $key => $id_remove)
 			if ($id_remove == (int) $_GET['remove'])
+			{
 				unset($ignoreArray[$key]);
+				$_SESSION['prf-save'] = true;
+			}
 
 		// Make the changes.
 		$user_profile[$memID]['pm_ignore_list'] = implode(',', $ignoreArray);
@@ -1500,6 +1524,7 @@ function editIgnoreList($memID)
 				unset($new_entries[$k]);
 		}
 
+		$_SESSION['prf-save'] = $txt['could_not_add_person'];
 		if (!empty($new_entries))
 		{
 			// Now find out the id_member for the members in question.
@@ -1514,6 +1539,9 @@ function editIgnoreList($memID)
 				)
 			);
 
+			if ($smcFunc['db_num_rows']($request) != 0)
+				$_SESSION['prf-save'] = true;
+
 			// Add the new member to the buddies array.
 			while ($row = $smcFunc['db_fetch_assoc']($request))
 				$ignoreArray[] = (int) $row['id_member'];
@@ -1561,6 +1589,16 @@ function editIgnoreList($memID)
 		loadMemberContext($ignore_member);
 		$context['ignore_list'][$ignore_member] = $memberContext[$ignore_member];
 	}
+
+	if (isset($_SESSION['prf-save']))
+	{
+		if ($_SESSION['prf-save'] === true)
+			$context['saved_successful'] = true;
+		else
+			$context['saved_failed'] = $_SESSION['prf-save'];
+
+		unset($_SESSION['prf-save']);
+	}
 }
 
 /**

+ 14 - 0
Themes/default/Profile.template.php

@@ -586,6 +586,13 @@ function template_editBuddies()
 	$disabled_fields = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array();
 	$buddy_fields = array('icq', 'aim', 'yim', 'skype');
 
+	if (!empty($context['saved_successful']))
+		echo '
+					<div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>';
+	elseif (!empty($context['saved_failed']))
+		echo '
+					<div class="errorbox">', $context['saved_failed'], '</div>';
+
 	echo '
 	<div class="generic_list_wrapper" id="edit_buddies">
 		<div class="cat_bar">
@@ -698,6 +705,13 @@ function template_editIgnoreList()
 {
 	global $context, $settings, $options, $scripturl, $modSettings, $txt;
 
+	if (!empty($context['saved_successful']))
+		echo '
+					<div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>';
+	elseif (!empty($context['saved_failed']))
+		echo '
+					<div class="errorbox">', $context['saved_failed'], '</div>';
+
 	echo '
 	<div class="generic_list_wrapper" id="edit_buddies">
 		<div class="cat_bar">

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

@@ -201,6 +201,8 @@ $txt['showAttachments'] = 'Attachments';
 $txt['viewWarning_help'] = 'This section allows you to view all warnings issued to this member.';
 $txt['statPanel'] = 'Show Stats';
 $txt['editBuddyIgnoreLists'] = 'Buddies/Ignore List';
+$txt['could_not_add_person'] = 'You could not add that person to your list';
+$txt['could_not_remove_person'] = 'You could not remove that person from your list';
 $txt['editBuddies'] = 'Edit Buddies';
 $txt['editIgnoreList'] = 'Edit Ignore List';
 $txt['trackUser'] = 'Track User';