X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FSubMirror%2Factions%2Faddmirror.php;h=738fa92f47366e10ba5db02b8149d5d5522df77e;hb=0193c7548f075ecf2f07dd8ca55b1b8f45e708ff;hp=5acdf1dfe498c97d43eef019e00a21c3e095049f;hpb=338aa4bf1d36e11a354c67796509c6d1fec2aac2;p=quix0rs-gnu-social.git diff --git a/plugins/SubMirror/actions/addmirror.php b/plugins/SubMirror/actions/addmirror.php index 5acdf1dfe4..738fa92f47 100644 --- a/plugins/SubMirror/actions/addmirror.php +++ b/plugins/SubMirror/actions/addmirror.php @@ -26,9 +26,7 @@ * @link http://status.net/ */ -if (!defined('STATUSNET')) { - exit(1); -} +if (!defined('GNUSOCIAL') && !defined('STATUSNET')) { exit(1); } /** * Takes parameters: @@ -45,7 +43,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3 * @link http://status.net/ */ - class AddMirrorAction extends BaseMirrorAction { var $feedurl; @@ -57,21 +54,30 @@ class AddMirrorAction extends BaseMirrorAction * * @return boolean success flag */ - - function prepare($args) + protected function prepare(array $args=array()) { parent::prepare($args); - $this->feedurl = $this->validateFeedUrl($this->trimmed('feedurl')); + $feedurl = $this->getFeedUrl(); + $this->feedurl = $this->validateFeedUrl($feedurl); $this->profile = $this->profileForFeed($this->feedurl); return true; } - function saveMirror() + function getFeedUrl() { - if ($this->oprofile->subscribe()) { - SubMirror::saveMirror($this->user, $this->profile); - } else { - $this->serverError(_m("Could not subscribe to feed.")); + $provider = $this->trimmed('provider'); + switch ($provider) { + case 'feed': + return $this->trimmed('feedurl'); + default: + // TRANS: Exception thrown when a feed provider could not be recognised. + throw new Exception(_m('Internal form error: Unrecognized feed provider.')); } } + + protected function saveMirror() + { + $this->oprofile->subscribe(); + SubMirror::saveMirror($this->user, $this->profile); + } }