X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FUserFlag%2Fflagprofile.php;h=8ff2f1f7271edf338bfac92ae3f2e10be1724ec4;hb=409ce3556d07f66e5a65e035f9d52b8421441911;hp=f128b9c40e32a7ed5ada00e0ca5ecc8b3cd067bc;hpb=d9cde0ef80ee838a99035d44f0286b3cc902e332;p=quix0rs-gnu-social.git diff --git a/plugins/UserFlag/flagprofile.php b/plugins/UserFlag/flagprofile.php index f128b9c40e..8ff2f1f727 100644 --- a/plugins/UserFlag/flagprofile.php +++ b/plugins/UserFlag/flagprofile.php @@ -41,11 +41,8 @@ if (!defined('STATUSNET')) { * @link http://status.net/ */ -class FlagprofileAction extends Action +class FlagprofileAction extends ProfileFormAction { - var $profile = null; - var $flag = null; - /** * Take arguments for running * @@ -56,44 +53,17 @@ class FlagprofileAction extends Action function prepare($args) { - parent::prepare($args); - - if ($_SERVER['REQUEST_METHOD'] != 'POST') { - throw new ClientException(_('Action only accepts POST')); - } - - if (!common_logged_in()) { - $this->clientError(_('Not logged in.')); - return false; - } - - $id = $this->trimmed('flagprofileto'); - - if (!$id) { - $this->clientError(_('No profile specified.')); + if (!parent::prepare($args)) { return false; } - $this->profile = Profile::staticGet('id', $id); - - if (empty($this->profile)) { - $this->clientError(_('No profile with that ID.')); - return false; - } - - $this->flag = $this->trimmed('flag'); - - if (empty($this->flag)) { - $this->flag = Profile_flag::DEFAULTFLAG; - } - $user = common_current_user(); assert(!empty($user)); // checked above + assert(!empty($this->profile)); // checked above if (User_flag_profile::exists($this->profile->id, - $user->id, - $this->flag)) + $user->id)) { $this->clientError(_('Flag already exists.')); return false; @@ -103,66 +73,43 @@ class FlagprofileAction extends Action } /** - * Handle request - * - * @param array $args $_REQUEST args; handled in prepare() + * Handle POST * * @return void */ - function handle($args) - { - parent::handle($args); - - $this->flagProfile(); - $this->returnTo(); - } - - function title() { - return _('Flag profile'); - } - - /** - * save the profile flag - * - * @return void - */ - - function flagProfile() + function handlePost() { $user = common_current_user(); assert(!empty($user)); assert(!empty($this->profile)); - assert(!empty($this->flag)); $ufp = new User_flag_profile(); $ufp->profile_id = $this->profile->id; $ufp->user_id = $user->id; - $ufp->flag = $this->flag; $ufp->created = common_sql_now(); if (!$ufp->insert()) { - throw new ServerException(sprintf(_("Couldn't flag profile '%s' with flag '%s'."), - $this->profile->nickname, $this->flag)); + throw new ServerException(sprintf(_("Couldn't flag profile '%s' for review."), + $this->profile->nickname)); } $ufp->free(); } - function returnTo() - { - // Now, gotta figure where we go back to - foreach ($this->args as $k => $v) { - if ($k == 'returnto-action') { - $action = $v; - } elseif (substr($k, 0, 9) == 'returnto-') { - $args[substr($k, 9)] = $v; - } - } - - common_redirect(common_local_url($action, $args), 303); + 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')); + $this->elementEnd('head'); + $this->elementStart('body'); + $this->element('p', 'flagged', _('Flagged')); + $this->elementEnd('body'); + $this->elementEnd('html'); } }