summaryrefslogtreecommitdiff
path: root/plugins/UserFlag
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-11-03 12:32:11 -0700
committerBrion Vibber <brion@pobox.com>2010-11-03 12:32:11 -0700
commit5592333b73d970cb9ae326880fc587b1fb8032ce (patch)
tree6943726824d030d8a3a317574545e1f2509c9ec2 /plugins/UserFlag
parent607d9589775dc79afd4e7295ce00bcf3eeb84d04 (diff)
Fix for ticket #2168: if we've already flagged a profile from another window, let the 'Flag' form submission gracefully show the updated state instead of throwing an error (error message isn't even exposed properly in AJAX submissions)
Diffstat (limited to 'plugins/UserFlag')
-rw-r--r--plugins/UserFlag/flagprofile.php15
1 files changed, 7 insertions, 8 deletions
diff --git a/plugins/UserFlag/flagprofile.php b/plugins/UserFlag/flagprofile.php
index 283eea40c..7096d3748 100644
--- a/plugins/UserFlag/flagprofile.php
+++ b/plugins/UserFlag/flagprofile.php
@@ -60,13 +60,6 @@ class FlagprofileAction extends ProfileFormAction
assert(!empty($user)); // checked above
assert(!empty($this->profile)); // checked above
- if (User_flag_profile::exists($this->profile->id,
- $user->id)) {
- // TRANS: Client error when setting flag that has already been set for a profile.
- $this->clientError(_m('Flag already exists.'));
- return false;
- }
-
return true;
}
@@ -104,7 +97,13 @@ class FlagprofileAction extends ProfileFormAction
// throws an exception on error
- User_flag_profile::create($user->id, $this->profile->id);
+ if (User_flag_profile::exists($this->profile->id,
+ $user->id)) {
+ // We'll return to the profile page (or return the updated AJAX form)
+ // showing the current state, so no harm done.
+ } else {
+ User_flag_profile::create($user->id, $this->profile->id);
+ }
if ($this->boolean('ajax')) {
$this->ajaxResults();