* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
+if (!defined('GNUSOCIAL')) { exit(1); }
define('LISTENER', 1);
define('LISTENEE', -1);
define('BOTH', 0);
// @todo XXX: Documentation missing.
-class FoafAction extends Action
+class FoafAction extends ManagedAction
{
function isReadOnly($args)
{
return true;
}
- function prepare($args)
+ protected function doPreparation()
{
- parent::prepare($args);
-
$nickname_arg = $this->arg('nickname');
if (empty($nickname_arg)) {
return true;
}
- function handle($args)
+ public function showPage()
{
- parent::handle($args);
-
header('Content-Type: application/rdf+xml');
$this->startXML();
* @link http://status.net/
*/
-if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
/**
* A list of the user's subscriptions
function showPageNotice()
{
- if ($this->scoped instanceof Profile && $this->scoped->id === $this->target->id) {
+ if ($this->scoped instanceof Profile && $this->scoped->sameAs($this->getTarget())) {
$this->element('p', null,
// TRANS: Page notice for page with an overview of all subscriptions
// TRANS: of the logged in user's own profile.
if ($this->page == 1) {
// TRANS: Page title for first page of groups for a user.
// TRANS: %s is a nickname.
- return sprintf(_('%s groups'), $this->user->nickname);
+ return sprintf(_('%s groups'), $this->getTarget()->getNickname());
} else {
// TRANS: Page title for all but the first page of groups for a user.
// TRANS: %1$s is a nickname, %2$d is a page number.
return sprintf(_('%1$s groups, page %2$d'),
- $this->user->nickname,
+ $this->getTarget()->getNickname(),
$this->page);
}
}
$offset = ($this->page-1) * GROUPS_PER_PAGE;
$limit = GROUPS_PER_PAGE + 1;
- $groups = $this->user->getGroups($offset, $limit);
+ $groups = $this->getTarget()->getGroups($offset, $limit);
if ($groups instanceof User_group) {
- $gl = new GroupList($groups, $this->user, $this);
+ $gl = new GroupList($groups, $this->getTarget(), $this);
$cnt = $gl->show();
$this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE,
$this->page, 'usergroups',
- array('nickname' => $this->user->nickname));
+ array('nickname' => $this->getTarget()->getNickname()));
} else {
$this->showEmptyListMessage();
}
{
// TRANS: Text on group page for a user that is not a member of any group.
// TRANS: %s is a user nickname.
- $message = sprintf(_('%s is not a member of any group.'), $this->user->nickname) . ' ';
+ $message = sprintf(_('%s is not a member of any group.'), $this->getTarget()->getNickname()) . ' ';
if (common_logged_in()) {
$current_user = common_current_user();
- if ($this->user->id === $current_user->id) {
+ if ($this->scoped->sameAs($this->getTarget())) {
// TRANS: Text on group page for a user that is not a member of any group. This message contains
// TRANS: a Markdown link in the form [link text](link) and a variable that should not be changed.
$message .= _('Try [searching for groups](%%action.groupsearch%%) and joining them.');
function showProfileBlock()
{
- $block = new AccountProfileBlock($this, $this->profile);
+ $block = new AccountProfileBlock($this, $this->getTarget());
$block->show();
}
}
}
$stream = new ConversationNoticeStream($this->conversation);
- $notices = $stream->getNotices(/*offset*/ 1, /*limit*/ 1);
+ $notice = $stream->getNotices(/*offset*/ 1, /*limit*/ 1);
// if our "offset 1, limit 1" query got a result, return true else false
return $notice->N > 0;
return $rq;
}
- public function exists(Profile $subscriber, Profile $other)
+ static function exists(Profile $subscriber, Profile $other)
{
- $sub = Subscription_queue::pkeyGet(array('subscriber' => $subscriber->id,
- 'subscribed' => $other->id));
+ $sub = Subscription_queue::pkeyGet(array('subscriber' => $subscriber->getID(),
+ 'subscribed' => $other->getID()));
return ($sub instanceof Subscription_queue);
}
label.attr('title', label.text());
check.change(function () {
- if (check.prop('checked') === true || $.cookie(SN.C.S.NoticeDataGeoCookie) === null) {
+ if (check.prop('checked') === true || $.cookie(SN.C.S.NoticeDataGeoCookie) === undefined) {
label
.attr('title', NoticeDataGeo_text.ShareDisable)
.addClass('checked');
- if ($.cookie(SN.C.S.NoticeDataGeoCookie) === null || $.cookie(SN.C.S.NoticeDataGeoCookie) == 'disabled') {
+ if ($.cookie(SN.C.S.NoticeDataGeoCookie) === undefined || $.cookie(SN.C.S.NoticeDataGeoCookie) == 'disabled') {
if (navigator.geolocation) {
SN.U.NoticeGeoStatus(form, 'Requesting location from browser...');
navigator.geolocation.getCurrentPosition(
* @fixme what is this?
*/
Delete: function () {
- $.cookie(SN.C.S.StatusNetInstance, null);
+ $.removeCookie(SN.C.S.StatusNetInstance);
}
},
$twitter_user['friends_count'] = $profile->subscriptionCount();
- $twitter_user['created_at'] = $this->dateTwitter($profile->created);
+ $twitter_user['created_at'] = self::dateTwitter($profile->created);
$timezone = 'UTC';
$twitter_status = array();
$twitter_status['text'] = $notice->content;
$twitter_status['truncated'] = false; # Not possible on StatusNet
- $twitter_status['created_at'] = $this->dateTwitter($notice->created);
+ $twitter_status['created_at'] = self::dateTwitter($notice->created);
try {
// We could just do $notice->reply_to but maybe the future holds a
// different story for parenting.
$twitter_group['homepage'] = $group->homepage;
$twitter_group['description'] = $group->description;
$twitter_group['location'] = $group->location;
- $twitter_group['created'] = $this->dateTwitter($group->created);
- $twitter_group['modified'] = $this->dateTwitter($group->modified);
+ $twitter_group['created'] = self::dateTwitter($group->created);
+ $twitter_group['modified'] = self::dateTwitter($group->modified);
return $twitter_group;
}
$this->endDocument('xml');
}
- function dateTwitter($dt)
+ static function dateTwitter($dt)
{
$dateStr = date('d F Y H:i:s', strtotime($dt));
$d = new DateTime($dateStr, new DateTimeZone('UTC'));
define('GNUSOCIAL_ENGINE_URL', 'https://www.gnu.org/software/social/');
define('GNUSOCIAL_BASE_VERSION', '1.2.0');
-define('GNUSOCIAL_LIFECYCLE', 'alpha1'); // 'dev', 'alpha[0-9]+', 'beta[0-9]+', 'rc[0-9]+', 'release'
+define('GNUSOCIAL_LIFECYCLE', 'alpha2'); // 'dev', 'alpha[0-9]+', 'beta[0-9]+', 'rc[0-9]+', 'release'
define('GNUSOCIAL_VERSION', GNUSOCIAL_BASE_VERSION . '-' . GNUSOCIAL_LIFECYCLE);
/** Action object using us. */
var $action = null;
- function __construct(Profile $target, HTMLOutputter $action)
+ // FIXME: Directory plugin sends a User_group here, but should send a Profile and handle User_group specifics itself
+ function __construct($target, HTMLOutputter $action)
{
parent::__construct($action);
function tagUrl($tag)
{
- if ('showstream' === $this->out->trimmed('action')) {
- return common_local_url('showstream', array('nickname' => $this->out->profile->nickname, 'tag' => $tag));
- } else {
- return common_local_url('tag', array('tag' => $tag));
+ if ($this->out instanceof ShowstreamAction) {
+ return common_local_url('showstream', array('nickname' => $this->out->getTarget()->getNickname(), 'tag' => $tag));
}
+ return common_local_url('tag', array('tag' => $tag));
}
function divId()
--- /dev/null
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Base class for RSS 1.0 feed actions
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Mail
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Earle Martin <earle@downlode.org>
+ * @copyright 2008-9 StatusNet, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+if (!defined('GNUSOCIAL')) { exit(1); }
+
+class TargetedRss10Action extends Rss10Action
+{
+ protected $target = null;
+
+ protected function doStreamPreparation()
+ {
+ $this->target = User::getByNickname($this->trimmed('nickname'))->getProfile();
+ }
+
+ function getImage()
+ {
+ return $this->target->avatarUrl(AVATAR_PROFILE_SIZE);
+ }
+}
* @link http://status.net/
*/
-if (!defined('STATUSNET')) {
- exit(1);
-}
-
-require_once INSTALLDIR . '/lib/subscriptionlist.php';
+if (!defined('GNUSOCIAL')) { exit(1); }
/**
* Widget to show a sortable list of subscriptions
*/
class SortableGroupList extends SortableSubscriptionList
{
- /** Owner of this list */
- var $owner = null;
-
- function __construct($profile, $owner=null, $action=null)
- {
- parent::__construct($profile, $owner, $action);
-
- $this->owner = $owner;
- }
-
function startList()
{
$this->out->elementStart('table', array('class' => 'profile_list xoxo'));
$this->out->elementStart('tbody');
}
- function newListItem($profile, $odd)
+ function newListItem($profile)
{
- return new SortableGroupListItem($profile, $this->owner, $this->action, $odd);
+ return new SortableGroupListItem($profile, $this->owner, $this->action);
}
}
class SortableGroupListItem extends SortableSubscriptionListItem
{
- /** Owner of this list */
- var $owner = null;
-
- function __construct($profile, $owner, $action, $alt)
- {
- parent::__construct($profile, $owner, $action, $alt);
-
- $this->alt = $alt; // is this row alternate?
- $this->owner = $owner;
- }
-
function showHomepage()
{
if (!empty($this->profile->homepage)) {
*/
class SortableSubscriptionList extends SubscriptionList
{
- /** Owner of this list */
- var $owner = null;
-
- function __construct($profile, $owner=null, $action=null)
- {
- parent::__construct($profile, $owner, $action);
-
- $this->owner = $owner;
- }
-
function startList()
{
$this->out->elementStart('table', array('class' => 'profile_list xoxo'));
class SortableSubscriptionListItem extends SubscriptionListItem
{
- /** Owner of this list */
- var $owner = null;
-
- function __construct($profile, $owner, $action)
- {
- parent::__construct($profile, $owner, $action);
-
- $this->owner = $owner;
- }
-
function startItem()
{
$attr = array(
* @link http://status.net/
*/
-if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
-}
-
-require_once INSTALLDIR.'/lib/personalgroupnav.php';
-require_once INSTALLDIR.'/lib/noticelist.php';
-require_once INSTALLDIR.'/lib/feedlist.php';
+if (!defined('GNUSOCIAL')) { exit(1); }
/**
* List of replies
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
-class ShowfavoritesAction extends Action
+class ShowfavoritesAction extends ShowstreamAction
{
- /** User we're getting the faves of */
- var $user = null;
- /** Page of the faves we're on */
- var $page = null;
-
- /**
- * Is this a read-only page?
- *
- * @return boolean true
- */
- function isReadOnly($args)
- {
- return true;
- }
-
- /**
- * Title of the page
- *
- * Includes name of user and page number.
- *
- * @return string title of page
- */
function title()
{
if ($this->page == 1) {
// TRANS: Title for first page of favourite notices of a user.
// TRANS: %s is the user for whom the favourite notices are displayed.
- return sprintf(_('%s\'s favorite notices'), $this->user->nickname);
+ return sprintf(_('%s\'s favorite notices'), $this->getTarget()->getNickname());
} else {
// TRANS: Title for all but the first page of favourite notices of a user.
// TRANS: %1$s is the user for whom the favourite notices are displayed, %2$d is the page number.
return sprintf(_('%1$s\'s favorite notices, page %2$d'),
- $this->user->nickname,
+ $this->getTarget()->getNickname(),
$this->page);
}
}
- /**
- * Prepare the object
- *
- * Check the input values and initialize the object.
- * Shows an error page on bad input.
- *
- * @param array $args $_REQUEST data
- *
- * @return boolean success flag
- */
- function prepare($args)
+ public function getStream()
{
- parent::prepare($args);
-
- $nickname = common_canonical_nickname($this->arg('nickname'));
-
- $this->user = User::getKV('nickname', $nickname);
-
- if (!$this->user) {
- // TRANS: Client error displayed when trying to display favourite notices for a non-existing user.
- $this->clientError(_('No such user.'));
- }
-
- $this->page = $this->trimmed('page');
-
- if (!$this->page) {
- $this->page = 1;
- }
-
- common_set_returnto($this->selfUrl());
-
- $cur = common_current_user();
-
- // Show imported/gateway notices as well as local if
- // the user is looking at their own favorites, otherwise not.
- $this->notice = Fave::stream($this->user->id,
- ($this->page-1)*NOTICES_PER_PAGE, // offset
- NOTICES_PER_PAGE + 1, // limit
- (!empty($cur) && $cur->id == $this->user->id) // own feed?
- );
-
- if (empty($this->notice)) {
- // TRANS: Server error displayed when favourite notices could not be retrieved from the database.
- $this->serverError(_('Could not retrieve favorite notices.'));
- }
-
- if($this->page > 1 && $this->notice->N == 0){
- // TRANS: Client error when page not found (404)
- $this->clientError(_('No such page.'), 404);
- }
-
- return true;
- }
-
- /**
- * Handle a request
- *
- * Just show the page. All args already handled.
- *
- * @param array $args $_REQUEST data
- *
- * @return void
- */
- function handle($args)
- {
- parent::handle($args);
- $this->showPage();
+ $own = $this->scoped instanceof Profile ? $this->scoped->sameAs($this->getTarget()) : false;
+ return new FaveNoticeStream($this->getTarget()->getID(), $own);
}
- /**
- * Feeds for the <head> section
- *
- * @return array Feed objects to show
- */
function getFeeds()
{
return array(new Feed(Feed::JSON,
*
* @return void
*/
- function showContent()
+ function showNotices()
{
$nl = new FavoritesNoticeList($this->notice, $this);
$this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
$this->page, 'showfavorites',
- array('nickname' => $this->user->nickname));
+ array('nickname' => $this->getTarget()->getNickname()));
}
function showPageNotice() {
$action->elementStart('div', 'entity_actions');
$action->elementStart('p', array('id' => 'entity_remote_subscribe',
'class' => 'entity_subscribe'));
- $action->element('a', array('href' => common_local_url($action->getTarget()),
+ $action->element('a', array('href' => common_local_url($target),
'class' => 'entity_remote_subscribe'),
// TRANS: Link text for link to remote subscribe.
_m('Remote'));
*/
public function __construct($xml=null) {
if (!empty($xml)) {
- $dom = DOMDocument::loadXML($xml);
- if (!$dom instanceof DOMDocument) {
+ $dom = new DOMDocument();
+ if (!$dom->loadXML($xml)) {
throw new ServerException('Tried to load malformed XML as DOM');
} elseif (!$this->fromDom($dom)) {
throw new ServerException('Could not load MagicEnvelope from DOM');
* @link http://status.net/
*/
-if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
/**
* A list of the user's subscriptions
if ($this->page == 1) {
// TRANS: Header for subscriptions overview for a user (first page).
// TRANS: %s is a user nickname.
- return sprintf(_m('%s\'s search subscriptions'), $this->user->nickname);
+ return sprintf(_m('%s\'s search subscriptions'), $this->getTarget()->getNickname());
} else {
// TRANS: Header for subscriptions overview for a user (not first page).
// TRANS: %1$s is a user nickname, %2$d is the page number.
return sprintf(_m('%1$s\'s search subscriptions, page %2$d'),
- $this->user->nickname,
+ $this->getTarget()->getNickname(),
$this->page);
}
}
function showPageNotice()
{
- $user = common_current_user();
- if ($user && ($user->id == $this->profile->id)) {
+ if ($this->scoped instanceof Profile && $this->scoped->sameAs($this->getTarget())) {
$this->element('p', null,
// TRANS: Page notice for page with an overview of all search subscriptions
// TRANS: of the logged in user's own profile.
// TRANS: Page notice for page with an overview of all subscriptions of a user other
// TRANS: than the logged in user. %s is the user nickname.
sprintf(_m('%s has subscribed to receive all notices on this site matching the following searches:'),
- $this->profile->nickname));
+ $this->getTarget()->getNickname()));
}
}
$cnt = 0;
$searchsub = new SearchSub();
- $searchsub->profile_id = $this->user->id;
+ $searchsub->profile_id = $this->getTarget()->getID();
$searchsub->limit($limit, $offset);
$searchsub->find();
if ($searchsub->N) {
- $list = new SearchSubscriptionsList($searchsub, $this->user, $this);
+ $list = new SearchSubscriptionsList($searchsub, $this->getTarget(), $this);
$cnt = $list->show();
if (0 == $cnt) {
$this->showEmptyListMessage();
$this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
$this->page, 'searchsubs',
- array('nickname' => $this->user->nickname));
+ array('nickname' => $this->getTarget()->getNickname()));
Event::handle('EndShowTagSubscriptionsContent', array($this));
function showEmptyListMessage()
{
if (common_logged_in()) {
- $current_user = common_current_user();
- if ($this->user->id === $current_user->id) {
+ if ($this->scoped->sameAs($this->getTarget())) {
// TRANS: Search subscription list text when the logged in user has no search subscriptions.
$message = _m('You are not subscribed to any text searches right now. You can push the "Subscribe" button ' .
'on any notice text search to automatically receive any public messages on this site that match that ' .
} else {
// TRANS: Search subscription list text when looking at the subscriptions for a of a user other
// TRANS: than the logged in user that has no search subscriptions. %s is the user nickname.
- $message = sprintf(_m('%s is not subscribed to any searches.'), $this->user->nickname);
+ $message = sprintf(_m('%s is not subscribed to any searches.'), $this->getTarget()->getNickname());
}
}
else {
// TRANS: Subscription list text when looking at the subscriptions for a of a user that has none
// TRANS: as an anonymous user. %s is the user nickname.
- $message = sprintf(_m('%s is not subscribed to any searches.'), $this->user->nickname);
+ $message = sprintf(_m('%s is not subscribed to any searches.'), $this->getTarget()->getNickname());
}
$this->elementStart('div', 'guide');
* @link http://status.net/
*/
-if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
/**
* A list of the user's subscriptions
if ($this->page == 1) {
// TRANS: Header for subscriptions overview for a user (first page).
// TRANS: %s is a user nickname.
- return sprintf(_m('%s\'s tag subscriptions'), $this->user->nickname);
+ return sprintf(_m('%s\'s tag subscriptions'), $this->getTarget()->getNickname());
} else {
// TRANS: Header for subscriptions overview for a user (not first page).
// TRANS: %1$s is a user nickname, %2$d is the page number.
return sprintf(_m('%1$s\'s tag subscriptions, page %2$d'),
- $this->user->nickname,
+ $this->getTarget()->getNickname(),
$this->page);
}
}
function showPageNotice()
{
- $user = common_current_user();
- if ($user && ($user->id == $this->profile->id)) {
+ if ($this->scoped instanceof Profile && $this->scoped->sameAs($this->getTarget())) {
$this->element('p', null,
// TRANS: Page notice for page with an overview of all tag subscriptions
// TRANS: of the logged in user's own profile.
// TRANS: Page notice for page with an overview of all subscriptions of a user other
// TRANS: than the logged in user. %s is the user nickname.
sprintf(_m('%s has subscribed to receive all notices on this site containing the following tags:'),
- $this->profile->nickname));
+ $this->getTarget()->getNickname()));
}
}
$cnt = 0;
$tagsub = new TagSub();
- $tagsub->profile_id = $this->user->id;
+ $tagsub->profile_id = $this->getTarget()->getID();
$tagsub->limit($limit, $offset);
$tagsub->find();
if ($tagsub->N) {
- $list = new TagSubscriptionsList($tagsub, $this->user, $this);
+ $list = new TagSubscriptionsList($tagsub, $this->getTarget(), $this);
$cnt = $list->show();
if (0 == $cnt) {
$this->showEmptyListMessage();
$this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
$this->page, 'tagsubs',
- array('nickname' => $this->user->nickname));
+ array('nickname' => $this->getTarget()->getNickname()));
Event::handle('EndShowTagSubscriptionsContent', array($this));
function showEmptyListMessage()
{
if (common_logged_in()) {
- $current_user = common_current_user();
- if ($this->user->id === $current_user->id) {
+ if ($this->scoped->sameAs($this->getTarget())) {
// TRANS: Tag subscription list text when the logged in user has no tag subscriptions.
$message = _m('You are not listening to any hash tags right now. You can push the "Subscribe" button ' .
'on any hashtag page to automatically receive any public messages on this site that use that ' .
} else {
// TRANS: Tag subscription list text when looking at the subscriptions for a of a user other
// TRANS: than the logged in user that has no tag subscriptions. %s is the user nickname.
- $message = sprintf(_m('%s is not following any tags.'), $this->user->nickname);
+ $message = sprintf(_m('%s is not following any tags.'), $this->getTarget()->getNickname());
}
}
else {
// TRANS: Subscription list text when looking at the subscriptions for a of a user that has none
// TRANS: as an anonymous user. %s is the user nickname.
- $message = sprintf(_m('%s is not following any tags.'), $this->user->nickname);
+ $message = sprintf(_m('%s is not following any tags.'), $this->getTarget()->getNickname());
}
$this->elementStart('div', 'guide');