X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FUserFlag%2Fflagprofile.php;h=7096d3748e4cb9fd3cfe2edab43264799d71e6a2;hb=e1791525e818d7d4276da0fe7e7c526fe8794e7c;hp=018c1e8ac99992eda613d86b6e42647d5371cd46;hpb=6d8e01ad13dd9bc9e149f43a1eb88671d4737f4d;p=quix0rs-gnu-social.git diff --git a/plugins/UserFlag/flagprofile.php b/plugins/UserFlag/flagprofile.php index 018c1e8ac9..7096d3748e 100644 --- a/plugins/UserFlag/flagprofile.php +++ b/plugins/UserFlag/flagprofile.php @@ -40,7 +40,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 * @link http://status.net/ */ - class FlagprofileAction extends ProfileFormAction { /** @@ -50,7 +49,6 @@ class FlagprofileAction extends ProfileFormAction * * @return boolean success flag */ - function prepare($args) { if (!parent::prepare($args)) { @@ -62,12 +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)) { - $this->clientError(_('Flag already exists.')); - return false; - } - return true; } @@ -81,7 +73,6 @@ class FlagprofileAction extends ProfileFormAction * * @return void */ - function handle($args) { if ($_SERVER['REQUEST_METHOD'] == 'POST') { @@ -97,7 +88,6 @@ class FlagprofileAction extends ProfileFormAction * * @return void */ - function handlePost() { $user = common_current_user(); @@ -107,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(); @@ -119,19 +115,19 @@ class FlagprofileAction extends ProfileFormAction * * @return void */ - function ajaxResults() { header('Content-Type: text/xml;charset=utf-8'); $this->xw->startDocument('1.0', 'UTF-8'); $this->elementStart('html'); $this->elementStart('head'); - $this->element('title', null, _('Flagged for review')); + // TRANS: AJAX form title for a flagged profile. + $this->element('title', null, _m('Flagged for review')); $this->elementEnd('head'); $this->elementStart('body'); - $this->element('p', 'flagged', _('Flagged')); + // TRANS: Body text for AJAX form when a profile has been flagged for review. + $this->element('p', 'flagged', _m('Flagged')); $this->elementEnd('body'); $this->elementEnd('html'); } } -