forked from GNUsocial/gnu-social
Merge branch 'nightly' of git.gnu.io:gnu/gnu-social into nightly
This commit is contained in:
commit
c10a4cf6d2
@ -1,7 +1,7 @@
|
|||||||
Plugins
|
Plugins
|
||||||
=======
|
=======
|
||||||
|
|
||||||
Beginning with the 0.7.x branch, StatusNet has supported a simple but
|
GNU social supports a simple but
|
||||||
powerful plugin architecture. Important events in the code are named,
|
powerful plugin architecture. Important events in the code are named,
|
||||||
like 'StartNoticeSave', and other software can register interest
|
like 'StartNoticeSave', and other software can register interest
|
||||||
in those events. When the events happen, the other software is called
|
in those events. When the events happen, the other software is called
|
||||||
@ -37,7 +37,7 @@ can enable a plugin with the following line in config.php:
|
|||||||
|
|
||||||
This will look for and load files named 'ExamplePlugin.php' or
|
This will look for and load files named 'ExamplePlugin.php' or
|
||||||
'Example/ExamplePlugin.php' either in the plugins/ directory (for
|
'Example/ExamplePlugin.php' either in the plugins/ directory (for
|
||||||
plugins that ship with StatusNet) or in the local/ directory (for
|
plugins that ship with GNU social) or in the local/ directory (for
|
||||||
plugins you write yourself or that you get from somewhere else) or
|
plugins you write yourself or that you get from somewhere else) or
|
||||||
local/plugins/.
|
local/plugins/.
|
||||||
|
|
||||||
|
@ -39,9 +39,7 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||||||
|
|
||||||
class AllAction extends ShowstreamAction
|
class AllAction extends ShowstreamAction
|
||||||
{
|
{
|
||||||
var $notice;
|
public function getStream()
|
||||||
|
|
||||||
protected 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()) {
|
||||||
$stream = new InboxNoticeStream($this->target, $this->scoped);
|
$stream = new InboxNoticeStream($this->target, $this->scoped);
|
||||||
@ -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 @@
|
|||||||
* 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') && !defined('LACONICA')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once INSTALLDIR.'/lib/rssaction.php';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RSS feed for user and friends timeline.
|
* RSS feed for user and friends timeline.
|
||||||
@ -46,52 +42,12 @@ require_once INSTALLDIR.'/lib/rssaction.php';
|
|||||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
class AllrssAction extends Rss10Action
|
class AllrssAction extends TargetedRss10Action
|
||||||
{
|
{
|
||||||
var $user = null;
|
protected function getNotices()
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialization.
|
|
||||||
*
|
|
||||||
* @param array $args Web and URL arguments
|
|
||||||
*
|
|
||||||
* @return boolean false if user doesn't exist
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function prepare($args)
|
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
$stream = new InboxNoticeStream($this->target);
|
||||||
$nickname = $this->trimmed('nickname');
|
return $stream->getNotices(0, $this->limit)->fetchAll();
|
||||||
$this->user = User::getKV('nickname', $nickname);
|
|
||||||
|
|
||||||
if (!$this->user) {
|
|
||||||
// TRANS: Client error when user not found for an rss related action.
|
|
||||||
$this->clientError(_('No such user.'));
|
|
||||||
} else {
|
|
||||||
$this->notices = $this->getNotices($this->limit);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get notices
|
|
||||||
*
|
|
||||||
* @param integer $limit max number of notices to return
|
|
||||||
*
|
|
||||||
* @return array notices
|
|
||||||
*/
|
|
||||||
function getNotices($limit=0)
|
|
||||||
{
|
|
||||||
$stream = new InboxNoticeStream($this->user->getProfile());
|
|
||||||
$notice = $stream->getNotices(0, $limit, null, null);
|
|
||||||
|
|
||||||
$notices = array();
|
|
||||||
|
|
||||||
while ($notice->fetch()) {
|
|
||||||
$notices[] = clone($notice);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $notices;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,33 +57,17 @@ class AllrssAction extends Rss10Action
|
|||||||
*/
|
*/
|
||||||
function getChannel()
|
function getChannel()
|
||||||
{
|
{
|
||||||
$user = $this->user;
|
|
||||||
$c = array('url' => common_local_url('allrss',
|
$c = array('url' => common_local_url('allrss',
|
||||||
array('nickname' =>
|
array('nickname' =>
|
||||||
$user->nickname)),
|
$this->target->getNickname())),
|
||||||
// TRANS: Message is used as link title. %s is a user nickname.
|
// TRANS: Message is used as link title. %s is a user nickname.
|
||||||
'title' => sprintf(_('%s and friends'), $user->nickname),
|
'title' => sprintf(_('%s and friends'), $this->target->getNickname()),
|
||||||
'link' => common_local_url('all',
|
'link' => common_local_url('all',
|
||||||
array('nickname' =>
|
array('nickname' =>
|
||||||
$user->nickname)),
|
$this->target->getNickname())),
|
||||||
// TRANS: Message is used as link description. %1$s is a username, %2$s is a site name.
|
// TRANS: Message is used as link description. %1$s is a username, %2$s is a site name.
|
||||||
'description' => sprintf(_('Updates from %1$s and friends on %2$s!'),
|
'description' => sprintf(_('Updates from %1$s and friends on %2$s!'),
|
||||||
$user->nickname, common_config('site', 'name')));
|
$this->target->getNickname(), common_config('site', 'name')));
|
||||||
return $c;
|
return $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get image.
|
|
||||||
*
|
|
||||||
* @return string user avatar URL or null
|
|
||||||
*/
|
|
||||||
function getImage()
|
|
||||||
{
|
|
||||||
$user = $this->user;
|
|
||||||
$profile = $user->getProfile();
|
|
||||||
if (!$profile) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return $profile->avatarUrl(AVATAR_PROFILE_SIZE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -51,19 +51,10 @@ class ApiTimelineTagAction extends ApiPrivateAuthAction
|
|||||||
{
|
{
|
||||||
var $notices = null;
|
var $notices = null;
|
||||||
|
|
||||||
/**
|
protected function prepare(array $args=array())
|
||||||
* Take arguments for running
|
|
||||||
*
|
|
||||||
* @param array $args $_REQUEST args
|
|
||||||
*
|
|
||||||
* @return boolean success flag
|
|
||||||
*/
|
|
||||||
function prepare($args)
|
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
common_debug("apitimelinetag prepare()");
|
|
||||||
|
|
||||||
$this->tag = $this->arg('tag');
|
$this->tag = $this->arg('tag');
|
||||||
$this->notices = $this->getNotices();
|
$this->notices = $this->getNotices();
|
||||||
|
|
||||||
@ -79,9 +70,9 @@ class ApiTimelineTagAction extends ApiPrivateAuthAction
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function handle($args)
|
protected function handle()
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle();
|
||||||
$this->showTimeline();
|
$this->showTimeline();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,21 +163,12 @@ class ApiTimelineTagAction extends ApiPrivateAuthAction
|
|||||||
*/
|
*/
|
||||||
function getNotices()
|
function getNotices()
|
||||||
{
|
{
|
||||||
$notices = array();
|
$notice = Notice_tag::getStream($this->tag)->getNotices(($this->page - 1) * $this->count,
|
||||||
|
$this->count + 1,
|
||||||
|
$this->since_id,
|
||||||
|
$this->max_id);
|
||||||
|
|
||||||
$notice = Notice_tag::getStream(
|
return $notice->fetchAll();
|
||||||
$this->tag,
|
|
||||||
($this->page - 1) * $this->count,
|
|
||||||
$this->count + 1,
|
|
||||||
$this->since_id,
|
|
||||||
$this->max_id
|
|
||||||
);
|
|
||||||
|
|
||||||
while ($notice->fetch()) {
|
|
||||||
$notices[] = clone($notice);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $notices;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,80 +28,24 @@
|
|||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// @todo FIXME: documentation needed.
|
// @todo FIXME: documentation needed.
|
||||||
class DeletenoticeAction extends Action
|
class DeletenoticeAction extends FormAction
|
||||||
{
|
{
|
||||||
var $error = null;
|
protected $notice = null;
|
||||||
var $user = null;
|
|
||||||
var $notice = null;
|
|
||||||
var $profile = null;
|
|
||||||
var $user_profile = null;
|
|
||||||
|
|
||||||
function prepare($args)
|
protected function doPreparation()
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
$this->notice = Notice::getByID($this->trimmed('notice'));
|
||||||
|
|
||||||
$this->user = common_current_user();
|
if (!$this->scoped->sameAs($this->notice->getProfile()) &&
|
||||||
|
!$this->scoped->hasRight(Right::DELETEOTHERSNOTICE)) {
|
||||||
if (!$this->user) {
|
|
||||||
// TRANS: Error message displayed when trying to perform an action that requires a logged in user.
|
|
||||||
common_user_error(_('Not logged in.'));
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$notice_id = $this->trimmed('notice');
|
|
||||||
$this->notice = Notice::getKV($notice_id);
|
|
||||||
|
|
||||||
if (!$this->notice) {
|
|
||||||
// TRANS: Error message displayed trying to delete a non-existing notice.
|
|
||||||
common_user_error(_('No such notice.'));
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->profile = $this->notice->getProfile();
|
|
||||||
$this->user_profile = $this->user->getProfile();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function handle($args)
|
|
||||||
{
|
|
||||||
parent::handle($args);
|
|
||||||
|
|
||||||
if ($this->notice->profile_id != $this->user_profile->id &&
|
|
||||||
!$this->user->hasRight(Right::DELETEOTHERSNOTICE)) {
|
|
||||||
// TRANS: Error message displayed trying to delete a notice that was not made by the current user.
|
// TRANS: Error message displayed trying to delete a notice that was not made by the current user.
|
||||||
common_user_error(_('Cannot delete this notice.'));
|
$this->clientError(_('Cannot delete this notice.'));
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
// XXX: Ajax!
|
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
$this->formOpts['notice'] = $this->notice;
|
||||||
$this->deleteNotice();
|
|
||||||
} else if ($_SERVER['REQUEST_METHOD'] == 'GET') {
|
|
||||||
$this->showForm();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show the page notice
|
|
||||||
*
|
|
||||||
* Shows instructions for the page
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function showPageNotice()
|
|
||||||
{
|
|
||||||
$instr = $this->getInstructions();
|
|
||||||
$output = common_markup_to_html($instr);
|
|
||||||
|
|
||||||
$this->elementStart('div', 'instructions');
|
|
||||||
$this->raw($output);
|
|
||||||
$this->elementEnd('div');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getInstructions()
|
function getInstructions()
|
||||||
@ -117,84 +61,17 @@ class DeletenoticeAction extends Action
|
|||||||
return _('Delete notice');
|
return _('Delete notice');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected function doPost()
|
||||||
* Wrapper for showing a page
|
|
||||||
*
|
|
||||||
* Stores an error and shows the page
|
|
||||||
*
|
|
||||||
* @param string $error Error, if any
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function showForm($error = null)
|
|
||||||
{
|
{
|
||||||
$this->error = $error;
|
|
||||||
$this->showPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Insert delete notice form into the content
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function showContent()
|
|
||||||
{
|
|
||||||
$this->elementStart('form', array('id' => 'form_notice_delete',
|
|
||||||
'class' => 'form_settings',
|
|
||||||
'method' => 'post',
|
|
||||||
'action' => common_local_url('deletenotice')));
|
|
||||||
$this->elementStart('fieldset');
|
|
||||||
// TRANS: Fieldset legend for the delete notice form.
|
|
||||||
$this->element('legend', null, _('Delete notice'));
|
|
||||||
$this->hidden('token', common_session_token());
|
|
||||||
$this->hidden('notice', $this->trimmed('notice'));
|
|
||||||
// TRANS: Message for the delete notice form.
|
|
||||||
$this->element('p', null, _('Are you sure you want to delete this notice?'));
|
|
||||||
$this->submit('form_action-no',
|
|
||||||
// TRANS: Button label on the delete notice form.
|
|
||||||
_m('BUTTON','No'),
|
|
||||||
'submit form_action-primary',
|
|
||||||
'no',
|
|
||||||
// TRANS: Submit button title for 'No' when deleting a notice.
|
|
||||||
_('Do not delete this notice.'));
|
|
||||||
$this->submit('form_action-yes',
|
|
||||||
// TRANS: Button label on the delete notice form.
|
|
||||||
_m('BUTTON','Yes'),
|
|
||||||
'submit form_action-secondary',
|
|
||||||
'yes',
|
|
||||||
// TRANS: Submit button title for 'Yes' when deleting a notice.
|
|
||||||
_('Delete this notice.'));
|
|
||||||
$this->elementEnd('fieldset');
|
|
||||||
$this->elementEnd('form');
|
|
||||||
}
|
|
||||||
|
|
||||||
function deleteNotice()
|
|
||||||
{
|
|
||||||
// CSRF protection
|
|
||||||
$token = $this->trimmed('token');
|
|
||||||
|
|
||||||
if (!$token || $token != common_session_token()) {
|
|
||||||
// TRANS: Client error displayed when the session token does not match or is not given.
|
|
||||||
$this->showForm(_('There was a problem with your session token. ' .
|
|
||||||
'Try again, please.'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->arg('yes')) {
|
if ($this->arg('yes')) {
|
||||||
if (Event::handle('StartDeleteOwnNotice', array($this->user, $this->notice))) {
|
if (Event::handle('StartDeleteOwnNotice', array($this->scoped->getUser(), $this->notice))) {
|
||||||
$this->notice->delete();
|
$this->notice->delete();
|
||||||
Event::handle('EndDeleteOwnNotice', array($this->user, $this->notice));
|
Event::handle('EndDeleteOwnNotice', array($this->scoped->getUser(), $this->notice));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$url = common_get_returnto();
|
|
||||||
|
|
||||||
if ($url) {
|
|
||||||
common_set_returnto(null);
|
|
||||||
} else {
|
} else {
|
||||||
$url = common_local_url('public');
|
common_redirect(common_get_returnto(), 303);
|
||||||
}
|
}
|
||||||
|
|
||||||
common_redirect($url, 303);
|
common_redirect(common_local_url('top'), 303);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,24 +17,22 @@
|
|||||||
* 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') && !defined('LACONICA')) { exit(1); }
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
|
|
||||||
define('LISTENER', 1);
|
define('LISTENER', 1);
|
||||||
define('LISTENEE', -1);
|
define('LISTENEE', -1);
|
||||||
define('BOTH', 0);
|
define('BOTH', 0);
|
||||||
|
|
||||||
// @todo XXX: Documentation missing.
|
// @todo XXX: Documentation missing.
|
||||||
class FoafAction extends Action
|
class FoafAction extends ManagedAction
|
||||||
{
|
{
|
||||||
function isReadOnly($args)
|
function isReadOnly($args)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepare($args)
|
protected function doPreparation()
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
|
||||||
|
|
||||||
$nickname_arg = $this->arg('nickname');
|
$nickname_arg = $this->arg('nickname');
|
||||||
|
|
||||||
if (empty($nickname_arg)) {
|
if (empty($nickname_arg)) {
|
||||||
@ -69,10 +67,8 @@ class FoafAction extends Action
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function handle($args)
|
public function showPage()
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
|
||||||
|
|
||||||
header('Content-Type: application/rdf+xml');
|
header('Content-Type: application/rdf+xml');
|
||||||
|
|
||||||
$this->startXML();
|
$this->startXML();
|
||||||
|
@ -28,11 +28,7 @@
|
|||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once INSTALLDIR.'/lib/rssaction.php';
|
|
||||||
|
|
||||||
define('MEMBERS_PER_SECTION', 27);
|
define('MEMBERS_PER_SECTION', 27);
|
||||||
|
|
||||||
@ -45,10 +41,10 @@ define('MEMBERS_PER_SECTION', 27);
|
|||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
class groupRssAction extends Rss10Action
|
class GroupRssAction extends TargetedRss10Action
|
||||||
{
|
{
|
||||||
/** group we're viewing. */
|
/** group we're viewing. */
|
||||||
var $group = null;
|
protected $group = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is this page read-only?
|
* Is this page read-only?
|
||||||
@ -60,18 +56,8 @@ class groupRssAction extends Rss10Action
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected function doStreamPreparation()
|
||||||
* Prepare the action
|
|
||||||
*
|
|
||||||
* Reads and validates arguments and instantiates the attributes.
|
|
||||||
*
|
|
||||||
* @param array $args $_REQUEST args
|
|
||||||
*
|
|
||||||
* @return boolean success flag
|
|
||||||
*/
|
|
||||||
function prepare($args)
|
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
|
||||||
|
|
||||||
$nickname_arg = $this->arg('nickname');
|
$nickname_arg = $this->arg('nickname');
|
||||||
$nickname = common_canonical_nickname($nickname_arg);
|
$nickname = common_canonical_nickname($nickname_arg);
|
||||||
@ -90,52 +76,32 @@ class groupRssAction extends Rss10Action
|
|||||||
|
|
||||||
$local = Local_group::getKV('nickname', $nickname);
|
$local = Local_group::getKV('nickname', $nickname);
|
||||||
|
|
||||||
if (!$local) {
|
if (!$local instanceof Local_group) {
|
||||||
// TRANS: Client error displayed when requesting a group RSS feed for group that does not exist.
|
// TRANS: Client error displayed when requesting a group RSS feed for group that does not exist.
|
||||||
$this->clientError(_('No such group.'), 404);
|
$this->clientError(_('No such group.'), 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->group = User_group::getKV('id', $local->group_id);
|
$this->group = $local->getGroup();
|
||||||
|
$this->target = $this->group->getProfile();
|
||||||
if (!$this->group) {
|
|
||||||
// TRANS: Client error displayed when requesting a group RSS feed for an object that is not a group.
|
|
||||||
$this->clientError(_('No such group.'), 404);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->notices = $this->getNotices($this->limit);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNotices($limit=0)
|
protected function getNotices()
|
||||||
{
|
{
|
||||||
$group = $this->group;
|
$stream = $this->group->getNotices(0, $this->limit);
|
||||||
|
return $stream->fetchAll();
|
||||||
if (is_null($group)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$notices = array();
|
|
||||||
$notice = $group->getNotices(0, ($limit == 0) ? NOTICES_PER_PAGE : $limit);
|
|
||||||
|
|
||||||
while ($notice->fetch()) {
|
|
||||||
$notices[] = clone($notice);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $notices;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getChannel()
|
function getChannel()
|
||||||
{
|
{
|
||||||
$group = $this->group;
|
|
||||||
$c = array('url' => common_local_url('grouprss',
|
$c = array('url' => common_local_url('grouprss',
|
||||||
array('nickname' =>
|
array('nickname' =>
|
||||||
$group->nickname)),
|
$this->target->getNickname())),
|
||||||
// TRANS: Message is used as link title. %s is a user nickname.
|
// TRANS: Message is used as link title. %s is a user nickname.
|
||||||
'title' => sprintf(_('%s timeline'), $group->nickname),
|
'title' => sprintf(_('%s timeline'), $this->target->getNickname()),
|
||||||
'link' => common_local_url('showgroup', array('nickname' => $group->nickname)),
|
'link' => common_local_url('showgroup', array('nickname' => $this->target->getNickname())),
|
||||||
// TRANS: Message is used as link description. %1$s is a group name, %2$s is a site name.
|
// TRANS: Message is used as link description. %1$s is a group name, %2$s is a site name.
|
||||||
'description' => sprintf(_('Updates from members of %1$s on %2$s!'),
|
'description' => sprintf(_('Updates from members of %1$s on %2$s!'),
|
||||||
$group->nickname, common_config('site', 'name')));
|
$this->target->getNickname(), common_config('site', 'name')));
|
||||||
return $c;
|
return $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ class LogoutAction extends ManagedAction
|
|||||||
}
|
}
|
||||||
Event::handle('EndLogout', array($this));
|
Event::handle('EndLogout', array($this));
|
||||||
|
|
||||||
common_redirect(common_local_url('startpage'));
|
common_redirect(common_local_url('top'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accessed through the action on events
|
// Accessed through the action on events
|
||||||
|
@ -28,11 +28,7 @@
|
|||||||
* 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') && !defined('LACONICA')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once INSTALLDIR.'/lib/rssaction.php';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RSS feed for notice search action class.
|
* RSS feed for notice search action class.
|
||||||
@ -48,19 +44,7 @@ require_once INSTALLDIR.'/lib/rssaction.php';
|
|||||||
*/
|
*/
|
||||||
class NoticesearchrssAction extends Rss10Action
|
class NoticesearchrssAction extends Rss10Action
|
||||||
{
|
{
|
||||||
function init()
|
protected function getNotices()
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function prepare($args)
|
|
||||||
{
|
|
||||||
parent::prepare($args);
|
|
||||||
$this->notices = $this->getNotices();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getNotices($limit=0)
|
|
||||||
{
|
{
|
||||||
$q = $this->trimmed('q');
|
$q = $this->trimmed('q');
|
||||||
$notices = array();
|
$notices = array();
|
||||||
@ -70,8 +54,7 @@ class NoticesearchrssAction extends Rss10Action
|
|||||||
$search_engine = $notice->getSearchEngine('notice');
|
$search_engine = $notice->getSearchEngine('notice');
|
||||||
$search_engine->set_sort_mode('chron');
|
$search_engine->set_sort_mode('chron');
|
||||||
|
|
||||||
if (!$limit) $limit = 20;
|
$search_engine->limit(0, $this->limit, true);
|
||||||
$search_engine->limit(0, $limit, true);
|
|
||||||
if (false === $search_engine->query($q)) {
|
if (false === $search_engine->query($q)) {
|
||||||
$cnt = 0;
|
$cnt = 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -62,7 +62,7 @@ class PluginsadminpanelAction extends AdminPanelAction
|
|||||||
{
|
{
|
||||||
// TRANS: Instructions at top of plugin admin page.
|
// TRANS: Instructions at top of plugin admin page.
|
||||||
return _('Additional plugins can be enabled and configured manually. ' .
|
return _('Additional plugins can be enabled and configured manually. ' .
|
||||||
'See the <a href="http://status.net/wiki/Plugins">online plugin ' .
|
'See the <a href="https://git.gnu.io/gnu/gnu-social/blob/master/plugins/README.md">online plugin ' .
|
||||||
'documentation</a> for more details.');
|
'documentation</a> for more details.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,11 +28,7 @@
|
|||||||
* 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') && !defined('LACONICA')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once INSTALLDIR.'/lib/rssaction.php';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RSS feed for public timeline.
|
* RSS feed for public timeline.
|
||||||
@ -48,29 +44,6 @@ require_once INSTALLDIR.'/lib/rssaction.php';
|
|||||||
*/
|
*/
|
||||||
class PublicrssAction extends Rss10Action
|
class PublicrssAction extends Rss10Action
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Read arguments and initialize members
|
|
||||||
*
|
|
||||||
* @param array $args Arguments from $_REQUEST
|
|
||||||
* @return boolean success
|
|
||||||
*/
|
|
||||||
function prepare($args)
|
|
||||||
{
|
|
||||||
parent::prepare($args);
|
|
||||||
$this->notices = $this->getNotices($this->limit);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialization.
|
|
||||||
*
|
|
||||||
* @return boolean true
|
|
||||||
*/
|
|
||||||
function init()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get notices
|
* Get notices
|
||||||
*
|
*
|
||||||
@ -78,15 +51,10 @@ class PublicrssAction extends Rss10Action
|
|||||||
*
|
*
|
||||||
* @return array notices
|
* @return array notices
|
||||||
*/
|
*/
|
||||||
function getNotices($limit=0)
|
protected function getNotices()
|
||||||
{
|
{
|
||||||
$notices = array();
|
$stream = Notice::publicStream(0, $this->limit);
|
||||||
$notice = Notice::publicStream(0, ($limit == 0) ? 48 : $limit);
|
return $stream->fetchAll();
|
||||||
while ($notice->fetch()) {
|
|
||||||
$notices[] = clone($notice);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $notices;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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,10 +40,7 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||||||
*/
|
*/
|
||||||
class RepliesAction extends ShowstreamAction
|
class RepliesAction extends ShowstreamAction
|
||||||
{
|
{
|
||||||
var $page = null;
|
public function getStream()
|
||||||
var $notice;
|
|
||||||
|
|
||||||
protected 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())),
|
||||||
|
@ -17,70 +17,34 @@
|
|||||||
* 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') && !defined('LACONICA')) { exit(1); }
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/lib/rssaction.php');
|
|
||||||
|
|
||||||
// Formatting of RSS handled by Rss10Action
|
// Formatting of RSS handled by Rss10Action
|
||||||
|
|
||||||
class RepliesrssAction extends Rss10Action
|
class RepliesrssAction extends TargetedRss10Action
|
||||||
{
|
{
|
||||||
var $user = null;
|
protected function getNotices()
|
||||||
|
|
||||||
function prepare($args)
|
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
$stream = $this->target->getReplies(0, $this->limit);
|
||||||
$nickname = $this->trimmed('nickname');
|
return $stream->fetchAll();
|
||||||
$this->user = User::getKV('nickname', $nickname);
|
|
||||||
|
|
||||||
if (!$this->user) {
|
|
||||||
// TRANS: Client error displayed when providing a non-existing nickname in a RSS 1.0 action.
|
|
||||||
$this->clientError(_('No such user.'));
|
|
||||||
} else {
|
|
||||||
$this->notices = $this->getNotices($this->limit);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getNotices($limit=0)
|
|
||||||
{
|
|
||||||
$user = $this->user;
|
|
||||||
|
|
||||||
$notice = $user->getReplies(0, ($limit == 0) ? 48 : $limit);
|
|
||||||
|
|
||||||
$notices = array();
|
|
||||||
|
|
||||||
while ($notice->fetch()) {
|
|
||||||
$notices[] = clone($notice);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $notices;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getChannel()
|
function getChannel()
|
||||||
{
|
{
|
||||||
$user = $this->user;
|
|
||||||
$c = array('url' => common_local_url('repliesrss',
|
$c = array('url' => common_local_url('repliesrss',
|
||||||
array('nickname' =>
|
array('nickname' =>
|
||||||
$user->nickname)),
|
$this->target->getNickname())),
|
||||||
// TRANS: RSS reply feed title. %s is a user nickname.
|
// TRANS: RSS reply feed title. %s is a user nickname.
|
||||||
'title' => sprintf(_("Replies to %s"), $user->nickname),
|
'title' => sprintf(_("Replies to %s"), $this->target->getNickname()),
|
||||||
'link' => common_local_url('replies',
|
'link' => common_local_url('replies',
|
||||||
array('nickname' =>
|
array('nickname' => $this->target->getNickname())),
|
||||||
$user->nickname)),
|
|
||||||
// TRANS: RSS reply feed description.
|
// TRANS: RSS reply feed description.
|
||||||
// TRANS: %1$s is a user nickname, %2$s is the StatusNet site name.
|
// TRANS: %1$s is a user nickname, %2$s is the StatusNet site name.
|
||||||
'description' => sprintf(_('Replies to %1$s on %2$s.'),
|
'description' => sprintf(_('Replies to %1$s on %2$s.'),
|
||||||
$user->nickname, common_config('site', 'name')));
|
$this->target->getNickname(), common_config('site', 'name')));
|
||||||
return $c;
|
return $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getImage()
|
|
||||||
{
|
|
||||||
$profile = $this->user->getProfile();
|
|
||||||
return $profile->avatarUrl(AVATAR_PROFILE_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
function isReadOnly($args)
|
function isReadOnly($args)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
@ -27,9 +27,7 @@
|
|||||||
* 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints out a static robots.txt
|
* Prints out a static robots.txt
|
||||||
@ -40,19 +38,9 @@ if (!defined('STATUSNET')) {
|
|||||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
class RobotstxtAction extends Action
|
class RobotstxtAction extends ManagedAction
|
||||||
{
|
{
|
||||||
/**
|
public function showPage()
|
||||||
* Handles requests
|
|
||||||
*
|
|
||||||
* Since this is a relatively static document, we
|
|
||||||
* don't do a prepare()
|
|
||||||
*
|
|
||||||
* @param array $args GET, POST, and URL params; unused.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function handle($args)
|
|
||||||
{
|
{
|
||||||
if (Event::handle('StartRobotsTxt', array($this))) {
|
if (Event::handle('StartRobotsTxt', array($this))) {
|
||||||
|
|
||||||
|
@ -45,18 +45,17 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
class ShowstreamAction extends ProfileAction
|
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,32 +63,23 @@ class ShowstreamAction extends ProfileAction
|
|||||||
}
|
}
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function profileActionPreparation()
|
public function getStream()
|
||||||
{
|
|
||||||
$stream = $this->getStream();
|
|
||||||
$this->notice = $stream->getNotices(($this->page-1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
|
|
||||||
|
|
||||||
if ($this->page > 1 && $this->notice->N == 0) {
|
|
||||||
// TRANS: Client error when page not found (404).
|
|
||||||
$this->clientError(_('No such page.'), 404);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getStream()
|
|
||||||
{
|
{
|
||||||
if (empty($this->tag)) {
|
if (empty($this->tag)) {
|
||||||
$stream = new ProfileNoticeStream($this->target, $this->scoped);
|
$stream = new ProfileNoticeStream($this->target, $this->scoped);
|
||||||
@ -300,7 +290,7 @@ class ShowstreamAction extends ProfileAction
|
|||||||
{
|
{
|
||||||
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -309,7 +299,7 @@ class ShowstreamAction extends ProfileAction
|
|||||||
{
|
{
|
||||||
$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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Startpage action. Decides what to show on the first page.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
|
||||||
|
|
||||||
class StartpageAction extends ManagedAction
|
|
||||||
{
|
|
||||||
function isReadOnly($args)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function showPage()
|
|
||||||
{
|
|
||||||
if (common_config('singleuser', 'enabled')) {
|
|
||||||
$user = User::singleUser();
|
|
||||||
common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)), 303);
|
|
||||||
} elseif (common_config('public', 'localonly')) {
|
|
||||||
common_redirect(common_local_url('public'), 303);
|
|
||||||
} else {
|
|
||||||
common_redirect(common_local_url('networkpublic'), 303);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -28,9 +28,7 @@
|
|||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of the user's subscriptions
|
* A list of the user's subscriptions
|
||||||
@ -60,7 +58,7 @@ class SubscriptionsAction extends GalleryAction
|
|||||||
|
|
||||||
function showPageNotice()
|
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,
|
$this->element('p', null,
|
||||||
// TRANS: Page notice for page with an overview of all subscriptions
|
// TRANS: Page notice for page with an overview of all subscriptions
|
||||||
// TRANS: of the logged in user's own profile.
|
// TRANS: of the logged in user's own profile.
|
||||||
|
@ -46,7 +46,8 @@ class TagAction extends ManagedAction
|
|||||||
|
|
||||||
common_set_returnto($this->selfUrl());
|
common_set_returnto($this->selfUrl());
|
||||||
|
|
||||||
$this->notice = Notice_tag::getStream($this->tag, (($this->page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
|
$this->notice = Notice_tag::getStream($this->tag)->getNotices(($this->page-1)*NOTICES_PER_PAGE,
|
||||||
|
NOTICES_PER_PAGE + 1);
|
||||||
|
|
||||||
if($this->page > 1 && $this->notice->N == 0){
|
if($this->page > 1 && $this->notice->N == 0){
|
||||||
// TRANS: Client error when page not found (404).
|
// TRANS: Client error when page not found (404).
|
||||||
|
@ -17,42 +17,28 @@
|
|||||||
* 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') && !defined('LACONICA')) { exit(1); }
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/lib/rssaction.php');
|
|
||||||
|
|
||||||
// Formatting of RSS handled by Rss10Action
|
// Formatting of RSS handled by Rss10Action
|
||||||
|
|
||||||
class TagrssAction extends Rss10Action
|
class TagrssAction extends Rss10Action
|
||||||
{
|
{
|
||||||
var $tag;
|
protected $tag;
|
||||||
|
|
||||||
function prepare($args) {
|
protected function doStreamPreparation()
|
||||||
parent::prepare($args);
|
{
|
||||||
$tag = common_canonical_tag($this->trimmed('tag'));
|
$tag = common_canonical_tag($this->trimmed('tag'));
|
||||||
$this->tag = Notice_tag::getKV('tag', $tag);
|
$this->tag = Notice_tag::getKV('tag', $tag);
|
||||||
if (!$this->tag) {
|
if (!$this->tag instanceof Notice_tag) {
|
||||||
// TRANS: Client error when requesting a tag feed for a non-existing tag.
|
// TRANS: Client error when requesting a tag feed for a non-existing tag.
|
||||||
$this->clientError(_('No such tag.'));
|
$this->clientError(_('No such tag.'));
|
||||||
} else {
|
|
||||||
$this->notices = $this->getNotices($this->limit);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNotices($limit=0)
|
protected function getNotices()
|
||||||
{
|
{
|
||||||
$tag = $this->tag;
|
$stream = Notice_tag::getStream($this->tag->tag)->getNotices(0, $this->limit);
|
||||||
|
return $stream->fetchAll();
|
||||||
if (is_null($tag)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$notice = Notice_tag::getStream($tag->tag, 0, ($limit == 0) ? NOTICES_PER_PAGE : $limit);
|
|
||||||
while ($notice->fetch()) {
|
|
||||||
$notices[] = clone($notice);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $notices;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getChannel()
|
function getChannel()
|
||||||
|
@ -20,67 +20,29 @@
|
|||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* @category Top
|
|
||||||
* @package StatusNet
|
|
||||||
* @author Evan Prodromou <evan@status.net>
|
|
||||||
* @copyright 2010 StatusNet, Inc.
|
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
|
||||||
// This check helps protect against security problems;
|
|
||||||
// your code file can't be executed directly from the web.
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An action to redirect to the top of the site
|
|
||||||
*
|
|
||||||
* @category Action
|
* @category Action
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
|
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||||
* @copyright 2010 StatusNet, Inc.
|
* @copyright 2010 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
* @copyright 2015 Free Software Foundation, Inc.
|
||||||
* @link http://status.net/
|
* @license https://www.gnu.org/licenses/agpl-3.0.html AGPL 3.0
|
||||||
|
* @link https://gnu.io/social
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class TopAction extends Action
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
|
|
||||||
|
class TopAction extends ManagedAction
|
||||||
{
|
{
|
||||||
/**
|
public function showPage()
|
||||||
* For initializing members of the class.
|
|
||||||
*
|
|
||||||
* @param array $argarray misc. arguments
|
|
||||||
*
|
|
||||||
* @return boolean true
|
|
||||||
*/
|
|
||||||
|
|
||||||
function prepare($argarray)
|
|
||||||
{
|
|
||||||
parent::prepare($argarray);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handler method
|
|
||||||
*
|
|
||||||
* @param array $argarray is ignored since it's now passed in in prepare()
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
|
|
||||||
function handle($argarray=null)
|
|
||||||
{
|
{
|
||||||
if (common_config('singleuser', 'enabled')) {
|
if (common_config('singleuser', 'enabled')) {
|
||||||
$url = common_local_url('showstream', array('nickname' => User::singleUserNickname()));
|
$user = User::singleUser();
|
||||||
|
common_redirect(common_local_url('showstream', array('nickname' => $user->getNickname())), 303);
|
||||||
|
} elseif (common_config('public', 'localonly')) {
|
||||||
|
common_redirect(common_local_url('public'), 303);
|
||||||
} else {
|
} else {
|
||||||
$url = common_local_url('public');
|
common_redirect(common_local_url('networkpublic'), 303);
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX: Permanent? I think so.
|
|
||||||
|
|
||||||
common_redirect($url, 301);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,12 +52,12 @@ class UsergroupsAction extends GalleryAction
|
|||||||
if ($this->page == 1) {
|
if ($this->page == 1) {
|
||||||
// TRANS: Page title for first page of groups for a user.
|
// TRANS: Page title for first page of groups for a user.
|
||||||
// TRANS: %s is a nickname.
|
// TRANS: %s is a nickname.
|
||||||
return sprintf(_('%s groups'), $this->user->nickname);
|
return sprintf(_('%s groups'), $this->getTarget()->getNickname());
|
||||||
} else {
|
} else {
|
||||||
// TRANS: Page title for all but the first page of groups for a user.
|
// 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.
|
// TRANS: %1$s is a nickname, %2$d is a page number.
|
||||||
return sprintf(_('%1$s groups, page %2$d'),
|
return sprintf(_('%1$s groups, page %2$d'),
|
||||||
$this->user->nickname,
|
$this->getTarget()->getNickname(),
|
||||||
$this->page);
|
$this->page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -82,14 +82,14 @@ class UsergroupsAction extends GalleryAction
|
|||||||
$offset = ($this->page-1) * GROUPS_PER_PAGE;
|
$offset = ($this->page-1) * GROUPS_PER_PAGE;
|
||||||
$limit = GROUPS_PER_PAGE + 1;
|
$limit = GROUPS_PER_PAGE + 1;
|
||||||
|
|
||||||
$groups = $this->user->getGroups($offset, $limit);
|
$groups = $this->getTarget()->getGroups($offset, $limit);
|
||||||
|
|
||||||
if ($groups instanceof User_group) {
|
if ($groups instanceof User_group) {
|
||||||
$gl = new GroupList($groups, $this->user, $this);
|
$gl = new GroupList($groups, $this->getTarget(), $this);
|
||||||
$cnt = $gl->show();
|
$cnt = $gl->show();
|
||||||
$this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE,
|
$this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE,
|
||||||
$this->page, 'usergroups',
|
$this->page, 'usergroups',
|
||||||
array('nickname' => $this->user->nickname));
|
array('nickname' => $this->getTarget()->getNickname()));
|
||||||
} else {
|
} else {
|
||||||
$this->showEmptyListMessage();
|
$this->showEmptyListMessage();
|
||||||
}
|
}
|
||||||
@ -102,11 +102,11 @@ class UsergroupsAction extends GalleryAction
|
|||||||
{
|
{
|
||||||
// TRANS: Text on group page for a user that is not a member of any group.
|
// TRANS: Text on group page for a user that is not a member of any group.
|
||||||
// TRANS: %s is a user nickname.
|
// 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()) {
|
if (common_logged_in()) {
|
||||||
$current_user = common_current_user();
|
$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: 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.
|
// 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.');
|
$message .= _('Try [searching for groups](%%action.groupsearch%%) and joining them.');
|
||||||
@ -119,7 +119,7 @@ class UsergroupsAction extends GalleryAction
|
|||||||
|
|
||||||
function showProfileBlock()
|
function showProfileBlock()
|
||||||
{
|
{
|
||||||
$block = new AccountProfileBlock($this, $this->profile);
|
$block = new AccountProfileBlock($this, $this->getTarget());
|
||||||
$block->show();
|
$block->show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,100 +17,52 @@
|
|||||||
* 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') && !defined('LACONICA')) { exit(1); }
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/lib/rssaction.php');
|
|
||||||
|
|
||||||
// Formatting of RSS handled by Rss10Action
|
// Formatting of RSS handled by Rss10Action
|
||||||
|
|
||||||
class UserrssAction extends Rss10Action
|
class UserrssAction extends TargetedRss10Action
|
||||||
{
|
{
|
||||||
var $tag = null;
|
protected $tag = null;
|
||||||
|
|
||||||
function prepare($args)
|
protected function doStreamPreparation()
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
|
||||||
$nickname = $this->trimmed('nickname');
|
|
||||||
$this->user = User::getKV('nickname', $nickname);
|
|
||||||
$this->tag = $this->trimmed('tag');
|
$this->tag = $this->trimmed('tag');
|
||||||
|
}
|
||||||
|
|
||||||
if (!$this->user) {
|
protected function getNotices()
|
||||||
// TRANS: Client error displayed when user not found for an action.
|
{
|
||||||
$this->clientError(_('No such user.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($this->tag)) {
|
if (!empty($this->tag)) {
|
||||||
$this->notices = $this->getTaggedNotices();
|
$stream = $this->target->getTaggedNotices($this->tag, 0, $this->limit);
|
||||||
} else {
|
return $stream->fetchAll();
|
||||||
$this->notices = $this->getNotices();
|
|
||||||
}
|
}
|
||||||
|
// otherwise we fetch a normal user stream
|
||||||
|
|
||||||
return true;
|
$stream = $this->target->getNotices(0, $this->limit);
|
||||||
}
|
return $stream->fetchAll();
|
||||||
|
|
||||||
function getTaggedNotices()
|
|
||||||
{
|
|
||||||
$notice = $this->user->getTaggedNotices(
|
|
||||||
$this->tag,
|
|
||||||
0,
|
|
||||||
($this->limit == 0) ? NOTICES_PER_PAGE : $this->limit,
|
|
||||||
0,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
|
|
||||||
$notices = array();
|
|
||||||
while ($notice->fetch()) {
|
|
||||||
$notices[] = clone($notice);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $notices;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function getNotices()
|
|
||||||
{
|
|
||||||
$notice = $this->user->getNotices(
|
|
||||||
0,
|
|
||||||
($this->limit == 0) ? NOTICES_PER_PAGE : $this->limit
|
|
||||||
);
|
|
||||||
|
|
||||||
$notices = array();
|
|
||||||
while ($notice->fetch()) {
|
|
||||||
$notices[] = clone($notice);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $notices;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getChannel()
|
function getChannel()
|
||||||
{
|
{
|
||||||
$user = $this->user;
|
|
||||||
$profile = $user->getProfile();
|
|
||||||
$c = array('url' => common_local_url('userrss',
|
$c = array('url' => common_local_url('userrss',
|
||||||
array('nickname' =>
|
array('nickname' =>
|
||||||
$user->nickname)),
|
$this->target->getNickname())),
|
||||||
// TRANS: Message is used as link title. %s is a user nickname.
|
// TRANS: Message is used as link title. %s is a user nickname.
|
||||||
'title' => sprintf(_('%s timeline'), $user->nickname),
|
'title' => sprintf(_('%s timeline'), $this->target->getNickname()),
|
||||||
'link' => $profile->profileurl,
|
'link' => $this->target->getUrl(),
|
||||||
// TRANS: Message is used as link description. %1$s is a username, %2$s is a site name.
|
// TRANS: Message is used as link description. %1$s is a username, %2$s is a site name.
|
||||||
'description' => sprintf(_('Updates from %1$s on %2$s!'),
|
'description' => sprintf(_('Updates from %1$s on %2$s!'),
|
||||||
$user->nickname, common_config('site', 'name')));
|
$this->target->getNickname(), common_config('site', 'name')));
|
||||||
return $c;
|
return $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getImage()
|
|
||||||
{
|
|
||||||
$profile = $this->user->getProfile();
|
|
||||||
return $profile->avatarUrl(AVATAR_PROFILE_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// override parent to add X-SUP-ID URL
|
// override parent to add X-SUP-ID URL
|
||||||
|
|
||||||
function initRss($limit=0)
|
function initRss()
|
||||||
{
|
{
|
||||||
$url = common_local_url('sup', null, null, $this->user->id);
|
$url = common_local_url('sup', null, null, $this->target->getID());
|
||||||
header('X-SUP-ID: '.$url);
|
header('X-SUP-ID: '.$url);
|
||||||
parent::initRss($limit);
|
parent::initRss();
|
||||||
}
|
}
|
||||||
|
|
||||||
function isReadOnly($args)
|
function isReadOnly($args)
|
||||||
|
@ -166,7 +166,7 @@ class File_redirection extends Managed_DataObject
|
|||||||
* size (optional): byte size from Content-Length header
|
* size (optional): byte size from Content-Length header
|
||||||
* time (optional): timestamp from Last-Modified header
|
* time (optional): timestamp from Last-Modified header
|
||||||
*/
|
*/
|
||||||
public function where($in_url, $discover=true) {
|
static function where($in_url, $discover=true) {
|
||||||
// let's see if we know this...
|
// let's see if we know this...
|
||||||
try {
|
try {
|
||||||
$a = File::getByUrl($in_url);
|
$a = File::getByUrl($in_url);
|
||||||
@ -176,7 +176,7 @@ class File_redirection extends Managed_DataObject
|
|||||||
try {
|
try {
|
||||||
$b = File_redirection::getByUrl($in_url);
|
$b = File_redirection::getByUrl($in_url);
|
||||||
// this is a redirect to $b->file_id
|
// this is a redirect to $b->file_id
|
||||||
$a = File::getKV('id', $b->file_id);
|
$a = File::getByID($b->file_id);
|
||||||
return $a->url;
|
return $a->url;
|
||||||
} catch (NoResultException $e) {
|
} catch (NoResultException $e) {
|
||||||
// Oh well, let's keep going
|
// Oh well, let's keep going
|
||||||
@ -186,10 +186,10 @@ class File_redirection extends Managed_DataObject
|
|||||||
if ($discover) {
|
if ($discover) {
|
||||||
$ret = File_redirection::lookupWhere($in_url);
|
$ret = File_redirection::lookupWhere($in_url);
|
||||||
return $ret;
|
return $ret;
|
||||||
} else {
|
|
||||||
// No manual dereferencing; leave the unknown URL as is.
|
|
||||||
return $in_url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No manual dereferencing; leave the unknown URL as is.
|
||||||
|
return $in_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -206,7 +206,7 @@ class File_redirection extends Managed_DataObject
|
|||||||
* @param User $user whose shortening options to use; defaults to the current web session user
|
* @param User $user whose shortening options to use; defaults to the current web session user
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function makeShort($long_url, $user=null)
|
static function makeShort($long_url, $user=null)
|
||||||
{
|
{
|
||||||
$canon = File_redirection::_canonUrl($long_url);
|
$canon = File_redirection::_canonUrl($long_url);
|
||||||
|
|
||||||
@ -214,11 +214,7 @@ class File_redirection extends Managed_DataObject
|
|||||||
|
|
||||||
// Did we get one? Is it shorter?
|
// Did we get one? Is it shorter?
|
||||||
|
|
||||||
if (!empty($short_url)) {
|
return !empty($short_url) ? $short_url : $long_url;
|
||||||
return $short_url;
|
|
||||||
} else {
|
|
||||||
return $long_url;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -235,18 +231,14 @@ class File_redirection extends Managed_DataObject
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function forceShort($long_url, $user)
|
static function forceShort($long_url, $user)
|
||||||
{
|
{
|
||||||
$canon = File_redirection::_canonUrl($long_url);
|
$canon = File_redirection::_canonUrl($long_url);
|
||||||
|
|
||||||
$short_url = File_redirection::_userMakeShort($canon, $user, true);
|
$short_url = File_redirection::_userMakeShort($canon, $user, true);
|
||||||
|
|
||||||
// Did we get one? Is it shorter?
|
// Did we get one? Is it shorter?
|
||||||
if (!empty($short_url)) {
|
return !empty($short_url) ? $short_url : $long_url;
|
||||||
return $short_url;
|
|
||||||
} else {
|
|
||||||
return $long_url;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static function _userMakeShort($long_url, User $user=null, $force = false) {
|
static function _userMakeShort($long_url, User $user=null, $force = false) {
|
||||||
|
@ -50,7 +50,7 @@ class Local_group extends Managed_DataObject
|
|||||||
$group->find(true);
|
$group->find(true);
|
||||||
if (!$group instanceof User_group) {
|
if (!$group instanceof User_group) {
|
||||||
common_log(LOG_ERR, 'User_group does not exist for Local_group: '.$this->group_id);
|
common_log(LOG_ERR, 'User_group does not exist for Local_group: '.$this->group_id);
|
||||||
throw new NoResultException($group);
|
throw new NoSuchGroupException(array('id' => $this->group_id));
|
||||||
}
|
}
|
||||||
return $group;
|
return $group;
|
||||||
}
|
}
|
||||||
|
@ -1203,17 +1203,15 @@ class Notice extends Managed_DataObject
|
|||||||
$this->_attachments[$this->id] = $attachments;
|
$this->_attachments[$this->id] = $attachments;
|
||||||
}
|
}
|
||||||
|
|
||||||
function publicStream($offset=0, $limit=20, $since_id=0, $max_id=0)
|
static function publicStream($offset=0, $limit=20, $since_id=null, $max_id=null)
|
||||||
{
|
{
|
||||||
$stream = new PublicNoticeStream();
|
$stream = new PublicNoticeStream();
|
||||||
return $stream->getNotices($offset, $limit, $since_id, $max_id);
|
return $stream->getNotices($offset, $limit, $since_id, $max_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static function conversationStream($id, $offset=0, $limit=20, $since_id=null, $max_id=null)
|
||||||
function conversationStream($id, $offset=0, $limit=20, $since_id=0, $max_id=0)
|
|
||||||
{
|
{
|
||||||
$stream = new ConversationNoticeStream($id);
|
$stream = new ConversationNoticeStream($id);
|
||||||
|
|
||||||
return $stream->getNotices($offset, $limit, $since_id, $max_id);
|
return $stream->getNotices($offset, $limit, $since_id, $max_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1225,18 +1223,17 @@ class Notice extends Managed_DataObject
|
|||||||
*/
|
*/
|
||||||
function hasConversation()
|
function hasConversation()
|
||||||
{
|
{
|
||||||
if (!empty($this->conversation)) {
|
if (empty($this->conversation)) {
|
||||||
$conversation = Notice::conversationStream(
|
// this notice is not part of a conversation apparently
|
||||||
$this->conversation,
|
// FIXME: all notices should have a conversation value, right?
|
||||||
1,
|
return false;
|
||||||
1
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($conversation->N > 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
$stream = new ConversationNoticeStream($this->conversation);
|
||||||
|
$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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1271,8 +1268,7 @@ class Notice extends Managed_DataObject
|
|||||||
$root = new Notice;
|
$root = new Notice;
|
||||||
$root->conversation = $this->conversation;
|
$root->conversation = $this->conversation;
|
||||||
$root->orderBy('notice.created ASC');
|
$root->orderBy('notice.created ASC');
|
||||||
$root->find();
|
$root->find(true); // true means "fetch first result"
|
||||||
$root->fetch();
|
|
||||||
$root->free();
|
$root->free();
|
||||||
return $root;
|
return $root;
|
||||||
}
|
}
|
||||||
@ -2193,7 +2189,7 @@ class Notice extends Managed_DataObject
|
|||||||
return $notice->fetchAll('id');
|
return $notice->fetchAll('id');
|
||||||
}
|
}
|
||||||
|
|
||||||
function locationOptions($lat, $lon, $location_id, $location_ns, $profile = null)
|
static function locationOptions($lat, $lon, $location_id, $location_ns, $profile = null)
|
||||||
{
|
{
|
||||||
$options = array();
|
$options = array();
|
||||||
|
|
||||||
|
@ -56,8 +56,7 @@ class Notice_tag extends Managed_DataObject
|
|||||||
static function getStream($tag, $offset=0, $limit=20, $sinceId=0, $maxId=0)
|
static function getStream($tag, $offset=0, $limit=20, $sinceId=0, $maxId=0)
|
||||||
{
|
{
|
||||||
$stream = new TagNoticeStream($tag);
|
$stream = new TagNoticeStream($tag);
|
||||||
|
return $stream;
|
||||||
return $stream->getNotices($offset, $limit, $sinceId, $maxId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function blowCache($blowLast=false)
|
function blowCache($blowLast=false)
|
||||||
|
@ -242,6 +242,11 @@ class Profile extends Managed_DataObject
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getReplies($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
|
||||||
|
{
|
||||||
|
return Reply::stream($this->getID(), $offset, $limit, $since_id, $before_id);
|
||||||
|
}
|
||||||
|
|
||||||
function getTaggedNotices($tag, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
|
function getTaggedNotices($tag, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
|
||||||
{
|
{
|
||||||
$stream = new TaggedProfileNoticeStream($this, $tag);
|
$stream = new TaggedProfileNoticeStream($this, $tag);
|
||||||
@ -1566,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.
|
||||||
*
|
*
|
||||||
|
@ -55,10 +55,9 @@ class Reply extends Managed_DataObject
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function stream($user_id, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
|
static function stream($user_id, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
|
||||||
{
|
{
|
||||||
$stream = new ReplyNoticeStream($user_id);
|
$stream = new ReplyNoticeStream($user_id);
|
||||||
|
|
||||||
return $stream->getNotices($offset, $limit, $since_id, $max_id);
|
return $stream->getNotices($offset, $limit, $since_id, $max_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,10 +47,10 @@ class Subscription_queue extends Managed_DataObject
|
|||||||
return $rq;
|
return $rq;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function exists(Profile $subscriber, Profile $other)
|
static function exists(Profile $subscriber, Profile $other)
|
||||||
{
|
{
|
||||||
$sub = Subscription_queue::pkeyGet(array('subscriber' => $subscriber->id,
|
$sub = Subscription_queue::pkeyGet(array('subscriber' => $subscriber->getID(),
|
||||||
'subscribed' => $other->id));
|
'subscribed' => $other->getID()));
|
||||||
return ($sub instanceof Subscription_queue);
|
return ($sub instanceof Subscription_queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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,6 +147,16 @@ class User extends Managed_DataObject
|
|||||||
return $this->getProfile()->getNickname();
|
return $this->getProfile()->getNickname();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static function getByNickname($nickname)
|
||||||
|
{
|
||||||
|
$user = User::getKV('nickname', $nickname);
|
||||||
|
if (!$user instanceof User) {
|
||||||
|
throw new NoSuchUserException(array('nickname' => $nickname));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
|
|
||||||
function isSubscribed(Profile $other)
|
function isSubscribed(Profile $other)
|
||||||
{
|
{
|
||||||
return $this->getProfile()->isSubscribed($other);
|
return $this->getProfile()->isSubscribed($other);
|
||||||
@ -439,7 +454,7 @@ class User extends Managed_DataObject
|
|||||||
|
|
||||||
function getReplies($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
|
function getReplies($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
|
||||||
{
|
{
|
||||||
return Reply::stream($this->id, $offset, $limit, $since_id, $before_id);
|
return $this->getProfile()->getReplies($offset, $limit, $since_id, $before_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTaggedNotices($tag, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) {
|
function getTaggedNotices($tag, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) {
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
* identity check.
|
* identity check.
|
||||||
*
|
*
|
||||||
* LIBRARY DESIGN
|
* LIBRARY DESIGN
|
||||||
*
|
*
|
||||||
* This consumer library is designed with that flow in mind. The goal
|
* This consumer library is designed with that flow in mind. The goal
|
||||||
* is to make it as easy as possible to perform the above steps
|
* is to make it as easy as possible to perform the above steps
|
||||||
* securely.
|
* securely.
|
||||||
@ -427,7 +427,7 @@ class Auth_OpenID_Consumer {
|
|||||||
$loader->fromSession($endpoint_data);
|
$loader->fromSession($endpoint_data);
|
||||||
|
|
||||||
$message = Auth_OpenID_Message::fromPostArgs($query);
|
$message = Auth_OpenID_Message::fromPostArgs($query);
|
||||||
$response = $this->consumer->complete($message, $endpoint,
|
$response = $this->consumer->complete($message, $endpoint,
|
||||||
$current_url);
|
$current_url);
|
||||||
$this->session->del($this->_token_key);
|
$this->session->del($this->_token_key);
|
||||||
|
|
||||||
@ -616,6 +616,9 @@ class Auth_OpenID_GenericConsumer {
|
|||||||
$this->store = $store;
|
$this->store = $store;
|
||||||
$this->negotiator = Auth_OpenID_getDefaultNegotiator();
|
$this->negotiator = Auth_OpenID_getDefaultNegotiator();
|
||||||
$this->_use_assocs = (is_null($this->store) ? false : true);
|
$this->_use_assocs = (is_null($this->store) ? false : true);
|
||||||
|
if (get_class($this->store) == "Auth_OpenID_DumbStore") {
|
||||||
|
$this->_use_assocs = false;
|
||||||
|
}
|
||||||
|
|
||||||
$this->fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
|
$this->fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
|
||||||
|
|
||||||
@ -666,7 +669,7 @@ class Auth_OpenID_GenericConsumer {
|
|||||||
'_completeInvalid');
|
'_completeInvalid');
|
||||||
|
|
||||||
return call_user_func_array(array($this, $method),
|
return call_user_func_array(array($this, $method),
|
||||||
array($message, &$endpoint, $return_to));
|
array($message, $endpoint, $return_to));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1186,7 +1189,7 @@ class Auth_OpenID_GenericConsumer {
|
|||||||
list($unused, $services) = call_user_func_array($this->discoverMethod,
|
list($unused, $services) = call_user_func_array($this->discoverMethod,
|
||||||
array(
|
array(
|
||||||
$claimed_id,
|
$claimed_id,
|
||||||
&$this->fetcher,
|
$this->fetcher,
|
||||||
));
|
));
|
||||||
|
|
||||||
if (!$services) {
|
if (!$services) {
|
||||||
@ -1202,7 +1205,7 @@ class Auth_OpenID_GenericConsumer {
|
|||||||
/**
|
/**
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _verifyDiscoveryServices($claimed_id,
|
function _verifyDiscoveryServices($claimed_id,
|
||||||
$services, $to_match_endpoints)
|
$services, $to_match_endpoints)
|
||||||
{
|
{
|
||||||
// Search the services resulting from discovery to find one
|
// Search the services resulting from discovery to find one
|
||||||
@ -1210,7 +1213,7 @@ class Auth_OpenID_GenericConsumer {
|
|||||||
|
|
||||||
foreach ($services as $endpoint) {
|
foreach ($services as $endpoint) {
|
||||||
foreach ($to_match_endpoints as $to_match_endpoint) {
|
foreach ($to_match_endpoints as $to_match_endpoint) {
|
||||||
$result = $this->_verifyDiscoverySingle($endpoint,
|
$result = $this->_verifyDiscoverySingle($endpoint,
|
||||||
$to_match_endpoint);
|
$to_match_endpoint);
|
||||||
|
|
||||||
if (!Auth_OpenID::isFailure($result)) {
|
if (!Auth_OpenID::isFailure($result)) {
|
||||||
@ -1368,7 +1371,7 @@ class Auth_OpenID_GenericConsumer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$ca_message = $message->copy();
|
$ca_message = $message->copy();
|
||||||
$ca_message->setArg(Auth_OpenID_OPENID_NS, 'mode',
|
$ca_message->setArg(Auth_OpenID_OPENID_NS, 'mode',
|
||||||
'check_authentication');
|
'check_authentication');
|
||||||
return $ca_message;
|
return $ca_message;
|
||||||
}
|
}
|
||||||
@ -1606,7 +1609,7 @@ class Auth_OpenID_GenericConsumer {
|
|||||||
|
|
||||||
$expires_in = Auth_OpenID::intval($expires_in_str);
|
$expires_in = Auth_OpenID::intval($expires_in_str);
|
||||||
if ($expires_in === false) {
|
if ($expires_in === false) {
|
||||||
|
|
||||||
$err = sprintf("Could not parse expires_in from association ".
|
$err = sprintf("Could not parse expires_in from association ".
|
||||||
"response %s", print_r($assoc_response, true));
|
"response %s", print_r($assoc_response, true));
|
||||||
return new Auth_OpenID_FailureResponse(null, $err);
|
return new Auth_OpenID_FailureResponse(null, $err);
|
||||||
@ -1953,7 +1956,7 @@ class Auth_OpenID_AuthRequest {
|
|||||||
function htmlMarkup($realm, $return_to=null, $immediate=false,
|
function htmlMarkup($realm, $return_to=null, $immediate=false,
|
||||||
$form_tag_attrs=null)
|
$form_tag_attrs=null)
|
||||||
{
|
{
|
||||||
$form = $this->formMarkup($realm, $return_to, $immediate,
|
$form = $this->formMarkup($realm, $return_to, $immediate,
|
||||||
$form_tag_attrs);
|
$form_tag_attrs);
|
||||||
|
|
||||||
if (Auth_OpenID::isFailure($form)) {
|
if (Auth_OpenID::isFailure($form)) {
|
||||||
|
@ -482,7 +482,7 @@ class Auth_OpenID_FileStore extends Auth_OpenID_OpenIDStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($handle = opendir($dir)) {
|
if ($handle = opendir($dir)) {
|
||||||
while ($item = readdir($handle)) {
|
while (false !== ($item = readdir($handle))) {
|
||||||
if (!in_array($item, array('.', '..'))) {
|
if (!in_array($item, array('.', '..'))) {
|
||||||
if (is_dir($dir . $item)) {
|
if (is_dir($dir . $item)) {
|
||||||
|
|
||||||
|
@ -104,8 +104,11 @@ class Auth_OpenID_PredisStore extends Auth_OpenID_OpenIDStore {
|
|||||||
|
|
||||||
// no handle given, receiving the latest issued
|
// no handle given, receiving the latest issued
|
||||||
$serverKey = $this->associationServerKey($server_url);
|
$serverKey = $this->associationServerKey($server_url);
|
||||||
$lastKey = $this->redis->lpop($serverKey);
|
$lastKey = $this->redis->lindex($serverKey, -1);
|
||||||
if (!$lastKey) { return null; }
|
if (!$lastKey) {
|
||||||
|
// no previous association with this server
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// get association, return null if failed
|
// get association, return null if failed
|
||||||
return $this->getAssociationFromServer($lastKey);
|
return $this->getAssociationFromServer($lastKey);
|
||||||
@ -156,10 +159,10 @@ class Auth_OpenID_PredisStore extends Auth_OpenID_OpenIDStore {
|
|||||||
|
|
||||||
// SETNX will set the value only of the key doesn't exist yet.
|
// SETNX will set the value only of the key doesn't exist yet.
|
||||||
$nonceKey = $this->nonceKey($server_url, $salt);
|
$nonceKey = $this->nonceKey($server_url, $salt);
|
||||||
$added = $this->predis->setnx($nonceKey);
|
$added = $this->redis->setnx($nonceKey, "1");
|
||||||
if ($added) {
|
if ($added) {
|
||||||
// Will set expiration
|
// Will set expiration
|
||||||
$this->predis->expire($nonceKey, $Auth_OpenID_SKEW);
|
$this->redis->expire($nonceKey, $Auth_OpenID_SKEW);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -210,7 +210,7 @@ class Auth_OpenID_TrustRoot {
|
|||||||
if ($parts['host'] == 'localhost') {
|
if ($parts['host'] == 'localhost') {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$host_parts = explode('.', $parts['host']);
|
$host_parts = explode('.', $parts['host']);
|
||||||
if ($parts['wildcard']) {
|
if ($parts['wildcard']) {
|
||||||
// Remove the empty string from the beginning of the array
|
// Remove the empty string from the beginning of the array
|
||||||
@ -413,7 +413,7 @@ function Auth_OpenID_getAllowedReturnURLs($relying_party_url, $fetcher,
|
|||||||
}
|
}
|
||||||
|
|
||||||
call_user_func_array($discover_function,
|
call_user_func_array($discover_function,
|
||||||
array($relying_party_url, &$fetcher));
|
array($relying_party_url, $fetcher));
|
||||||
|
|
||||||
$return_to_urls = array();
|
$return_to_urls = array();
|
||||||
$matching_endpoints = Auth_OpenID_extractReturnURL($endpoints);
|
$matching_endpoints = Auth_OpenID_extractReturnURL($endpoints);
|
||||||
|
@ -414,7 +414,7 @@ class Auth_Yadis_Discovery {
|
|||||||
list($yadis_url, $services) = call_user_func_array($discover_cb,
|
list($yadis_url, $services) = call_user_func_array($discover_cb,
|
||||||
array(
|
array(
|
||||||
$this->url,
|
$this->url,
|
||||||
&$fetcher,
|
$fetcher,
|
||||||
));
|
));
|
||||||
|
|
||||||
$manager = $this->createManager($services, $yadis_url);
|
$manager = $this->createManager($services, $yadis_url);
|
||||||
|
@ -90,6 +90,15 @@ class Auth_Yadis_ParanoidHTTPFetcher extends Auth_Yadis_HTTPFetcher {
|
|||||||
$this->reset();
|
$this->reset();
|
||||||
|
|
||||||
$c = curl_init();
|
$c = curl_init();
|
||||||
|
if (defined('Auth_OpenID_DISABLE_SSL_VERIFYPEER')
|
||||||
|
&& Auth_OpenID_DISABLE_SSL_VERIFYPEER === true) {
|
||||||
|
trigger_error(
|
||||||
|
'You have disabled SSL verifcation, this is a TERRIBLE ' .
|
||||||
|
'idea in almost all cases. Set Auth_OpenID_DISABLE_SSL_' .
|
||||||
|
'VERIFYPEER to false if you want to be safe again',
|
||||||
|
E_USER_WARNING);
|
||||||
|
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
|
||||||
|
}
|
||||||
|
|
||||||
if ($c === false) {
|
if ($c === false) {
|
||||||
Auth_OpenID::log(
|
Auth_OpenID::log(
|
||||||
|
@ -65,29 +65,6 @@ class Auth_Yadis_ParseHTML {
|
|||||||
$this->_entity_replacements));
|
$this->_entity_replacements));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Replace HTML entities (amp, lt, gt, and quot) as well as
|
|
||||||
* numeric entities (e.g. #x9f;) with their actual values and
|
|
||||||
* return the new string.
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
* @param string $str The string in which to look for entities
|
|
||||||
* @return string $new_str The new string entities decoded
|
|
||||||
*/
|
|
||||||
function replaceEntities($str)
|
|
||||||
{
|
|
||||||
foreach ($this->_entity_replacements as $old => $new) {
|
|
||||||
$str = preg_replace(sprintf("/&%s;/", $old), $new, $str);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Replace numeric entities because html_entity_decode doesn't
|
|
||||||
// do it for us.
|
|
||||||
$str = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $str);
|
|
||||||
$str = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $str);
|
|
||||||
|
|
||||||
return $str;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Strip single and double quotes off of a string, if they are
|
* Strip single and double quotes off of a string, if they are
|
||||||
* present.
|
* present.
|
||||||
@ -216,7 +193,7 @@ class Auth_Yadis_ParseHTML {
|
|||||||
$link_attrs = array();
|
$link_attrs = array();
|
||||||
foreach ($attr_matches[0] as $index => $full_match) {
|
foreach ($attr_matches[0] as $index => $full_match) {
|
||||||
$name = $attr_matches[1][$index];
|
$name = $attr_matches[1][$index];
|
||||||
$value = $this->replaceEntities(
|
$value = html_entity_decode(
|
||||||
$this->removeQuotes($attr_matches[2][$index]));
|
$this->removeQuotes($attr_matches[2][$index]));
|
||||||
|
|
||||||
$link_attrs[strtolower($name)] = $value;
|
$link_attrs[strtolower($name)] = $value;
|
||||||
|
@ -250,6 +250,10 @@ class Auth_Yadis_dom extends Auth_Yadis_XMLParser {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($this->doc->doctype)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$this->xpath = new DOMXPath($this->doc);
|
$this->xpath = new DOMXPath($this->doc);
|
||||||
|
|
||||||
if ($this->xpath) {
|
if ($this->xpath) {
|
||||||
@ -343,11 +347,11 @@ function Auth_Yadis_getSupportedExtensions()
|
|||||||
function Auth_Yadis_getXMLParser()
|
function Auth_Yadis_getXMLParser()
|
||||||
{
|
{
|
||||||
global $__Auth_Yadis_defaultParser;
|
global $__Auth_Yadis_defaultParser;
|
||||||
|
|
||||||
if (isset($__Auth_Yadis_defaultParser)) {
|
if (isset($__Auth_Yadis_defaultParser)) {
|
||||||
return $__Auth_Yadis_defaultParser;
|
return $__Auth_Yadis_defaultParser;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(Auth_Yadis_getSupportedExtensions() as $extension => $classname)
|
foreach(Auth_Yadis_getSupportedExtensions() as $extension => $classname)
|
||||||
{
|
{
|
||||||
if (extension_loaded($extension))
|
if (extension_loaded($extension))
|
||||||
@ -357,7 +361,7 @@ function Auth_Yadis_getXMLParser()
|
|||||||
return $p;
|
return $p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -429,7 +429,7 @@ class Auth_Yadis_XRDS {
|
|||||||
|
|
||||||
foreach ($filters as $filter) {
|
foreach ($filters as $filter) {
|
||||||
|
|
||||||
if (call_user_func_array($filter, array(&$service))) {
|
if (call_user_func_array($filter, array($service))) {
|
||||||
$matches++;
|
$matches++;
|
||||||
|
|
||||||
if ($filter_mode == SERVICES_YADIS_MATCH_ANY) {
|
if ($filter_mode == SERVICES_YADIS_MATCH_ANY) {
|
||||||
|
@ -141,7 +141,7 @@ function Auth_Yadis_getServiceEndpoints($input_url, $xrds_parse_func,
|
|||||||
}
|
}
|
||||||
|
|
||||||
$yadis_result = call_user_func_array($discover_func,
|
$yadis_result = call_user_func_array($discover_func,
|
||||||
array($input_url, &$fetcher));
|
array($input_url, $fetcher));
|
||||||
|
|
||||||
if ($yadis_result === null) {
|
if ($yadis_result === null) {
|
||||||
return array($input_url, array());
|
return array($input_url, array());
|
||||||
|
0
extlib/DB/DataObject.php
Executable file → Normal file
0
extlib/DB/DataObject.php
Executable file → Normal file
0
extlib/DB/DataObject/Cast.php
Executable file → Normal file
0
extlib/DB/DataObject/Cast.php
Executable file → Normal file
0
extlib/DB/DataObject/Error.php
Executable file → Normal file
0
extlib/DB/DataObject/Error.php
Executable file → Normal file
0
extlib/DB/DataObject/Generator.php
Executable file → Normal file
0
extlib/DB/DataObject/Generator.php
Executable file → Normal file
0
extlib/Mail.php
Executable file → Normal file
0
extlib/Mail.php
Executable file → Normal file
0
extlib/Mail/RFC822.php
Executable file → Normal file
0
extlib/Mail/RFC822.php
Executable file → Normal file
0
extlib/Mail/mail.php
Executable file → Normal file
0
extlib/Mail/mail.php
Executable file → Normal file
@ -52,7 +52,7 @@
|
|||||||
* @author Sean Coates <sean@php.net>
|
* @author Sean Coates <sean@php.net>
|
||||||
* @copyright 2003-2006 PEAR <pear-group@php.net>
|
* @copyright 2003-2006 PEAR <pear-group@php.net>
|
||||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||||
* @version CVS: $Id: mimeDecode.php,v 1.48 2006/12/03 13:43:33 cipri Exp $
|
* @version CVS: $Id: mimeDecode.php 305875 2010-12-01 07:17:10Z alan_k $
|
||||||
* @link http://pear.php.net/package/Mail_mime
|
* @link http://pear.php.net/package/Mail_mime
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -147,6 +147,15 @@ class Mail_mimeDecode extends PEAR
|
|||||||
*/
|
*/
|
||||||
var $_decode_headers;
|
var $_decode_headers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flag to determine whether to include attached messages
|
||||||
|
* as body in the returned object. Depends on $_include_bodies
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
var $_rfc822_bodies;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
@ -165,6 +174,7 @@ class Mail_mimeDecode extends PEAR
|
|||||||
$this->_body = $body;
|
$this->_body = $body;
|
||||||
$this->_decode_bodies = false;
|
$this->_decode_bodies = false;
|
||||||
$this->_include_bodies = true;
|
$this->_include_bodies = true;
|
||||||
|
$this->_rfc822_bodies = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -187,7 +197,7 @@ class Mail_mimeDecode extends PEAR
|
|||||||
function decode($params = null)
|
function decode($params = null)
|
||||||
{
|
{
|
||||||
// determine if this method has been called statically
|
// determine if this method has been called statically
|
||||||
$isStatic = !(isset($this) && get_class($this) == __CLASS__);
|
$isStatic = empty($this) || !is_a($this, __CLASS__);
|
||||||
|
|
||||||
// Have we been called statically?
|
// Have we been called statically?
|
||||||
// If so, create an object and pass details to that.
|
// If so, create an object and pass details to that.
|
||||||
@ -208,6 +218,8 @@ class Mail_mimeDecode extends PEAR
|
|||||||
$params['decode_bodies'] : false;
|
$params['decode_bodies'] : false;
|
||||||
$this->_decode_headers = isset($params['decode_headers']) ?
|
$this->_decode_headers = isset($params['decode_headers']) ?
|
||||||
$params['decode_headers'] : false;
|
$params['decode_headers'] : false;
|
||||||
|
$this->_rfc822_bodies = isset($params['rfc_822bodies']) ?
|
||||||
|
$params['rfc_822bodies'] : false;
|
||||||
|
|
||||||
$structure = $this->_decode($this->_header, $this->_body);
|
$structure = $this->_decode($this->_header, $this->_body);
|
||||||
if ($structure === false) {
|
if ($structure === false) {
|
||||||
@ -235,6 +247,7 @@ class Mail_mimeDecode extends PEAR
|
|||||||
$headers = $this->_parseHeaders($headers);
|
$headers = $this->_parseHeaders($headers);
|
||||||
|
|
||||||
foreach ($headers as $value) {
|
foreach ($headers as $value) {
|
||||||
|
$value['value'] = $this->_decode_headers ? $this->_decodeHeader($value['value']) : $value['value'];
|
||||||
if (isset($return->headers[strtolower($value['name'])]) AND !is_array($return->headers[strtolower($value['name'])])) {
|
if (isset($return->headers[strtolower($value['name'])]) AND !is_array($return->headers[strtolower($value['name'])])) {
|
||||||
$return->headers[strtolower($value['name'])] = array($return->headers[strtolower($value['name'])]);
|
$return->headers[strtolower($value['name'])] = array($return->headers[strtolower($value['name'])]);
|
||||||
$return->headers[strtolower($value['name'])][] = $value['value'];
|
$return->headers[strtolower($value['name'])][] = $value['value'];
|
||||||
@ -247,8 +260,8 @@ class Mail_mimeDecode extends PEAR
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reset($headers);
|
|
||||||
while (list($key, $value) = each($headers)) {
|
foreach ($headers as $key => $value) {
|
||||||
$headers[$key]['name'] = strtolower($headers[$key]['name']);
|
$headers[$key]['name'] = strtolower($headers[$key]['name']);
|
||||||
switch ($headers[$key]['name']) {
|
switch ($headers[$key]['name']) {
|
||||||
|
|
||||||
@ -261,7 +274,7 @@ class Mail_mimeDecode extends PEAR
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($content_type['other'])) {
|
if (isset($content_type['other'])) {
|
||||||
while (list($p_name, $p_value) = each($content_type['other'])) {
|
foreach($content_type['other'] as $p_name => $p_value) {
|
||||||
$return->ctype_parameters[$p_name] = $p_value;
|
$return->ctype_parameters[$p_name] = $p_value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -271,7 +284,7 @@ class Mail_mimeDecode extends PEAR
|
|||||||
$content_disposition = $this->_parseHeaderValue($headers[$key]['value']);
|
$content_disposition = $this->_parseHeaderValue($headers[$key]['value']);
|
||||||
$return->disposition = $content_disposition['value'];
|
$return->disposition = $content_disposition['value'];
|
||||||
if (isset($content_disposition['other'])) {
|
if (isset($content_disposition['other'])) {
|
||||||
while (list($p_name, $p_value) = each($content_disposition['other'])) {
|
foreach($content_disposition['other'] as $p_name => $p_value) {
|
||||||
$return->d_parameters[$p_name] = $p_value;
|
$return->d_parameters[$p_name] = $p_value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -303,6 +316,7 @@ class Mail_mimeDecode extends PEAR
|
|||||||
case 'multipart/alternative':
|
case 'multipart/alternative':
|
||||||
case 'multipart/related':
|
case 'multipart/related':
|
||||||
case 'multipart/mixed':
|
case 'multipart/mixed':
|
||||||
|
case 'application/vnd.wap.multipart.related':
|
||||||
if(!isset($content_type['other']['boundary'])){
|
if(!isset($content_type['other']['boundary'])){
|
||||||
$this->_error = 'No boundary found for ' . $content_type['value'] . ' part';
|
$this->_error = 'No boundary found for ' . $content_type['value'] . ' part';
|
||||||
return false;
|
return false;
|
||||||
@ -321,7 +335,11 @@ class Mail_mimeDecode extends PEAR
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'message/rfc822':
|
case 'message/rfc822':
|
||||||
$obj = &new Mail_mimeDecode($body);
|
if ($this->_rfc822_bodies) {
|
||||||
|
$encoding = isset($content_transfer_encoding) ? $content_transfer_encoding['value'] : '7bit';
|
||||||
|
$return->body = ($this->_decode_bodies ? $this->_decodeBody($body, $encoding) : $body);
|
||||||
|
}
|
||||||
|
$obj = new Mail_mimeDecode($body);
|
||||||
$return->parts[] = $obj->decode(array('include_bodies' => $this->_include_bodies,
|
$return->parts[] = $obj->decode(array('include_bodies' => $this->_include_bodies,
|
||||||
'decode_bodies' => $this->_decode_bodies,
|
'decode_bodies' => $this->_decode_bodies,
|
||||||
'decode_headers' => $this->_decode_headers));
|
'decode_headers' => $this->_decode_headers));
|
||||||
@ -401,6 +419,11 @@ class Mail_mimeDecode extends PEAR
|
|||||||
if (preg_match("/^(.*?)\r?\n\r?\n(.*)/s", $input, $match)) {
|
if (preg_match("/^(.*?)\r?\n\r?\n(.*)/s", $input, $match)) {
|
||||||
return array($match[1], $match[2]);
|
return array($match[1], $match[2]);
|
||||||
}
|
}
|
||||||
|
// bug #17325 - empty bodies are allowed. - we just check that at least one line
|
||||||
|
// of headers exist..
|
||||||
|
if (count(explode("\n",$input))) {
|
||||||
|
return array($input, '');
|
||||||
|
}
|
||||||
$this->_error = 'Could not split header and body';
|
$this->_error = 'Could not split header and body';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -419,7 +442,12 @@ class Mail_mimeDecode extends PEAR
|
|||||||
if ($input !== '') {
|
if ($input !== '') {
|
||||||
// Unfold the input
|
// Unfold the input
|
||||||
$input = preg_replace("/\r?\n/", "\r\n", $input);
|
$input = preg_replace("/\r?\n/", "\r\n", $input);
|
||||||
|
//#7065 - wrapping.. with encoded stuff.. - probably not needed,
|
||||||
|
// wrapping space should only get removed if the trailing item on previous line is a
|
||||||
|
// encoded character
|
||||||
|
$input = preg_replace("/=\r\n(\t| )+/", '=', $input);
|
||||||
$input = preg_replace("/\r\n(\t| )+/", ' ', $input);
|
$input = preg_replace("/\r\n(\t| )+/", ' ', $input);
|
||||||
|
|
||||||
$headers = explode("\r\n", trim($input));
|
$headers = explode("\r\n", trim($input));
|
||||||
|
|
||||||
foreach ($headers as $value) {
|
foreach ($headers as $value) {
|
||||||
@ -430,7 +458,7 @@ class Mail_mimeDecode extends PEAR
|
|||||||
|
|
||||||
$return[] = array(
|
$return[] = array(
|
||||||
'name' => $hdr_name,
|
'name' => $hdr_name,
|
||||||
'value' => $this->_decode_headers ? $this->_decodeHeader($hdr_value) : $hdr_value
|
'value' => $hdr_value
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -454,41 +482,161 @@ class Mail_mimeDecode extends PEAR
|
|||||||
function _parseHeaderValue($input)
|
function _parseHeaderValue($input)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (($pos = strpos($input, ';')) !== false) {
|
if (($pos = strpos($input, ';')) === false) {
|
||||||
|
$input = $this->_decode_headers ? $this->_decodeHeader($input) : $input;
|
||||||
$return['value'] = trim(substr($input, 0, $pos));
|
|
||||||
$input = trim(substr($input, $pos+1));
|
|
||||||
|
|
||||||
if (strlen($input) > 0) {
|
|
||||||
|
|
||||||
// This splits on a semi-colon, if there's no preceeding backslash
|
|
||||||
// Now works with quoted values; had to glue the \; breaks in PHP
|
|
||||||
// the regex is already bordering on incomprehensible
|
|
||||||
$splitRegex = '/([^;\'"]*[\'"]([^\'"]*([^\'"]*)*)[\'"][^;\'"]*|([^;]+))(;|$)/';
|
|
||||||
preg_match_all($splitRegex, $input, $matches);
|
|
||||||
$parameters = array();
|
|
||||||
for ($i=0; $i<count($matches[0]); $i++) {
|
|
||||||
$param = $matches[0][$i];
|
|
||||||
while (substr($param, -2) == '\;') {
|
|
||||||
$param .= $matches[0][++$i];
|
|
||||||
}
|
|
||||||
$parameters[] = $param;
|
|
||||||
}
|
|
||||||
|
|
||||||
for ($i = 0; $i < count($parameters); $i++) {
|
|
||||||
$param_name = trim(substr($parameters[$i], 0, $pos = strpos($parameters[$i], '=')), "'\";\t\\ ");
|
|
||||||
$param_value = trim(str_replace('\;', ';', substr($parameters[$i], $pos + 1)), "'\";\t\\ ");
|
|
||||||
if ($param_value[0] == '"') {
|
|
||||||
$param_value = substr($param_value, 1, -1);
|
|
||||||
}
|
|
||||||
$return['other'][$param_name] = $param_value;
|
|
||||||
$return['other'][strtolower($param_name)] = $param_value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$return['value'] = trim($input);
|
$return['value'] = trim($input);
|
||||||
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$value = substr($input, 0, $pos);
|
||||||
|
$value = $this->_decode_headers ? $this->_decodeHeader($value) : $value;
|
||||||
|
$return['value'] = trim($value);
|
||||||
|
$input = trim(substr($input, $pos+1));
|
||||||
|
|
||||||
|
if (!strlen($input) > 0) {
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
// at this point input contains xxxx=".....";zzzz="...."
|
||||||
|
// since we are dealing with quoted strings, we need to handle this properly..
|
||||||
|
$i = 0;
|
||||||
|
$l = strlen($input);
|
||||||
|
$key = '';
|
||||||
|
$val = false; // our string - including quotes..
|
||||||
|
$q = false; // in quote..
|
||||||
|
$lq = ''; // last quote..
|
||||||
|
|
||||||
|
while ($i < $l) {
|
||||||
|
|
||||||
|
$c = $input[$i];
|
||||||
|
//var_dump(array('i'=>$i,'c'=>$c,'q'=>$q, 'lq'=>$lq, 'key'=>$key, 'val' =>$val));
|
||||||
|
|
||||||
|
$escaped = false;
|
||||||
|
if ($c == '\\') {
|
||||||
|
$i++;
|
||||||
|
if ($i == $l-1) { // end of string.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$escaped = true;
|
||||||
|
$c = $input[$i];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// state - in key..
|
||||||
|
if ($val === false) {
|
||||||
|
if (!$escaped && $c == '=') {
|
||||||
|
$val = '';
|
||||||
|
$key = trim($key);
|
||||||
|
$i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!$escaped && $c == ';') {
|
||||||
|
if ($key) { // a key without a value..
|
||||||
|
$key= trim($key);
|
||||||
|
$return['other'][$key] = '';
|
||||||
|
$return['other'][strtolower($key)] = '';
|
||||||
|
}
|
||||||
|
$key = '';
|
||||||
|
}
|
||||||
|
$key .= $c;
|
||||||
|
$i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// state - in value.. (as $val is set..)
|
||||||
|
|
||||||
|
if ($q === false) {
|
||||||
|
// not in quote yet.
|
||||||
|
if ((!strlen($val) || $lq !== false) && $c == ' ' || $c == "\t") {
|
||||||
|
$i++;
|
||||||
|
continue; // skip leading spaces after '=' or after '"'
|
||||||
|
}
|
||||||
|
if (!$escaped && ($c == '"' || $c == "'")) {
|
||||||
|
// start quoted area..
|
||||||
|
$q = $c;
|
||||||
|
// in theory should not happen raw text in value part..
|
||||||
|
// but we will handle it as a merged part of the string..
|
||||||
|
$val = !strlen(trim($val)) ? '' : trim($val);
|
||||||
|
$i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// got end....
|
||||||
|
if (!$escaped && $c == ';') {
|
||||||
|
|
||||||
|
$val = trim($val);
|
||||||
|
$added = false;
|
||||||
|
if (preg_match('/\*[0-9]+$/', $key)) {
|
||||||
|
// this is the extended aaa*0=...;aaa*1=.... code
|
||||||
|
// it assumes the pieces arrive in order, and are valid...
|
||||||
|
$key = preg_replace('/\*[0-9]+$/', '', $key);
|
||||||
|
if (isset($return['other'][$key])) {
|
||||||
|
$return['other'][$key] .= $val;
|
||||||
|
if (strtolower($key) != $key) {
|
||||||
|
$return['other'][strtolower($key)] .= $val;
|
||||||
|
}
|
||||||
|
$added = true;
|
||||||
|
}
|
||||||
|
// continue and use standard setters..
|
||||||
|
}
|
||||||
|
if (!$added) {
|
||||||
|
$return['other'][$key] = $val;
|
||||||
|
$return['other'][strtolower($key)] = $val;
|
||||||
|
}
|
||||||
|
$val = false;
|
||||||
|
$key = '';
|
||||||
|
$lq = false;
|
||||||
|
$i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$val .= $c;
|
||||||
|
$i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// state - in quote..
|
||||||
|
if (!$escaped && $c == $q) { // potential exit state..
|
||||||
|
|
||||||
|
// end of quoted string..
|
||||||
|
$lq = $q;
|
||||||
|
$q = false;
|
||||||
|
$i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// normal char inside of quoted string..
|
||||||
|
$val.= $c;
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// do we have anything left..
|
||||||
|
if (strlen(trim($key)) || $val !== false) {
|
||||||
|
|
||||||
|
$val = trim($val);
|
||||||
|
$added = false;
|
||||||
|
if ($val !== false && preg_match('/\*[0-9]+$/', $key)) {
|
||||||
|
// no dupes due to our crazy regexp.
|
||||||
|
$key = preg_replace('/\*[0-9]+$/', '', $key);
|
||||||
|
if (isset($return['other'][$key])) {
|
||||||
|
$return['other'][$key] .= $val;
|
||||||
|
if (strtolower($key) != $key) {
|
||||||
|
$return['other'][strtolower($key)] .= $val;
|
||||||
|
}
|
||||||
|
$added = true;
|
||||||
|
}
|
||||||
|
// continue and use standard setters..
|
||||||
|
}
|
||||||
|
if (!$added) {
|
||||||
|
$return['other'][$key] = $val;
|
||||||
|
$return['other'][strtolower($key)] = $val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// decode values.
|
||||||
|
foreach($return['other'] as $key =>$val) {
|
||||||
|
$return['other'][$key] = $this->_decode_headers ? $this->_decodeHeader($val) : $val;
|
||||||
|
}
|
||||||
|
//print_r($return);
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -510,13 +658,19 @@ class Mail_mimeDecode extends PEAR
|
|||||||
if ($boundary == $bs_check) {
|
if ($boundary == $bs_check) {
|
||||||
$boundary = $bs_possible;
|
$boundary = $bs_possible;
|
||||||
}
|
}
|
||||||
|
$tmp = preg_split("/--".preg_quote($boundary, '/')."((?=\s)|--)/", $input);
|
||||||
|
|
||||||
$tmp = explode('--' . $boundary, $input);
|
$len = count($tmp) -1;
|
||||||
|
for ($i = 1; $i < $len; $i++) {
|
||||||
for ($i = 1; $i < count($tmp) - 1; $i++) {
|
if (strlen(trim($tmp[$i]))) {
|
||||||
$parts[] = $tmp[$i];
|
$parts[] = $tmp[$i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the last part on if it does not end with the 'closing indicator'
|
||||||
|
if (!empty($tmp[$len]) && strlen(trim($tmp[$len])) && $tmp[$len][0] != '-') {
|
||||||
|
$parts[] = $tmp[$len];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $parts;
|
return $parts;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -719,7 +873,7 @@ class Mail_mimeDecode extends PEAR
|
|||||||
case "to":
|
case "to":
|
||||||
case "cc":
|
case "cc":
|
||||||
case "bcc":
|
case "bcc":
|
||||||
$to = ",".$item['value'];
|
$to .= ",".$item['value'];
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
0
extlib/Mail/mock.php
Executable file → Normal file
0
extlib/Mail/mock.php
Executable file → Normal file
0
extlib/Mail/null.php
Executable file → Normal file
0
extlib/Mail/null.php
Executable file → Normal file
0
extlib/Mail/sendmail.php
Executable file → Normal file
0
extlib/Mail/sendmail.php
Executable file → Normal file
0
extlib/Mail/smtp.php
Executable file → Normal file
0
extlib/Mail/smtp.php
Executable file → Normal file
0
extlib/Mail/smtpmx.php
Executable file → Normal file
0
extlib/Mail/smtpmx.php
Executable file → Normal file
0
extlib/Net/URL2.php
Executable file → Normal file
0
extlib/Net/URL2.php
Executable file → Normal file
@ -2,19 +2,19 @@
|
|||||||
/**
|
/**
|
||||||
* Validation class
|
* Validation class
|
||||||
*
|
*
|
||||||
* Copyright (c) 1997-2006 Pierre-Alain Joye,Tomas V.V.Cox, Amir Saied
|
* Copyright (c) 1997-2006 Pierre-Alain Joye,Tomas V.V.Cox, Amir Saied
|
||||||
*
|
*
|
||||||
* This source file is subject to the New BSD license, That is bundled
|
* This source file is subject to the New BSD license, That is bundled
|
||||||
* with this package in the file LICENSE, and is available through
|
* with this package in the file LICENSE, and is available through
|
||||||
* the world-wide-web at
|
* the world-wide-web at
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* http://www.opensource.org/licenses/bsd-license.php
|
||||||
* If you did not receive a copy of the new BSDlicense and are unable
|
* If you did not receive a copy of the new BSDlicense and are unable
|
||||||
* to obtain it through the world-wide-web, please send a note to
|
* to obtain it through the world-wide-web, please send a note to
|
||||||
* pajoye@php.net so we can mail you a copy immediately.
|
* pajoye@php.net so we can mail you a copy immediately.
|
||||||
*
|
*
|
||||||
* Author: Tomas V.V.Cox <cox@idecnet.com>
|
* Author: Tomas V.V.Cox <cox@idecnet.com>
|
||||||
* Pierre-Alain Joye <pajoye@php.net>
|
* Pierre-Alain Joye <pajoye@php.net>
|
||||||
* Amir Mohammad Saied <amir@php.net>
|
* Amir Mohammad Saied <amir@php.net>
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Package to validate various datas. It includes :
|
* Package to validate various datas. It includes :
|
||||||
@ -32,10 +32,11 @@
|
|||||||
* @author Amir Mohammad Saied <amir@php.net>
|
* @author Amir Mohammad Saied <amir@php.net>
|
||||||
* @copyright 1997-2006 Pierre-Alain Joye,Tomas V.V.Cox,Amir Mohammad Saied
|
* @copyright 1997-2006 Pierre-Alain Joye,Tomas V.V.Cox,Amir Mohammad Saied
|
||||||
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
|
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
|
||||||
* @version CVS: $Id: Validate.php,v 1.134 2009/01/28 12:27:33 davidc Exp $
|
* @version CVS: $Id$
|
||||||
* @link http://pear.php.net/package/Validate
|
* @link http://pear.php.net/package/Validate
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// {{{ Constants
|
||||||
/**
|
/**
|
||||||
* Methods for common data validations
|
* Methods for common data validations
|
||||||
*/
|
*/
|
||||||
@ -44,17 +45,18 @@ define('VALIDATE_SPACE', '\s');
|
|||||||
define('VALIDATE_ALPHA_LOWER', 'a-z');
|
define('VALIDATE_ALPHA_LOWER', 'a-z');
|
||||||
define('VALIDATE_ALPHA_UPPER', 'A-Z');
|
define('VALIDATE_ALPHA_UPPER', 'A-Z');
|
||||||
define('VALIDATE_ALPHA', VALIDATE_ALPHA_LOWER . VALIDATE_ALPHA_UPPER);
|
define('VALIDATE_ALPHA', VALIDATE_ALPHA_LOWER . VALIDATE_ALPHA_UPPER);
|
||||||
define('VALIDATE_EALPHA_LOWER', VALIDATE_ALPHA_LOWER . 'áéíóúýàèìòùäëïöüÿâêîôûãñõ¨åæç½ðøþß');
|
define('VALIDATE_EALPHA_LOWER', VALIDATE_ALPHA_LOWER . 'áéíóúýàèìòùäëïöüÿâêîôûãñõ¨åæç½ðøþß');
|
||||||
define('VALIDATE_EALPHA_UPPER', VALIDATE_ALPHA_UPPER . 'ÁÉÍÓÚÝÀÈÌÒÙÄËÏÖܾÂÊÎÔÛÃÑÕ¦ÅÆǼÐØÞ');
|
define('VALIDATE_EALPHA_UPPER', VALIDATE_ALPHA_UPPER . 'ÁÉÍÓÚÝÀÈÌÒÙÄËÏÖܾÂÊÎÔÛÃÑÕ¦ÅÆǼÐØÞ');
|
||||||
define('VALIDATE_EALPHA', VALIDATE_EALPHA_LOWER . VALIDATE_EALPHA_UPPER);
|
define('VALIDATE_EALPHA', VALIDATE_EALPHA_LOWER . VALIDATE_EALPHA_UPPER);
|
||||||
define('VALIDATE_PUNCTUATION', VALIDATE_SPACE . '\.,;\:&"\'\?\!\(\)');
|
define('VALIDATE_PUNCTUATION', VALIDATE_SPACE . '\.,;\:&"\'\?\!\(\)');
|
||||||
define('VALIDATE_NAME', VALIDATE_EALPHA . VALIDATE_SPACE . "'" . "-");
|
define('VALIDATE_NAME', VALIDATE_EALPHA . VALIDATE_SPACE . "'" . '\-');
|
||||||
define('VALIDATE_STREET', VALIDATE_NUM . VALIDATE_NAME . "/\\ºª\.");
|
define('VALIDATE_STREET', VALIDATE_NUM . VALIDATE_NAME . "/\\ºª\.");
|
||||||
|
|
||||||
define('VALIDATE_ITLD_EMAILS', 1);
|
define('VALIDATE_ITLD_EMAILS', 1);
|
||||||
define('VALIDATE_GTLD_EMAILS', 2);
|
define('VALIDATE_GTLD_EMAILS', 2);
|
||||||
define('VALIDATE_CCTLD_EMAILS', 4);
|
define('VALIDATE_CCTLD_EMAILS', 4);
|
||||||
define('VALIDATE_ALL_EMAILS', 8);
|
define('VALIDATE_ALL_EMAILS', 8);
|
||||||
|
// }}}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validation class
|
* Validation class
|
||||||
@ -79,6 +81,7 @@ define('VALIDATE_ALL_EMAILS', 8);
|
|||||||
*/
|
*/
|
||||||
class Validate
|
class Validate
|
||||||
{
|
{
|
||||||
|
// {{{ International, Generic and Country code TLDs
|
||||||
/**
|
/**
|
||||||
* International Top-Level Domain
|
* International Top-Level Domain
|
||||||
*
|
*
|
||||||
@ -202,6 +205,7 @@ class Validate
|
|||||||
'ye','yt','yu','za',
|
'ye','yt','yu','za',
|
||||||
'zm','zw',
|
'zm','zw',
|
||||||
);
|
);
|
||||||
|
// }}}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate a tag URI (RFC4151)
|
* Validate a tag URI (RFC4151)
|
||||||
@ -445,6 +449,10 @@ class Validate
|
|||||||
if(!empty($options["VALIDATE_GTLD_EMAILS"])) array_push($validate, 'gtld');
|
if(!empty($options["VALIDATE_GTLD_EMAILS"])) array_push($validate, 'gtld');
|
||||||
if(!empty($options["VALIDATE_CCTLD_EMAILS"])) array_push($validate, 'cctld');
|
if(!empty($options["VALIDATE_CCTLD_EMAILS"])) array_push($validate, 'cctld');
|
||||||
|
|
||||||
|
if (count($validate) === 0) {
|
||||||
|
array_push($validate, 'itld', 'gtld', 'cctld');
|
||||||
|
}
|
||||||
|
|
||||||
$self = new Validate;
|
$self = new Validate;
|
||||||
|
|
||||||
$toValidate = array();
|
$toValidate = array();
|
||||||
@ -459,7 +467,7 @@ class Validate
|
|||||||
|
|
||||||
return $e;
|
return $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the validation
|
* Execute the validation
|
||||||
*
|
*
|
||||||
@ -501,7 +509,7 @@ class Validate
|
|||||||
* 'use_rfc822' => 'true',
|
* 'use_rfc822' => 'true',
|
||||||
* 'VALIDATE_GTLD_EMAILS' => 'true',
|
* 'VALIDATE_GTLD_EMAILS' => 'true',
|
||||||
* 'VALIDATE_CCTLD_EMAILS' => 'true',
|
* 'VALIDATE_CCTLD_EMAILS' => 'true',
|
||||||
* 'VALIDATE_ITLD_EMAILS' => 'true',
|
* 'VALIDATE_ITLD_EMAILS' => 'true',
|
||||||
* );
|
* );
|
||||||
*
|
*
|
||||||
* @return boolean true if valid email, false if not
|
* @return boolean true if valid email, false if not
|
||||||
@ -524,15 +532,17 @@ class Validate
|
|||||||
*/
|
*/
|
||||||
$hasIDNA = false;
|
$hasIDNA = false;
|
||||||
|
|
||||||
if (@include_once('Net/IDNA.php')) {
|
if (Validate::_includePathFileExists('Net/IDNA.php')) {
|
||||||
|
include_once('Net/IDNA.php');
|
||||||
$hasIDNA = true;
|
$hasIDNA = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($hasIDNA === true) {
|
if ($hasIDNA === true) {
|
||||||
if (strpos($email, '@') !== false) {
|
if (strpos($email, '@') !== false) {
|
||||||
list($name, $domain) = explode('@', $email, 2);
|
$tmpEmail = explode('@', $email);
|
||||||
|
$domain = array_pop($tmpEmail);
|
||||||
|
|
||||||
// Check if the domain contains characters > 127 which means
|
// Check if the domain contains characters > 127 which means
|
||||||
// it's an idn domain name.
|
// it's an idn domain name.
|
||||||
$chars = count_chars($domain, 1);
|
$chars = count_chars($domain, 1);
|
||||||
if (!empty($chars) && max(array_keys($chars)) > 127) {
|
if (!empty($chars) && max(array_keys($chars)) > 127) {
|
||||||
@ -540,10 +550,11 @@ class Validate
|
|||||||
$domain = $idna->encode($domain);
|
$domain = $idna->encode($domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
$email = "$name@$domain";
|
array_push($tmpEmail, $domain);
|
||||||
|
$email = implode('@', $tmpEmail);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo Fix bug here.. even if it passes this, it won't be passing
|
* @todo Fix bug here.. even if it passes this, it won't be passing
|
||||||
* The regular expression below
|
* The regular expression below
|
||||||
@ -565,14 +576,14 @@ class Validate
|
|||||||
(?:(?:(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:[0-1]?[0-9]?[0-9]))\.){3}
|
(?:(?:(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:[0-1]?[0-9]?[0-9]))\.){3}
|
||||||
(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:[0-1]?[0-9]?[0-9]))))(?(5)\])|
|
(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:[0-1]?[0-9]?[0-9]))))(?(5)\])|
|
||||||
((?:[a-z0-9](?:[-a-z0-9]*[a-z0-9])?\.)*[a-z0-9](?:[-a-z0-9]*[a-z0-9])?) #6 domain as hostname
|
((?:[a-z0-9](?:[-a-z0-9]*[a-z0-9])?\.)*[a-z0-9](?:[-a-z0-9]*[a-z0-9])?) #6 domain as hostname
|
||||||
\.((?:([^- ])[-a-z]*[-a-z]))) #7 TLD
|
\.((?:([^- ])[-a-z]*[-a-z]))) #7 TLD
|
||||||
$&xi';
|
$&xi';
|
||||||
|
|
||||||
//checks if exists the domain (MX or A)
|
//checks if exists the domain (MX or A)
|
||||||
if ($use_rfc822? Validate::__emailRFC822($email, $options) :
|
if ($use_rfc822? Validate::__emailRFC822($email, $options) :
|
||||||
preg_match($regex, $email)) {
|
preg_match($regex, $email)) {
|
||||||
if ($check_domain && function_exists('checkdnsrr')) {
|
if ($check_domain && function_exists('checkdnsrr')) {
|
||||||
list ($account, $domain) = explode('@', $email);
|
$domain = preg_replace('/[^-a-z.0-9]/i', '', array_pop(explode('@', $email)));
|
||||||
if (checkdnsrr($domain, 'MX') || checkdnsrr($domain, 'A')) {
|
if (checkdnsrr($domain, 'MX') || checkdnsrr($domain, 'A')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -913,7 +924,7 @@ class Validate
|
|||||||
*
|
*
|
||||||
* @param string &$date Date
|
* @param string &$date Date
|
||||||
* @param string $num Length
|
* @param string $num Length
|
||||||
* @param string $opt Unknown
|
* @param string $opt Unknown
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @return string
|
* @return string
|
||||||
@ -1086,8 +1097,10 @@ class Validate
|
|||||||
$class = implode('_', $validateType);
|
$class = implode('_', $validateType);
|
||||||
$classPath = str_replace('_', DIRECTORY_SEPARATOR, $class);
|
$classPath = str_replace('_', DIRECTORY_SEPARATOR, $class);
|
||||||
$class = 'Validate_' . $class;
|
$class = 'Validate_' . $class;
|
||||||
if (!@include_once "Validate/$classPath.php") {
|
if (Validate::_includePathFileExists("Validate/$classPath.php")) {
|
||||||
trigger_error("$class isn't installed or you may have some permissoin issues", E_USER_ERROR);
|
include_once "Validate/$classPath.php";
|
||||||
|
} else {
|
||||||
|
trigger_error("$class isn't installed or you may have some permission issues", E_USER_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ce = substr(phpversion(), 0, 1) > 4 ?
|
$ce = substr(phpversion(), 0, 1) > 4 ?
|
||||||
@ -1112,5 +1125,25 @@ class Validate
|
|||||||
}
|
}
|
||||||
return $valid;
|
return $valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether specified file exists along the include path.
|
||||||
|
*
|
||||||
|
* @param string $filename file to search for
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
*
|
||||||
|
* @return bool true if file exists
|
||||||
|
*/
|
||||||
|
function _includePathFileExists($filename)
|
||||||
|
{
|
||||||
|
$paths = explode(":", ini_get("include_path"));
|
||||||
|
$result = false;
|
||||||
|
|
||||||
|
while ((!($result)) && (list($key,$val) = each($paths))) {
|
||||||
|
$result = file_exists($val . "/" . $filename);
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
183
js/util.js
183
js/util.js
@ -60,6 +60,13 @@ var SN = { // StatusNet
|
|||||||
V: { // Variables
|
V: { // Variables
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list of callbacks, categorized into _callbacks['event_name'] = [ callback_function_1, callback_function_2 ]
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
_callbacks: {},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map of localized message strings exported to script from the PHP
|
* Map of localized message strings exported to script from the PHP
|
||||||
* side via Action::getScriptMessages().
|
* side via Action::getScriptMessages().
|
||||||
@ -343,21 +350,6 @@ var SN = { // StatusNet
|
|||||||
// Make sure we don't have a mixed HTTP/HTTPS submission...
|
// Make sure we don't have a mixed HTTP/HTTPS submission...
|
||||||
form.attr('action', SN.U.RewriteAjaxAction(form.attr('action')));
|
form.attr('action', SN.U.RewriteAjaxAction(form.attr('action')));
|
||||||
|
|
||||||
/**
|
|
||||||
* Show a response feedback bit under the new-notice dialog.
|
|
||||||
*
|
|
||||||
* @param {String} cls: CSS class name to use ('error' or 'success')
|
|
||||||
* @param {String} text
|
|
||||||
* @access private
|
|
||||||
*/
|
|
||||||
var showFeedback = function (cls, text) {
|
|
||||||
form.append(
|
|
||||||
$('<p class="form_response"></p>')
|
|
||||||
.addClass(cls)
|
|
||||||
.text(text)
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hide the previous response feedback, if any.
|
* Hide the previous response feedback, if any.
|
||||||
*/
|
*/
|
||||||
@ -392,7 +384,7 @@ var SN = { // StatusNet
|
|||||||
removeFeedback();
|
removeFeedback();
|
||||||
if (textStatus == 'timeout') {
|
if (textStatus == 'timeout') {
|
||||||
// @fixme i18n
|
// @fixme i18n
|
||||||
showFeedback('error', 'Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists.');
|
SN.U.showFeedback(form, 'error', 'Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists.');
|
||||||
} else {
|
} else {
|
||||||
var response = SN.U.GetResponseXML(xhr);
|
var response = SN.U.GetResponseXML(xhr);
|
||||||
if ($('.' + SN.C.S.Error, response).length > 0) {
|
if ($('.' + SN.C.S.Error, response).length > 0) {
|
||||||
@ -405,7 +397,7 @@ var SN = { // StatusNet
|
|||||||
SN.U.FormNoticeEnhancements(form);
|
SN.U.FormNoticeEnhancements(form);
|
||||||
} else {
|
} else {
|
||||||
// @fixme i18n
|
// @fixme i18n
|
||||||
showFeedback('error', '(Sorry! We had trouble sending your notice (' + xhr.status + ' ' + xhr.statusText + '). Please report the problem to the site administrator if this happens again.');
|
SN.U.showFeedback(form, 'error', '(Sorry! We had trouble sending your notice (' + xhr.status + ' ' + xhr.statusText + '). Please report the problem to the site administrator if this happens again.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -414,59 +406,9 @@ var SN = { // StatusNet
|
|||||||
removeFeedback();
|
removeFeedback();
|
||||||
var errorResult = $('#' + SN.C.S.Error, data);
|
var errorResult = $('#' + SN.C.S.Error, data);
|
||||||
if (errorResult.length > 0) {
|
if (errorResult.length > 0) {
|
||||||
showFeedback('error', errorResult.text());
|
SN.U.showFeedback(form, 'error', errorResult.text());
|
||||||
} else {
|
} else {
|
||||||
var commandResult = $('#' + SN.C.S.CommandResult, data);
|
SN.E.ajaxNoticePosted(form, data, textStatus);
|
||||||
if (commandResult.length > 0) {
|
|
||||||
showFeedback('success', commandResult.text());
|
|
||||||
} else {
|
|
||||||
// New notice post was successful. If on our timeline, show it!
|
|
||||||
var notice = document._importNode($('li', data)[0], true);
|
|
||||||
var notices = $('#notices_primary .notices:first');
|
|
||||||
var replyItem = form.closest('li.notice-reply');
|
|
||||||
|
|
||||||
if (replyItem.length > 0) {
|
|
||||||
// If this is an inline reply, remove the form...
|
|
||||||
var list = form.closest('.threaded-replies');
|
|
||||||
|
|
||||||
var id = $(notice).attr('id');
|
|
||||||
if ($('#' + id).length == 0) {
|
|
||||||
$(notice).insertBefore(replyItem);
|
|
||||||
} // else Realtime came through before us...
|
|
||||||
|
|
||||||
replyItem.remove();
|
|
||||||
|
|
||||||
} else if (notices.length > 0 && SN.U.belongsOnTimeline(notice)) {
|
|
||||||
// Not a reply. If on our timeline, show it at the top!
|
|
||||||
|
|
||||||
if ($('#' + notice.id).length === 0) {
|
|
||||||
var notice_irt_value = form.find('[name=inreplyto]').val();
|
|
||||||
var notice_irt = '#notices_primary #notice-' + notice_irt_value;
|
|
||||||
if ($('body')[0].id == 'conversation') {
|
|
||||||
if (notice_irt_value.length > 0 && $(notice_irt + ' .notices').length < 1) {
|
|
||||||
$(notice_irt).append('<ul class="notices"></ul>');
|
|
||||||
}
|
|
||||||
$($(notice_irt + ' .notices')[0]).append(notice);
|
|
||||||
} else {
|
|
||||||
notices.prepend(notice);
|
|
||||||
}
|
|
||||||
$('#' + notice.id)
|
|
||||||
.css({display: 'none'})
|
|
||||||
.fadeIn(2500);
|
|
||||||
SN.U.NoticeWithAttachment($('#' + notice.id));
|
|
||||||
SN.U.switchInputFormTab(null);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Not on a timeline that this belongs on?
|
|
||||||
// Just show a success message.
|
|
||||||
// @fixme inline
|
|
||||||
showFeedback('success', $('title', data).text());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
form.resetForm();
|
|
||||||
form.find('[name=inreplyto]').val('');
|
|
||||||
form.find('.attach-status').remove();
|
|
||||||
SN.U.FormNoticeEnhancements(form);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
complete: function (xhr, textStatus) {
|
complete: function (xhr, textStatus) {
|
||||||
@ -1139,12 +1081,12 @@ var SN = { // StatusNet
|
|||||||
label.attr('title', label.text());
|
label.attr('title', label.text());
|
||||||
|
|
||||||
check.change(function () {
|
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
|
label
|
||||||
.attr('title', NoticeDataGeo_text.ShareDisable)
|
.attr('title', NoticeDataGeo_text.ShareDisable)
|
||||||
.addClass('checked');
|
.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) {
|
if (navigator.geolocation) {
|
||||||
SN.U.NoticeGeoStatus(form, 'Requesting location from browser...');
|
SN.U.NoticeGeoStatus(form, 'Requesting location from browser...');
|
||||||
navigator.geolocation.getCurrentPosition(
|
navigator.geolocation.getCurrentPosition(
|
||||||
@ -1355,7 +1297,7 @@ var SN = { // StatusNet
|
|||||||
* @fixme what is this?
|
* @fixme what is this?
|
||||||
*/
|
*/
|
||||||
Delete: function () {
|
Delete: function () {
|
||||||
$.cookie(SN.C.S.StatusNetInstance, null);
|
$.removeCookie(SN.C.S.StatusNetInstance);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1442,9 +1384,106 @@ var SN = { // StatusNet
|
|||||||
var extended = $(selector);
|
var extended = $(selector);
|
||||||
extended.removeClass('extended_menu');
|
extended.removeClass('extended_menu');
|
||||||
return void(0);
|
return void(0);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a response feedback bit under a form.
|
||||||
|
*
|
||||||
|
* @param {Element} form: the new-notice form usually
|
||||||
|
* @param {String} cls: CSS class name to use ('error' or 'success')
|
||||||
|
* @param {String} text
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
showFeedback: function (form, cls, text) {
|
||||||
|
form.append(
|
||||||
|
$('<p class="form_response"></p>')
|
||||||
|
.addClass(cls)
|
||||||
|
.text(text)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
addCallback: function (ename, callback) {
|
||||||
|
// initialize to array if it's undefined
|
||||||
|
if (typeof SN._callbacks[ename] === 'undefined') {
|
||||||
|
SN._callbacks[ename] = [];
|
||||||
|
}
|
||||||
|
SN._callbacks[ename].push(callback);
|
||||||
|
},
|
||||||
|
|
||||||
|
runCallbacks: function (ename, data) {
|
||||||
|
if (typeof SN._callbacks[ename] === 'undefined') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (cbname in SN._callbacks[ename]) {
|
||||||
|
SN._callbacks[ename][cbname](data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
E: { /* Events */
|
||||||
|
/* SN.E.ajaxNoticePosted, called when a notice has been posted successfully via an AJAX form
|
||||||
|
@param form the originating form element
|
||||||
|
@param data data from success() callback
|
||||||
|
@param textStatus textStatus from success() callback
|
||||||
|
*/
|
||||||
|
ajaxNoticePosted: function (form, data, textStatus) {
|
||||||
|
var commandResult = $('#' + SN.C.S.CommandResult, data);
|
||||||
|
if (commandResult.length > 0) {
|
||||||
|
SN.U.showFeedback(form, 'success', commandResult.text());
|
||||||
|
} else {
|
||||||
|
// New notice post was successful. If on our timeline, show it!
|
||||||
|
var notice = document._importNode($('li', data)[0], true);
|
||||||
|
var notices = $('#notices_primary .notices:first');
|
||||||
|
var replyItem = form.closest('li.notice-reply');
|
||||||
|
|
||||||
|
if (replyItem.length > 0) {
|
||||||
|
// If this is an inline reply, remove the form...
|
||||||
|
var list = form.closest('.threaded-replies');
|
||||||
|
|
||||||
|
var id = $(notice).attr('id');
|
||||||
|
if ($('#' + id).length == 0) {
|
||||||
|
$(notice).insertBefore(replyItem);
|
||||||
|
} // else Realtime came through before us...
|
||||||
|
|
||||||
|
replyItem.remove();
|
||||||
|
|
||||||
|
} else if (notices.length > 0 && SN.U.belongsOnTimeline(notice)) {
|
||||||
|
// Not a reply. If on our timeline, show it at the top!
|
||||||
|
|
||||||
|
if ($('#' + notice.id).length === 0) {
|
||||||
|
var notice_irt_value = form.find('[name=inreplyto]').val();
|
||||||
|
var notice_irt = '#notices_primary #notice-' + notice_irt_value;
|
||||||
|
if ($('body')[0].id == 'conversation') {
|
||||||
|
if (notice_irt_value.length > 0 && $(notice_irt + ' .notices').length < 1) {
|
||||||
|
$(notice_irt).append('<ul class="notices"></ul>');
|
||||||
|
}
|
||||||
|
$($(notice_irt + ' .notices')[0]).append(notice);
|
||||||
|
} else {
|
||||||
|
notices.prepend(notice);
|
||||||
|
}
|
||||||
|
$('#' + notice.id)
|
||||||
|
.css({display: 'none'})
|
||||||
|
.fadeIn(2500);
|
||||||
|
SN.U.NoticeWithAttachment($('#' + notice.id));
|
||||||
|
SN.U.switchInputFormTab(null);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Not on a timeline that this belongs on?
|
||||||
|
// Just show a success message.
|
||||||
|
// @fixme inline
|
||||||
|
SN.U.showFeedback(form, 'success', $('title', data).text());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
form.resetForm();
|
||||||
|
form.find('[name=inreplyto]').val('');
|
||||||
|
form.find('.attach-status').remove();
|
||||||
|
SN.U.FormNoticeEnhancements(form);
|
||||||
|
|
||||||
|
SN.U.runCallbacks('notice_posted', {"notice": notice});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
Init: {
|
Init: {
|
||||||
/**
|
/**
|
||||||
* If user is logged in, run setup code for the new notice form:
|
* If user is logged in, run setup code for the new notice form:
|
||||||
|
@ -205,7 +205,7 @@ class Action extends HTMLOutputter // lawsuit
|
|||||||
*
|
*
|
||||||
* @return nothing
|
* @return nothing
|
||||||
*/
|
*/
|
||||||
function showPage()
|
public function showPage()
|
||||||
{
|
{
|
||||||
if (GNUsocial::isAjax()) {
|
if (GNUsocial::isAjax()) {
|
||||||
self::showAjax();
|
self::showAjax();
|
||||||
@ -534,15 +534,11 @@ class Action extends HTMLOutputter // lawsuit
|
|||||||
*/
|
*/
|
||||||
function showFeeds()
|
function showFeeds()
|
||||||
{
|
{
|
||||||
$feeds = $this->getFeeds();
|
foreach ($this->getFeeds() as $feed) {
|
||||||
|
$this->element('link', array('rel' => $feed->rel(),
|
||||||
if ($feeds) {
|
'href' => $feed->url,
|
||||||
foreach ($feeds as $feed) {
|
'type' => $feed->mimeType(),
|
||||||
$this->element('link', array('rel' => $feed->rel(),
|
'title' => $feed->title));
|
||||||
'href' => $feed->url,
|
|
||||||
'type' => $feed->mimeType(),
|
|
||||||
'title' => $feed->title));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1035,9 +1031,9 @@ class Action extends HTMLOutputter // lawsuit
|
|||||||
function showExportData()
|
function showExportData()
|
||||||
{
|
{
|
||||||
$feeds = $this->getFeeds();
|
$feeds = $this->getFeeds();
|
||||||
if ($feeds) {
|
if (!empty($feeds)) {
|
||||||
$fl = new FeedList($this);
|
$fl = new FeedList($this, $feeds);
|
||||||
$fl->show($feeds);
|
$fl->show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1658,7 +1654,7 @@ class Action extends HTMLOutputter // lawsuit
|
|||||||
*/
|
*/
|
||||||
function getFeeds()
|
function getFeeds()
|
||||||
{
|
{
|
||||||
return null;
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -281,19 +281,20 @@ class ActivityUtils
|
|||||||
static function validateUri($uri)
|
static function validateUri($uri)
|
||||||
{
|
{
|
||||||
// Check mailto: URIs first
|
// Check mailto: URIs first
|
||||||
|
$validate = new Validate();
|
||||||
|
|
||||||
if (preg_match('/^mailto:(.*)$/', $uri, $match)) {
|
if (preg_match('/^mailto:(.*)$/', $uri, $match)) {
|
||||||
return Validate::email($match[1], common_config('email', 'check_domain'));
|
return $validate->email($match[1], common_config('email', 'check_domain'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Validate::uri($uri)) {
|
if ($validate->uri($uri)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Possibly an upstream bug; tag: URIs aren't validated properly
|
// Possibly an upstream bug; tag: URIs aren't validated properly
|
||||||
// unless you explicitly ask for them. All other schemes are accepted
|
// unless you explicitly ask for them. All other schemes are accepted
|
||||||
// for basic URI validation without asking.
|
// for basic URI validation without asking.
|
||||||
if (Validate::uri($uri, array('allowed_scheme' => array('tag')))) {
|
if ($validate->uri($uri, array('allowed_scheme' => array('tag')))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
lib/apiaction.php
Executable file → Normal file
10
lib/apiaction.php
Executable file → Normal file
@ -248,7 +248,7 @@ class ApiAction extends Action
|
|||||||
|
|
||||||
$twitter_user['friends_count'] = $profile->subscriptionCount();
|
$twitter_user['friends_count'] = $profile->subscriptionCount();
|
||||||
|
|
||||||
$twitter_user['created_at'] = $this->dateTwitter($profile->created);
|
$twitter_user['created_at'] = self::dateTwitter($profile->created);
|
||||||
|
|
||||||
$timezone = 'UTC';
|
$timezone = 'UTC';
|
||||||
|
|
||||||
@ -322,7 +322,7 @@ class ApiAction extends Action
|
|||||||
$twitter_status = array();
|
$twitter_status = array();
|
||||||
$twitter_status['text'] = $notice->content;
|
$twitter_status['text'] = $notice->content;
|
||||||
$twitter_status['truncated'] = false; # Not possible on StatusNet
|
$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 {
|
try {
|
||||||
// We could just do $notice->reply_to but maybe the future holds a
|
// We could just do $notice->reply_to but maybe the future holds a
|
||||||
// different story for parenting.
|
// different story for parenting.
|
||||||
@ -440,8 +440,8 @@ class ApiAction extends Action
|
|||||||
$twitter_group['homepage'] = $group->homepage;
|
$twitter_group['homepage'] = $group->homepage;
|
||||||
$twitter_group['description'] = $group->description;
|
$twitter_group['description'] = $group->description;
|
||||||
$twitter_group['location'] = $group->location;
|
$twitter_group['location'] = $group->location;
|
||||||
$twitter_group['created'] = $this->dateTwitter($group->created);
|
$twitter_group['created'] = self::dateTwitter($group->created);
|
||||||
$twitter_group['modified'] = $this->dateTwitter($group->modified);
|
$twitter_group['modified'] = self::dateTwitter($group->modified);
|
||||||
|
|
||||||
return $twitter_group;
|
return $twitter_group;
|
||||||
}
|
}
|
||||||
@ -1196,7 +1196,7 @@ class ApiAction extends Action
|
|||||||
$this->endDocument('xml');
|
$this->endDocument('xml');
|
||||||
}
|
}
|
||||||
|
|
||||||
function dateTwitter($dt)
|
static function dateTwitter($dt)
|
||||||
{
|
{
|
||||||
$dateStr = date('d F Y H:i:s', strtotime($dt));
|
$dateStr = date('d F Y H:i:s', strtotime($dt));
|
||||||
$d = new DateTime($dateStr, new DateTimeZone('UTC'));
|
$d = new DateTime($dateStr, new DateTimeZone('UTC'));
|
||||||
|
@ -113,10 +113,12 @@ class AtomNoticeFeed extends Atom10Feed
|
|||||||
foreach ($notices as $notice) {
|
foreach ($notices as $notice) {
|
||||||
$this->addEntryFromNotice($notice);
|
$this->addEntryFromNotice($notice);
|
||||||
}
|
}
|
||||||
} else {
|
} elseif ($notices instanceof Notice) {
|
||||||
while ($notices->fetch()) {
|
while ($notices->fetch()) {
|
||||||
$this->addEntryFromNotice($notices);
|
$this->addEntryFromNotice($notices);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
throw new ServerException('addEntryFromNotices got neither an array nor a Notice object');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +127,7 @@ class AtomNoticeFeed extends Atom10Feed
|
|||||||
*
|
*
|
||||||
* @param Notice $notice a Notice to add
|
* @param Notice $notice a Notice to add
|
||||||
*/
|
*/
|
||||||
function addEntryFromNotice($notice)
|
function addEntryFromNotice(Notice $notice)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$source = $this->showSource();
|
$source = $this->showSource();
|
||||||
|
@ -85,7 +85,8 @@ class AvatarLink
|
|||||||
|
|
||||||
// yuck!
|
// yuck!
|
||||||
static function mediatype($filename) {
|
static function mediatype($filename) {
|
||||||
$ext = strtolower(end(explode('.', $filename)));
|
$parts = explode('.', $filename);
|
||||||
|
$ext = strtolower(end($parts));
|
||||||
if ($ext == 'jpeg') {
|
if ($ext == 'jpeg') {
|
||||||
$ext = 'jpg';
|
$ext = 'jpg';
|
||||||
}
|
}
|
||||||
|
@ -327,7 +327,6 @@ $default =
|
|||||||
'OpportunisticQM' => array(),
|
'OpportunisticQM' => array(),
|
||||||
'OStatus' => array(),
|
'OStatus' => array(),
|
||||||
'Poll' => array(),
|
'Poll' => array(),
|
||||||
'QnA' => array(),
|
|
||||||
'SearchSub' => array(),
|
'SearchSub' => array(),
|
||||||
'TagSub' => array(),
|
'TagSub' => array(),
|
||||||
'WebFinger' => array(),
|
'WebFinger' => array(),
|
||||||
|
67
lib/deletenoticeform.php
Normal file
67
lib/deletenoticeform.php
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
|
|
||||||
|
class DeletenoticeForm extends Form
|
||||||
|
{
|
||||||
|
protected $notice = null;
|
||||||
|
|
||||||
|
function __construct(HTMLOutputter $out=null, array $formOpts=array())
|
||||||
|
{
|
||||||
|
if (!array_key_exists('notice', $formOpts) || !$formOpts['notice'] instanceof Notice) {
|
||||||
|
throw new ServerException('No notice provided to DeletenoticeForm');
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::__construct($out);
|
||||||
|
|
||||||
|
$this->notice = $formOpts['notice'];
|
||||||
|
}
|
||||||
|
|
||||||
|
function id()
|
||||||
|
{
|
||||||
|
return 'form_notice_delete-' . $this->notice->getID();
|
||||||
|
}
|
||||||
|
|
||||||
|
function formClass()
|
||||||
|
{
|
||||||
|
return 'form_settings';
|
||||||
|
}
|
||||||
|
|
||||||
|
function action()
|
||||||
|
{
|
||||||
|
return common_local_url('deletenotice', array('notice' => $this->notice->getID()));
|
||||||
|
}
|
||||||
|
|
||||||
|
function formLegend()
|
||||||
|
{
|
||||||
|
$this->out->element('legend', null, _('Delete notice'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function formData()
|
||||||
|
{
|
||||||
|
$this->out->element('p', null, _('Are you sure you want to delete this notice?'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action elements
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function formActions()
|
||||||
|
{
|
||||||
|
$this->out->submit('form_action-no',
|
||||||
|
// TRANS: Button label on the delete notice form.
|
||||||
|
_m('BUTTON','No'),
|
||||||
|
'submit form_action-primary',
|
||||||
|
'no',
|
||||||
|
// TRANS: Submit button title for 'No' when deleting a notice.
|
||||||
|
_('Do not delete this notice.'));
|
||||||
|
$this->out->submit('form_action-yes',
|
||||||
|
// TRANS: Button label on the delete notice form.
|
||||||
|
_m('BUTTON','Yes'),
|
||||||
|
'submit form_action-secondary',
|
||||||
|
'yes',
|
||||||
|
// TRANS: Submit button title for 'Yes' when deleting a notice.
|
||||||
|
_('Delete this notice.'));
|
||||||
|
}
|
||||||
|
}
|
@ -28,9 +28,7 @@
|
|||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Widget for showing a list of feeds
|
* Widget for showing a list of feeds
|
||||||
@ -50,30 +48,33 @@ class FeedList extends Widget
|
|||||||
{
|
{
|
||||||
var $action = null;
|
var $action = null;
|
||||||
|
|
||||||
function __construct($action=null)
|
protected $feeds = null;
|
||||||
|
|
||||||
|
public function __construct(Action $action=null, array $feeds=array())
|
||||||
{
|
{
|
||||||
parent::__construct($action);
|
parent::__construct($action);
|
||||||
$this->action = $action;
|
$this->action = $action;
|
||||||
|
$this->feeds = $feeds;
|
||||||
}
|
}
|
||||||
|
|
||||||
function show($feeds)
|
public function show()
|
||||||
{
|
{
|
||||||
if (Event::handle('StartShowFeedLinkList', array($this->action, &$feeds))) {
|
if (Event::handle('StartShowFeedLinkList', array($this->action, &$this->feeds))) {
|
||||||
if (!empty($feeds)) {
|
if (!empty($this->feeds)) {
|
||||||
$this->out->elementStart('div', array('id' => 'export_data',
|
$this->out->elementStart('div', array('id' => 'export_data',
|
||||||
'class' => 'section'));
|
'class' => 'section'));
|
||||||
// TRANS: Header for feed links (h2).
|
// TRANS: Header for feed links (h2).
|
||||||
$this->out->element('h2', null, _('Feeds'));
|
$this->out->element('h2', null, _('Feeds'));
|
||||||
$this->out->elementStart('ul', array('class' => 'xoxo'));
|
$this->out->elementStart('ul', array('class' => 'xoxo'));
|
||||||
|
|
||||||
foreach ($feeds as $feed) {
|
foreach ($this->feeds as $feed) {
|
||||||
$this->feedItem($feed);
|
$this->feedItem($feed);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->out->elementEnd('ul');
|
$this->out->elementEnd('ul');
|
||||||
$this->out->elementEnd('div');
|
$this->out->elementEnd('div');
|
||||||
}
|
}
|
||||||
Event::handle('EndShowFeedLinkList', array($this->action, &$feeds));
|
Event::handle('EndShowFeedLinkList', array($this->action, &$this->feeds));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ class FormAction extends ManagedAction
|
|||||||
protected function prepare(array $args=array()) {
|
protected function prepare(array $args=array()) {
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
$this->form = $this->form ?: $this->action;
|
$this->form = $this->form ?: ucfirst($this->action);
|
||||||
$this->args['form'] = $this->form;
|
$this->args['form'] = $this->form;
|
||||||
|
|
||||||
$this->type = !is_null($this->type) ? $this->type : $this->trimmed('type');
|
$this->type = !is_null($this->type) ? $this->type : $this->trimmed('type');
|
||||||
|
@ -23,7 +23,7 @@ define('GNUSOCIAL_ENGINE', 'GNU social');
|
|||||||
define('GNUSOCIAL_ENGINE_URL', 'https://www.gnu.org/software/social/');
|
define('GNUSOCIAL_ENGINE_URL', 'https://www.gnu.org/software/social/');
|
||||||
|
|
||||||
define('GNUSOCIAL_BASE_VERSION', '1.2.0');
|
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);
|
define('GNUSOCIAL_VERSION', GNUSOCIAL_BASE_VERSION . '-' . GNUSOCIAL_LIFECYCLE);
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ class GroupsNav extends MoreMenu
|
|||||||
_('See all groups you belong to.'));
|
_('See all groups you belong to.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function item($actionName, $args, $label, $description, $id=null, $cls=null)
|
function item($actionName, array $args, $label, $description, $id=null, $cls=null)
|
||||||
{
|
{
|
||||||
if ($actionName != 'placeholder') {
|
if ($actionName != 'placeholder') {
|
||||||
return parent::item($actionName, $args, $label, $description, $id, $cls);
|
return parent::item($actionName, $args, $label, $description, $id, $cls);
|
||||||
|
@ -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',
|
||||||
|
@ -53,7 +53,7 @@ class InviteButtonSection extends Section
|
|||||||
$this->out = $out;
|
$this->out = $out;
|
||||||
if (empty($buttonText)) {
|
if (empty($buttonText)) {
|
||||||
// TRANS: Default button text for inviting more users to the StatusNet instance.
|
// TRANS: Default button text for inviting more users to the StatusNet instance.
|
||||||
$this->buttonText = _m('BUTTON', 'Invite more colleagues');
|
$this->buttonText = _m('BUTTON', 'Invite more people');
|
||||||
} else {
|
} else {
|
||||||
$this->buttonText = $buttonText;
|
$this->buttonText = $buttonText;
|
||||||
}
|
}
|
||||||
|
@ -47,11 +47,13 @@ require_once 'Mail.php';
|
|||||||
function mail_backend()
|
function mail_backend()
|
||||||
{
|
{
|
||||||
static $backend = null;
|
static $backend = null;
|
||||||
|
global $_PEAR;
|
||||||
|
|
||||||
if (!$backend) {
|
if (!$backend) {
|
||||||
$backend = Mail::factory(common_config('mail', 'backend'),
|
$mail = new Mail();
|
||||||
|
$backend = $mail->factory(common_config('mail', 'backend'),
|
||||||
common_config('mail', 'params') ?: array());
|
common_config('mail', 'params') ?: array());
|
||||||
if (PEAR::isError($backend)) {
|
if ($_PEAR->isError($backend)) {
|
||||||
common_server_error($backend->getMessage(), 500);
|
common_server_error($backend->getMessage(), 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
26
lib/noticestreamaction.php
Normal file
26
lib/noticestreamaction.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
|
|
||||||
|
abstract class NoticestreamAction extends ProfileAction
|
||||||
|
{
|
||||||
|
protected $notice = null; // holds the stream result
|
||||||
|
|
||||||
|
protected function prepare(array $args=array()) {
|
||||||
|
parent::prepare($args);
|
||||||
|
|
||||||
|
// fetch the actual stream stuff
|
||||||
|
$stream = $this->getStream();
|
||||||
|
$this->notice = $stream->getNotices(($this->page-1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
|
||||||
|
|
||||||
|
if ($this->page > 1 && $this->notice->N == 0) {
|
||||||
|
// TRANS: Client error when page not found (404).
|
||||||
|
$this->clientError(_('No such page.'), 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// this fetches the NoticeStream
|
||||||
|
abstract public function getStream();
|
||||||
|
}
|
@ -103,8 +103,8 @@ class PeopletagsWidget extends Widget
|
|||||||
$this->out->elementStart('li', 'hashptag mode-' . $mode);
|
$this->out->elementStart('li', 'hashptag mode-' . $mode);
|
||||||
// Avoid space by using raw output.
|
// Avoid space by using raw output.
|
||||||
$pt = '<span class="mark_hash">#</span><a rel="tag" href="' .
|
$pt = '<span class="mark_hash">#</span><a rel="tag" href="' .
|
||||||
$this->url($this->tag->tag) .
|
htmlspecialchars($this->url()) .
|
||||||
'">' . $this->tag->tag . '</a>';
|
'">' . htmlspecialchars($this->tag->tag) . '</a>';
|
||||||
$this->out->raw($pt);
|
$this->out->raw($pt);
|
||||||
$this->out->elementEnd('li');
|
$this->out->elementEnd('li');
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ abstract class ProfileAction extends ManagedAction
|
|||||||
|
|
||||||
protected function prepare(array $args=array())
|
protected function prepare(array $args=array())
|
||||||
{
|
{
|
||||||
// this will call ->doPreparation() which lower classes can use
|
// this will call ->doPreparation() which child classes use to set $this->target
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
if ($this->target->hasRole(Profile_role::SILENCED)
|
if ($this->target->hasRole(Profile_role::SILENCED)
|
||||||
@ -58,16 +58,10 @@ 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());
|
||||||
|
|
||||||
// fetch the actual stream stuff
|
|
||||||
$this->profileActionPreparation();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,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,26 @@ 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)
|
// 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);
|
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))) {
|
||||||
|
@ -50,7 +50,7 @@ class PublicTagCloudSection extends TagCloudSection
|
|||||||
function title()
|
function title()
|
||||||
{
|
{
|
||||||
// TRANS: Title for inbox tag cloud section.
|
// TRANS: Title for inbox tag cloud section.
|
||||||
return _m('TITLE', 'Trending topics');
|
return _m('TITLE', 'Trends');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTags()
|
function getTags()
|
||||||
|
@ -108,6 +108,11 @@ class Router
|
|||||||
|
|
||||||
if (Event::handle('StartInitializeRouter', array(&$m))) {
|
if (Event::handle('StartInitializeRouter', array(&$m))) {
|
||||||
|
|
||||||
|
// top of the menu hierarchy, sometimes "Home"
|
||||||
|
$m->connect('', array('action' => 'top'));
|
||||||
|
|
||||||
|
// public endpoints
|
||||||
|
|
||||||
$m->connect('robots.txt', array('action' => 'robotstxt'));
|
$m->connect('robots.txt', array('action' => 'robotstxt'));
|
||||||
|
|
||||||
$m->connect('opensearch/people', array('action' => 'opensearch',
|
$m->connect('opensearch/people', array('action' => 'opensearch',
|
||||||
@ -156,13 +161,13 @@ class Router
|
|||||||
'deleteaccount',
|
'deleteaccount',
|
||||||
'restoreaccount',
|
'restoreaccount',
|
||||||
'top',
|
'top',
|
||||||
|
'public',
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($main as $a) {
|
foreach ($main as $a) {
|
||||||
$m->connect('main/'.$a, array('action' => $a));
|
$m->connect('main/'.$a, array('action' => $a));
|
||||||
}
|
}
|
||||||
|
|
||||||
$m->connect('main/public', array('action' => 'public'));
|
|
||||||
$m->connect('main/all', array('action' => 'networkpublic'));
|
$m->connect('main/all', array('action' => 'networkpublic'));
|
||||||
|
|
||||||
$m->connect('main/tagprofile/:id', array('action' => 'tagprofile'),
|
$m->connect('main/tagprofile/:id', array('action' => 'tagprofile'),
|
||||||
@ -239,12 +244,10 @@ class Router
|
|||||||
array('action' => 'shownotice'),
|
array('action' => 'shownotice'),
|
||||||
array('notice' => '[0-9]+'));
|
array('notice' => '[0-9]+'));
|
||||||
|
|
||||||
$m->connect('notice/delete/:notice',
|
$m->connect('notice/:notice/delete',
|
||||||
array('action' => 'deletenotice'),
|
array('action' => 'deletenotice'),
|
||||||
array('notice' => '[0-9]+'));
|
array('notice' => '[0-9]+'));
|
||||||
|
|
||||||
$m->connect('notice/delete', array('action' => 'deletenotice'));
|
|
||||||
|
|
||||||
// conversation
|
// conversation
|
||||||
|
|
||||||
$m->connect('conversation/:id',
|
$m->connect('conversation/:id',
|
||||||
@ -875,9 +878,6 @@ class Router
|
|||||||
array('action' => 'rsd',
|
array('action' => 'rsd',
|
||||||
'nickname' => $nickname));
|
'nickname' => $nickname));
|
||||||
|
|
||||||
$m->connect('',
|
|
||||||
array('action' => 'startpage'));
|
|
||||||
|
|
||||||
// peopletags
|
// peopletags
|
||||||
|
|
||||||
$m->connect('peopletags',
|
$m->connect('peopletags',
|
||||||
@ -930,9 +930,6 @@ class Router
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$m->connect('', array('action' => 'startpage'));
|
|
||||||
$m->connect('main/public', array('action' => 'public'));
|
|
||||||
$m->connect('main/all', array('action' => 'networkpublic'));
|
|
||||||
$m->connect('rss', array('action' => 'publicrss'));
|
$m->connect('rss', array('action' => 'publicrss'));
|
||||||
$m->connect('featuredrss', array('action' => 'featuredrss'));
|
$m->connect('featuredrss', array('action' => 'featuredrss'));
|
||||||
$m->connect('featured/', array('action' => 'featured'));
|
$m->connect('featured/', array('action' => 'featured'));
|
||||||
@ -950,6 +947,13 @@ class Router
|
|||||||
array('action' => 'subqueue'),
|
array('action' => 'subqueue'),
|
||||||
array('nickname' => Nickname::DISPLAY_FMT));
|
array('nickname' => Nickname::DISPLAY_FMT));
|
||||||
|
|
||||||
|
// some targeted RSS 1.0 actions (extends TargetedRss10Action)
|
||||||
|
foreach (array('all', 'replies') as $a) {
|
||||||
|
$m->connect(':nickname/'.$a.'/rss',
|
||||||
|
array('action' => $a.'rss'),
|
||||||
|
array('nickname' => Nickname::DISPLAY_FMT));
|
||||||
|
}
|
||||||
|
|
||||||
// people tags
|
// people tags
|
||||||
|
|
||||||
$m->connect(':nickname/peopletags',
|
$m->connect(':nickname/peopletags',
|
||||||
@ -1017,12 +1021,6 @@ class Router
|
|||||||
array('nickname' => Nickname::DISPLAY_FMT));
|
array('nickname' => Nickname::DISPLAY_FMT));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (array('all', 'replies') as $a) {
|
|
||||||
$m->connect(':nickname/'.$a.'/rss',
|
|
||||||
array('action' => $a.'rss'),
|
|
||||||
array('nickname' => Nickname::DISPLAY_FMT));
|
|
||||||
}
|
|
||||||
|
|
||||||
$m->connect(':nickname/avatar',
|
$m->connect(':nickname/avatar',
|
||||||
array('action' => 'avatarbynickname'),
|
array('action' => 'avatarbynickname'),
|
||||||
array('nickname' => Nickname::DISPLAY_FMT));
|
array('nickname' => Nickname::DISPLAY_FMT));
|
||||||
|
@ -28,11 +28,11 @@
|
|||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
|
|
||||||
define('DEFAULT_RSS_LIMIT', 48);
|
define('DEFAULT_RSS_LIMIT', 48);
|
||||||
|
|
||||||
class Rss10Action extends Action
|
class Rss10Action extends ManagedAction
|
||||||
{
|
{
|
||||||
// This will contain the details of each feed item's author and be used to generate SIOC data.
|
// This will contain the details of each feed item's author and be used to generate SIOC data.
|
||||||
|
|
||||||
@ -41,47 +41,16 @@ class Rss10Action extends Action
|
|||||||
var $notices = null;
|
var $notices = null;
|
||||||
var $tags_already_output = array();
|
var $tags_already_output = array();
|
||||||
|
|
||||||
/**
|
public function isReadOnly($args)
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* Just wraps the Action constructor.
|
|
||||||
*
|
|
||||||
* @param string $output URI to output to, default = stdout
|
|
||||||
* @param boolean $indent Whether to indent output, default true
|
|
||||||
*
|
|
||||||
* @see Action::__construct
|
|
||||||
*/
|
|
||||||
|
|
||||||
function __construct($output='php://output', $indent=null)
|
|
||||||
{
|
|
||||||
parent::__construct($output, $indent);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Do we need to write to the database?
|
|
||||||
*
|
|
||||||
* @return boolean true
|
|
||||||
*/
|
|
||||||
|
|
||||||
function isReadonly()
|
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected function doPreparation()
|
||||||
* Read arguments and initialize members
|
|
||||||
*
|
|
||||||
* @param array $args Arguments from $_REQUEST
|
|
||||||
* @return boolean success
|
|
||||||
*/
|
|
||||||
|
|
||||||
function prepare($args)
|
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
$this->limit = $this->int('limit');
|
||||||
|
|
||||||
$this->limit = (int) $this->trimmed('limit');
|
if (empty($this->limit)) {
|
||||||
|
|
||||||
if ($this->limit == 0) {
|
|
||||||
$this->limit = DEFAULT_RSS_LIMIT;
|
$this->limit = DEFAULT_RSS_LIMIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +62,7 @@ class Rss10Action extends Action
|
|||||||
|
|
||||||
// If the user hits cancel -- bam!
|
// If the user hits cancel -- bam!
|
||||||
$this->show_basic_auth_error();
|
$this->show_basic_auth_error();
|
||||||
return;
|
// the above calls 'exit'
|
||||||
} else {
|
} else {
|
||||||
$nickname = $_SERVER['PHP_AUTH_USER'];
|
$nickname = $_SERVER['PHP_AUTH_USER'];
|
||||||
$password = $_SERVER['PHP_AUTH_PW'];
|
$password = $_SERVER['PHP_AUTH_PW'];
|
||||||
@ -104,27 +73,19 @@ class Rss10Action extends Action
|
|||||||
|
|
||||||
common_log(LOG_WARNING, "Failed RSS auth attempt, nickname = $nickname, proxy = $proxy, ip = $ip.");
|
common_log(LOG_WARNING, "Failed RSS auth attempt, nickname = $nickname, proxy = $proxy, ip = $ip.");
|
||||||
$this->show_basic_auth_error();
|
$this->show_basic_auth_error();
|
||||||
return;
|
// the above calls 'exit'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
$this->doStreamPreparation();
|
||||||
|
|
||||||
|
$this->notices = $this->getNotices($this->limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected function doStreamPreparation()
|
||||||
* Handle a request
|
|
||||||
*
|
|
||||||
* @param array $args Arguments from $_REQUEST
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
|
|
||||||
function handle($args)
|
|
||||||
{
|
{
|
||||||
// Parent handling, including cache check
|
// for example if we need to set $this->target or something
|
||||||
parent::handle($args);
|
|
||||||
$this->showRss();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_basic_auth_error()
|
function show_basic_auth_error()
|
||||||
@ -137,6 +98,7 @@ class Rss10Action extends Action
|
|||||||
$this->element('request', null, $_SERVER['REQUEST_URI']);
|
$this->element('request', null, $_SERVER['REQUEST_URI']);
|
||||||
$this->elementEnd('hash');
|
$this->elementEnd('hash');
|
||||||
$this->endXML();
|
$this->endXML();
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -145,7 +107,7 @@ class Rss10Action extends Action
|
|||||||
* @return array an array of Notice objects sorted in reverse chron
|
* @return array an array of Notice objects sorted in reverse chron
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getNotices()
|
protected function getNotices()
|
||||||
{
|
{
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
@ -170,7 +132,7 @@ class Rss10Action extends Action
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function showRss()
|
function showPage()
|
||||||
{
|
{
|
||||||
$this->initRss();
|
$this->initRss();
|
||||||
$this->showChannel();
|
$this->showChannel();
|
@ -29,10 +29,10 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||||||
|
|
||||||
class SelftagsWidget extends PeopletagsWidget
|
class SelftagsWidget extends PeopletagsWidget
|
||||||
{
|
{
|
||||||
function url($tag)
|
public function url()
|
||||||
{
|
{
|
||||||
// link to self tag page
|
// link to self tag page
|
||||||
return common_local_url('selftag', array('tag' => $tag));
|
return common_local_url('selftag', array('tag' => $this->tag->tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
function label()
|
function label()
|
||||||
|
@ -115,11 +115,10 @@ class TagCloudSection extends Section
|
|||||||
|
|
||||||
function tagUrl($tag)
|
function tagUrl($tag)
|
||||||
{
|
{
|
||||||
if ('showstream' === $this->out->trimmed('action')) {
|
if ($this->out instanceof ShowstreamAction) {
|
||||||
return common_local_url('showstream', array('nickname' => $this->out->profile->nickname, 'tag' => $tag));
|
return common_local_url('showstream', array('nickname' => $this->out->getTarget()->getNickname(), 'tag' => $tag));
|
||||||
} else {
|
|
||||||
return common_local_url('tag', array('tag' => $tag));
|
|
||||||
}
|
}
|
||||||
|
return common_local_url('tag', array('tag' => $tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
function divId()
|
function divId()
|
||||||
|
46
lib/targetedrss10action.php
Normal file
46
lib/targetedrss10action.php
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<?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);
|
||||||
|
}
|
||||||
|
}
|
@ -87,10 +87,9 @@ class ToSelector extends Widget
|
|||||||
$choices['public:everyone'] = _m('SENDTO','Everyone');
|
$choices['public:everyone'] = _m('SENDTO','Everyone');
|
||||||
$default = 'public:everyone';
|
$default = 'public:everyone';
|
||||||
}
|
}
|
||||||
// XXX: better name...?
|
|
||||||
// TRANS: Option in drop-down of potential addressees.
|
// TRANS: Option in drop-down of potential addressees.
|
||||||
// TRANS: %s is a StatusNet sitename.
|
// TRANS: %s is a StatusNet sitename.
|
||||||
$choices['public:site'] = sprintf(_('My colleagues at %s'), common_config('site', 'name'));
|
$choices['public:site'] = sprintf(_('Everyone at %s'), common_config('site', 'name'));
|
||||||
|
|
||||||
$groups = $this->user->getGroups();
|
$groups = $this->user->getGroups();
|
||||||
|
|
||||||
|
0
plugins/AntiBrute/AntiBrutePlugin.php
Executable file → Normal file
0
plugins/AntiBrute/AntiBrutePlugin.php
Executable file → Normal file
@ -28,11 +28,7 @@
|
|||||||
* 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') && !defined('LACONICA')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once INSTALLDIR.'/lib/rssaction.php';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RSS feed for user bookmarks action class.
|
* RSS feed for user bookmarks action class.
|
||||||
@ -48,54 +44,12 @@ require_once INSTALLDIR.'/lib/rssaction.php';
|
|||||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
class BookmarksrssAction extends Rss10Action
|
class BookmarksrssAction extends TargetedRss10Action
|
||||||
{
|
{
|
||||||
/** The user whose bookmarks to display */
|
protected function getNotices()
|
||||||
|
|
||||||
var $user = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find the user to display by supplied nickname
|
|
||||||
*
|
|
||||||
* @param array $args Arguments from $_REQUEST
|
|
||||||
*
|
|
||||||
* @return boolean success
|
|
||||||
*/
|
|
||||||
function prepare($args)
|
|
||||||
{
|
|
||||||
parent::prepare($args);
|
|
||||||
|
|
||||||
$nickname = $this->trimmed('nickname');
|
|
||||||
$this->user = User::getKV('nickname', $nickname);
|
|
||||||
|
|
||||||
if (!$this->user) {
|
|
||||||
// TRANS: Client error displayed when trying to get the RSS feed with bookmarks of a user that does not exist.
|
|
||||||
$this->clientError(_('No such user.'));
|
|
||||||
} else {
|
|
||||||
$this->notices = $this->getNotices($this->limit);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get notices
|
|
||||||
*
|
|
||||||
* @param integer $limit max number of notices to return
|
|
||||||
*
|
|
||||||
* @return array notices
|
|
||||||
*/
|
|
||||||
function getNotices($limit=0)
|
|
||||||
{
|
{
|
||||||
$user = $this->user;
|
$stream = new BookmarksNoticeStream($this->target->getID(), true);
|
||||||
|
return $stream->getNotices(0, $this->limit)->fetchAll();
|
||||||
$notice = new BookmarksNoticeStream($this->user->id, true);
|
|
||||||
$notice = $notice->getNotices(0, NOTICES_PER_PAGE);
|
|
||||||
|
|
||||||
$notices = array();
|
|
||||||
while ($notice->fetch()) {
|
|
||||||
$notices[] = clone($notice);
|
|
||||||
}
|
|
||||||
return $notices;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,31 +59,19 @@ class BookmarksrssAction extends Rss10Action
|
|||||||
*/
|
*/
|
||||||
function getChannel()
|
function getChannel()
|
||||||
{
|
{
|
||||||
$user = $this->user;
|
|
||||||
$c = array('url' => common_local_url('bookmarksrss',
|
$c = array('url' => common_local_url('bookmarksrss',
|
||||||
array('nickname' =>
|
array('nickname' =>
|
||||||
$user->nickname)),
|
$this->target->getNickname())),
|
||||||
// TRANS: Title of RSS feed with bookmarks of a user.
|
// TRANS: Title of RSS feed with bookmarks of a user.
|
||||||
// TRANS: %s is a user's nickname.
|
// TRANS: %s is a user's nickname.
|
||||||
'title' => sprintf(_("%s's bookmarks"), $user->nickname),
|
'title' => sprintf(_("%s's bookmarks"), $this->target->getNickname()),
|
||||||
'link' => common_local_url('bookmarks',
|
'link' => common_local_url('bookmarks',
|
||||||
array('nickname' =>
|
array('nickname' =>
|
||||||
$user->nickname)),
|
$this->target->getNickname())),
|
||||||
// TRANS: Desciption of RSS feed with bookmarks of a user.
|
// TRANS: Desciption of RSS feed with bookmarks of a user.
|
||||||
// TRANS: %1$s is a user's nickname, %2$s is the name of the StatusNet site.
|
// TRANS: %1$s is a user's nickname, %2$s is the name of the StatusNet site.
|
||||||
'description' => sprintf(_('Bookmarks posted by %1$s on %2$s!'),
|
'description' => sprintf(_('Bookmarks posted by %1$s on %2$s!'),
|
||||||
$user->nickname, common_config('site', 'name')));
|
$this->target->getNickname(), common_config('site', 'name')));
|
||||||
return $c;
|
return $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get image.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function getImage()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,9 +30,7 @@
|
|||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show a list of direct messages from or to the authenticating user
|
* Show a list of direct messages from or to the authenticating user
|
||||||
@ -62,13 +60,11 @@ class ApiDirectMessageAction extends ApiAuthAction
|
|||||||
*
|
*
|
||||||
* @return boolean success flag
|
* @return boolean success flag
|
||||||
*/
|
*/
|
||||||
function prepare($args)
|
protected function prepare(array $args=array())
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
$this->user = $this->auth_user;
|
if (!$this->scoped instanceof Profile) {
|
||||||
|
|
||||||
if (empty($this->user)) {
|
|
||||||
// TRANS: Client error given when a user was not found (404).
|
// TRANS: Client error given when a user was not found (404).
|
||||||
$this->clientError(_('No such user.'), 404);
|
$this->clientError(_('No such user.'), 404);
|
||||||
}
|
}
|
||||||
@ -83,30 +79,30 @@ class ApiDirectMessageAction extends ApiAuthAction
|
|||||||
$this->title = sprintf(
|
$this->title = sprintf(
|
||||||
// TRANS: Title. %s is a user nickname.
|
// TRANS: Title. %s is a user nickname.
|
||||||
_("Direct messages from %s"),
|
_("Direct messages from %s"),
|
||||||
$this->user->nickname
|
$this->scoped->getNickname()
|
||||||
);
|
);
|
||||||
$this->subtitle = sprintf(
|
$this->subtitle = sprintf(
|
||||||
// TRANS: Subtitle. %s is a user nickname.
|
// TRANS: Subtitle. %s is a user nickname.
|
||||||
_("All the direct messages sent from %s"),
|
_("All the direct messages sent from %s"),
|
||||||
$this->user->nickname
|
$this->scoped->getNickname()
|
||||||
);
|
);
|
||||||
$this->link = $server . $this->user->nickname . '/outbox';
|
$this->link = $server . $this->scoped->getNickname() . '/outbox';
|
||||||
$this->selfuri_base = common_root_url() . 'api/direct_messages/sent';
|
$this->selfuri_base = common_root_url() . 'api/direct_messages/sent';
|
||||||
$this->id = "tag:$taguribase:SentDirectMessages:" . $this->user->id;
|
$this->id = "tag:$taguribase:SentDirectMessages:" . $this->scoped->getID();
|
||||||
} else {
|
} else {
|
||||||
$this->title = sprintf(
|
$this->title = sprintf(
|
||||||
// TRANS: Title. %s is a user nickname.
|
// TRANS: Title. %s is a user nickname.
|
||||||
_("Direct messages to %s"),
|
_("Direct messages to %s"),
|
||||||
$this->user->nickname
|
$this->scoped->getNickname()
|
||||||
);
|
);
|
||||||
$this->subtitle = sprintf(
|
$this->subtitle = sprintf(
|
||||||
// TRANS: Subtitle. %s is a user nickname.
|
// TRANS: Subtitle. %s is a user nickname.
|
||||||
_("All the direct messages sent to %s"),
|
_("All the direct messages sent to %s"),
|
||||||
$this->user->nickname
|
$this->scoped->getNickname()
|
||||||
);
|
);
|
||||||
$this->link = $server . $this->user->nickname . '/inbox';
|
$this->link = $server . $this->scoped->getNickname() . '/inbox';
|
||||||
$this->selfuri_base = common_root_url() . 'api/direct_messages';
|
$this->selfuri_base = common_root_url() . 'api/direct_messages';
|
||||||
$this->id = "tag:$taguribase:DirectMessages:" . $this->user->id;
|
$this->id = "tag:$taguribase:DirectMessages:" . $this->scoped->getID();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->messages = $this->getMessages();
|
$this->messages = $this->getMessages();
|
||||||
@ -114,18 +110,9 @@ class ApiDirectMessageAction extends ApiAuthAction
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected function handle()
|
||||||
* Handle the request
|
|
||||||
*
|
|
||||||
* Show the messages
|
|
||||||
*
|
|
||||||
* @param array $args $_REQUEST data (unused)
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function handle($args)
|
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle();
|
||||||
$this->showMessages();
|
$this->showMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,9 +153,9 @@ class ApiDirectMessageAction extends ApiAuthAction
|
|||||||
$message = new Message();
|
$message = new Message();
|
||||||
|
|
||||||
if ($this->arg('sent')) {
|
if ($this->arg('sent')) {
|
||||||
$message->from_profile = $this->user->id;
|
$message->from_profile = $this->scoped->getID();
|
||||||
} else {
|
} else {
|
||||||
$message->to_profile = $this->user->id;
|
$message->to_profile = $this->scoped->getID();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($this->max_id)) {
|
if (!empty($this->max_id)) {
|
||||||
|
@ -30,9 +30,7 @@
|
|||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new direct message from the authenticating user to
|
* Creates a new direct message from the authenticating user to
|
||||||
@ -65,7 +63,7 @@ class ApiDirectMessageNewAction extends ApiAuthAction
|
|||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
if (empty($this->user)) {
|
if (!$this->scoped instanceof Profile) {
|
||||||
// TRANS: Client error when user not found for an API direct message action.
|
// TRANS: Client error when user not found for an API direct message action.
|
||||||
$this->clientError(_('No such user.'), 404);
|
$this->clientError(_('No such user.'), 404);
|
||||||
}
|
}
|
||||||
@ -111,10 +109,10 @@ class ApiDirectMessageNewAction extends ApiAuthAction
|
|||||||
if (!$this->other instanceof Profile) {
|
if (!$this->other instanceof Profile) {
|
||||||
// TRANS: Client error displayed if a recipient user could not be found (403).
|
// TRANS: Client error displayed if a recipient user could not be found (403).
|
||||||
$this->clientError(_('Recipient user not found.'), 403);
|
$this->clientError(_('Recipient user not found.'), 403);
|
||||||
} else if (!$this->user->mutuallySubscribed($this->other)) {
|
} else if (!$this->scoped->mutuallySubscribed($this->other)) {
|
||||||
// TRANS: Client error displayed trying to direct message another user who's not a friend (403).
|
// TRANS: Client error displayed trying to direct message another user who's not a friend (403).
|
||||||
$this->clientError(_('Cannot send direct messages to users who aren\'t your friend.'), 403);
|
$this->clientError(_('Cannot send direct messages to users who aren\'t your friend.'), 403);
|
||||||
} else if ($this->user->id == $this->other->id) {
|
} else if ($this->scoped->getID() === $this->other->getID()) {
|
||||||
|
|
||||||
// Note: sending msgs to yourself is allowed by Twitter
|
// Note: sending msgs to yourself is allowed by Twitter
|
||||||
|
|
||||||
@ -123,8 +121,8 @@ class ApiDirectMessageNewAction extends ApiAuthAction
|
|||||||
}
|
}
|
||||||
|
|
||||||
$message = Message::saveNew(
|
$message = Message::saveNew(
|
||||||
$this->user->id,
|
$this->scoped->getID(),
|
||||||
$this->other->id,
|
$this->other->getID(),
|
||||||
html_entity_decode($this->content, ENT_NOQUOTES, 'UTF-8'),
|
html_entity_decode($this->content, ENT_NOQUOTES, 'UTF-8'),
|
||||||
$this->source
|
$this->source
|
||||||
);
|
);
|
||||||
|
@ -238,9 +238,9 @@ class DirectoryPlugin extends Plugin
|
|||||||
$nav->out->menuItem(
|
$nav->out->menuItem(
|
||||||
common_local_url('userdirectory'),
|
common_local_url('userdirectory'),
|
||||||
// TRANS: Menu item text for user directory.
|
// TRANS: Menu item text for user directory.
|
||||||
_m('MENU','Directory'),
|
_m('MENU','People'),
|
||||||
// TRANS: Menu item title for user directory.
|
// TRANS: Menu item title for user directory.
|
||||||
_m('User Directory.'),
|
_m('People.'),
|
||||||
$actionName == 'userdirectory',
|
$actionName == 'userdirectory',
|
||||||
'nav_directory'
|
'nav_directory'
|
||||||
);
|
);
|
||||||
|
@ -41,10 +41,6 @@ table.profile_list tr {
|
|||||||
float: none;
|
float: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.profile_list tr.alt {
|
|
||||||
background-color: #def; /* zebra stripe */
|
|
||||||
}
|
|
||||||
|
|
||||||
table.profie_list td {
|
table.profie_list td {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
@ -61,4 +57,4 @@ th.current.reverse {
|
|||||||
background-image: url(../images/control_arrow_up.gif);
|
background-image: url(../images/control_arrow_up.gif);
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-position: 60% 2px;
|
background-position: 60% 2px;
|
||||||
}
|
}
|
||||||
|
@ -27,11 +27,7 @@
|
|||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once INSTALLDIR . '/lib/subscriptionlist.php';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Widget to show a sortable list of subscriptions
|
* Widget to show a sortable list of subscriptions
|
||||||
@ -44,16 +40,6 @@ require_once INSTALLDIR . '/lib/subscriptionlist.php';
|
|||||||
*/
|
*/
|
||||||
class SortableGroupList extends SortableSubscriptionList
|
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()
|
function startList()
|
||||||
{
|
{
|
||||||
$this->out->elementStart('table', array('class' => 'profile_list xoxo'));
|
$this->out->elementStart('table', array('class' => 'profile_list xoxo'));
|
||||||
@ -119,25 +105,14 @@ class SortableGroupList extends SortableSubscriptionList
|
|||||||
$this->out->elementStart('tbody');
|
$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
|
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()
|
function showHomepage()
|
||||||
{
|
{
|
||||||
if (!empty($this->profile->homepage)) {
|
if (!empty($this->profile->homepage)) {
|
||||||
|
@ -27,11 +27,7 @@
|
|||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once INSTALLDIR . '/lib/subscriptionlist.php';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Widget to show a sortable list of subscriptions
|
* Widget to show a sortable list of subscriptions
|
||||||
@ -44,16 +40,6 @@ require_once INSTALLDIR . '/lib/subscriptionlist.php';
|
|||||||
*/
|
*/
|
||||||
class SortableSubscriptionList extends SubscriptionList
|
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()
|
function startList()
|
||||||
{
|
{
|
||||||
$this->out->elementStart('table', array('class' => 'profile_list xoxo'));
|
$this->out->elementStart('table', array('class' => 'profile_list xoxo'));
|
||||||
@ -128,48 +114,14 @@ class SortableSubscriptionList extends SubscriptionList
|
|||||||
$this->out->elementEnd('table');
|
$this->out->elementEnd('table');
|
||||||
}
|
}
|
||||||
|
|
||||||
function showProfiles()
|
function newListItem($profile)
|
||||||
{
|
{
|
||||||
// Note: we don't use fetchAll() because it's borked with query()
|
return new SortableSubscriptionListItem($profile, $this->owner, $this->action);
|
||||||
|
|
||||||
$profiles = array();
|
|
||||||
|
|
||||||
while ($this->profile->fetch()) {
|
|
||||||
$profiles[] = clone($this->profile);
|
|
||||||
}
|
|
||||||
|
|
||||||
$cnt = count($profiles);
|
|
||||||
|
|
||||||
$max = min($cnt, $this->maxProfiles());
|
|
||||||
|
|
||||||
for ($i = 0; $i < $max; $i++) {
|
|
||||||
$odd = ($i % 2 == 0); // for zebra striping
|
|
||||||
$pli = $this->newListItem($profiles[$i], $odd);
|
|
||||||
$pli->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $cnt;
|
|
||||||
}
|
|
||||||
|
|
||||||
function newListItem($profile, $odd)
|
|
||||||
{
|
|
||||||
return new SortableSubscriptionListItem($profile, $this->owner, $this->action, $odd);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SortableSubscriptionListItem extends SubscriptionListItem
|
class SortableSubscriptionListItem extends SubscriptionListItem
|
||||||
{
|
{
|
||||||
/** Owner of this list */
|
|
||||||
var $owner = null;
|
|
||||||
|
|
||||||
function __construct($profile, $owner, $action, $alt)
|
|
||||||
{
|
|
||||||
parent::__construct($profile, $owner, $action);
|
|
||||||
|
|
||||||
$this->alt = $alt; // is this row alternate?
|
|
||||||
$this->owner = $owner;
|
|
||||||
}
|
|
||||||
|
|
||||||
function startItem()
|
function startItem()
|
||||||
{
|
{
|
||||||
$attr = array(
|
$attr = array(
|
||||||
@ -177,10 +129,6 @@ class SortableSubscriptionListItem extends SubscriptionListItem
|
|||||||
'id' => 'profile-' . $this->profile->id
|
'id' => 'profile-' . $this->profile->id
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($this->alt) {
|
|
||||||
$attr['class'] .= ' alt';
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->out->elementStart('tr', $attr);
|
$this->out->elementStart('tr', $attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
0
plugins/DomainStatusNetwork/scripts/installforemail.php
Normal file → Executable file
0
plugins/DomainStatusNetwork/scripts/installforemail.php
Normal file → Executable file
0
plugins/DomainStatusNetwork/scripts/proposesite.php
Normal file → Executable file
0
plugins/DomainStatusNetwork/scripts/proposesite.php
Normal file → Executable file
0
plugins/DomainStatusNetwork/scripts/sitefordomain.php
Normal file → Executable file
0
plugins/DomainStatusNetwork/scripts/sitefordomain.php
Normal file → Executable file
0
plugins/EmailRegistration/scripts/cancelemailregistration.php
Normal file → Executable file
0
plugins/EmailRegistration/scripts/cancelemailregistration.php
Normal file → Executable file
0
plugins/EmailRegistration/scripts/registeremailuser.php
Normal file → Executable file
0
plugins/EmailRegistration/scripts/registeremailuser.php
Normal file → Executable file
0
plugins/EmailReminder/scripts/sendemailreminder.php
Normal file → Executable file
0
plugins/EmailReminder/scripts/sendemailreminder.php
Normal file → Executable file
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,11 +28,7 @@
|
|||||||
* 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') && !defined('LACONICA')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once INSTALLDIR.'/lib/rssaction.php';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RSS feed for user favorites action class.
|
* RSS feed for user favorites action class.
|
||||||
@ -47,50 +43,15 @@ require_once INSTALLDIR.'/lib/rssaction.php';
|
|||||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
class FavoritesrssAction extends Rss10Action
|
class FavoritesrssAction extends TargetedRss10Action
|
||||||
{
|
{
|
||||||
/** The user whose favorites to display */
|
protected function getNotices()
|
||||||
|
|
||||||
var $user = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find the user to display by supplied nickname
|
|
||||||
*
|
|
||||||
* @param array $args Arguments from $_REQUEST
|
|
||||||
*
|
|
||||||
* @return boolean success
|
|
||||||
*/
|
|
||||||
function prepare($args)
|
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
// is this our own stream?
|
||||||
|
$own = $this->scoped instanceof Profile ? $this->target->getID() === $this->scoped->getID() : false;
|
||||||
|
|
||||||
$nickname = $this->trimmed('nickname');
|
$stream = Fave::stream($this->target->getID(), 0, $this->limit, $own);
|
||||||
$this->user = User::getKV('nickname', $nickname);
|
return $stream->fetchAll();
|
||||||
|
|
||||||
if (!$this->user) {
|
|
||||||
// TRANS: Client error displayed when trying to get the RSS feed with favorites of a user that does not exist.
|
|
||||||
$this->clientError(_('No such user.'));
|
|
||||||
} else {
|
|
||||||
$this->notices = $this->getNotices($this->limit);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get notices
|
|
||||||
*
|
|
||||||
* @param integer $limit max number of notices to return
|
|
||||||
*
|
|
||||||
* @return array notices
|
|
||||||
*/
|
|
||||||
function getNotices($limit=0)
|
|
||||||
{
|
|
||||||
$notice = Fave::stream($this->user->id, 0, $limit, $false);
|
|
||||||
$notices = array();
|
|
||||||
while ($notice->fetch()) {
|
|
||||||
$notices[] = clone($notice);
|
|
||||||
}
|
|
||||||
return $notices;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -116,15 +77,4 @@ class FavoritesrssAction extends Rss10Action
|
|||||||
$user->nickname, common_config('site', 'name')));
|
$user->nickname, common_config('site', 'name')));
|
||||||
return $c;
|
return $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get image.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function getImage()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,13 +27,7 @@
|
|||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once INSTALLDIR.'/lib/personalgroupnav.php';
|
|
||||||
require_once INSTALLDIR.'/lib/noticelist.php';
|
|
||||||
require_once INSTALLDIR.'/lib/feedlist.php';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of replies
|
* List of replies
|
||||||
@ -44,119 +38,29 @@ require_once INSTALLDIR.'/lib/feedlist.php';
|
|||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
* @link http://status.net/
|
* @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()
|
function title()
|
||||||
{
|
{
|
||||||
if ($this->page == 1) {
|
if ($this->page == 1) {
|
||||||
// TRANS: Title for first page of favourite notices of a user.
|
// TRANS: Title for first page of favourite notices of a user.
|
||||||
// TRANS: %s is the user for whom the favourite notices are displayed.
|
// 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 {
|
} else {
|
||||||
// TRANS: Title for all but the first page of favourite notices of a user.
|
// 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.
|
// 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'),
|
return sprintf(_('%1$s\'s favorite notices, page %2$d'),
|
||||||
$this->user->nickname,
|
$this->getTarget()->getNickname(),
|
||||||
$this->page);
|
$this->page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getStream()
|
||||||
* 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)
|
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
$own = $this->scoped instanceof Profile ? $this->scoped->sameAs($this->getTarget()) : false;
|
||||||
|
return new FaveNoticeStream($this->getTarget()->getID(), $own);
|
||||||
$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();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Feeds for the <head> section
|
|
||||||
*
|
|
||||||
* @return array Feed objects to show
|
|
||||||
*/
|
|
||||||
function getFeeds()
|
function getFeeds()
|
||||||
{
|
{
|
||||||
return array(new Feed(Feed::JSON,
|
return array(new Feed(Feed::JSON,
|
||||||
@ -223,7 +127,7 @@ class ShowfavoritesAction extends Action
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function showContent()
|
function showNotices()
|
||||||
{
|
{
|
||||||
$nl = new FavoritesNoticeList($this->notice, $this);
|
$nl = new FavoritesNoticeList($this->notice, $this);
|
||||||
|
|
||||||
@ -234,7 +138,7 @@ class ShowfavoritesAction extends Action
|
|||||||
|
|
||||||
$this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
|
$this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
|
||||||
$this->page, 'showfavorites',
|
$this->page, 'showfavorites',
|
||||||
array('nickname' => $this->user->nickname));
|
array('nickname' => $this->getTarget()->getNickname()));
|
||||||
}
|
}
|
||||||
|
|
||||||
function showPageNotice() {
|
function showPageNotice() {
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user