3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2010, StatusNet, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 * @author Brion Vibber <brion@status.net>
24 * @copyright 2010 StatusNet, Inc.
25 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
26 * @link http://status.net/
29 if (!defined('GNUSOCIAL') && !defined('STATUSNET')) { exit(1); }
34 * - feed: a profile ID
35 * - token: session token to prevent CSRF attacks
36 * - ajax: boolean; whether to return Ajax or full-browser results
38 * Only works if the current user is logged in.
42 * @copyright 2010 StatusNet, Inc.
43 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
44 * @link http://status.net/
46 class AddMirrorAction extends BaseMirrorAction
51 * Check pre-requisites and instantiate attributes
53 * @param Array $args array of arguments (URL, GET, POST)
55 * @return boolean success flag
57 protected function prepare(array $args=array())
59 parent::prepare($args);
60 $feedurl = $this->getFeedUrl();
61 $this->feedurl = $this->validateFeedUrl($feedurl);
62 $this->profile = $this->profileForFeed($this->feedurl);
68 $provider = $this->trimmed('provider');
71 return $this->trimmed('feedurl');
73 // TRANS: Exception thrown when a feed provider could not be recognised.
74 throw new Exception(_m('Internal form error: Unrecognized feed provider.'));
78 protected function saveMirror()
80 $this->oprofile->subscribe();
81 SubMirror::saveMirror($this->user, $this->profile);