. * * PHP version 5 * * @category Action * @package StatusNet * @author Brion Vibber * @copyright 2010 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3 * @link http://status.net/ */ if (!defined('GNUSOCIAL') && !defined('STATUSNET')) { exit(1); } /** * Takes parameters: * * - feed: a profile ID * - token: session token to prevent CSRF attacks * - ajax: boolean; whether to return Ajax or full-browser results * * Only works if the current user is logged in. * * @category Action * @package StatusNet * @copyright 2010 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3 * @link http://status.net/ */ class AddMirrorAction extends BaseMirrorAction { var $feedurl; /** * Check pre-requisites and instantiate attributes * * @param Array $args array of arguments (URL, GET, POST) * * @return boolean success flag */ protected function prepare(array $args=array()) { parent::prepare($args); $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'); 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); } }