X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FSubMirror%2Factions%2Faddmirror.php;h=0031cf1bf4735b17833c620b743bd52a873f5bae;hb=64df40e409812249748723b8acb0b48920ed786b;hp=5acdf1dfe498c97d43eef019e00a21c3e095049f;hpb=640e7e7c43fa8e9b1a8516b486e560df84bd9887;p=quix0rs-gnu-social.git diff --git a/plugins/SubMirror/actions/addmirror.php b/plugins/SubMirror/actions/addmirror.php index 5acdf1dfe4..0031cf1bf4 100644 --- a/plugins/SubMirror/actions/addmirror.php +++ b/plugins/SubMirror/actions/addmirror.php @@ -45,7 +45,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 +56,38 @@ class AddMirrorAction extends BaseMirrorAction * * @return boolean success flag */ - function prepare($args) { 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 getFeedUrl() + { + $provider = $this->trimmed('provider'); + switch ($provider) { + case 'feed': + return $this->trimmed('feedurl'); + case 'twitter': + $screenie = $this->trimmed('screen_name'); + $base = 'http://api.twitter.com/1/statuses/user_timeline.atom?screen_name='; + return $base . urlencode($screenie); + default: + // TRANS: Exception thrown when a feed provider could not be recognised. + throw new Exception(_m('Internal form error: Unrecognized feed provider.')); + } + } + function saveMirror() { if ($this->oprofile->subscribe()) { SubMirror::saveMirror($this->user, $this->profile); } else { - $this->serverError(_m("Could not subscribe to feed.")); + // TRANS: Exception thrown when a subscribing to a feed fails. + $this->serverError(_m('Could not subscribe to feed.')); } } }