Merge branch 'nightly' into deletenotice_form_fix
This commit is contained in:
commit
6c4985476e
@ -39,8 +39,6 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||||||
|
|
||||||
class AllAction extends ShowstreamAction
|
class AllAction extends ShowstreamAction
|
||||||
{
|
{
|
||||||
var $notice;
|
|
||||||
|
|
||||||
public function getStream()
|
public function getStream()
|
||||||
{
|
{
|
||||||
if ($this->scoped instanceof Profile && $this->scoped->isLocal() && $this->scoped->getUser()->streamModeOnly()) {
|
if ($this->scoped instanceof Profile && $this->scoped->isLocal() && $this->scoped->getUser()->streamModeOnly()) {
|
||||||
@ -54,7 +52,7 @@ class AllAction extends ShowstreamAction
|
|||||||
|
|
||||||
function title()
|
function title()
|
||||||
{
|
{
|
||||||
if (!empty($this->scoped) && $this->scoped->id == $this->target->id) {
|
if (!empty($this->scoped) && $this->scoped->sameAs($this->target)) {
|
||||||
// TRANS: Title of a user's own start page.
|
// TRANS: Title of a user's own start page.
|
||||||
return _('Home timeline');
|
return _('Home timeline');
|
||||||
} else {
|
} else {
|
||||||
@ -71,44 +69,44 @@ class AllAction extends ShowstreamAction
|
|||||||
common_local_url(
|
common_local_url(
|
||||||
'ApiTimelineFriends', array(
|
'ApiTimelineFriends', array(
|
||||||
'format' => 'as',
|
'format' => 'as',
|
||||||
'id' => $this->target->nickname
|
'id' => $this->target->getNickname()
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
// TRANS: %s is user nickname.
|
// TRANS: %s is user nickname.
|
||||||
sprintf(_('Feed for friends of %s (Activity Streams JSON)'), $this->target->nickname)),
|
sprintf(_('Feed for friends of %s (Activity Streams JSON)'), $this->target->getNickname())),
|
||||||
new Feed(Feed::RSS1,
|
new Feed(Feed::RSS1,
|
||||||
common_local_url(
|
common_local_url(
|
||||||
'allrss', array(
|
'allrss', array(
|
||||||
'nickname' =>
|
'nickname' =>
|
||||||
$this->target->nickname)
|
$this->target->getNickname())
|
||||||
),
|
),
|
||||||
// TRANS: %s is user nickname.
|
// TRANS: %s is user nickname.
|
||||||
sprintf(_('Feed for friends of %s (RSS 1.0)'), $this->target->nickname)),
|
sprintf(_('Feed for friends of %s (RSS 1.0)'), $this->target->getNickname())),
|
||||||
new Feed(Feed::RSS2,
|
new Feed(Feed::RSS2,
|
||||||
common_local_url(
|
common_local_url(
|
||||||
'ApiTimelineFriends', array(
|
'ApiTimelineFriends', array(
|
||||||
'format' => 'rss',
|
'format' => 'rss',
|
||||||
'id' => $this->target->nickname
|
'id' => $this->target->getNickname()
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
// TRANS: %s is user nickname.
|
// TRANS: %s is user nickname.
|
||||||
sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->target->nickname)),
|
sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->target->getNickname())),
|
||||||
new Feed(Feed::ATOM,
|
new Feed(Feed::ATOM,
|
||||||
common_local_url(
|
common_local_url(
|
||||||
'ApiTimelineFriends', array(
|
'ApiTimelineFriends', array(
|
||||||
'format' => 'atom',
|
'format' => 'atom',
|
||||||
'id' => $this->target->nickname
|
'id' => $this->target->getNickname()
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
// TRANS: %s is user nickname.
|
// TRANS: %s is user nickname.
|
||||||
sprintf(_('Feed for friends of %s (Atom)'), $this->target->nickname))
|
sprintf(_('Feed for friends of %s (Atom)'), $this->target->getNickname()))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function showEmptyListMessage()
|
function showEmptyListMessage()
|
||||||
{
|
{
|
||||||
// TRANS: Empty list message. %s is a user nickname.
|
// TRANS: Empty list message. %s is a user nickname.
|
||||||
$message = sprintf(_('This is the timeline for %s and friends but no one has posted anything yet.'), $this->target->nickname) . ' ';
|
$message = sprintf(_('This is the timeline for %s and friends but no one has posted anything yet.'), $this->target->getNickname()) . ' ';
|
||||||
|
|
||||||
if (common_logged_in()) {
|
if (common_logged_in()) {
|
||||||
if ($this->target->id === $this->scoped->id) {
|
if ($this->target->id === $this->scoped->id) {
|
||||||
@ -118,12 +116,12 @@ class AllAction extends ShowstreamAction
|
|||||||
} else {
|
} else {
|
||||||
// TRANS: %1$s is user nickname, %2$s is user nickname, %2$s is user nickname prefixed with "@".
|
// TRANS: %1$s is user nickname, %2$s is user nickname, %2$s is user nickname prefixed with "@".
|
||||||
// TRANS: This message contains Markdown links. Keep "](" together.
|
// TRANS: This message contains Markdown links. Keep "](" together.
|
||||||
$message .= sprintf(_('You can try to [nudge %1$s](../%2$s) from their profile or [post something to them](%%%%action.newnotice%%%%?status_textarea=%3$s).'), $this->target->nickname, $this->target->nickname, '@' . $this->target->nickname);
|
$message .= sprintf(_('You can try to [nudge %1$s](../%2$s) from their profile or [post something to them](%%%%action.newnotice%%%%?status_textarea=%3$s).'), $this->target->getNickname(), $this->target->getNickname(), '@' . $this->target->getNickname());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// TRANS: Encouragement displayed on empty timeline user pages for anonymous users.
|
// TRANS: Encouragement displayed on empty timeline user pages for anonymous users.
|
||||||
// TRANS: %s is a user nickname. This message contains Markdown links. Keep "](" together.
|
// TRANS: %s is a user nickname. This message contains Markdown links. Keep "](" together.
|
||||||
$message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to them.'), $this->target->nickname);
|
$message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to them.'), $this->target->getNickname());
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->elementStart('div', 'guide');
|
$this->elementStart('div', 'guide');
|
||||||
@ -134,19 +132,10 @@ class AllAction extends ShowstreamAction
|
|||||||
function showContent()
|
function showContent()
|
||||||
{
|
{
|
||||||
if (Event::handle('StartShowAllContent', array($this))) {
|
if (Event::handle('StartShowAllContent', array($this))) {
|
||||||
|
if ($this->scoped instanceof Profile && $this->scoped->isLocal() && $this->scoped->getUser()->streamModeOnly()) {
|
||||||
$profile = null;
|
|
||||||
|
|
||||||
$current_user = common_current_user();
|
|
||||||
|
|
||||||
if (!empty($current_user)) {
|
|
||||||
$profile = $current_user->getProfile();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($current_user) && $current_user->streamModeOnly()) {
|
|
||||||
$nl = new PrimaryNoticeList($this->notice, $this, array('show_n'=>NOTICES_PER_PAGE));
|
$nl = new PrimaryNoticeList($this->notice, $this, array('show_n'=>NOTICES_PER_PAGE));
|
||||||
} else {
|
} else {
|
||||||
$nl = new ThreadedNoticeList($this->notice, $this, $profile);
|
$nl = new ThreadedNoticeList($this->notice, $this, $this->scoped);
|
||||||
}
|
}
|
||||||
|
|
||||||
$cnt = $nl->show();
|
$cnt = $nl->show();
|
||||||
@ -157,7 +146,7 @@ class AllAction extends ShowstreamAction
|
|||||||
|
|
||||||
$this->pagination(
|
$this->pagination(
|
||||||
$this->page > 1, $cnt > NOTICES_PER_PAGE,
|
$this->page > 1, $cnt > NOTICES_PER_PAGE,
|
||||||
$this->page, 'all', array('nickname' => $this->target->nickname)
|
$this->page, 'all', array('nickname' => $this->target->getNickname())
|
||||||
);
|
);
|
||||||
|
|
||||||
Event::handle('EndShowAllContent', array($this));
|
Event::handle('EndShowAllContent', array($this));
|
||||||
|
@ -28,11 +28,7 @@
|
|||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
// This check helps protect against security problems;
|
|
||||||
// your code file can't be executed directly from the web.
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redirect to a given URL
|
* Redirect to a given URL
|
||||||
@ -47,75 +43,27 @@ if (!defined('STATUSNET')) {
|
|||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class RedirecturlAction extends Action
|
class RedirecturlAction extends ManagedAction
|
||||||
{
|
{
|
||||||
protected $id = null;
|
|
||||||
protected $file = null;
|
protected $file = null;
|
||||||
|
|
||||||
/**
|
protected function doPreparation()
|
||||||
* For initializing members of the class.
|
|
||||||
*
|
|
||||||
* @param array $argarray misc. arguments
|
|
||||||
*
|
|
||||||
* @return boolean true
|
|
||||||
*/
|
|
||||||
function prepare($argarray)
|
|
||||||
{
|
{
|
||||||
parent::prepare($argarray);
|
$this->file = File::getByID($this->int('id'));
|
||||||
|
|
||||||
$this->id = $this->trimmed('id');
|
|
||||||
|
|
||||||
if (empty($this->id)) {
|
|
||||||
// TRANS: Client exception thrown when no ID parameter was provided.
|
|
||||||
throw new ClientException(_('No id parameter.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->file = File::getKV('id', $this->id);
|
|
||||||
|
|
||||||
if (empty($this->file)) {
|
|
||||||
// TRANS: Client exception thrown when an invalid ID parameter was provided for a file.
|
|
||||||
// TRANS: %d is the provided ID for which the file is not present (number).
|
|
||||||
throw new ClientException(sprintf(_('No such file "%d".'),
|
|
||||||
$this->id),
|
|
||||||
404);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function showPage()
|
||||||
* Handler method
|
|
||||||
*
|
|
||||||
* @param array $argarray is ignored since it's now passed in in prepare()
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function handle($argarray=null)
|
|
||||||
{
|
{
|
||||||
common_redirect($this->file->url, 307);
|
common_redirect($this->file->url, 307);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return true if read only.
|
|
||||||
*
|
|
||||||
* MAY override
|
|
||||||
*
|
|
||||||
* @param array $args other arguments
|
|
||||||
*
|
|
||||||
* @return boolean is read only action?
|
|
||||||
*/
|
|
||||||
function isReadOnly($args)
|
function isReadOnly($args)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return last modified, if applicable.
|
|
||||||
*
|
|
||||||
* MAY override
|
|
||||||
*
|
|
||||||
* @return string last modified http header
|
|
||||||
*/
|
|
||||||
function lastModified()
|
function lastModified()
|
||||||
{
|
{
|
||||||
// For comparison with If-Last-Modified
|
// For comparison with If-Last-Modified
|
||||||
@ -133,9 +81,9 @@ class RedirecturlAction extends Action
|
|||||||
*/
|
*/
|
||||||
function etag()
|
function etag()
|
||||||
{
|
{
|
||||||
return 'W/"' . implode(':', array($this->arg('action'),
|
return 'W/"' . implode(':', array($this->getActionName(),
|
||||||
common_user_cache_hash(),
|
common_user_cache_hash(),
|
||||||
common_language(),
|
common_language(),
|
||||||
$this->file->id)) . '"';
|
$this->file->getID())) . '"';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,9 +40,6 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||||||
*/
|
*/
|
||||||
class RepliesAction extends ShowstreamAction
|
class RepliesAction extends ShowstreamAction
|
||||||
{
|
{
|
||||||
var $page = null;
|
|
||||||
var $notice;
|
|
||||||
|
|
||||||
public function getStream()
|
public function getStream()
|
||||||
{
|
{
|
||||||
return new ReplyNoticeStream($this->target->getID(), $this->scoped);
|
return new ReplyNoticeStream($this->target->getID(), $this->scoped);
|
||||||
@ -85,7 +82,7 @@ class RepliesAction extends ShowstreamAction
|
|||||||
// TRANS: Link for feed with replies for a user.
|
// TRANS: Link for feed with replies for a user.
|
||||||
// TRANS: %s is a user nickname.
|
// TRANS: %s is a user nickname.
|
||||||
sprintf(_('Replies feed for %s (Activity Streams JSON)'),
|
sprintf(_('Replies feed for %s (Activity Streams JSON)'),
|
||||||
$this->user->nickname)),
|
$this->target->getNickname())),
|
||||||
new Feed(Feed::RSS1,
|
new Feed(Feed::RSS1,
|
||||||
common_local_url('repliesrss',
|
common_local_url('repliesrss',
|
||||||
array('nickname' => $this->target->getNickname())),
|
array('nickname' => $this->target->getNickname())),
|
||||||
|
@ -47,16 +47,15 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||||||
*/
|
*/
|
||||||
class ShowstreamAction extends NoticestreamAction
|
class ShowstreamAction extends NoticestreamAction
|
||||||
{
|
{
|
||||||
var $notice;
|
protected $target = null;
|
||||||
|
|
||||||
protected function doPreparation()
|
protected function doPreparation()
|
||||||
{
|
{
|
||||||
// showstream requires a nickname
|
// showstream requires a nickname
|
||||||
$nickname_arg = $this->arg('nickname');
|
$nickname_arg = $this->trimmed('nickname');
|
||||||
$nickname = common_canonical_nickname($nickname_arg);
|
$nickname = common_canonical_nickname($nickname_arg);
|
||||||
|
|
||||||
// Permanent redirect on non-canonical nickname
|
// Permanent redirect on non-canonical nickname
|
||||||
|
|
||||||
if ($nickname_arg != $nickname) {
|
if ($nickname_arg != $nickname) {
|
||||||
$args = array('nickname' => $nickname);
|
$args = array('nickname' => $nickname);
|
||||||
if ($this->arg('page') && $this->arg('page') != 1) {
|
if ($this->arg('page') && $this->arg('page') != 1) {
|
||||||
@ -64,18 +63,20 @@ class ShowstreamAction extends NoticestreamAction
|
|||||||
}
|
}
|
||||||
common_redirect(common_local_url($this->getActionName(), $args), 301);
|
common_redirect(common_local_url($this->getActionName(), $args), 301);
|
||||||
}
|
}
|
||||||
$this->user = User::getKV('nickname', $nickname);
|
|
||||||
|
|
||||||
if (!$this->user) {
|
try {
|
||||||
|
$user = User::getByNickname($nickname);
|
||||||
|
} catch (NoSuchUserException $e) {
|
||||||
$group = Local_group::getKV('nickname', $nickname);
|
$group = Local_group::getKV('nickname', $nickname);
|
||||||
if ($group instanceof Local_group) {
|
if ($group instanceof Local_group) {
|
||||||
common_redirect($group->getProfile()->getUrl());
|
common_redirect($group->getProfile()->getUrl());
|
||||||
}
|
}
|
||||||
// TRANS: Client error displayed when calling a profile action without specifying a user.
|
|
||||||
$this->clientError(_('No such user.'), 404);
|
// No user nor group found, throw the NoSuchUserException again
|
||||||
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->target = $this->user->getProfile();
|
$this->target = $user->getProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStream()
|
public function getStream()
|
||||||
@ -289,7 +290,7 @@ class ShowstreamAction extends NoticestreamAction
|
|||||||
{
|
{
|
||||||
parent::showSections();
|
parent::showSections();
|
||||||
if (!common_config('performance', 'high')) {
|
if (!common_config('performance', 'high')) {
|
||||||
$cloud = new PersonalTagCloudSection($this, $this->user);
|
$cloud = new PersonalTagCloudSection($this->target, $this);
|
||||||
$cloud->show();
|
$cloud->show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -298,7 +299,7 @@ class ShowstreamAction extends NoticestreamAction
|
|||||||
{
|
{
|
||||||
$options = parent::noticeFormOptions();
|
$options = parent::noticeFormOptions();
|
||||||
|
|
||||||
if (!$this->scoped instanceof Profile || $this->scoped->id != $this->target->id) {
|
if (!$this->scoped instanceof Profile || !$this->scoped->sameAs($this->target)) {
|
||||||
$options['to_profile'] = $this->target;
|
$options['to_profile'] = $this->target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1571,6 +1571,11 @@ class Profile extends Managed_DataObject
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function sameAs(Profile $other)
|
||||||
|
{
|
||||||
|
return $this->getID() === $other->getID();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This will perform shortenLinks with the connected User object.
|
* This will perform shortenLinks with the connected User object.
|
||||||
*
|
*
|
||||||
|
@ -132,6 +132,11 @@ class User extends Managed_DataObject
|
|||||||
return $this->_profile[$this->id];
|
return $this->_profile[$this->id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function sameAs(Profile $other)
|
||||||
|
{
|
||||||
|
return $this->getProfile()->sameAs($other);
|
||||||
|
}
|
||||||
|
|
||||||
public function getUri()
|
public function getUri()
|
||||||
{
|
{
|
||||||
return $this->uri;
|
return $this->uri;
|
||||||
@ -142,7 +147,7 @@ class User extends Managed_DataObject
|
|||||||
return $this->getProfile()->getNickname();
|
return $this->getProfile()->getNickname();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getByNickname($nickname)
|
static function getByNickname($nickname)
|
||||||
{
|
{
|
||||||
$user = User::getKV('nickname', $nickname);
|
$user = User::getKV('nickname', $nickname);
|
||||||
if (!$user instanceof User) {
|
if (!$user instanceof User) {
|
||||||
|
@ -563,14 +563,12 @@ abstract class ImPlugin extends Plugin
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onEndShowHeadElements($action)
|
function onEndShowHeadElements(Action $action)
|
||||||
{
|
{
|
||||||
$aname = $action->trimmed('action');
|
if ($action instanceof ShownoticeAction) {
|
||||||
|
|
||||||
if ($aname == 'shownotice') {
|
|
||||||
|
|
||||||
$user_im_prefs = new User_im_prefs();
|
$user_im_prefs = new User_im_prefs();
|
||||||
$user_im_prefs->user_id = $action->profile->id;
|
$user_im_prefs->user_id = $action->notice->getProfile()->getID();
|
||||||
$user_im_prefs->transport = $this->transport;
|
$user_im_prefs->transport = $this->transport;
|
||||||
|
|
||||||
if ($user_im_prefs->find() && $user_im_prefs->fetch() && $user_im_prefs->microid && $action->notice->uri) {
|
if ($user_im_prefs->find() && $user_im_prefs->fetch() && $user_im_prefs->microid && $action->notice->uri) {
|
||||||
@ -580,13 +578,13 @@ abstract class ImPlugin extends Plugin
|
|||||||
'content' => $id->toString()));
|
'content' => $id->toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if ($aname == 'showstream') {
|
} elseif ($action instanceof ShowstreamAction) {
|
||||||
|
|
||||||
$user_im_prefs = new User_im_prefs();
|
$user_im_prefs = new User_im_prefs();
|
||||||
$user_im_prefs->user_id = $action->user->id;
|
$user_im_prefs->user_id = $action->getTarget()->getID();
|
||||||
$user_im_prefs->transport = $this->transport;
|
$user_im_prefs->transport = $this->transport;
|
||||||
|
|
||||||
if ($user_im_prefs->find() && $user_im_prefs->fetch() && $user_im_prefs->microid && $action->profile->profileurl) {
|
if ($user_im_prefs->find() && $user_im_prefs->fetch() && $user_im_prefs->microid && $action->getTarget()->getUrl()) {
|
||||||
$id = new Microid($this->microiduri($user_im_prefs->screenname),
|
$id = new Microid($this->microiduri($user_im_prefs->screenname),
|
||||||
$action->selfUrl());
|
$action->selfUrl());
|
||||||
$action->element('meta', array('name' => 'microid',
|
$action->element('meta', array('name' => 'microid',
|
||||||
|
@ -4,6 +4,7 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||||||
|
|
||||||
abstract class NoticestreamAction extends ProfileAction
|
abstract class NoticestreamAction extends ProfileAction
|
||||||
{
|
{
|
||||||
|
protected $notice = null; // holds the stream result
|
||||||
|
|
||||||
protected function prepare(array $args=array()) {
|
protected function prepare(array $args=array()) {
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
@ -27,9 +27,7 @@
|
|||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Personal tag cloud section
|
* Personal tag cloud section
|
||||||
@ -42,12 +40,12 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
|||||||
*/
|
*/
|
||||||
class PersonalTagCloudSection extends TagCloudSection
|
class PersonalTagCloudSection extends TagCloudSection
|
||||||
{
|
{
|
||||||
var $user = null;
|
protected $profile = null;
|
||||||
|
|
||||||
function __construct($out=null, $user=null)
|
function __construct(Profile $profile, HTMLOutputter $out=null)
|
||||||
{
|
{
|
||||||
parent::__construct($out);
|
parent::__construct($out);
|
||||||
$this->user = $user;
|
$this->profile = $profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
function title()
|
function title()
|
||||||
@ -80,7 +78,7 @@ class PersonalTagCloudSection extends TagCloudSection
|
|||||||
|
|
||||||
$tag = Memcached_DataObject::cachedQuery('Notice_tag',
|
$tag = Memcached_DataObject::cachedQuery('Notice_tag',
|
||||||
sprintf($qry,
|
sprintf($qry,
|
||||||
$this->user->id),
|
$this->profile->getID()),
|
||||||
3600);
|
3600);
|
||||||
return $tag;
|
return $tag;
|
||||||
}
|
}
|
||||||
|
@ -58,9 +58,6 @@ abstract class ProfileAction extends ManagedAction
|
|||||||
throw new ClientException(_('This profile has been silenced by site moderators'), 403);
|
throw new ClientException(_('This profile has been silenced by site moderators'), 403);
|
||||||
}
|
}
|
||||||
|
|
||||||
// backwards compatibility until all actions are fixed to use $this->target
|
|
||||||
$this->profile = $this->target;
|
|
||||||
|
|
||||||
$this->tag = $this->trimmed('tag');
|
$this->tag = $this->trimmed('tag');
|
||||||
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
||||||
common_set_returnto($this->selfUrl());
|
common_set_returnto($this->selfUrl());
|
||||||
@ -75,6 +72,9 @@ abstract class ProfileAction extends ManagedAction
|
|||||||
|
|
||||||
public function getTarget()
|
public function getTarget()
|
||||||
{
|
{
|
||||||
|
if (!$this->target instanceof Profile) {
|
||||||
|
throw new ServerException('No target profile in ProfileAction class');
|
||||||
|
}
|
||||||
return $this->target;
|
return $this->target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,18 +32,25 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||||||
class ProfileListItem extends Widget
|
class ProfileListItem extends Widget
|
||||||
{
|
{
|
||||||
/** Current profile. */
|
/** Current profile. */
|
||||||
|
protected $target = null;
|
||||||
var $profile = null;
|
var $profile = null;
|
||||||
/** Action object using us. */
|
/** Action object using us. */
|
||||||
var $action = null;
|
var $action = null;
|
||||||
|
|
||||||
function __construct($profile, $action)
|
function __construct(Profile $target, HTMLOutputter $action)
|
||||||
{
|
{
|
||||||
parent::__construct($action);
|
parent::__construct($action);
|
||||||
|
|
||||||
$this->profile = $profile;
|
$this->target = $target;
|
||||||
|
$this->profile = $this->target;
|
||||||
$this->action = $action;
|
$this->action = $action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getTarget()
|
||||||
|
{
|
||||||
|
return $this->target;
|
||||||
|
}
|
||||||
|
|
||||||
function show()
|
function show()
|
||||||
{
|
{
|
||||||
if (Event::handle('StartProfileListItem', array($this))) {
|
if (Event::handle('StartProfileListItem', array($this))) {
|
||||||
|
@ -17,13 +17,10 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
class ProfileDetailAction extends ShowstreamAction
|
class ProfileDetailAction extends ShowstreamAction
|
||||||
{
|
{
|
||||||
|
|
||||||
function isReadOnly($args)
|
function isReadOnly($args)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@ -31,7 +28,7 @@ class ProfileDetailAction extends ShowstreamAction
|
|||||||
|
|
||||||
function title()
|
function title()
|
||||||
{
|
{
|
||||||
return $this->profile->getFancyName();
|
return $this->target->getFancyName();
|
||||||
}
|
}
|
||||||
|
|
||||||
function showStylesheets() {
|
function showStylesheets() {
|
||||||
@ -43,7 +40,7 @@ class ProfileDetailAction extends ShowstreamAction
|
|||||||
function showContent()
|
function showContent()
|
||||||
{
|
{
|
||||||
$cur = common_current_user();
|
$cur = common_current_user();
|
||||||
if ($cur && $cur->id == $this->profile->id) { // your own page
|
if ($this->scoped instanceof Profile && $this->scoped->sameAs($this->target)) {
|
||||||
$this->elementStart('div', 'entity_actions');
|
$this->elementStart('div', 'entity_actions');
|
||||||
$this->elementStart('ul');
|
$this->elementStart('ul');
|
||||||
$this->elementStart('li', 'entity_edit');
|
$this->elementStart('li', 'entity_edit');
|
||||||
@ -57,7 +54,7 @@ class ProfileDetailAction extends ShowstreamAction
|
|||||||
$this->elementEnd('div');
|
$this->elementEnd('div');
|
||||||
}
|
}
|
||||||
|
|
||||||
$widget = new ExtendedProfileWidget($this, $this->profile);
|
$widget = new ExtendedProfileWidget($this, $this->target);
|
||||||
$widget->show();
|
$widget->show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,25 +57,27 @@ class GeoURLPlugin extends Plugin
|
|||||||
*
|
*
|
||||||
* @return boolean event handler flag
|
* @return boolean event handler flag
|
||||||
*/
|
*/
|
||||||
function onEndShowHeadElements($action)
|
function onEndShowHeadElements(Action $action)
|
||||||
{
|
{
|
||||||
$name = $action->trimmed('action');
|
$name = $action->trimmed('action');
|
||||||
|
|
||||||
$location = null;
|
$location = null;
|
||||||
|
|
||||||
if ($name == 'showstream') {
|
if ($action instanceof ShowstreamAction) {
|
||||||
$profile = $action->profile;
|
$profile = $action->getTarget();
|
||||||
if (!empty($profile) && !empty($profile->lat) && !empty($profile->lon)) {
|
if (!empty($profile->lat) && !empty($profile->lon)) {
|
||||||
$location = $profile->lat . ', ' . $profile->lon;
|
$location = $profile->lat . ', ' . $profile->lon;
|
||||||
}
|
}
|
||||||
} else if ($name == 'shownotice') {
|
} elseif ($action instanceof ShownoticeAction) {
|
||||||
$notice = $action->profile;
|
// FIXME: getNotice in ShownoticeAction will do a new lookup, we should fix those classes
|
||||||
if (!empty($notice) && !empty($notice->lat) && !empty($notice->lon)) {
|
// so they can reliably just get a pre-stored notice object which was fetched in Shownotice prepare()...
|
||||||
|
$notice = $action->notice;
|
||||||
|
if ($notice instanceof Notice && !empty($notice->lat) && !empty($notice->lon)) {
|
||||||
$location = $notice->lat . ', ' . $notice->lon;
|
$location = $notice->lat . ', ' . $notice->lon;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($location)) {
|
if (!is_null($location)) {
|
||||||
$action->element('meta', array('name' => 'ICBM',
|
$action->element('meta', array('name' => 'ICBM',
|
||||||
'content' => $location));
|
'content' => $location));
|
||||||
$action->element('meta', array('name' => 'DC.title',
|
$action->element('meta', array('name' => 'DC.title',
|
||||||
|
@ -101,10 +101,10 @@ class ModLogPlugin extends Plugin
|
|||||||
|
|
||||||
$modlog->profile_id = $profile->id;
|
$modlog->profile_id = $profile->id;
|
||||||
|
|
||||||
$cur = common_current_user();
|
$scoped = Profile::current();
|
||||||
|
|
||||||
if (!empty($cur)) {
|
if ($scoped instanceof Profile) {
|
||||||
$modlog->moderator_id = $cur->id;
|
$modlog->moderator_id = $scoped->getID();
|
||||||
}
|
}
|
||||||
|
|
||||||
$modlog->role = $role;
|
$modlog->role = $role;
|
||||||
@ -118,21 +118,22 @@ class ModLogPlugin extends Plugin
|
|||||||
|
|
||||||
function onEndShowSections(Action $action)
|
function onEndShowSections(Action $action)
|
||||||
{
|
{
|
||||||
if ($action->arg('action') != 'showstream') {
|
if (!$action instanceof ShowstreamAction) {
|
||||||
|
// early return for actions we're not interested in
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cur = common_current_user();
|
$scoped = $action->getScoped();
|
||||||
|
if (!$scoped instanceof Profile || !$scoped->hasRight(self::VIEWMODLOG)) {
|
||||||
if (empty($cur) || !$cur->hasRight(self::VIEWMODLOG)) {
|
// only continue if we are allowed to VIEWMODLOG
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile = $action->profile;
|
$profile = $action->getTarget();
|
||||||
|
|
||||||
$ml = new ModLog();
|
$ml = new ModLog();
|
||||||
|
|
||||||
$ml->profile_id = $profile->id;
|
$ml->profile_id = $profile->getID();
|
||||||
$ml->orderBy("created");
|
$ml->orderBy("created");
|
||||||
|
|
||||||
$cnt = $ml->find();
|
$cnt = $ml->find();
|
||||||
@ -152,13 +153,13 @@ class ModLogPlugin extends Plugin
|
|||||||
$action->element('td', null, sprintf(($ml->is_grant) ? _('+%s') : _('-%s'), $ml->role));
|
$action->element('td', null, sprintf(($ml->is_grant) ? _('+%s') : _('-%s'), $ml->role));
|
||||||
$action->elementStart('td');
|
$action->elementStart('td');
|
||||||
if ($ml->moderator_id) {
|
if ($ml->moderator_id) {
|
||||||
$mod = Profile::getKV('id', $ml->moderator_id);
|
$mod = Profile::getByID($ml->moderator_id);
|
||||||
if (empty($mod)) {
|
if (empty($mod)) {
|
||||||
$action->text(_('[unknown]'));
|
$action->text(_('[unknown]'));
|
||||||
} else {
|
} else {
|
||||||
$action->element('a', array('href' => $mod->profileurl,
|
$action->element('a', array('href' => $mod->getUrl(),
|
||||||
'title' => $mod->fullname),
|
'title' => $mod->getFullname()),
|
||||||
$mod->nickname);
|
$mod->getNickname());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$action->text(_('[unknown]'));
|
$action->text(_('[unknown]'));
|
||||||
|
@ -1063,12 +1063,16 @@ class OStatusPlugin extends Plugin
|
|||||||
|
|
||||||
function showEntityRemoteSubscribe($action, $target='ostatussub')
|
function showEntityRemoteSubscribe($action, $target='ostatussub')
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
if (!$action->getScoped() instanceof Profile) {
|
||||||
if ($user && ($user->id == $action->profile->id)) {
|
// early return if we're not logged in
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action->getScoped()->sameAs($action->getTarget())) {
|
||||||
$action->elementStart('div', 'entity_actions');
|
$action->elementStart('div', 'entity_actions');
|
||||||
$action->elementStart('p', array('id' => 'entity_remote_subscribe',
|
$action->elementStart('p', array('id' => 'entity_remote_subscribe',
|
||||||
'class' => 'entity_subscribe'));
|
'class' => 'entity_subscribe'));
|
||||||
$action->element('a', array('href' => common_local_url($target),
|
$action->element('a', array('href' => common_local_url($action->getTarget()),
|
||||||
'class' => 'entity_remote_subscribe'),
|
'class' => 'entity_remote_subscribe'),
|
||||||
// TRANS: Link text for link to remote subscribe.
|
// TRANS: Link text for link to remote subscribe.
|
||||||
_m('Remote'));
|
_m('Remote'));
|
||||||
@ -1127,42 +1131,45 @@ class OStatusPlugin extends Plugin
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onStartProfileListItemActionElements($item, $profile=null)
|
// FIXME: This one can accept both an Action and a Widget. Confusing! Refactor to (HTMLOutputter $out, Profile $target)!
|
||||||
|
function onStartProfileListItemActionElements($item)
|
||||||
{
|
{
|
||||||
if (!common_logged_in()) {
|
if (common_logged_in()) {
|
||||||
|
// only non-logged in users get to see the "remote subscribe" form
|
||||||
$profileUser = User::getKV('id', $item->profile->id);
|
return true;
|
||||||
|
} elseif (!$item->getTarget()->isLocal()) {
|
||||||
if (!empty($profileUser)) {
|
// we can (for now) only provide remote subscribe forms for local users
|
||||||
|
return true;
|
||||||
if ($item instanceof Action) {
|
|
||||||
$output = $item;
|
|
||||||
$profile = $item->profile;
|
|
||||||
} else {
|
|
||||||
$output = $item->out;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add an OStatus subscribe
|
|
||||||
$output->elementStart('li', 'entity_subscribe');
|
|
||||||
$url = common_local_url('ostatusinit',
|
|
||||||
array('nickname' => $profileUser->nickname));
|
|
||||||
$output->element('a', array('href' => $url,
|
|
||||||
'class' => 'entity_remote_subscribe'),
|
|
||||||
// TRANS: Link text for a user to subscribe to an OStatus user.
|
|
||||||
_m('Subscribe'));
|
|
||||||
$output->elementEnd('li');
|
|
||||||
|
|
||||||
$output->elementStart('li', 'entity_tag');
|
|
||||||
$url = common_local_url('ostatustag',
|
|
||||||
array('nickname' => $profileUser->nickname));
|
|
||||||
$output->element('a', array('href' => $url,
|
|
||||||
'class' => 'entity_remote_tag'),
|
|
||||||
// TRANS: Link text for a user to list an OStatus user.
|
|
||||||
_m('List'));
|
|
||||||
$output->elementEnd('li');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($item instanceof ProfileAction) {
|
||||||
|
$output = $item;
|
||||||
|
} elseif ($item instanceof Widget) {
|
||||||
|
$output = $item->out;
|
||||||
|
} else {
|
||||||
|
// Bad $item class, don't know how to use this for outputting!
|
||||||
|
throw new ServerException('Bad item type for onStartProfileListItemActionElements');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add an OStatus subscribe
|
||||||
|
$output->elementStart('li', 'entity_subscribe');
|
||||||
|
$url = common_local_url('ostatusinit',
|
||||||
|
array('nickname' => $item->getTarget()->getNickname()));
|
||||||
|
$output->element('a', array('href' => $url,
|
||||||
|
'class' => 'entity_remote_subscribe'),
|
||||||
|
// TRANS: Link text for a user to subscribe to an OStatus user.
|
||||||
|
_m('Subscribe'));
|
||||||
|
$output->elementEnd('li');
|
||||||
|
|
||||||
|
$output->elementStart('li', 'entity_tag');
|
||||||
|
$url = common_local_url('ostatustag',
|
||||||
|
array('nickname' => $item->getTarget()->getNickname()));
|
||||||
|
$output->element('a', array('href' => $url,
|
||||||
|
'class' => 'entity_remote_tag'),
|
||||||
|
// TRANS: Link text for a user to list an OStatus user.
|
||||||
|
_m('List'));
|
||||||
|
$output->elementEnd('li');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,11 +390,11 @@ class OpenIDPlugin extends Plugin
|
|||||||
$action->element('link', array('rel' => 'openid2.provider',
|
$action->element('link', array('rel' => 'openid2.provider',
|
||||||
'href' => common_local_url('openidserver')));
|
'href' => common_local_url('openidserver')));
|
||||||
$action->element('link', array('rel' => 'openid2.local_id',
|
$action->element('link', array('rel' => 'openid2.local_id',
|
||||||
'href' => $action->profile->profileurl));
|
'href' => $action->getTarget()->getUrl()));
|
||||||
$action->element('link', array('rel' => 'openid.server',
|
$action->element('link', array('rel' => 'openid.server',
|
||||||
'href' => common_local_url('openidserver')));
|
'href' => common_local_url('openidserver')));
|
||||||
$action->element('link', array('rel' => 'openid.delegate',
|
$action->element('link', array('rel' => 'openid.delegate',
|
||||||
'href' => $action->profile->profileurl));
|
'href' => $action->getTarget()->getUrl()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action instanceof SitestreamAction) {
|
if ($action instanceof SitestreamAction) {
|
||||||
|
@ -144,7 +144,7 @@ class WebFingerPlugin extends Plugin
|
|||||||
public function onStartShowHTML($action)
|
public function onStartShowHTML($action)
|
||||||
{
|
{
|
||||||
if ($action instanceof ShowstreamAction) {
|
if ($action instanceof ShowstreamAction) {
|
||||||
$acct = 'acct:'. $action->profile->nickname .'@'. common_config('site', 'server');
|
$acct = 'acct:'. $action->getTarget()->getNickname() .'@'. common_config('site', 'server');
|
||||||
$url = common_local_url('webfinger') . '?resource='.$acct;
|
$url = common_local_url('webfinger') . '?resource='.$acct;
|
||||||
|
|
||||||
foreach (array(Discovery::JRD_MIMETYPE, Discovery::XRD_MIMETYPE) as $type) {
|
foreach (array(Discovery::JRD_MIMETYPE, Discovery::XRD_MIMETYPE) as $type) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user