--- /dev/null
+<?php
+
+if (!defined('GNUSOCIAL')) { exit(1); }
+
+class NetworkpublicAction extends PublicAction
+{
+ protected function streamPrepare()
+ {
+ if (!$this->scoped instanceof Profile && common_config('public', 'localonly')) {
+ $this->serverError(_('Network wide public feed is not permitted without authorization'), 403);
+ }
+ if ($this->scoped instanceof Profile && $this->scoped->isLocal() && $this->scoped->getUser()->streamModeOnly()) {
+ $this->stream = new NetworkPublicNoticeStream($this->scoped);
+ } else {
+ $this->stream = new ThreadingNetworkPublicNoticeStream($this->scoped);
+ }
+ }
+
+ function title()
+ {
+ if ($this->page > 1) {
+ // TRANS: Title for all public timeline pages but the first.
+ // TRANS: %d is the page number.
+ return sprintf(_('Network public timeline, page %d'), $this->page);
+ } else {
+ // TRANS: Title for the first public timeline page.
+ return _('Network public timeline');
+ }
+ }
+
+ function extraHead()
+ {
+ // the PublicAction has some XRDS stuff that might be unique to the non-network public feed
+ // FIXME: Solve this with a call that doesn't rely on parent:: and is unique for each class.
+ ManagedAction::extraHead();
+ }
+
+ function showSections()
+ {
+ // Show invite button, as long as site isn't closed, and
+ // we have a logged in user.
+ if (common_config('invite', 'enabled') && !common_config('site', 'closed') && common_logged_in()) {
+ if (!common_config('site', 'private')) {
+ $ibs = new InviteButtonSection(
+ $this,
+ // TRANS: Button text for inviting more users to the StatusNet instance.
+ // TRANS: Less business/enterprise-oriented language for public sites.
+ _m('BUTTON', 'Send invite')
+ );
+ } else {
+ $ibs = new InviteButtonSection($this);
+ }
+ $ibs->show();
+ }
+
+ // Network public tag cloud?
+ }
+
+ /**
+ * FIXME: Network public feed! Get a template from PublicAction
+ */
+ function getFeeds()
+ {
+ return array();
+ }
+}
* @see PublicrssAction
* @see PublicxrdsAction
*/
-class PublicAction extends Action
+class PublicAction extends ManagedAction
{
/**
* page of the stream we're on; default = 1
return true;
}
- /**
- * Read and validate arguments
- *
- * @param array $args URL parameters
- *
- * @return boolean success value
- */
- protected function prepare(array $args=array())
+ protected function doPreparation()
{
- parent::prepare($args);
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
if ($this->page > MAX_PUBLIC_PAGE) {
}
}
- /**
- * handle request
- *
- * Show the public stream, using recipe method showPage()
- *
- * @param array $args arguments, mostly unused
- *
- * @return void
- */
- protected function handle()
- {
- parent::handle();
-
- $this->showPage();
- }
-
/**
* Title of the page
*
*/
function showContent()
{
- $user = common_current_user();
-
- if (!empty($user) && $user->streamModeOnly()) {
+ if ($this->scoped instanceof Profile && $this->scoped->isLocal() && $this->scoped->getUser()->streamModeOnly()) {
$nl = new PrimaryNoticeList($this->notice, $this, array('show_n'=>NOTICES_PER_PAGE));
} else {
$nl = new ThreadedNoticeList($this->notice, $this, $this->scoped);
}
$this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
- $this->page, 'public');
+ $this->page, $this->action);
}
function showSections()
$this->elementEnd('div');
}
}
-
-class ThreadingPublicNoticeStream extends ThreadingNoticeStream
-{
- function __construct($profile)
- {
- parent::__construct(new PublicNoticeStream($profile));
- }
-}
if ($this->isPublic()) {
$this->blowStream('public');
+ $this->blowStream('networkpublic');
}
self::blow('notice:list-ids:conversation:%s', $this->conversation);
if ($this->isPublic()) {
self::blow('public;last');
+ self::blow('networkpublic;last');
}
self::blow('fave:by_notice', $this->id);
function isPublic()
{
- if (common_config('public', 'localonly')) {
- return ($this->is_local == Notice::LOCAL_PUBLIC);
- } else {
- return (($this->is_local != Notice::LOCAL_NONPUBLIC) &&
- ($this->is_local != Notice::GATEWAY));
- }
+ return (($this->is_local != Notice::LOCAL_NONPUBLIC) &&
+ ($this->is_local != Notice::GATEWAY));
}
/**
--- /dev/null
+<?php
+
+if (!defined('GNUSOCIAL')) { exit(1); }
+
+class NetworkPublicNoticeStream extends ScopingNoticeStream
+{
+ function __construct(Profile $scoped=null)
+ {
+ parent::__construct(new CachingNoticeStream(new RawNetworkPublicNoticeStream(),
+ 'networkpublic'),
+ $scoped);
+ }
+}
+
+/**
+ * Raw public stream
+ *
+ * @category Stream
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @copyright 2011 StatusNet, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
+ * @link http://status.net/
+ */
+
+class RawNetworkPublicNoticeStream extends NoticeStream
+{
+ function getNoticeIds($offset, $limit, $since_id, $max_id)
+ {
+ $notice = new Notice();
+
+ $notice->selectAdd(); // clears it
+ $notice->selectAdd('id');
+
+ $notice->orderBy('created DESC, id DESC');
+
+ if (!is_null($offset)) {
+ $notice->limit($offset, $limit);
+ }
+
+ $notice->whereAdd('is_local ='. Notice::REMOTE);
+ // -1 == blacklisted, -2 == gateway (i.e. Twitter)
+ $notice->whereAdd('is_local !='. Notice::LOCAL_NONPUBLIC);
+ $notice->whereAdd('is_local !='. Notice::GATEWAY);
+
+ Notice::addWhereSinceId($notice, $since_id);
+ Notice::addWhereMaxId($notice, $max_id);
+
+ if (!empty($this->selectVerbs)) {
+ $notice->whereAddIn('verb', $this->selectVerbs, $notice->columnType('verb'));
+ }
+
+ $ids = array();
+
+ if ($notice->find()) {
+ while ($notice->fetch()) {
+ $ids[] = $notice->id;
+ }
+ }
+
+ $notice->free();
+ $notice = NULL;
+
+ return $ids;
+ }
+}
$notice->limit($offset, $limit);
}
- if (common_config('public', 'localonly')) {
- $notice->whereAdd('is_local = ' . Notice::LOCAL_PUBLIC);
- } else {
- // -1 == blacklisted, -2 == gateway (i.e. Twitter)
- $notice->whereAdd('is_local !='. Notice::LOCAL_NONPUBLIC);
- $notice->whereAdd('is_local !='. Notice::GATEWAY);
- }
+ // This feed always gives only local activities.
+ $notice->whereAdd('is_local = ' . Notice::LOCAL_PUBLIC);
Notice::addWhereSinceId($notice, $since_id);
Notice::addWhereMaxId($notice, $max_id);
}
} else {
$m->connect('main/public', array('action' => 'public'));
- $m->connect('', array('action' => 'public'));
$m->connect('main/all', array('action' => 'networkpublic'));
+ if (common_config('site', 'localonly')) {
+ $m->connect('', array('action' => 'public'));
+ } else {
+ $m->connect('', array('action' => 'networkpublic'));
+ }
$m->connect('rss', array('action' => 'publicrss'));
$m->connect('featuredrss', array('action' => 'featuredrss'));
$m->connect('featured/', array('action' => 'featured'));
--- /dev/null
+<?php
+
+if (!defined('GNUSOCIAL')) { exit(1); }
+
+class ThreadingNetworkPublicNoticeStream extends ThreadingNoticeStream
+{
+ public function __construct(Profile $scoped=null)
+ {
+ parent::__construct(new NetworkPublicNoticeStream($scoped));
+ }
+}
--- /dev/null
+<?php
+
+if (!defined('GNUSOCIAL')) { exit(1); }
+
+class ThreadingPublicNoticeStream extends ThreadingNoticeStream
+{
+ function __construct($scoped)
+ {
+ parent::__construct(new PublicNoticeStream($scoped));
+ }
+}