forked from GNUsocial/gnu-social
Merge branch 'testing' into privategroup
Conflicts: lib/groupeditform.php
This commit is contained in:
commit
99db745f9d
@ -143,7 +143,7 @@ class ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction
|
||||
|
||||
if ($this->format == 'xml') {
|
||||
$this->initDocument('xml');
|
||||
$this->showTwitterXmlUser($twitter_user);
|
||||
$this->showTwitterXmlUser($twitter_user, 'user', true);
|
||||
$this->endDocument('xml');
|
||||
} elseif ($this->format == 'json') {
|
||||
$this->initDocument('json');
|
||||
|
@ -154,7 +154,7 @@ class ApiAccountUpdateProfileAction extends ApiAuthAction
|
||||
|
||||
if ($this->format == 'xml') {
|
||||
$this->initDocument('xml');
|
||||
$this->showTwitterXmlUser($twitter_user);
|
||||
$this->showTwitterXmlUser($twitter_user, 'user', true);
|
||||
$this->endDocument('xml');
|
||||
} elseif ($this->format == 'json') {
|
||||
$this->initDocument('json');
|
||||
|
@ -204,7 +204,7 @@ class ApiAccountUpdateProfileBackgroundImageAction extends ApiAuthAction
|
||||
|
||||
if ($this->format == 'xml') {
|
||||
$this->initDocument('xml');
|
||||
$this->showTwitterXmlUser($twitter_user);
|
||||
$this->showTwitterXmlUser($twitter_user, 'user', true);
|
||||
$this->endDocument('xml');
|
||||
} elseif ($this->format == 'json') {
|
||||
$this->initDocument('json');
|
||||
|
@ -188,7 +188,7 @@ class ApiAccountUpdateProfileColorsAction extends ApiAuthAction
|
||||
|
||||
if ($this->format == 'xml') {
|
||||
$this->initDocument('xml');
|
||||
$this->showTwitterXmlUser($twitter_user);
|
||||
$this->showTwitterXmlUser($twitter_user, 'user', true);
|
||||
$this->endDocument('xml');
|
||||
} elseif ($this->format == 'json') {
|
||||
$this->initDocument('json');
|
||||
|
@ -112,16 +112,17 @@ class ApiAccountUpdateProfileImageAction extends ApiAuthAction
|
||||
return;
|
||||
}
|
||||
|
||||
$type = $imagefile->preferredType();
|
||||
$filename = Avatar::filename(
|
||||
$user->id,
|
||||
image_type_to_extension($imagefile->type),
|
||||
image_type_to_extension($type),
|
||||
null,
|
||||
'tmp'.common_timestamp()
|
||||
);
|
||||
|
||||
$filepath = Avatar::path($filename);
|
||||
|
||||
move_uploaded_file($imagefile->filepath, $filepath);
|
||||
$imagefile->copyTo($filepath);
|
||||
|
||||
$profile = $this->user->getProfile();
|
||||
|
||||
@ -139,7 +140,7 @@ class ApiAccountUpdateProfileImageAction extends ApiAuthAction
|
||||
|
||||
if ($this->format == 'xml') {
|
||||
$this->initDocument('xml');
|
||||
$this->showTwitterXmlUser($twitter_user);
|
||||
$this->showTwitterXmlUser($twitter_user, 'user', true);
|
||||
$this->endDocument('xml');
|
||||
} elseif ($this->format == 'json') {
|
||||
$this->initDocument('json');
|
||||
|
@ -39,7 +39,6 @@ require_once INSTALLDIR.'/lib/apibareauth.php';
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class ApiAtomServiceAction extends ApiBareAuthAction
|
||||
{
|
||||
/**
|
||||
@ -50,13 +49,13 @@ class ApiAtomServiceAction extends ApiBareAuthAction
|
||||
* @return boolean success flag
|
||||
*
|
||||
*/
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
parent::prepare($args);
|
||||
$this->user = $this->getTargetUser($this->arg('id'));
|
||||
|
||||
if (empty($this->user)) {
|
||||
// TRANS: Client error displayed when making an Atom API request for an unknown user.
|
||||
$this->clientError(_('No such user.'), 404, $this->format);
|
||||
return;
|
||||
}
|
||||
@ -71,7 +70,6 @@ class ApiAtomServiceAction extends ApiBareAuthAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($args)
|
||||
{
|
||||
parent::handle($args);
|
||||
@ -83,13 +81,15 @@ class ApiAtomServiceAction extends ApiBareAuthAction
|
||||
'xmlns:atom' => 'http://www.w3.org/2005/Atom',
|
||||
'xmlns:activity' => 'http://activitystrea.ms/spec/1.0/'));
|
||||
$this->elementStart('workspace');
|
||||
$this->element('atom:title', null, _('Main'));
|
||||
// TRANS: Title for Atom feed.
|
||||
$this->element('atom:title', null, _m('ATOM','Main'));
|
||||
$this->elementStart('collection',
|
||||
array('href' => common_local_url('ApiTimelineUser',
|
||||
array('id' => $this->user->id,
|
||||
'format' => 'atom'))));
|
||||
$this->element('atom:title',
|
||||
null,
|
||||
// TRANS: Title for Atom feed. %s is a user nickname.
|
||||
sprintf(_("%s timeline"),
|
||||
$this->user->nickname));
|
||||
$this->element('accept', null, 'application/atom+xml;type=entry');
|
||||
@ -100,6 +100,7 @@ class ApiAtomServiceAction extends ApiBareAuthAction
|
||||
array('subscriber' => $this->user->id))));
|
||||
$this->element('atom:title',
|
||||
null,
|
||||
// TRANS: Title for Atom feed with a user's subscriptions. %s is a user nickname.
|
||||
sprintf(_("%s subscriptions"),
|
||||
$this->user->nickname));
|
||||
$this->element('accept', null, 'application/atom+xml;type=entry');
|
||||
@ -110,6 +111,7 @@ class ApiAtomServiceAction extends ApiBareAuthAction
|
||||
array('profile' => $this->user->id))));
|
||||
$this->element('atom:title',
|
||||
null,
|
||||
// TRANS: Title for Atom feed with a user's favorite notices. %s is a user nickname.
|
||||
sprintf(_("%s favorites"),
|
||||
$this->user->nickname));
|
||||
$this->element('accept', null, 'application/atom+xml;type=entry');
|
||||
@ -120,6 +122,7 @@ class ApiAtomServiceAction extends ApiBareAuthAction
|
||||
array('profile' => $this->user->id))));
|
||||
$this->element('atom:title',
|
||||
null,
|
||||
// TRANS: Title for Atom feed with a user's memberships. %s is a user nickname.
|
||||
sprintf(_("%s memberships"),
|
||||
$this->user->nickname));
|
||||
$this->element('accept', null, 'application/atom+xml;type=entry');
|
||||
|
@ -92,6 +92,7 @@ class ApiBlockCreateAction extends ApiAuthAction
|
||||
}
|
||||
|
||||
if (empty($this->user) || empty($this->other)) {
|
||||
// TRANS: Client error displayed when trying to block a non-existing user or a user from another site.
|
||||
$this->clientError(_('No such user.'), 404, $this->format);
|
||||
return;
|
||||
}
|
||||
|
@ -84,6 +84,7 @@ class ApiOauthAccessTokenAction extends ApiOauthAction
|
||||
common_debug(var_export($req, true));
|
||||
$code = $e->getCode();
|
||||
$this->clientError($e->getMessage(), empty($code) ? 401 : $code, 'text');
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($atok)) {
|
||||
@ -98,7 +99,7 @@ class ApiOauthAccessTokenAction extends ApiOauthAction
|
||||
|
||||
common_log(LOG_WARNING, $msg);
|
||||
// TRANS: Client error given from the OAuth API when the request token or verifier is invalid.
|
||||
$this->clientError(_("Invalid request token or verifier.", 400, 'text'));
|
||||
$this->clientError(_("Invalid request token or verifier."), 400, 'text');
|
||||
} else {
|
||||
common_log(
|
||||
LOG_INFO,
|
||||
|
@ -114,6 +114,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
|
||||
$this->deleteNotice();
|
||||
break;
|
||||
default:
|
||||
// TRANS: Client error displayed calling an unsupported HTTP error in API status show.
|
||||
$this->clientError(_('HTTP method not supported.'), 405);
|
||||
return;
|
||||
}
|
||||
@ -138,6 +139,8 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
|
||||
$this->showSingleAtomStatus($this->notice);
|
||||
break;
|
||||
default:
|
||||
// TRANS: Exception thrown requesting an unsupported notice output format.
|
||||
// TRANS: %s is the requested output format.
|
||||
throw new Exception(sprintf(_("Unsupported format: %s"), $this->format));
|
||||
}
|
||||
} else {
|
||||
@ -171,7 +174,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
|
||||
*
|
||||
* @return boolean true
|
||||
*/
|
||||
|
||||
|
||||
function isReadOnly($args)
|
||||
{
|
||||
return ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD');
|
||||
@ -220,6 +223,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
|
||||
function deleteNotice()
|
||||
{
|
||||
if ($this->format != 'atom') {
|
||||
// TRANS: Client error displayed when trying to delete a notice not using the Atom format.
|
||||
$this->clientError(_("Can only delete using the Atom format."));
|
||||
return;
|
||||
}
|
||||
@ -227,7 +231,8 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
|
||||
if (empty($this->auth_user) ||
|
||||
($this->notice->profile_id != $this->auth_user->id &&
|
||||
!$this->auth_user->hasRight(Right::DELETEOTHERSNOTICE))) {
|
||||
$this->clientError(_('Can\'t delete this notice.'), 403);
|
||||
// TRANS: Client error displayed when a user has no rights to delete notices of other users.
|
||||
$this->clientError(_('Cannot delete this notice.'), 403);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -240,6 +245,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
|
||||
|
||||
header('HTTP/1.1 200 OK');
|
||||
header('Content-Type: text/plain');
|
||||
// TRANS: Confirmation of notice deletion in API. %d is the ID (number) of the deleted notice.
|
||||
print(sprintf(_('Deleted notice %d'), $this->notice->id));
|
||||
print("\n");
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
||||
*
|
||||
* @return boolean true
|
||||
*/
|
||||
|
||||
|
||||
function isReadOnly($args)
|
||||
{
|
||||
return ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD');
|
||||
@ -307,11 +307,13 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
||||
|
||||
$xml = trim(file_get_contents('php://input'));
|
||||
if (empty($xml)) {
|
||||
// TRANS: Client error displayed attempting to post an empty API notice.
|
||||
$this->clientError(_('Atom post must not be empty.'));
|
||||
}
|
||||
|
||||
$dom = DOMDocument::loadXML($xml);
|
||||
if (!$dom) {
|
||||
// TRANS: Client error displayed attempting to post an API that is not well-formed XML.
|
||||
$this->clientError(_('Atom post must be well-formed XML.'));
|
||||
}
|
||||
|
||||
@ -329,8 +331,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
||||
if (Event::handle('StartAtomPubNewActivity', array(&$activity, $this->user, &$saved))) {
|
||||
|
||||
if ($activity->verb != ActivityVerb::POST) {
|
||||
// TRANS: Client error displayed when not using the POST verb.
|
||||
// TRANS: Do not translate POST.
|
||||
// TRANS: Client error displayed when not using the POST verb. Do not translate POST.
|
||||
$this->clientError(_('Can only handle POST activities.'));
|
||||
return;
|
||||
}
|
||||
@ -375,6 +376,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
||||
} else {
|
||||
// @fixme fetch from $sourceUrl?
|
||||
// TRANS: Client error displayed when posting a notice without content through the API.
|
||||
// TRANS: %d is the notice ID (number).
|
||||
$this->clientError(sprintf(_('No content for notice %d.'),
|
||||
$note->id));
|
||||
return;
|
||||
@ -427,14 +429,14 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
||||
$profile = Profile::fromURI($uri);
|
||||
|
||||
if (!empty($profile)) {
|
||||
$options['replies'] = $uri;
|
||||
$options['replies'][] = $uri;
|
||||
} else {
|
||||
$group = User_group::staticGet('uri', $uri);
|
||||
if (!empty($group)) {
|
||||
$options['groups'] = $uri;
|
||||
$options['groups'][] = $uri;
|
||||
} else {
|
||||
// @fixme: hook for discovery here
|
||||
common_log(LOG_WARNING, sprintf(_('AtomPub post with unknown attention URI %s'), $uri));
|
||||
common_log(LOG_WARNING, sprintf('AtomPub post with unknown attention URI %s', $uri));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Copyright (C) 2010, StatusNet, Inc.
|
||||
*
|
||||
* Feed of ActivityStreams 'favorite' actions
|
||||
*
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@ -46,7 +46,6 @@ require_once INSTALLDIR . '/lib/apiauth.php';
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class AtompubfavoritefeedAction extends ApiAuthAction
|
||||
{
|
||||
private $_profile = null;
|
||||
@ -59,7 +58,6 @@ class AtompubfavoritefeedAction extends ApiAuthAction
|
||||
*
|
||||
* @return boolean true
|
||||
*/
|
||||
|
||||
function prepare($argarray)
|
||||
{
|
||||
parent::prepare($argarray);
|
||||
@ -67,7 +65,8 @@ class AtompubfavoritefeedAction extends ApiAuthAction
|
||||
$this->_profile = Profile::staticGet('id', $this->trimmed('profile'));
|
||||
|
||||
if (empty($this->_profile)) {
|
||||
throw new ClientException(_('No such profile'), 404);
|
||||
// TRANS: Client exception thrown when requesting a favorite feed for a non-existing profile.
|
||||
throw new ClientException(_('No such profile.'), 404);
|
||||
}
|
||||
|
||||
$offset = ($this->page-1) * $this->count;
|
||||
@ -76,7 +75,7 @@ class AtompubfavoritefeedAction extends ApiAuthAction
|
||||
$this->_faves = Fave::byProfile($this->_profile->id,
|
||||
$offset,
|
||||
$limit);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -87,7 +86,6 @@ class AtompubfavoritefeedAction extends ApiAuthAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($argarray=null)
|
||||
{
|
||||
parent::handle($argarray);
|
||||
@ -101,6 +99,7 @@ class AtompubfavoritefeedAction extends ApiAuthAction
|
||||
$this->addFavorite();
|
||||
break;
|
||||
default:
|
||||
// TRANS: Client exception thrown when using an unsupported HTTP method.
|
||||
throw new ClientException(_('HTTP method not supported.'), 405);
|
||||
return;
|
||||
}
|
||||
@ -113,7 +112,6 @@ class AtompubfavoritefeedAction extends ApiAuthAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showFeed()
|
||||
{
|
||||
header('Content-Type: application/atom+xml; charset=utf-8');
|
||||
@ -139,21 +137,25 @@ class AtompubfavoritefeedAction extends ApiAuthAction
|
||||
$feed->addAuthor($this->_profile->getBestName(),
|
||||
$this->_profile->getURI());
|
||||
|
||||
// TRANS: Title for Atom favorites feed.
|
||||
// TRANS: %s is a user nickname.
|
||||
$feed->setTitle(sprintf(_("%s favorites"),
|
||||
$this->_profile->getBestName()));
|
||||
|
||||
$feed->setSubtitle(sprintf(_("Notices %s has favorited to on %s"),
|
||||
// TRANS: Subtitle for Atom favorites feed.
|
||||
// TRANS: %1$s is a user nickname, %2$s is the StatusNet sitename.
|
||||
$feed->setSubtitle(sprintf(_('Notices %1$s has favorited on %2$s'),
|
||||
$this->_profile->getBestName(),
|
||||
common_config('site', 'name')));
|
||||
|
||||
$feed->addLink(common_local_url('showfavorites',
|
||||
array('nickname' =>
|
||||
array('nickname' =>
|
||||
$this->_profile->nickname)));
|
||||
|
||||
$feed->addLink($url,
|
||||
array('rel' => 'self',
|
||||
'type' => 'application/atom+xml'));
|
||||
|
||||
|
||||
// If there's more...
|
||||
|
||||
if ($this->page > 1) {
|
||||
@ -162,9 +164,9 @@ class AtompubfavoritefeedAction extends ApiAuthAction
|
||||
'type' => 'application/atom+xml'));
|
||||
|
||||
$feed->addLink(common_local_url('AtomPubFavoriteFeed',
|
||||
array('profile' =>
|
||||
array('profile' =>
|
||||
$this->_profile->id),
|
||||
array('page' =>
|
||||
array('page' =>
|
||||
$this->page - 1)),
|
||||
array('rel' => 'prev',
|
||||
'type' => 'application/atom+xml'));
|
||||
@ -205,17 +207,17 @@ class AtompubfavoritefeedAction extends ApiAuthAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function addFavorite()
|
||||
{
|
||||
// XXX: Refactor this; all the same for atompub
|
||||
|
||||
if (empty($this->auth_user) ||
|
||||
$this->auth_user->id != $this->_profile->id) {
|
||||
throw new ClientException(_("Can't add someone else's".
|
||||
" subscription"), 403);
|
||||
// TRANS: Client exception thrown when trying to set a favorite for another user.
|
||||
throw new ClientException(_("Cannot add someone else's".
|
||||
" subscription."), 403);
|
||||
}
|
||||
|
||||
|
||||
$xml = file_get_contents('php://input');
|
||||
|
||||
$dom = DOMDocument::loadXML($xml);
|
||||
@ -234,9 +236,8 @@ class AtompubfavoritefeedAction extends ApiAuthAction
|
||||
if (Event::handle('StartAtomPubNewActivity', array(&$activity))) {
|
||||
|
||||
if ($activity->verb != ActivityVerb::FAVORITE) {
|
||||
// TRANS: Client error displayed when not using the POST verb.
|
||||
// TRANS: Do not translate POST.
|
||||
throw new ClientException(_('Can only handle Favorite activities.'));
|
||||
// TRANS: Client exception thrown when trying use an incorrect activity verb for the Atom pub method.
|
||||
throw new ClientException(_('Can only handle favorite activities.'));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -245,6 +246,7 @@ class AtompubfavoritefeedAction extends ApiAuthAction
|
||||
if (!in_array($note->type, array(ActivityObject::NOTE,
|
||||
ActivityObject::BLOGENTRY,
|
||||
ActivityObject::STATUS))) {
|
||||
// TRANS: Client exception thrown when trying favorite an object that is not a notice.
|
||||
throw new ClientException(_('Can only fave notices.'));
|
||||
return;
|
||||
}
|
||||
@ -253,6 +255,7 @@ class AtompubfavoritefeedAction extends ApiAuthAction
|
||||
|
||||
if (empty($notice)) {
|
||||
// XXX: import from listed URL or something
|
||||
// TRANS: Client exception thrown when trying favorite a notice without content.
|
||||
throw new ClientException(_('Unknown note.'));
|
||||
}
|
||||
|
||||
@ -260,6 +263,7 @@ class AtompubfavoritefeedAction extends ApiAuthAction
|
||||
'notice_id' => $notice->id));
|
||||
|
||||
if (!empty($old)) {
|
||||
// TRANS: Client exception thrown when trying favorite an already favorited notice.
|
||||
throw new ClientException(_('Already a favorite.'));
|
||||
}
|
||||
|
||||
@ -296,7 +300,6 @@ class AtompubfavoritefeedAction extends ApiAuthAction
|
||||
*
|
||||
* @return boolean is read only action?
|
||||
*/
|
||||
|
||||
function isReadOnly($args)
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'GET' ||
|
||||
@ -328,7 +331,6 @@ class AtompubfavoritefeedAction extends ApiAuthAction
|
||||
*
|
||||
* @return string etag http header
|
||||
*/
|
||||
|
||||
function etag()
|
||||
{
|
||||
return null;
|
||||
@ -339,7 +341,6 @@ class AtompubfavoritefeedAction extends ApiAuthAction
|
||||
*
|
||||
* @return boolean true if delete, else false
|
||||
*/
|
||||
|
||||
function requiresAuth()
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'GET' ||
|
||||
@ -359,7 +360,6 @@ class AtompubfavoritefeedAction extends ApiAuthAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function notify($fave, $notice, $user)
|
||||
{
|
||||
$other = User::staticGet('id', $notice->profile_id);
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Copyright (C) 2010, StatusNet, Inc.
|
||||
*
|
||||
* Feed of group memberships for a user, in ActivityStreams format
|
||||
*
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@ -46,7 +46,6 @@ require_once INSTALLDIR . '/lib/apiauth.php';
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class AtompubmembershipfeedAction extends ApiAuthAction
|
||||
{
|
||||
private $_profile = null;
|
||||
@ -59,7 +58,6 @@ class AtompubmembershipfeedAction extends ApiAuthAction
|
||||
*
|
||||
* @return boolean true
|
||||
*/
|
||||
|
||||
function prepare($argarray)
|
||||
{
|
||||
parent::prepare($argarray);
|
||||
@ -67,8 +65,9 @@ class AtompubmembershipfeedAction extends ApiAuthAction
|
||||
$profileId = $this->trimmed('profile');
|
||||
|
||||
$this->_profile = Profile::staticGet('id', $profileId);
|
||||
|
||||
|
||||
if (empty($this->_profile)) {
|
||||
// TRANS: Client exception.
|
||||
throw new ClientException(_('No such profile.'), 404);
|
||||
}
|
||||
|
||||
@ -78,7 +77,7 @@ class AtompubmembershipfeedAction extends ApiAuthAction
|
||||
$this->_memberships = Group_member::byMember($this->_profile->id,
|
||||
$offset,
|
||||
$limit);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -89,7 +88,6 @@ class AtompubmembershipfeedAction extends ApiAuthAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($argarray=null)
|
||||
{
|
||||
parent::handle($argarray);
|
||||
@ -103,6 +101,7 @@ class AtompubmembershipfeedAction extends ApiAuthAction
|
||||
$this->addMembership();
|
||||
break;
|
||||
default:
|
||||
// TRANS: Client exception thrown when using an unsupported HTTP method.
|
||||
throw new ClientException(_('HTTP method not supported.'), 405);
|
||||
return;
|
||||
}
|
||||
@ -115,7 +114,6 @@ class AtompubmembershipfeedAction extends ApiAuthAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showFeed()
|
||||
{
|
||||
header('Content-Type: application/atom+xml; charset=utf-8');
|
||||
@ -141,21 +139,25 @@ class AtompubmembershipfeedAction extends ApiAuthAction
|
||||
$feed->addAuthor($this->_profile->getBestName(),
|
||||
$this->_profile->getURI());
|
||||
|
||||
// TRANS: Title for group membership feed.
|
||||
// TRANS: %s is a username.
|
||||
$feed->setTitle(sprintf(_("%s group memberships"),
|
||||
$this->_profile->getBestName()));
|
||||
|
||||
$feed->setSubtitle(sprintf(_("Groups %s is a member of on %s"),
|
||||
// TRANS: Subtitle for group membership feed.
|
||||
// TRANS: %1$s is a username, %2$s is the StatusNet sitename.
|
||||
$feed->setSubtitle(sprintf(_('Groups %1$s is a member of on %2$s'),
|
||||
$this->_profile->getBestName(),
|
||||
common_config('site', 'name')));
|
||||
|
||||
$feed->addLink(common_local_url('usergroups',
|
||||
array('nickname' =>
|
||||
array('nickname' =>
|
||||
$this->_profile->nickname)));
|
||||
|
||||
$feed->addLink($url,
|
||||
array('rel' => 'self',
|
||||
'type' => 'application/atom+xml'));
|
||||
|
||||
|
||||
// If there's more...
|
||||
|
||||
if ($this->page > 1) {
|
||||
@ -164,9 +166,9 @@ class AtompubmembershipfeedAction extends ApiAuthAction
|
||||
'type' => 'application/atom+xml'));
|
||||
|
||||
$feed->addLink(common_local_url('AtomPubMembershipFeed',
|
||||
array('profile' =>
|
||||
array('profile' =>
|
||||
$this->_profile->id),
|
||||
array('page' =>
|
||||
array('page' =>
|
||||
$this->page - 1)),
|
||||
array('rel' => 'prev',
|
||||
'type' => 'application/atom+xml'));
|
||||
@ -207,17 +209,17 @@ class AtompubmembershipfeedAction extends ApiAuthAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function addMembership()
|
||||
{
|
||||
// XXX: Refactor this; all the same for atompub
|
||||
|
||||
if (empty($this->auth_user) ||
|
||||
$this->auth_user->id != $this->_profile->id) {
|
||||
throw new ClientException(_("Can't add someone else's".
|
||||
" membership"), 403);
|
||||
// TRANS: Client exception thrown when trying subscribe someone else to a group.
|
||||
throw new ClientException(_("Cannot add someone else's".
|
||||
" membership."), 403);
|
||||
}
|
||||
|
||||
|
||||
$xml = file_get_contents('php://input');
|
||||
|
||||
$dom = DOMDocument::loadXML($xml);
|
||||
@ -234,25 +236,26 @@ class AtompubmembershipfeedAction extends ApiAuthAction
|
||||
$membership = null;
|
||||
|
||||
if (Event::handle('StartAtomPubNewActivity', array(&$activity))) {
|
||||
|
||||
if ($activity->verb != ActivityVerb::JOIN) {
|
||||
// TRANS: Client error displayed when not using the POST verb.
|
||||
// TRANS: Do not translate POST.
|
||||
throw new ClientException(_('Can only handle Join activities.'));
|
||||
throw new ClientException(_('Can only handle join activities.'));
|
||||
return;
|
||||
}
|
||||
|
||||
$groupObj = $activity->objects[0];
|
||||
|
||||
if ($groupObj->type != ActivityObject::GROUP) {
|
||||
// TRANS: Client exception thrown when trying favorite an object that is not a notice.
|
||||
throw new ClientException(_('Can only fave notices.'));
|
||||
return;
|
||||
}
|
||||
|
||||
$group = User_group::staticGet('uri', $groupObj->id);
|
||||
|
||||
|
||||
if (empty($group)) {
|
||||
// XXX: import from listed URL or something
|
||||
// TRANS: Client exception thrown when trying to subscribe to a non-existing group.
|
||||
throw new ClientException(_('Unknown group.'));
|
||||
}
|
||||
|
||||
@ -260,6 +263,7 @@ class AtompubmembershipfeedAction extends ApiAuthAction
|
||||
'group_id' => $group->id));
|
||||
|
||||
if (!empty($old)) {
|
||||
// TRANS: Client exception thrown when trying to subscribe to an already subscribed group.
|
||||
throw new ClientException(_('Already a member.'));
|
||||
}
|
||||
|
||||
@ -267,6 +271,7 @@ class AtompubmembershipfeedAction extends ApiAuthAction
|
||||
|
||||
if (Group_block::isBlocked($group, $profile)) {
|
||||
// XXX: import from listed URL or something
|
||||
// TRANS: Client exception thrown when trying to subscribe to group while blocked from that group.
|
||||
throw new ClientException(_('Blocked by admin.'));
|
||||
}
|
||||
|
||||
@ -299,7 +304,6 @@ class AtompubmembershipfeedAction extends ApiAuthAction
|
||||
*
|
||||
* @return boolean is read only action?
|
||||
*/
|
||||
|
||||
function isReadOnly($args)
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'GET' ||
|
||||
@ -331,7 +335,6 @@ class AtompubmembershipfeedAction extends ApiAuthAction
|
||||
*
|
||||
* @return string etag http header
|
||||
*/
|
||||
|
||||
function etag()
|
||||
{
|
||||
return null;
|
||||
@ -342,7 +345,6 @@ class AtompubmembershipfeedAction extends ApiAuthAction
|
||||
*
|
||||
* @return boolean true if delete, else false
|
||||
*/
|
||||
|
||||
function requiresAuth()
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'GET' ||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Copyright (C) 2010, StatusNet, Inc.
|
||||
*
|
||||
* Show a single favorite in Atom Activity Streams format
|
||||
*
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@ -48,7 +48,6 @@ require_once INSTALLDIR . '/lib/apiauth.php';
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class AtompubshowfavoriteAction extends ApiAuthAction
|
||||
{
|
||||
private $_profile = null;
|
||||
@ -62,7 +61,6 @@ class AtompubshowfavoriteAction extends ApiAuthAction
|
||||
*
|
||||
* @return boolean true
|
||||
*/
|
||||
|
||||
function prepare($argarray)
|
||||
{
|
||||
parent::prepare($argarray);
|
||||
@ -73,12 +71,14 @@ class AtompubshowfavoriteAction extends ApiAuthAction
|
||||
$this->_profile = Profile::staticGet('id', $profileId);
|
||||
|
||||
if (empty($this->_profile)) {
|
||||
// TRANS: Client exception.
|
||||
throw new ClientException(_('No such profile.'), 404);
|
||||
}
|
||||
|
||||
$this->_notice = Notice::staticGet('id', $noticeId);
|
||||
|
||||
if (empty($this->_notice)) {
|
||||
// TRANS: Client exception thrown when referencing a non-existing notice.
|
||||
throw new ClientException(_('No such notice.'), 404);
|
||||
}
|
||||
|
||||
@ -86,6 +86,7 @@ class AtompubshowfavoriteAction extends ApiAuthAction
|
||||
'notice_id' => $noticeId));
|
||||
|
||||
if (empty($this->_fave)) {
|
||||
// TRANS: Client exception thrown when referencing a non-existing favorite.
|
||||
throw new ClientException(_('No such favorite.'), 404);
|
||||
}
|
||||
|
||||
@ -99,7 +100,6 @@ class AtompubshowfavoriteAction extends ApiAuthAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($argarray=null)
|
||||
{
|
||||
parent::handle($argarray);
|
||||
@ -113,6 +113,7 @@ class AtompubshowfavoriteAction extends ApiAuthAction
|
||||
$this->deleteFave();
|
||||
break;
|
||||
default:
|
||||
// TRANS: Client exception thrown using an unsupported HTTP method.
|
||||
throw new ClientException(_('HTTP method not supported.'),
|
||||
405);
|
||||
}
|
||||
@ -121,10 +122,9 @@ class AtompubshowfavoriteAction extends ApiAuthAction
|
||||
|
||||
/**
|
||||
* Show a single favorite, in ActivityStreams format
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showFave()
|
||||
{
|
||||
$activity = $this->_fave->asActivity();
|
||||
@ -140,16 +140,16 @@ class AtompubshowfavoriteAction extends ApiAuthAction
|
||||
|
||||
/**
|
||||
* Delete the favorite
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function deleteFave()
|
||||
{
|
||||
if (empty($this->auth_user) ||
|
||||
$this->auth_user->id != $this->_profile->id) {
|
||||
throw new ClientException(_("Can't delete someone else's".
|
||||
" favorite"), 403);
|
||||
// TRANS: Client exception thrown when trying to remove a favorite notice of another user.
|
||||
throw new ClientException(_("Cannot delete someone else's".
|
||||
" favorite."), 403);
|
||||
}
|
||||
|
||||
$this->_fave->delete();
|
||||
@ -166,7 +166,6 @@ class AtompubshowfavoriteAction extends ApiAuthAction
|
||||
*
|
||||
* @return boolean is read only action?
|
||||
*/
|
||||
|
||||
function isReadOnly($args)
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'GET' ||
|
||||
@ -184,7 +183,6 @@ class AtompubshowfavoriteAction extends ApiAuthAction
|
||||
*
|
||||
* @return string last modified http header
|
||||
*/
|
||||
|
||||
function lastModified()
|
||||
{
|
||||
return max(strtotime($this->_profile->modified),
|
||||
@ -199,7 +197,6 @@ class AtompubshowfavoriteAction extends ApiAuthAction
|
||||
*
|
||||
* @return string etag http header
|
||||
*/
|
||||
|
||||
function etag()
|
||||
{
|
||||
$mtime = strtotime($this->_fave->modified);
|
||||
@ -215,7 +212,6 @@ class AtompubshowfavoriteAction extends ApiAuthAction
|
||||
*
|
||||
* @return boolean true if delete, else false
|
||||
*/
|
||||
|
||||
function requiresAuth()
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'GET' ||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Copyright (C) 2010, StatusNet, Inc.
|
||||
*
|
||||
* Show a single membership as an Activity Streams entry
|
||||
*
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@ -46,7 +46,6 @@ require_once INSTALLDIR . '/lib/apiauth.php';
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class AtompubshowmembershipAction extends ApiAuthAction
|
||||
{
|
||||
private $_profile = null;
|
||||
@ -60,7 +59,6 @@ class AtompubshowmembershipAction extends ApiAuthAction
|
||||
*
|
||||
* @return boolean true
|
||||
*/
|
||||
|
||||
function prepare($argarray)
|
||||
{
|
||||
parent::prepare($argarray);
|
||||
@ -68,8 +66,9 @@ class AtompubshowmembershipAction extends ApiAuthAction
|
||||
$profileId = $this->trimmed('profile');
|
||||
|
||||
$this->_profile = Profile::staticGet('id', $profileId);
|
||||
|
||||
|
||||
if (empty($this->_profile)) {
|
||||
// TRANS: Client exception.
|
||||
throw new ClientException(_('No such profile.'), 404);
|
||||
}
|
||||
|
||||
@ -78,7 +77,8 @@ class AtompubshowmembershipAction extends ApiAuthAction
|
||||
$this->_group = User_group::staticGet('id', $groupId);
|
||||
|
||||
if (empty($this->_group)) {
|
||||
throw new ClientException(_('No such group'), 404);
|
||||
// TRANS: Client exception thrown when referencing a non-existing group.
|
||||
throw new ClientException(_('No such group.'), 404);
|
||||
}
|
||||
|
||||
$kv = array('group_id' => $groupId,
|
||||
@ -87,7 +87,8 @@ class AtompubshowmembershipAction extends ApiAuthAction
|
||||
$this->_membership = Group_member::pkeyGet($kv);
|
||||
|
||||
if (empty($this->_membership)) {
|
||||
throw new ClientException(_('Not a member'), 404);
|
||||
// TRANS: Client exception thrown when trying to show membership of a non-subscribed group
|
||||
throw new ClientException(_('Not a member.'), 404);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -100,7 +101,6 @@ class AtompubshowmembershipAction extends ApiAuthAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($argarray=null)
|
||||
{
|
||||
switch ($_SERVER['REQUEST_METHOD']) {
|
||||
@ -112,7 +112,8 @@ class AtompubshowmembershipAction extends ApiAuthAction
|
||||
$this->deleteMembership();
|
||||
break;
|
||||
default:
|
||||
throw new ClientException(_('Method not supported'), 405);
|
||||
// TRANS: Client exception thrown when using an unsupported HTTP method.
|
||||
throw new ClientException(_('HTTP method not supported.'), 405);
|
||||
break;
|
||||
}
|
||||
return;
|
||||
@ -123,7 +124,6 @@ class AtompubshowmembershipAction extends ApiAuthAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showMembership()
|
||||
{
|
||||
$activity = $this->_membership->asActivity();
|
||||
@ -147,8 +147,9 @@ class AtompubshowmembershipAction extends ApiAuthAction
|
||||
{
|
||||
if (empty($this->auth_user) ||
|
||||
$this->auth_user->id != $this->_profile->id) {
|
||||
throw new ClientException(_("Can't delete someone else's".
|
||||
" membership"), 403);
|
||||
// TRANS: Client exception thrown when deleting someone else's membership.
|
||||
throw new ClientException(_("Cannot delete someone else's".
|
||||
" membership."), 403);
|
||||
}
|
||||
|
||||
if (Event::handle('StartLeaveGroup', array($this->_group, $this->auth_user))) {
|
||||
@ -168,7 +169,6 @@ class AtompubshowmembershipAction extends ApiAuthAction
|
||||
*
|
||||
* @return boolean is read only action?
|
||||
*/
|
||||
|
||||
function isReadOnly($args)
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'GET' ||
|
||||
@ -203,7 +203,6 @@ class AtompubshowmembershipAction extends ApiAuthAction
|
||||
*
|
||||
* @return string etag http header
|
||||
*/
|
||||
|
||||
function etag()
|
||||
{
|
||||
$ctime = strtotime($this->_membership->created);
|
||||
@ -222,7 +221,6 @@ class AtompubshowmembershipAction extends ApiAuthAction
|
||||
*
|
||||
* @return boolean true if delete, else false
|
||||
*/
|
||||
|
||||
function requiresAuth()
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'GET' ||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Copyright (C) 2010, StatusNet, Inc.
|
||||
*
|
||||
* Single subscription
|
||||
*
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@ -46,21 +46,19 @@ require_once INSTALLDIR . '/lib/apiauth.php';
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class AtompubshowsubscriptionAction extends ApiAuthAction
|
||||
{
|
||||
private $_subscriber = null;
|
||||
private $_subscribed = null;
|
||||
private $_subscription = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* For initializing members of the class.
|
||||
*
|
||||
* @param array $argarray misc. arguments
|
||||
*
|
||||
* @return boolean true
|
||||
*/
|
||||
|
||||
function prepare($argarray)
|
||||
{
|
||||
parent::prepare($argarray);
|
||||
@ -69,7 +67,9 @@ class AtompubshowsubscriptionAction extends ApiAuthAction
|
||||
$this->_subscriber = Profile::staticGet('id', $subscriberId);
|
||||
|
||||
if (empty($this->_subscriber)) {
|
||||
throw new ClientException(sprintf(_('No such profile id: %d'),
|
||||
// TRANS: Client exception thrown when trying to display a subscription for a non-existing profile ID.
|
||||
// TRANS: %d is the non-existing profile ID number.
|
||||
throw new ClientException(sprintf(_('No such profile id: %d.'),
|
||||
$subscriberId), 404);
|
||||
}
|
||||
|
||||
@ -78,16 +78,20 @@ class AtompubshowsubscriptionAction extends ApiAuthAction
|
||||
$this->_subscribed = Profile::staticGet('id', $subscribedId);
|
||||
|
||||
if (empty($this->_subscribed)) {
|
||||
throw new ClientException(sprintf(_('No such profile id: %d'),
|
||||
// TRANS: Client exception thrown when trying to display a subscription for a non-existing profile ID.
|
||||
// TRANS: %d is the non-existing profile ID number.
|
||||
throw new ClientException(sprintf(_('No such profile id: %d.'),
|
||||
$subscribedId), 404);
|
||||
}
|
||||
|
||||
$this->_subscription =
|
||||
$this->_subscription =
|
||||
Subscription::pkeyGet(array('subscriber' => $subscriberId,
|
||||
'subscribed' => $subscribedId));
|
||||
|
||||
if (empty($this->_subscription)) {
|
||||
$msg = sprintf(_('Profile %d not subscribed to profile %d'),
|
||||
// TRANS: Client exception thrown when trying to display a subscription for a non-subscribed profile ID.
|
||||
// TRANS: %1$d is the non-existing subscriber ID number, $2$d is the ID of the profile that was not subscribed to.
|
||||
$msg = sprintf(_('Profile %1$d not subscribed to profile %2$d.'),
|
||||
$subscriberId, $subscribedId);
|
||||
throw new ClientException($msg, 404);
|
||||
}
|
||||
@ -102,7 +106,6 @@ class AtompubshowsubscriptionAction extends ApiAuthAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($argarray=null)
|
||||
{
|
||||
parent::handle($argarray);
|
||||
@ -115,6 +118,7 @@ class AtompubshowsubscriptionAction extends ApiAuthAction
|
||||
$this->deleteSubscription();
|
||||
break;
|
||||
default:
|
||||
// TRANS: Client error shown when using a non-supported HTTP method.
|
||||
$this->clientError(_('HTTP method not supported.'), 405);
|
||||
return;
|
||||
}
|
||||
@ -127,7 +131,6 @@ class AtompubshowsubscriptionAction extends ApiAuthAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showSubscription()
|
||||
{
|
||||
$activity = $this->_subscription->asActivity();
|
||||
@ -146,13 +149,13 @@ class AtompubshowsubscriptionAction extends ApiAuthAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function deleteSubscription()
|
||||
{
|
||||
if (empty($this->auth_user) ||
|
||||
$this->auth_user->id != $this->_subscriber->id) {
|
||||
throw new ClientException(_("Can't delete someone else's".
|
||||
" subscription"), 403);
|
||||
// TRANS: Client exception thrown when trying to delete a subscription of another user.
|
||||
throw new ClientException(_("Cannot delete someone else's ".
|
||||
"subscription."), 403);
|
||||
}
|
||||
|
||||
Subscription::cancel($this->_subscriber,
|
||||
@ -168,7 +171,6 @@ class AtompubshowsubscriptionAction extends ApiAuthAction
|
||||
*
|
||||
* @return boolean true
|
||||
*/
|
||||
|
||||
function isReadOnly($args)
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'DELETE') {
|
||||
@ -183,7 +185,6 @@ class AtompubshowsubscriptionAction extends ApiAuthAction
|
||||
*
|
||||
* @return string last modified http header
|
||||
*/
|
||||
|
||||
function lastModified()
|
||||
{
|
||||
return max(strtotime($this->_subscriber->modified),
|
||||
@ -196,7 +197,6 @@ class AtompubshowsubscriptionAction extends ApiAuthAction
|
||||
*
|
||||
* @return string etag http header
|
||||
*/
|
||||
|
||||
function etag()
|
||||
{
|
||||
$mtime = strtotime($this->_subscription->modified);
|
||||
@ -212,7 +212,6 @@ class AtompubshowsubscriptionAction extends ApiAuthAction
|
||||
*
|
||||
* @return boolean true if delete, else false
|
||||
*/
|
||||
|
||||
function requiresAuth()
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'DELETE') {
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Copyright (C) 2010, StatusNet, Inc.
|
||||
*
|
||||
* AtomPub subscription feed
|
||||
*
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@ -40,7 +40,7 @@ require_once INSTALLDIR . '/lib/apiauth.php';
|
||||
* Subscription feed class for AtomPub
|
||||
*
|
||||
* Generates a list of the user's subscriptions
|
||||
*
|
||||
*
|
||||
* @category AtomPub
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
@ -48,7 +48,6 @@ require_once INSTALLDIR . '/lib/apiauth.php';
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class AtompubsubscriptionfeedAction extends ApiAuthAction
|
||||
{
|
||||
private $_profile = null;
|
||||
@ -61,17 +60,18 @@ class AtompubsubscriptionfeedAction extends ApiAuthAction
|
||||
*
|
||||
* @return boolean true
|
||||
*/
|
||||
|
||||
function prepare($argarray)
|
||||
{
|
||||
parent::prepare($argarray);
|
||||
|
||||
|
||||
$subscriber = $this->trimmed('subscriber');
|
||||
|
||||
$this->_profile = Profile::staticGet('id', $subscriber);
|
||||
|
||||
if (empty($this->_profile)) {
|
||||
throw new ClientException(sprintf(_('No such profile id: %d'),
|
||||
// TRANS: Client exception thrown when trying to display a subscription for a non-existing profile ID.
|
||||
// TRANS: %d is the non-existing profile ID number.
|
||||
throw new ClientException(sprintf(_('No such profile id: %d.'),
|
||||
$subscriber), 404);
|
||||
}
|
||||
|
||||
@ -93,7 +93,6 @@ class AtompubsubscriptionfeedAction extends ApiAuthAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($argarray=null)
|
||||
{
|
||||
parent::handle($argarray);
|
||||
@ -106,6 +105,7 @@ class AtompubsubscriptionfeedAction extends ApiAuthAction
|
||||
$this->addSubscription();
|
||||
break;
|
||||
default:
|
||||
// TRANS: Client exception thrown when using an unsupported HTTP method.
|
||||
$this->clientError(_('HTTP method not supported.'), 405);
|
||||
return;
|
||||
}
|
||||
@ -118,7 +118,6 @@ class AtompubsubscriptionfeedAction extends ApiAuthAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showFeed()
|
||||
{
|
||||
header('Content-Type: application/atom+xml; charset=utf-8');
|
||||
@ -144,21 +143,25 @@ class AtompubsubscriptionfeedAction extends ApiAuthAction
|
||||
$feed->addAuthor($this->_profile->getBestName(),
|
||||
$this->_profile->getURI());
|
||||
|
||||
// TRANS: Title for Atom subscription feed.
|
||||
// TRANS: %s is a user nickname.
|
||||
$feed->setTitle(sprintf(_("%s subscriptions"),
|
||||
$this->_profile->getBestName()));
|
||||
|
||||
$feed->setSubtitle(sprintf(_("People %s has subscribed to on %s"),
|
||||
// TRANS: Subtitle for Atom subscription feed.
|
||||
// TRANS: %1$s is a user nickname, %s$s is the StatusNet sitename.
|
||||
$feed->setSubtitle(sprintf(_("People %1\$s has subscribed to on %2\$s"),
|
||||
$this->_profile->getBestName(),
|
||||
common_config('site', 'name')));
|
||||
|
||||
$feed->addLink(common_local_url('subscriptions',
|
||||
array('nickname' =>
|
||||
array('nickname' =>
|
||||
$this->_profile->nickname)));
|
||||
|
||||
$feed->addLink($url,
|
||||
array('rel' => 'self',
|
||||
'type' => 'application/atom+xml'));
|
||||
|
||||
|
||||
// If there's more...
|
||||
|
||||
if ($this->page > 1) {
|
||||
@ -167,9 +170,9 @@ class AtompubsubscriptionfeedAction extends ApiAuthAction
|
||||
'type' => 'application/atom+xml'));
|
||||
|
||||
$feed->addLink(common_local_url('AtomPubSubscriptionFeed',
|
||||
array('subscriber' =>
|
||||
array('subscriber' =>
|
||||
$this->_profile->id),
|
||||
array('page' =>
|
||||
array('page' =>
|
||||
$this->page - 1)),
|
||||
array('rel' => 'prev',
|
||||
'type' => 'application/atom+xml'));
|
||||
@ -214,15 +217,15 @@ class AtompubsubscriptionfeedAction extends ApiAuthAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function addSubscription()
|
||||
{
|
||||
if (empty($this->auth_user) ||
|
||||
$this->auth_user->id != $this->_profile->id) {
|
||||
throw new ClientException(_("Can't add someone else's".
|
||||
" subscription"), 403);
|
||||
// TRANS: Client exception thrown when trying to subscribe another user.
|
||||
throw new ClientException(_("Cannot add someone else's".
|
||||
" subscription."), 403);
|
||||
}
|
||||
|
||||
|
||||
$xml = file_get_contents('php://input');
|
||||
|
||||
$dom = DOMDocument::loadXML($xml);
|
||||
@ -241,8 +244,7 @@ class AtompubsubscriptionfeedAction extends ApiAuthAction
|
||||
if (Event::handle('StartAtomPubNewActivity', array(&$activity))) {
|
||||
|
||||
if ($activity->verb != ActivityVerb::FOLLOW) {
|
||||
// TRANS: Client error displayed when not using the POST verb.
|
||||
// TRANS: Do not translate POST.
|
||||
// TRANS: Client error displayed when not using the follow verb.
|
||||
$this->clientError(_('Can only handle Follow activities.'));
|
||||
return;
|
||||
}
|
||||
@ -250,6 +252,7 @@ class AtompubsubscriptionfeedAction extends ApiAuthAction
|
||||
$person = $activity->objects[0];
|
||||
|
||||
if ($person->type != ActivityObject::PERSON) {
|
||||
// TRANS: Client exception thrown when subscribing to an object that is not a person.
|
||||
$this->clientError(_('Can only follow people.'));
|
||||
return;
|
||||
}
|
||||
@ -259,7 +262,19 @@ class AtompubsubscriptionfeedAction extends ApiAuthAction
|
||||
$profile = Profile::fromURI($person->id);
|
||||
|
||||
if (empty($profile)) {
|
||||
$this->clientError(sprintf(_('Unknown profile %s'), $person->id));
|
||||
// TRANS: Client exception thrown when subscribing to a non-existing profile.
|
||||
// TRANS: %s is the unknown profile ID.
|
||||
$this->clientError(sprintf(_('Unknown profile %s.'), $person->id));
|
||||
return;
|
||||
}
|
||||
|
||||
if (Subscription::exists($this->_profile, $profile)) {
|
||||
// 409 Conflict
|
||||
// TRANS: Client error displayed trying to subscribe to an already subscribed profile.
|
||||
// TRANS: %s is the profile the user already has a subscription on.
|
||||
$this->clientError(sprintf(_('Already subscribed to %s.'),
|
||||
$person->id),
|
||||
409);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -290,7 +305,6 @@ class AtompubsubscriptionfeedAction extends ApiAuthAction
|
||||
*
|
||||
* @return boolean is read only action?
|
||||
*/
|
||||
|
||||
function isReadOnly($args)
|
||||
{
|
||||
return $_SERVER['REQUEST_METHOD'] != 'POST';
|
||||
@ -301,7 +315,6 @@ class AtompubsubscriptionfeedAction extends ApiAuthAction
|
||||
*
|
||||
* @return string last modified http header
|
||||
*/
|
||||
|
||||
function lastModified()
|
||||
{
|
||||
return null;
|
||||
@ -312,7 +325,6 @@ class AtompubsubscriptionfeedAction extends ApiAuthAction
|
||||
*
|
||||
* @return string etag http header
|
||||
*/
|
||||
|
||||
function etag()
|
||||
{
|
||||
return null;
|
||||
@ -323,7 +335,6 @@ class AtompubsubscriptionfeedAction extends ApiAuthAction
|
||||
*
|
||||
* @return boolean true if delete, else false
|
||||
*/
|
||||
|
||||
function requiresAuth()
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
|
@ -157,13 +157,13 @@ class AvatarsettingsAction extends AccountSettingsAction
|
||||
}
|
||||
|
||||
$this->elementStart('li', array ('id' => 'settings_attach'));
|
||||
$this->element('input', array('name' => 'avatarfile',
|
||||
'type' => 'file',
|
||||
'id' => 'avatarfile'));
|
||||
$this->element('input', array('name' => 'MAX_FILE_SIZE',
|
||||
'type' => 'hidden',
|
||||
'id' => 'MAX_FILE_SIZE',
|
||||
'value' => ImageFile::maxFileSizeInt()));
|
||||
$this->element('input', array('name' => 'avatarfile',
|
||||
'type' => 'file',
|
||||
'id' => 'avatarfile'));
|
||||
$this->elementEnd('li');
|
||||
$this->elementEnd('ul');
|
||||
|
||||
@ -320,21 +320,20 @@ class AvatarsettingsAction extends AccountSettingsAction
|
||||
}
|
||||
|
||||
$cur = common_current_user();
|
||||
|
||||
$type = $imagefile->preferredType();
|
||||
$filename = Avatar::filename($cur->id,
|
||||
image_type_to_extension($imagefile->type),
|
||||
image_type_to_extension($type),
|
||||
null,
|
||||
'tmp'.common_timestamp());
|
||||
|
||||
$filepath = Avatar::path($filename);
|
||||
|
||||
move_uploaded_file($imagefile->filepath, $filepath);
|
||||
$imagefile->copyTo($filepath);
|
||||
|
||||
$filedata = array('filename' => $filename,
|
||||
'filepath' => $filepath,
|
||||
'width' => $imagefile->width,
|
||||
'height' => $imagefile->height,
|
||||
'type' => $imagefile->type);
|
||||
'type' => $type);
|
||||
|
||||
$_SESSION['FILEDATA'] = $filedata;
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Copyright (C) 2010, StatusNet, Inc.
|
||||
*
|
||||
* Download a backup of your own account to the browser
|
||||
*
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@ -48,17 +48,16 @@ if (!defined('STATUSNET')) {
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class BackupaccountAction extends Action
|
||||
{
|
||||
/**
|
||||
* Returns the title of the page
|
||||
*
|
||||
*
|
||||
* @return string page title
|
||||
*/
|
||||
|
||||
function title()
|
||||
{
|
||||
// TRANS: Title for backup account page.
|
||||
return _("Backup account");
|
||||
}
|
||||
|
||||
@ -69,7 +68,6 @@ class BackupaccountAction extends Action
|
||||
*
|
||||
* @return boolean true
|
||||
*/
|
||||
|
||||
function prepare($argarray)
|
||||
{
|
||||
parent::prepare($argarray);
|
||||
@ -77,10 +75,12 @@ class BackupaccountAction extends Action
|
||||
$cur = common_current_user();
|
||||
|
||||
if (empty($cur)) {
|
||||
// TRANS: Client exception thrown when trying to backup an account while not logged in.
|
||||
throw new ClientException(_('Only logged-in users can backup their account.'), 403);
|
||||
}
|
||||
|
||||
if (!$cur->hasRight(Right::BACKUPACCOUNT)) {
|
||||
// TRANS: Client exception thrown when trying to backup an account without having backup rights.
|
||||
throw new ClientException(_('You may not backup your account.'), 403);
|
||||
}
|
||||
|
||||
@ -94,7 +94,6 @@ class BackupaccountAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($argarray=null)
|
||||
{
|
||||
parent::handle($argarray);
|
||||
@ -109,7 +108,7 @@ class BackupaccountAction extends Action
|
||||
|
||||
/**
|
||||
* Send a feed of the user's activities to the browser
|
||||
*
|
||||
*
|
||||
* Uses the UserActivityStream class; may take a long time!
|
||||
*
|
||||
* @return void
|
||||
@ -118,7 +117,7 @@ class BackupaccountAction extends Action
|
||||
function sendFeed()
|
||||
{
|
||||
$cur = common_current_user();
|
||||
|
||||
|
||||
$stream = new UserActivityStream($cur);
|
||||
|
||||
header('Content-Disposition: attachment; filename='.$cur->nickname.'.atom');
|
||||
@ -132,13 +131,13 @@ class BackupaccountAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
|
||||
function showContent()
|
||||
{
|
||||
$form = new BackupAccountForm($this);
|
||||
$form->show();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return true if read only.
|
||||
*
|
||||
@ -148,7 +147,6 @@ class BackupaccountAction extends Action
|
||||
*
|
||||
* @return boolean is read only action?
|
||||
*/
|
||||
|
||||
function isReadOnly($args)
|
||||
{
|
||||
return false;
|
||||
@ -161,7 +159,6 @@ class BackupaccountAction extends Action
|
||||
*
|
||||
* @return string last modified http header
|
||||
*/
|
||||
|
||||
function lastModified()
|
||||
{
|
||||
// For comparison with If-Last-Modified
|
||||
@ -176,7 +173,6 @@ class BackupaccountAction extends Action
|
||||
*
|
||||
* @return string etag http header
|
||||
*/
|
||||
|
||||
function etag()
|
||||
{
|
||||
return null;
|
||||
@ -193,7 +189,6 @@ class BackupaccountAction extends Action
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class BackupAccountForm extends Form
|
||||
{
|
||||
/**
|
||||
@ -201,7 +196,6 @@ class BackupAccountForm extends Form
|
||||
*
|
||||
* @return string the form's class
|
||||
*/
|
||||
|
||||
function formClass()
|
||||
{
|
||||
return 'form_profile_backup';
|
||||
@ -212,7 +206,6 @@ class BackupAccountForm extends Form
|
||||
*
|
||||
* @return string the form's action URL
|
||||
*/
|
||||
|
||||
function action()
|
||||
{
|
||||
return common_local_url('backupaccount');
|
||||
@ -220,18 +213,18 @@ class BackupAccountForm extends Form
|
||||
|
||||
/**
|
||||
* Output form data
|
||||
*
|
||||
*
|
||||
* Really, just instructions for doing a backup.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formData()
|
||||
{
|
||||
$msg =
|
||||
// TRANS: Information displayed on the backup account page.
|
||||
_('You can backup your account data in '.
|
||||
'<a href="http://activitystrea.ms/">Activity Streams</a> '.
|
||||
'format. This is an experimental feature and provides an '.
|
||||
'format. This is an experimental feature and provides an '.
|
||||
'incomplete backup; private account '.
|
||||
'information like email and IM addresses is not backed up. '.
|
||||
'Additionally, uploaded files and direct messages are not '.
|
||||
@ -243,18 +236,19 @@ class BackupAccountForm extends Form
|
||||
|
||||
/**
|
||||
* Buttons for the form
|
||||
*
|
||||
*
|
||||
* In this case, a single submit button
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formActions()
|
||||
{
|
||||
$this->out->submit('submit',
|
||||
// TRANS: Submit button to backup an account on the backup account page.
|
||||
_m('BUTTON', 'Backup'),
|
||||
'submit',
|
||||
null,
|
||||
// TRANS: Title for submit button to backup an account on the backup account page.
|
||||
_('Backup your account'));
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ class ConfirmaddressAction extends Action
|
||||
if (!$result) {
|
||||
common_log_db_error($cur, 'UPDATE', __FILE__);
|
||||
// TRANS: Server error displayed when a user update to the database fails in the contact address confirmation action.
|
||||
$this->serverError(_('Couldn\'t update user.'));
|
||||
$this->serverError(_('Could not update user.'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Copyright (C) 2010, StatusNet, Inc.
|
||||
*
|
||||
* Delete your own account
|
||||
*
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@ -36,7 +36,7 @@ if (!defined('STATUSNET')) {
|
||||
|
||||
/**
|
||||
* Action to delete your own account
|
||||
*
|
||||
*
|
||||
* Note that this is distinct from DeleteuserAction, which see. I thought
|
||||
* that making that action do both things (delete another user and delete the
|
||||
* current user) would open a lot of holes. I'm open to refactoring, however.
|
||||
@ -48,7 +48,6 @@ if (!defined('STATUSNET')) {
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class DeleteaccountAction extends Action
|
||||
{
|
||||
private $_complete = false;
|
||||
@ -61,19 +60,20 @@ class DeleteaccountAction extends Action
|
||||
*
|
||||
* @return boolean true
|
||||
*/
|
||||
|
||||
function prepare($argarray)
|
||||
{
|
||||
parent::prepare($argarray);
|
||||
|
||||
|
||||
$cur = common_current_user();
|
||||
|
||||
if (empty($cur)) {
|
||||
// TRANS: Client exception displayed trying to delete a user account while not logged in.
|
||||
throw new ClientException(_("Only logged-in users ".
|
||||
"can delete their account."), 403);
|
||||
}
|
||||
|
||||
if (!$cur->hasRight(Right::DELETEACCOUNT)) {
|
||||
// TRANS: Client exception displayed trying to delete a user account without have the rights to do that.
|
||||
throw new ClientException(_("You cannot delete your account."), 403);
|
||||
}
|
||||
|
||||
@ -87,7 +87,6 @@ class DeleteaccountAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($argarray=null)
|
||||
{
|
||||
parent::handle($argarray);
|
||||
@ -109,7 +108,6 @@ class DeleteaccountAction extends Action
|
||||
*
|
||||
* @return boolean is read only action?
|
||||
*/
|
||||
|
||||
function isReadOnly($args)
|
||||
{
|
||||
return false;
|
||||
@ -122,7 +120,6 @@ class DeleteaccountAction extends Action
|
||||
*
|
||||
* @return string last modified http header
|
||||
*/
|
||||
|
||||
function lastModified()
|
||||
{
|
||||
// For comparison with If-Last-Modified
|
||||
@ -137,7 +134,6 @@ class DeleteaccountAction extends Action
|
||||
*
|
||||
* @return string etag http header
|
||||
*/
|
||||
|
||||
function etag()
|
||||
{
|
||||
return null;
|
||||
@ -145,7 +141,7 @@ class DeleteaccountAction extends Action
|
||||
|
||||
/**
|
||||
* Delete the current user's account
|
||||
*
|
||||
*
|
||||
* Checks for the "I am sure." string to make sure the user really
|
||||
* wants to delete their account.
|
||||
*
|
||||
@ -156,13 +152,16 @@ class DeleteaccountAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function deleteAccount()
|
||||
{
|
||||
$this->checkSessionToken();
|
||||
|
||||
if ($this->trimmed('iamsure') != _('I am sure.')) {
|
||||
$this->_error = _('You must write "I am sure." exactly in the box.');
|
||||
// !!! If this string is changed, it also needs to be changed in DeleteAccountForm::formData()
|
||||
// TRANS: Confirmation text for user deletion. The user has to type this exactly the same, including punctuation.
|
||||
$iamsure = _('I am sure.');
|
||||
if ($this->trimmed('iamsure') != $iamsure ) {
|
||||
// TRANS: Notification for user about the text that must be input to be able to delete a user account.
|
||||
// TRANS: %s is the text that needs to be input.
|
||||
$this->_error = sprintf(_('You must write "%s" exactly in the box.'), $iamsure);
|
||||
$this->showPage();
|
||||
return;
|
||||
}
|
||||
@ -191,7 +190,7 @@ class DeleteaccountAction extends Action
|
||||
|
||||
/**
|
||||
* Shows the page content.
|
||||
*
|
||||
*
|
||||
* If the deletion is complete, just shows a completion message.
|
||||
*
|
||||
* Otherwise, shows the deletion form.
|
||||
@ -199,11 +198,11 @@ class DeleteaccountAction extends Action
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
|
||||
function showContent()
|
||||
{
|
||||
if ($this->_complete) {
|
||||
$this->element('p', 'confirmation',
|
||||
$this->element('p', 'confirmation',
|
||||
// TRANS: Confirmation that a user account has been deleted.
|
||||
_('Account deleted.'));
|
||||
return;
|
||||
}
|
||||
@ -216,7 +215,7 @@ class DeleteaccountAction extends Action
|
||||
$form = new DeleteAccountForm($this);
|
||||
$form->show();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the title of the page
|
||||
*
|
||||
@ -225,13 +224,14 @@ class DeleteaccountAction extends Action
|
||||
|
||||
function title()
|
||||
{
|
||||
// TRANS: Page title for page on which a user account can be deleted.
|
||||
return _('Delete account');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Form for deleting your account
|
||||
*
|
||||
*
|
||||
* Note that this mostly is here to keep you from accidentally deleting your
|
||||
* account.
|
||||
*
|
||||
@ -242,7 +242,6 @@ class DeleteaccountAction extends Action
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class DeleteAccountForm extends Form
|
||||
{
|
||||
/**
|
||||
@ -250,7 +249,6 @@ class DeleteAccountForm extends Form
|
||||
*
|
||||
* @return string the form's class
|
||||
*/
|
||||
|
||||
function formClass()
|
||||
{
|
||||
return 'form_profile_delete';
|
||||
@ -261,7 +259,6 @@ class DeleteAccountForm extends Form
|
||||
*
|
||||
* @return string the form's action URL
|
||||
*/
|
||||
|
||||
function action()
|
||||
{
|
||||
return common_local_url('deleteaccount');
|
||||
@ -269,51 +266,60 @@ class DeleteAccountForm extends Form
|
||||
|
||||
/**
|
||||
* Output form data
|
||||
*
|
||||
*
|
||||
* Instructions plus an 'i am sure' entry box.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formData()
|
||||
{
|
||||
$cur = common_current_user();
|
||||
|
||||
$msg = _('<p>This will <strong>permanently delete</strong> '.
|
||||
'your account data from this server. </p>');
|
||||
// TRANS: Form text for user deletion form.
|
||||
$msg = '<p>' . _('This will <strong>permanently delete</strong> '.
|
||||
'your account data from this server.') . '</p>';
|
||||
|
||||
if ($cur->hasRight(Right::BACKUPACCOUNT)) {
|
||||
$msg .= sprintf(_('<p>You are strongly advised to '.
|
||||
// TRANS: Additional form text for user deletion form shown if a user has account backup rights.
|
||||
// TRANS: %s is a URL to the backup page.
|
||||
$msg .= '<p>' . sprintf(_('You are strongly advised to '.
|
||||
'<a href="%s">back up your data</a>'.
|
||||
' before deletion.</p>'),
|
||||
common_local_url('backupaccount'));
|
||||
' before deletion.'),
|
||||
common_local_url('backupaccount')) . '</p>';
|
||||
}
|
||||
|
||||
$this->out->elementStart('p');
|
||||
$this->out->raw($msg);
|
||||
$this->out->elementEnd('p');
|
||||
|
||||
// !!! If this string is changed, it also needs to be changed in class DeleteaccountAction.
|
||||
// TRANS: Confirmation text for user deletion. The user has to type this exactly the same, including punctuation.
|
||||
$iamsure = _("I am sure.");
|
||||
$this->out->input('iamsure',
|
||||
// TRANS: Field label for delete account confirmation entry.
|
||||
_('Confirm'),
|
||||
null,
|
||||
_('Enter "I am sure." to confirm that '.
|
||||
'you want to delete your account.'));
|
||||
// TRANS: Input title for the delete account field.
|
||||
// TRANS: %s is the text that needs to be input.
|
||||
sprintf(_('Enter "%s" to confirm that '.
|
||||
'you want to delete your account.'),$iamsure ));
|
||||
}
|
||||
|
||||
/**
|
||||
* Buttons for the form
|
||||
*
|
||||
*
|
||||
* In this case, a single submit button
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formActions()
|
||||
{
|
||||
$this->out->submit('submit',
|
||||
// TRANS: Button text for user account deletion.
|
||||
_m('BUTTON', 'Delete'),
|
||||
'submit',
|
||||
null,
|
||||
_('Permanently your account'));
|
||||
// TRANS: Button title for user account deletion.
|
||||
_('Permanently delete your account'));
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ class DeletenoticeAction extends Action
|
||||
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.
|
||||
common_user_error(_('Can\'t delete this notice.'));
|
||||
common_user_error(_('Cannot delete this notice.'));
|
||||
exit;
|
||||
}
|
||||
// XXX: Ajax!
|
||||
|
@ -40,7 +40,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class DeleteuserAction extends ProfileFormAction
|
||||
{
|
||||
var $user = null;
|
||||
@ -52,7 +51,6 @@ class DeleteuserAction extends ProfileFormAction
|
||||
*
|
||||
* @return boolean success flag
|
||||
*/
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
if (!parent::prepare($args)) {
|
||||
@ -64,6 +62,7 @@ class DeleteuserAction extends ProfileFormAction
|
||||
assert(!empty($cur)); // checked by parent
|
||||
|
||||
if (!$cur->hasRight(Right::DELETEUSER)) {
|
||||
// TRANS: Client error displayed when trying to delete a user without having the right to delete users.
|
||||
$this->clientError(_('You cannot delete users.'));
|
||||
return false;
|
||||
}
|
||||
@ -71,6 +70,7 @@ class DeleteuserAction extends ProfileFormAction
|
||||
$this->user = User::staticGet('id', $this->profile->id);
|
||||
|
||||
if (empty($this->user)) {
|
||||
// TRANS: Client error displayed when trying to delete a non-local user.
|
||||
$this->clientError(_('You can only delete local users.'));
|
||||
return false;
|
||||
}
|
||||
@ -87,7 +87,6 @@ class DeleteuserAction extends ProfileFormAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($args)
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
@ -107,7 +106,8 @@ class DeleteuserAction extends ProfileFormAction
|
||||
}
|
||||
|
||||
function title() {
|
||||
return _('Delete user');
|
||||
// TRANS: Title of delete user page.
|
||||
return _m('TITLE','Delete user');
|
||||
}
|
||||
|
||||
function showNoticeForm() {
|
||||
@ -130,9 +130,11 @@ class DeleteuserAction extends ProfileFormAction
|
||||
'action' => common_local_url('deleteuser')));
|
||||
$this->elementStart('fieldset');
|
||||
$this->hidden('token', common_session_token());
|
||||
// TRANS: Fieldset legend on delete user page.
|
||||
$this->element('legend', _('Delete user'));
|
||||
if (Event::handle('StartDeleteUserForm', array($this, $this->user))) {
|
||||
$this->element('p', null,
|
||||
// TRANS: Information text to request if a user is certain that the described action has to be performed.
|
||||
_('Are you sure you want to delete this user? '.
|
||||
'This will clear all data about the user from the '.
|
||||
'database, without a backup.'));
|
||||
@ -153,7 +155,7 @@ class DeleteuserAction extends ProfileFormAction
|
||||
'submit form_action-primary',
|
||||
'no',
|
||||
// TRANS: Submit button title for 'No' when deleting a user.
|
||||
_('Do not block this user'));
|
||||
_('Do not delete this user'));
|
||||
$this->submit('form_action-yes',
|
||||
// TRANS: Button label on the delete user form.
|
||||
_m('BUTTON','Yes'),
|
||||
@ -170,7 +172,6 @@ class DeleteuserAction extends ProfileFormAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handlePost()
|
||||
{
|
||||
if (Event::handle('StartDeleteUser', array($this, $this->user))) {
|
||||
|
@ -44,10 +44,8 @@ if (!defined('STATUSNET')) {
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class DesignadminpanelAction extends AdminPanelAction
|
||||
{
|
||||
|
||||
/* The default site design */
|
||||
var $design = null;
|
||||
|
||||
@ -56,7 +54,6 @@ class DesignadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return string page title
|
||||
*/
|
||||
|
||||
function title()
|
||||
{
|
||||
// TRANS: Message used as title for design settings for the site.
|
||||
@ -68,9 +65,9 @@ class DesignadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return string instructions
|
||||
*/
|
||||
|
||||
function getInstructions()
|
||||
{
|
||||
// TRANS: Instructions for design adminsitration panel.
|
||||
return _('Design settings for this StatusNet site');
|
||||
}
|
||||
|
||||
@ -79,7 +76,6 @@ class DesignadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showForm()
|
||||
{
|
||||
$this->design = Design::siteDesign();
|
||||
@ -93,7 +89,6 @@ class DesignadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function saveSettings()
|
||||
{
|
||||
if ($this->arg('save')) {
|
||||
@ -101,6 +96,7 @@ class DesignadminpanelAction extends AdminPanelAction
|
||||
} else if ($this->arg('defaults')) {
|
||||
$this->restoreDefaults();
|
||||
} else {
|
||||
// TRANS: Client error displayed when the submitted form contains unexpected data.
|
||||
$this->clientError(_('Unexpected form submission.'));
|
||||
}
|
||||
}
|
||||
@ -110,7 +106,6 @@ class DesignadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function saveDesignSettings()
|
||||
{
|
||||
// Workaround for PHP returning empty $_POST and $_FILES when POST
|
||||
@ -225,11 +220,10 @@ class DesignadminpanelAction extends AdminPanelAction
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the default design
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
* Restore the default design
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function restoreDefaults()
|
||||
{
|
||||
$this->deleteSetting('site', 'logo');
|
||||
@ -257,7 +251,6 @@ class DesignadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return string $filename the filename of the image
|
||||
*/
|
||||
|
||||
function saveBackgroundImage()
|
||||
{
|
||||
$filename = null;
|
||||
@ -302,7 +295,6 @@ class DesignadminpanelAction extends AdminPanelAction
|
||||
* @throws ClientException for invalid theme archives
|
||||
* @throws ServerException if trouble saving the theme files
|
||||
*/
|
||||
|
||||
function saveCustomTheme()
|
||||
{
|
||||
if (common_config('theme_upload', 'enabled') &&
|
||||
@ -327,20 +319,23 @@ class DesignadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function validate(&$values)
|
||||
{
|
||||
if (!empty($values['logo']) &&
|
||||
!Validate::uri($values['logo'], array('allowed_schemes' => array('http', 'https')))) {
|
||||
// TRANS: Client error displayed when a logo URL does is not valid.
|
||||
$this->clientError(_('Invalid logo URL.'));
|
||||
}
|
||||
|
||||
if (!empty($values['ssllogo']) &&
|
||||
!Validate::uri($values['ssllogo'], array('allowed_schemes' => array('https')))) {
|
||||
// TRANS: Client error displayed when an SSL logo URL is invalid.
|
||||
$this->clientError(_('Invalid SSL logo URL.'));
|
||||
}
|
||||
|
||||
if (!in_array($values['theme'], Theme::listAvailable())) {
|
||||
// TRANS: Client error displayed when a theme is submitted through the form that is not in the theme list.
|
||||
// TRANS: %s is the chosen unavailable theme.
|
||||
$this->clientError(sprintf(_("Theme not available: %s."), $values['theme']));
|
||||
}
|
||||
}
|
||||
@ -350,7 +345,6 @@ class DesignadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showStylesheets()
|
||||
{
|
||||
parent::showStylesheets();
|
||||
@ -362,7 +356,6 @@ class DesignadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showScripts()
|
||||
{
|
||||
parent::showScripts();
|
||||
@ -383,7 +376,6 @@ class DesignAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return int ID of the form
|
||||
*/
|
||||
|
||||
function id()
|
||||
{
|
||||
return 'form_design_admin_panel';
|
||||
@ -394,7 +386,6 @@ class DesignAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return string class of the form
|
||||
*/
|
||||
|
||||
function formClass()
|
||||
{
|
||||
return 'form_settings';
|
||||
@ -408,7 +399,6 @@ class DesignAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return string the method to use for submitting
|
||||
*/
|
||||
|
||||
function method()
|
||||
{
|
||||
$this->enctype = 'multipart/form-data';
|
||||
@ -421,7 +411,6 @@ class DesignAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return string URL of the action
|
||||
*/
|
||||
|
||||
function action()
|
||||
{
|
||||
return common_local_url('designadminpanel');
|
||||
@ -432,7 +421,6 @@ class DesignAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formData()
|
||||
{
|
||||
$this->showLogo();
|
||||
@ -445,16 +433,25 @@ class DesignAdminPanelForm extends AdminForm
|
||||
function showLogo()
|
||||
{
|
||||
$this->out->elementStart('fieldset', array('id' => 'settings_design_logo'));
|
||||
// TRANS: Fieldset legend for form to change logo.
|
||||
$this->out->element('legend', null, _('Change logo'));
|
||||
|
||||
$this->out->elementStart('ul', 'form_data');
|
||||
|
||||
$this->li();
|
||||
$this->input('logo', _('Site logo'), 'Logo for the site (full URL)');
|
||||
$this->input('logo',
|
||||
// TRANS: Field label for StatusNet site logo.
|
||||
_('Site logo'),
|
||||
// TRANS: Title for field label for StatusNet site logo.
|
||||
'Logo for the site (full URL)');
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
$this->input('ssllogo', _('SSL logo'), 'Logo to show on SSL pages');
|
||||
$this->input('ssllogo',
|
||||
// TRANS: Field label for SSL StatusNet site logo.
|
||||
_('SSL logo'),
|
||||
// TRANS: Title for field label for SSL StatusNet site logo.
|
||||
'Logo to show on SSL pages');
|
||||
$this->unli();
|
||||
|
||||
$this->out->elementEnd('ul');
|
||||
@ -466,6 +463,7 @@ class DesignAdminPanelForm extends AdminForm
|
||||
function showTheme()
|
||||
{
|
||||
$this->out->elementStart('fieldset', array('id' => 'settings_design_theme'));
|
||||
// TRANS: Fieldset legend for form change StatusNet site's theme.
|
||||
$this->out->element('legend', null, _('Change theme'));
|
||||
|
||||
$this->out->elementStart('ul', 'form_data');
|
||||
@ -483,17 +481,21 @@ class DesignAdminPanelForm extends AdminForm
|
||||
$themes = array_combine($themes, $themes);
|
||||
|
||||
$this->li();
|
||||
// TRANS: Field label for dropdown to choose site theme.
|
||||
$this->out->dropdown('theme', _('Site theme'),
|
||||
// TRANS: Title for field label for dropdown to choose site theme.
|
||||
$themes, _('Theme for the site.'),
|
||||
false, $this->value('theme'));
|
||||
$this->unli();
|
||||
|
||||
if (common_config('theme_upload', 'enabled')) {
|
||||
$this->li();
|
||||
// TRANS: Field label for uploading a cutom theme.
|
||||
$this->out->element('label', array('for' => 'design_upload_theme'), _('Custom theme'));
|
||||
$this->out->element('input', array('id' => 'design_upload_theme',
|
||||
'name' => 'design_upload_theme',
|
||||
'type' => 'file'));
|
||||
// TRANS: Form instructions for uploading a cutom StatusNet theme.
|
||||
$this->out->element('p', 'form_guide', _('You can upload a custom StatusNet theme as a .ZIP archive.'));
|
||||
$this->unli();
|
||||
}
|
||||
@ -509,22 +511,25 @@ class DesignAdminPanelForm extends AdminForm
|
||||
|
||||
$this->out->elementStart('fieldset', array('id' =>
|
||||
'settings_design_background-image'));
|
||||
// TRANS: Fieldset legend for theme background image.
|
||||
$this->out->element('legend', null, _('Change background image'));
|
||||
$this->out->elementStart('ul', 'form_data');
|
||||
|
||||
$this->li();
|
||||
$this->out->element('input', array('name' => 'MAX_FILE_SIZE',
|
||||
'type' => 'hidden',
|
||||
'id' => 'MAX_FILE_SIZE',
|
||||
'value' => ImageFile::maxFileSizeInt()));
|
||||
$this->out->element('label', array('for' => 'design_background-image_file'),
|
||||
// TRANS: Field label for background image on theme designer page.
|
||||
_('Background'));
|
||||
$this->out->element('input', array('name' => 'design_background-image_file',
|
||||
'type' => 'file',
|
||||
'id' => 'design_background-image_file'));
|
||||
$this->out->element('p', 'form_guide',
|
||||
// TRANS: Form guide for background image upload form on theme designer page.
|
||||
sprintf(_('You can upload a background image for the site. ' .
|
||||
'The maximum file size is %1$s.'), ImageFile::maxFileSize()));
|
||||
$this->out->element('input', array('name' => 'MAX_FILE_SIZE',
|
||||
'type' => 'hidden',
|
||||
'id' => 'MAX_FILE_SIZE',
|
||||
'value' => ImageFile::maxFileSizeInt()));
|
||||
$this->unli();
|
||||
|
||||
if (!empty($design->backgroundimage)) {
|
||||
@ -568,11 +573,13 @@ class DesignAdminPanelForm extends AdminForm
|
||||
'class' => 'radio'),
|
||||
// TRANS: Used as radio button label to not add a background image.
|
||||
_('Off'));
|
||||
// TRANS: Form guide for turning background image on or off on theme designer page.
|
||||
$this->out->element('p', 'form_guide', _('Turn background image on or off.'));
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
$this->out->checkbox('design_background-image_repeat',
|
||||
// TRANS: Checkbox label to title background image on theme designer page.
|
||||
_('Tile background image'),
|
||||
($design->disposition & BACKGROUND_TILE) ? true : false);
|
||||
$this->unli();
|
||||
@ -587,7 +594,8 @@ class DesignAdminPanelForm extends AdminForm
|
||||
$design = $this->out->design;
|
||||
|
||||
$this->out->elementStart('fieldset', array('id' => 'settings_design_color'));
|
||||
$this->out->element('legend', null, _('Change colours'));
|
||||
// TRANS: Fieldset legend for theme colors.
|
||||
$this->out->element('legend', null, _('Change colors'));
|
||||
|
||||
$this->out->elementStart('ul', 'form_data');
|
||||
|
||||
@ -597,6 +605,7 @@ class DesignAdminPanelForm extends AdminForm
|
||||
$bgcolor = new WebColor($design->backgroundcolor);
|
||||
|
||||
$this->li();
|
||||
// TRANS: Field label for background color selector.
|
||||
$this->out->element('label', array('for' => 'swatch-1'), _('Background'));
|
||||
$this->out->element('input', array('name' => 'design_background',
|
||||
'type' => 'text',
|
||||
@ -610,6 +619,7 @@ class DesignAdminPanelForm extends AdminForm
|
||||
$ccolor = new WebColor($design->contentcolor);
|
||||
|
||||
$this->li();
|
||||
// TRANS: Field label for content color selector.
|
||||
$this->out->element('label', array('for' => 'swatch-2'), _('Content'));
|
||||
$this->out->element('input', array('name' => 'design_content',
|
||||
'type' => 'text',
|
||||
@ -623,6 +633,7 @@ class DesignAdminPanelForm extends AdminForm
|
||||
$sbcolor = new WebColor($design->sidebarcolor);
|
||||
|
||||
$this->li();
|
||||
// TRANS: Field label for sidebar color selector.
|
||||
$this->out->element('label', array('for' => 'swatch-3'), _('Sidebar'));
|
||||
$this->out->element('input', array('name' => 'design_sidebar',
|
||||
'type' => 'text',
|
||||
@ -636,6 +647,7 @@ class DesignAdminPanelForm extends AdminForm
|
||||
$tcolor = new WebColor($design->textcolor);
|
||||
|
||||
$this->li();
|
||||
// TRANS: Field label for text color selector.
|
||||
$this->out->element('label', array('for' => 'swatch-4'), _('Text'));
|
||||
$this->out->element('input', array('name' => 'design_text',
|
||||
'type' => 'text',
|
||||
@ -649,6 +661,7 @@ class DesignAdminPanelForm extends AdminForm
|
||||
$lcolor = new WebColor($design->linkcolor);
|
||||
|
||||
$this->li();
|
||||
// TRANS: Field label for link color selector.
|
||||
$this->out->element('label', array('for' => 'swatch-5'), _('Links'));
|
||||
$this->out->element('input', array('name' => 'design_links',
|
||||
'type' => 'text',
|
||||
@ -674,10 +687,12 @@ class DesignAdminPanelForm extends AdminForm
|
||||
{
|
||||
if (common_config('custom_css', 'enabled')) {
|
||||
$this->out->elementStart('fieldset', array('id' => 'settings_design_advanced'));
|
||||
// TRANS: Fieldset legend for advanced theme design settings.
|
||||
$this->out->element('legend', null, _('Advanced'));
|
||||
$this->out->elementStart('ul', 'form_data');
|
||||
|
||||
$this->li();
|
||||
// TRANS: Field label for custom CSS.
|
||||
$this->out->element('label', array('for' => 'css'), _('Custom CSS'));
|
||||
$this->out->element('textarea', array('name' => 'css',
|
||||
'id' => 'css',
|
||||
@ -699,17 +714,25 @@ class DesignAdminPanelForm extends AdminForm
|
||||
|
||||
function formActions()
|
||||
{
|
||||
$this->out->submit('defaults', _('Use defaults'), 'submit form_action-default',
|
||||
// TRANS: Button text for resetting theme settings.
|
||||
$this->out->submit('defaults', _m('BUTTON','Use defaults'), 'submit form_action-default',
|
||||
// TRANS: Title for button for resetting theme settings.
|
||||
'defaults', _('Restore default designs'));
|
||||
|
||||
$this->out->element('input', array('id' => 'settings_design_reset',
|
||||
'type' => 'reset',
|
||||
// TRANS: Button text for resetting theme settings.
|
||||
'value' => 'Reset',
|
||||
'class' => 'submit form_action-primary',
|
||||
// TRANS: Title for button for resetting theme settings.
|
||||
'title' => _('Reset back to default')));
|
||||
|
||||
$this->out->submit('save', _('Save'), 'submit form_action-secondary',
|
||||
'save', _('Save design'));
|
||||
$this->out->submit('save',
|
||||
// TRANS: Button text for saving theme settings.
|
||||
_m('BUTTON','Save'),
|
||||
'submit form_action-secondary',
|
||||
'save',
|
||||
// TRANS: Title for button for saving theme settings.
|
||||
_('Save design'));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Disfavor action.
|
||||
*
|
||||
@ -58,6 +57,7 @@ class DisfavorAction extends Action
|
||||
{
|
||||
parent::handle($args);
|
||||
if (!common_logged_in()) {
|
||||
// TRANS: Client error displayed when trying to remove a favorite while not logged in.
|
||||
$this->clientError(_('Not logged in.'));
|
||||
return;
|
||||
}
|
||||
@ -71,6 +71,7 @@ class DisfavorAction extends Action
|
||||
$notice = Notice::staticGet($id);
|
||||
$token = $this->trimmed('token-'.$notice->id);
|
||||
if (!$token || $token != common_session_token()) {
|
||||
// TRANS: Client error displayed when the session token does not match or is not given.
|
||||
$this->clientError(_('There was a problem with your session token. Try again, please.'));
|
||||
return;
|
||||
}
|
||||
@ -78,12 +79,14 @@ class DisfavorAction extends Action
|
||||
$fave->user_id = $user->id;
|
||||
$fave->notice_id = $notice->id;
|
||||
if (!$fave->find(true)) {
|
||||
// TRANS: Client error displayed when trying to remove favorite status for a notice that is not a favorite.
|
||||
$this->clientError(_('This notice is not a favorite!'));
|
||||
return;
|
||||
}
|
||||
$result = $fave->delete();
|
||||
if (!$result) {
|
||||
common_log_db_error($fave, 'DELETE', __FILE__);
|
||||
// TRANS: Server error displayed when removing a favorite from the database fails.
|
||||
$this->serverError(_('Could not delete favorite.'));
|
||||
return;
|
||||
}
|
||||
@ -91,6 +94,7 @@ class DisfavorAction extends Action
|
||||
if ($this->boolean('ajax')) {
|
||||
$this->startHTML('text/xml;charset=utf-8');
|
||||
$this->elementStart('head');
|
||||
// TRANS: Title for page on which favorites can be added.
|
||||
$this->element('title', null, _('Add to favorites'));
|
||||
$this->elementEnd('head');
|
||||
$this->elementStart('body');
|
||||
@ -105,4 +109,3 @@ class DisfavorAction extends Action
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Documentation action.
|
||||
*
|
||||
@ -83,7 +82,6 @@ class DocAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showPageTitle()
|
||||
{
|
||||
$this->element('h1', array('class' => 'entry-title'), $this->title());
|
||||
@ -96,7 +94,6 @@ class DocAction extends Action
|
||||
*
|
||||
* @return void.
|
||||
*/
|
||||
|
||||
function showContentBlock()
|
||||
{
|
||||
$this->elementStart('div', array('id' => 'content', 'class' => 'hentry'));
|
||||
@ -117,7 +114,6 @@ class DocAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showContent()
|
||||
{
|
||||
$this->raw($this->output);
|
||||
@ -142,7 +138,6 @@ class DocAction extends Action
|
||||
*
|
||||
* @return boolean read-only flag (false)
|
||||
*/
|
||||
|
||||
function isReadOnly($args)
|
||||
{
|
||||
return true;
|
||||
@ -155,7 +150,9 @@ class DocAction extends Action
|
||||
$this->filename = $this->getFilename();
|
||||
|
||||
if (empty($this->filename)) {
|
||||
throw new ClientException(sprintf(_('No such document "%s"'), $this->title), 404);
|
||||
// TRANS: Client exception thrown when requesting a document from the documentation that does not exist.
|
||||
// TRANS: %s is the non-existing document.
|
||||
throw new ClientException(sprintf(_('No such document "%s".'), $this->title), 404);
|
||||
}
|
||||
|
||||
$c = file_get_contents($this->filename);
|
||||
|
@ -198,6 +198,7 @@ class EditApplicationAction extends OwnerDesignAction
|
||||
} elseif (Oauth_application::descriptionTooLong($description)) {
|
||||
$this->showForm(sprintf(
|
||||
// TRANS: Validation error shown when providing too long a description in the "Edit application" form.
|
||||
// TRANS: %d is the maximum number of allowed characters.
|
||||
_m('Description is too long (maximum %d character).',
|
||||
'Description is too long (maximum %d characters).',
|
||||
Oauth_application::maxDesc()),
|
||||
@ -223,6 +224,7 @@ class EditApplicationAction extends OwnerDesignAction
|
||||
$this->showForm(_('Organization is too long (maximum 255 characters).'));
|
||||
return;
|
||||
} elseif (empty($homepage)) {
|
||||
// TRANS: Form validation error show when an organisation name has not been provided in the edit application form.
|
||||
$this->showForm(_('Organization homepage is required.'));
|
||||
return;
|
||||
} elseif ((mb_strlen($homepage) > 0)
|
||||
|
@ -46,7 +46,6 @@ require_once INSTALLDIR.'/lib/accountsettingsaction.php';
|
||||
*
|
||||
* @see Widget
|
||||
*/
|
||||
|
||||
class EmailsettingsAction extends AccountSettingsAction
|
||||
{
|
||||
/**
|
||||
@ -54,7 +53,6 @@ class EmailsettingsAction extends AccountSettingsAction
|
||||
*
|
||||
* @return string Title of the page
|
||||
*/
|
||||
|
||||
function title()
|
||||
{
|
||||
// TRANS: Title for e-mail settings.
|
||||
@ -66,7 +64,6 @@ class EmailsettingsAction extends AccountSettingsAction
|
||||
*
|
||||
* @return instructions for use
|
||||
*/
|
||||
|
||||
function getInstructions()
|
||||
{
|
||||
// XXX: For consistency of parameters in messages, this should be a
|
||||
@ -91,7 +88,6 @@ class EmailsettingsAction extends AccountSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showContent()
|
||||
{
|
||||
$user = common_current_user();
|
||||
@ -118,8 +114,8 @@ class EmailsettingsAction extends AccountSettingsAction
|
||||
$confirm = $this->getConfirmation();
|
||||
if ($confirm) {
|
||||
$this->element('p', array('id' => 'form_unconfirmed'), $confirm->address);
|
||||
// TRANS: Form note in e-mail settings form.
|
||||
$this->element('p', array('class' => 'form_note'),
|
||||
// TRANS: Form note in e-mail settings form.
|
||||
_('Awaiting confirmation on this address. '.
|
||||
'Check your inbox (and spam box!) for a message '.
|
||||
'with further instructions.'));
|
||||
@ -173,7 +169,7 @@ class EmailsettingsAction extends AccountSettingsAction
|
||||
if ($user->incomingemail) {
|
||||
$this->elementStart('p');
|
||||
$this->element('span', 'address', $user->incomingemail);
|
||||
// XXX: Looks a little awkward in the UI.
|
||||
// @todo XXX: Looks a little awkward in the UI.
|
||||
// Something like "xxxx@identi.ca Send email ..". Needs improvement.
|
||||
$this->element('span', 'input_instructions',
|
||||
// TRANS: Form instructions for incoming e-mail form in e-mail settings.
|
||||
@ -208,7 +204,7 @@ class EmailsettingsAction extends AccountSettingsAction
|
||||
$this->element('legend', null, _('Email preferences'));
|
||||
|
||||
$this->elementStart('ul', 'form_data');
|
||||
|
||||
|
||||
if (Event::handle('StartEmailFormData', array($this))) {
|
||||
$this->elementStart('li');
|
||||
$this->checkbox('emailnotifysub',
|
||||
@ -262,7 +258,6 @@ class EmailsettingsAction extends AccountSettingsAction
|
||||
*
|
||||
* @return Confirm_address Email address confirmation for user, or null
|
||||
*/
|
||||
|
||||
function getConfirmation()
|
||||
{
|
||||
$user = common_current_user();
|
||||
@ -288,7 +283,6 @@ class EmailsettingsAction extends AccountSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handlePost()
|
||||
{
|
||||
// CSRF protection
|
||||
@ -322,13 +316,12 @@ class EmailsettingsAction extends AccountSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function savePreferences()
|
||||
{
|
||||
$user = common_current_user();
|
||||
|
||||
|
||||
if (Event::handle('StartEmailSaveForm', array($this, &$user))) {
|
||||
|
||||
|
||||
$emailnotifysub = $this->boolean('emailnotifysub');
|
||||
$emailnotifyfav = $this->boolean('emailnotifyfav');
|
||||
$emailnotifymsg = $this->boolean('emailnotifymsg');
|
||||
@ -336,13 +329,13 @@ class EmailsettingsAction extends AccountSettingsAction
|
||||
$emailnotifyattn = $this->boolean('emailnotifyattn');
|
||||
$emailmicroid = $this->boolean('emailmicroid');
|
||||
$emailpost = $this->boolean('emailpost');
|
||||
|
||||
|
||||
assert(!is_null($user)); // should already be checked
|
||||
|
||||
|
||||
$user->query('BEGIN');
|
||||
|
||||
|
||||
$original = clone($user);
|
||||
|
||||
|
||||
$user->emailnotifysub = $emailnotifysub;
|
||||
$user->emailnotifyfav = $emailnotifyfav;
|
||||
$user->emailnotifymsg = $emailnotifymsg;
|
||||
@ -350,20 +343,20 @@ class EmailsettingsAction extends AccountSettingsAction
|
||||
$user->emailnotifyattn = $emailnotifyattn;
|
||||
$user->emailmicroid = $emailmicroid;
|
||||
$user->emailpost = $emailpost;
|
||||
|
||||
|
||||
$result = $user->update($original);
|
||||
|
||||
|
||||
if ($result === false) {
|
||||
common_log_db_error($user, 'UPDATE', __FILE__);
|
||||
// TRANS: Server error thrown on database error updating e-mail preferences.
|
||||
$this->serverError(_('Couldn\'t update user.'));
|
||||
$this->serverError(_('Could not update user.'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$user->query('COMMIT');
|
||||
|
||||
|
||||
Event::handle('EndEmailSaveForm', array($this));
|
||||
|
||||
|
||||
// TRANS: Confirmation message for successful e-mail preferences save.
|
||||
$this->showForm(_('Email preferences saved.'), true);
|
||||
}
|
||||
@ -374,7 +367,6 @@ class EmailsettingsAction extends AccountSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function addAddress()
|
||||
{
|
||||
$user = common_current_user();
|
||||
@ -393,7 +385,7 @@ class EmailsettingsAction extends AccountSettingsAction
|
||||
|
||||
if (!$email) {
|
||||
// TRANS: Message given saving e-mail address that cannot be normalised.
|
||||
$this->showForm(_('Cannot normalize that email address'));
|
||||
$this->showForm(_('Cannot normalize that email address.'));
|
||||
return;
|
||||
}
|
||||
if (!Validate::email($email, common_config('email', 'check_domain'))) {
|
||||
@ -423,7 +415,7 @@ class EmailsettingsAction extends AccountSettingsAction
|
||||
if ($result === false) {
|
||||
common_log_db_error($confirm, 'INSERT', __FILE__);
|
||||
// TRANS: Server error thrown on database error adding e-mail confirmation code.
|
||||
$this->serverError(_('Couldn\'t insert confirmation code.'));
|
||||
$this->serverError(_('Could not insert confirmation code.'));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -442,7 +434,6 @@ class EmailsettingsAction extends AccountSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function cancelConfirmation()
|
||||
{
|
||||
$email = $this->arg('email');
|
||||
@ -465,7 +456,7 @@ class EmailsettingsAction extends AccountSettingsAction
|
||||
if (!$result) {
|
||||
common_log_db_error($confirm, 'DELETE', __FILE__);
|
||||
// TRANS: Server error thrown on database error canceling e-mail address confirmation.
|
||||
$this->serverError(_('Couldn\'t delete email confirmation.'));
|
||||
$this->serverError(_('Could not delete email confirmation.'));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -478,7 +469,6 @@ class EmailsettingsAction extends AccountSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function removeAddress()
|
||||
{
|
||||
$user = common_current_user();
|
||||
@ -505,7 +495,7 @@ class EmailsettingsAction extends AccountSettingsAction
|
||||
if (!$result) {
|
||||
common_log_db_error($user, 'UPDATE', __FILE__);
|
||||
// TRANS: Server error thrown on database error removing a registered e-mail address.
|
||||
$this->serverError(_('Couldn\'t update user.'));
|
||||
$this->serverError(_('Could not update user.'));
|
||||
return;
|
||||
}
|
||||
$user->query('COMMIT');
|
||||
@ -519,12 +509,12 @@ class EmailsettingsAction extends AccountSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function removeIncoming()
|
||||
{
|
||||
$user = common_current_user();
|
||||
|
||||
if (!$user->incomingemail) {
|
||||
// TRANS: Form validation error displayed when trying to remove an incoming e-mail address while no address has been set.
|
||||
$this->showForm(_('No incoming email address.'));
|
||||
return;
|
||||
}
|
||||
@ -537,7 +527,7 @@ class EmailsettingsAction extends AccountSettingsAction
|
||||
if (!$user->updateKeys($orig)) {
|
||||
common_log_db_error($user, 'UPDATE', __FILE__);
|
||||
// TRANS: Server error thrown on database error removing incoming e-mail address.
|
||||
$this->serverError(_("Couldn't update user record."));
|
||||
$this->serverError(_("Could not update user record."));
|
||||
}
|
||||
|
||||
// TRANS: Message given after successfully removing an incoming e-mail address.
|
||||
@ -549,7 +539,6 @@ class EmailsettingsAction extends AccountSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function newIncoming()
|
||||
{
|
||||
$user = common_current_user();
|
||||
@ -562,7 +551,7 @@ class EmailsettingsAction extends AccountSettingsAction
|
||||
if (!$user->updateKeys($orig)) {
|
||||
common_log_db_error($user, 'UPDATE', __FILE__);
|
||||
// TRANS: Server error thrown on database error adding incoming e-mail address.
|
||||
$this->serverError(_("Couldn't update user record."));
|
||||
$this->serverError(_("Could not update user record."));
|
||||
}
|
||||
|
||||
// TRANS: Message given after successfully adding an incoming e-mail address.
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Favor action.
|
||||
*
|
||||
@ -59,6 +58,7 @@ class FavorAction extends Action
|
||||
{
|
||||
parent::handle($args);
|
||||
if (!common_logged_in()) {
|
||||
// TRANS: Client error displayed when trying to mark a notice as favorite without being logged in.
|
||||
$this->clientError(_('Not logged in.'));
|
||||
return;
|
||||
}
|
||||
@ -76,11 +76,13 @@ class FavorAction extends Action
|
||||
return;
|
||||
}
|
||||
if ($user->hasFave($notice)) {
|
||||
// TRANS: Client error displayed when trying to mark a notice as favorite that already is a favorite.
|
||||
$this->clientError(_('This notice is already a favorite!'));
|
||||
return;
|
||||
}
|
||||
$fave = Fave::addNew($user->getProfile(), $notice);
|
||||
if (!$fave) {
|
||||
// TRANS: Server error displayed when trying to mark a notice as favorite fails in the database.
|
||||
$this->serverError(_('Could not create favorite.'));
|
||||
return;
|
||||
}
|
||||
@ -89,6 +91,7 @@ class FavorAction extends Action
|
||||
if ($this->boolean('ajax')) {
|
||||
$this->startHTML('text/xml;charset=utf-8');
|
||||
$this->elementStart('head');
|
||||
// TRANS: Page title for page on which favorite notices can be unfavourited.
|
||||
$this->element('title', null, _('Disfavor favorite'));
|
||||
$this->elementEnd('head');
|
||||
$this->elementStart('body');
|
||||
@ -123,4 +126,3 @@ class FavorAction extends Action
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,6 @@ require_once INSTALLDIR.'/lib/noticelist.php';
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class FavoritedAction extends Action
|
||||
{
|
||||
var $page = null;
|
||||
@ -62,8 +61,11 @@ class FavoritedAction extends Action
|
||||
function title()
|
||||
{
|
||||
if ($this->page == 1) {
|
||||
// TRANS: Page title for first page of favorited notices.
|
||||
return _('Popular notices');
|
||||
} else {
|
||||
// TRANS: Page title for all but first page of favorited notices.
|
||||
// TRANS: %d is the page number being displayed.
|
||||
return sprintf(_('Popular notices, page %d'), $this->page);
|
||||
}
|
||||
}
|
||||
@ -73,9 +75,9 @@ class FavoritedAction extends Action
|
||||
*
|
||||
* @return instructions for use
|
||||
*/
|
||||
|
||||
function getInstructions()
|
||||
{
|
||||
// TRANS: Description on page displaying favorited notices.
|
||||
return _('The most popular notices on the site right now.');
|
||||
}
|
||||
|
||||
@ -84,7 +86,6 @@ class FavoritedAction extends Action
|
||||
*
|
||||
* @return boolean true
|
||||
*/
|
||||
|
||||
function isReadOnly($args)
|
||||
{
|
||||
return true;
|
||||
@ -99,7 +100,6 @@ class FavoritedAction extends Action
|
||||
*
|
||||
* @todo move queries from showContent() to here
|
||||
*/
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
parent::prepare($args);
|
||||
@ -119,7 +119,6 @@ class FavoritedAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($args)
|
||||
{
|
||||
parent::handle($args);
|
||||
@ -134,7 +133,6 @@ class FavoritedAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showPageNotice()
|
||||
{
|
||||
$instr = $this->getInstructions();
|
||||
@ -147,12 +145,16 @@ class FavoritedAction extends Action
|
||||
|
||||
function showEmptyList()
|
||||
{
|
||||
// TRANS: Text displayed instead of a list when a site does not yet have any favourited notices.
|
||||
$message = _('Favorite notices appear on this page but no one has favorited one yet.') . ' ';
|
||||
|
||||
if (common_logged_in()) {
|
||||
// TRANS: Additional text displayed instead of a list when a site does not yet have any favourited notices for logged in users.
|
||||
$message .= _('Be the first to add a notice to your favorites by clicking the fave button next to any notice you like.');
|
||||
}
|
||||
else {
|
||||
// TRANS: Additional text displayed instead of a list when a site does not yet have any favourited notices for not logged in users.
|
||||
// TRANS: %%action.register%% is a registration link. "[link text](link)" is Mark Down. Do not change the formatting.
|
||||
$message .= _('Why not [register an account](%%action.register%%) and be the first to add a notice to your favorites!');
|
||||
}
|
||||
|
||||
@ -168,7 +170,6 @@ class FavoritedAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showLocalNav()
|
||||
{
|
||||
$nav = new PublicGroupNav($this);
|
||||
@ -182,7 +183,6 @@ class FavoritedAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showContent()
|
||||
{
|
||||
$pop = new Popularity();
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* RSS feed for user favorites action class.
|
||||
*
|
||||
@ -50,7 +49,6 @@ require_once INSTALLDIR.'/lib/rssaction.php';
|
||||
*/
|
||||
class FavoritesrssAction extends Rss10Action
|
||||
{
|
||||
|
||||
/** The user whose favorites to display */
|
||||
|
||||
var $user = null;
|
||||
@ -62,7 +60,6 @@ class FavoritesrssAction extends Rss10Action
|
||||
*
|
||||
* @return boolean success
|
||||
*/
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
parent::prepare($args);
|
||||
@ -71,6 +68,7 @@ class FavoritesrssAction extends Rss10Action
|
||||
$this->user = User::staticGet('nickname', $nickname);
|
||||
|
||||
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.'));
|
||||
return false;
|
||||
} else {
|
||||
@ -108,10 +106,14 @@ class FavoritesrssAction extends Rss10Action
|
||||
$c = array('url' => common_local_url('favoritesrss',
|
||||
array('nickname' =>
|
||||
$user->nickname)),
|
||||
// TRANS: Title of RSS feed with favourite notices of a user.
|
||||
// TRANS: %s is a user's nickname.
|
||||
'title' => sprintf(_("%s's favorite notices"), $user->nickname),
|
||||
'link' => common_local_url('showfavorites',
|
||||
array('nickname' =>
|
||||
$user->nickname)),
|
||||
// TRANS: Desciption of RSS feed with favourite notices of a user.
|
||||
// TRANS: %1$s is a user's nickname, %2$s is the name of the StatusNet site.
|
||||
'description' => sprintf(_('Updates favored by %1$s on %2$s!'),
|
||||
$user->nickname, common_config('site', 'name')));
|
||||
return $c;
|
||||
|
@ -45,7 +45,6 @@ require_once INSTALLDIR.'/lib/publicgroupnav.php';
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class FeaturedAction extends Action
|
||||
{
|
||||
var $page = null;
|
||||
@ -66,8 +65,11 @@ class FeaturedAction extends Action
|
||||
function title()
|
||||
{
|
||||
if ($this->page == 1) {
|
||||
// TRANS: Page title for first page of featured users.
|
||||
return _('Featured users');
|
||||
} else {
|
||||
// TRANS: Page title for all but first page of featured users.
|
||||
// TRANS: %d is the page number being displayed.
|
||||
return sprintf(_('Featured users, page %d'), $this->page);
|
||||
}
|
||||
}
|
||||
@ -96,7 +98,8 @@ class FeaturedAction extends Action
|
||||
|
||||
function getInstructions()
|
||||
{
|
||||
return sprintf(_('A selection of some great users on %s'),
|
||||
// TRANS: Description on page displaying featured users.
|
||||
return sprintf(_('A selection of some great users on %s.'),
|
||||
common_config('site', 'name'));
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
|
||||
|
||||
require_once(INSTALLDIR.'/actions/shownotice.php');
|
||||
|
||||
// @todo FIXME: Add documentation.
|
||||
class FileAction extends Action
|
||||
{
|
||||
var $id = null;
|
||||
@ -31,14 +32,17 @@ class FileAction extends Action
|
||||
parent::prepare($args);
|
||||
$this->id = $this->trimmed('notice');
|
||||
if (empty($this->id)) {
|
||||
// TRANS: Client error displayed when no notice ID was given trying do display a file.
|
||||
$this->clientError(_('No notice ID.'));
|
||||
}
|
||||
$notice = Notice::staticGet('id', $this->id);
|
||||
if (empty($notice)) {
|
||||
// TRANS: Client error displayed when an invalid notice ID was given trying do display a file.
|
||||
$this->clientError(_('No notice.'));
|
||||
}
|
||||
$atts = $notice->attachments();
|
||||
if (empty($atts)) {
|
||||
// TRANS: Client error displayed when trying do display a file for a notice without a file attachement.
|
||||
$this->clientError(_('No attachments.'));
|
||||
}
|
||||
foreach ($atts as $att) {
|
||||
@ -48,6 +52,9 @@ class FileAction extends Action
|
||||
}
|
||||
}
|
||||
if (empty($this->filerec)) {
|
||||
// XXX: Is this translation hint correct? If yes, please remove comment, if no, please correct and remove comment.
|
||||
// TRANS: Client error displayed when trying do display a file for a notice with file attachements
|
||||
// TRANS: that could not be found.
|
||||
$this->clientError(_('No uploaded attachments.'));
|
||||
}
|
||||
return true;
|
||||
@ -62,11 +69,8 @@ class FileAction extends Action
|
||||
*
|
||||
* @return boolean true
|
||||
*/
|
||||
|
||||
function isReadOnly($args)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,6 @@ require_once INSTALLDIR.'/lib/omb.php';
|
||||
*/
|
||||
class FinishremotesubscribeAction extends Action
|
||||
{
|
||||
|
||||
/**
|
||||
* Class handler.
|
||||
*
|
||||
@ -56,7 +55,7 @@ class FinishremotesubscribeAction extends Action
|
||||
*
|
||||
* @return nothing
|
||||
*
|
||||
**/
|
||||
*/
|
||||
function handle($args)
|
||||
{
|
||||
parent::handle($args);
|
||||
@ -66,6 +65,7 @@ class FinishremotesubscribeAction extends Action
|
||||
$service = unserialize($_SESSION['oauth_authorization_request']);
|
||||
|
||||
if (!$service) {
|
||||
// TRANS: Client error displayed when subscribing to a remote profile and an unexpected response is received.
|
||||
$this->clientError(_('Not expecting this response!'));
|
||||
return;
|
||||
}
|
||||
@ -77,6 +77,7 @@ class FinishremotesubscribeAction extends Action
|
||||
$user = User::staticGet('uri', $service->getListeneeURI());
|
||||
|
||||
if (!$user) {
|
||||
// TRANS: Client error displayed when subscribing to a remote profile that does not exist.
|
||||
$this->clientError(_('User being listened to does not exist.'));
|
||||
return;
|
||||
}
|
||||
@ -84,6 +85,7 @@ class FinishremotesubscribeAction extends Action
|
||||
$other = User::staticGet('uri', $service->getListenerURI());
|
||||
|
||||
if ($other) {
|
||||
// TRANS: Client error displayed when subscribing to a remote profile that is a local profile.
|
||||
$this->clientError(_('You can use the local subscription!'));
|
||||
return;
|
||||
}
|
||||
@ -96,6 +98,7 @@ class FinishremotesubscribeAction extends Action
|
||||
$profile = Profile::staticGet($remote->id);
|
||||
|
||||
if ($user->hasBlocked($profile)) {
|
||||
// TRANS: Client error displayed when subscribing to a remote profile that is blocked form subscribing to.
|
||||
$this->clientError(_('That user has blocked you from subscribing.'));
|
||||
return;
|
||||
}
|
||||
@ -107,14 +110,17 @@ class FinishremotesubscribeAction extends Action
|
||||
} catch (OAuthException $e) {
|
||||
if ($e->getMessage() == 'The authorized token does not equal the ' .
|
||||
'submitted token.') {
|
||||
// TRANS: Client error displayed when subscribing to a remote profile without providing an authorised token.
|
||||
$this->clientError(_('You are not authorized.'));
|
||||
return;
|
||||
} else {
|
||||
// TRANS: Client error displayed when subscribing to a remote profile and conversion of the request token to access token fails.
|
||||
$this->clientError(_('Could not convert request token to ' .
|
||||
'access token.'));
|
||||
return;
|
||||
}
|
||||
} catch (OMB_RemoteServiceException $e) {
|
||||
// TRANS: Client error displayed when subscribing to a remote profile fails because of an unsupported version of the OMB protocol.
|
||||
$this->clientError(_('Remote service uses unknown version of ' .
|
||||
'OMB protocol.'));
|
||||
return;
|
||||
@ -135,6 +141,7 @@ class FinishremotesubscribeAction extends Action
|
||||
$service->getServiceURI(OMB_ENDPOINT_UPDATEPROFILE);
|
||||
|
||||
if (!$remote->update($orig_remote)) {
|
||||
// TRANS: Server error displayed when subscribing to a remote profile fails because the remote profile could not be updated.
|
||||
$this->serverError(_('Error updating remote profile.'));
|
||||
return;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ define('LISTENER', 1);
|
||||
define('LISTENEE', -1);
|
||||
define('BOTH', 0);
|
||||
|
||||
// @todo XXX: Documentation missing.
|
||||
class FoafAction extends Action
|
||||
{
|
||||
function isReadOnly($args)
|
||||
@ -37,6 +38,7 @@ class FoafAction extends Action
|
||||
$nickname_arg = $this->arg('nickname');
|
||||
|
||||
if (empty($nickname_arg)) {
|
||||
// TRANS: Client error displayed when requesting Friends of a Friend feed without providing a user nickname.
|
||||
$this->clientError(_('No such user.'), 404);
|
||||
return false;
|
||||
}
|
||||
@ -55,6 +57,7 @@ class FoafAction extends Action
|
||||
$this->user = User::staticGet('nickname', $this->nickname);
|
||||
|
||||
if (!$this->user) {
|
||||
// TRANS: Client error displayed when requesting Friends of a Friend feed for an object that is not a user.
|
||||
$this->clientError(_('No such user.'), 404);
|
||||
return false;
|
||||
}
|
||||
@ -62,6 +65,7 @@ class FoafAction extends Action
|
||||
$this->profile = $this->user->getProfile();
|
||||
|
||||
if (!$this->profile) {
|
||||
// TRANS: Server error displayed when requesting Friends of a Friend feed for a user for which the profile could not be found.
|
||||
$this->serverError(_('User has no profile.'), 500);
|
||||
return false;
|
||||
}
|
||||
@ -110,7 +114,7 @@ class FoafAction extends Action
|
||||
if ($this->profile->bio) {
|
||||
$this->element('bio:olb', null, $this->profile->bio);
|
||||
}
|
||||
|
||||
|
||||
$location = $this->profile->getLocation();
|
||||
if ($location) {
|
||||
$attr = array();
|
||||
@ -118,7 +122,7 @@ class FoafAction extends Action
|
||||
$attr['rdf:about'] = $location->getRdfURL();
|
||||
}
|
||||
$location_name = $location->getName();
|
||||
|
||||
|
||||
$this->elementStart('based_near');
|
||||
$this->elementStart('geo:SpatialThing', $attr);
|
||||
if ($location_name) {
|
||||
@ -193,7 +197,7 @@ class FoafAction extends Action
|
||||
$this->element('knows', array('rdf:resource' => $uri));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->elementEnd('Agent');
|
||||
|
||||
|
||||
@ -239,18 +243,17 @@ class FoafAction extends Action
|
||||
|
||||
/**
|
||||
* Output FOAF <account> bit for the given profile.
|
||||
*
|
||||
*
|
||||
* @param Profile $profile
|
||||
* @param mixed $service Root URL of this StatusNet instance for a local
|
||||
* user, otherwise null.
|
||||
* @param mixed $useruri URI string for the referenced profile..
|
||||
* @param boolean $fetchSubscriptions Should we load and list all their subscriptions?
|
||||
* @param boolean $isSubscriber if not fetching subs, we can still mark the user as following the current page.
|
||||
*
|
||||
*
|
||||
* @return array if $fetchSubscribers is set, return a list of info on those
|
||||
* subscriptions.
|
||||
*/
|
||||
|
||||
function showMicrobloggingAccount($profile, $service=null, $useruri=null, $fetchSubscriptions=false, $isSubscriber=false)
|
||||
{
|
||||
$attr = array();
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
|
||||
|
||||
// @todo XXX: Documentation missing.
|
||||
class FoafGroupAction extends Action
|
||||
{
|
||||
function isReadOnly($args)
|
||||
@ -41,6 +42,7 @@ class FoafGroupAction extends Action
|
||||
$nickname_arg = $this->arg('nickname');
|
||||
|
||||
if (empty($nickname_arg)) {
|
||||
// TRANS: Client error displayed when requesting Friends of a Friend feed without providing a group nickname.
|
||||
$this->clientError(_('No such group.'), 404);
|
||||
return false;
|
||||
}
|
||||
@ -59,6 +61,7 @@ class FoafGroupAction extends Action
|
||||
$local = Local_group::staticGet('nickname', $this->nickname);
|
||||
|
||||
if (!$local) {
|
||||
// TRANS: Client error displayed when requesting Friends of a Friend feed for a non-local group.
|
||||
$this->clientError(_('No such group.'), 404);
|
||||
return false;
|
||||
}
|
||||
@ -66,6 +69,7 @@ class FoafGroupAction extends Action
|
||||
$this->group = User_group::staticGet('id', $local->group_id);
|
||||
|
||||
if (!$this->group) {
|
||||
// TRANS: Client error displayed when requesting Friends of a Friend feed for a nickname that is not a group.
|
||||
$this->clientError(_('No such group.'), 404);
|
||||
return false;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ class GeocodeAction extends Action
|
||||
*
|
||||
* @return nothing
|
||||
*
|
||||
**/
|
||||
*/
|
||||
function handle($args)
|
||||
{
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
@ -89,7 +89,6 @@ class GeocodeAction extends Action
|
||||
*
|
||||
* @return boolean true
|
||||
*/
|
||||
|
||||
function isReadOnly($args)
|
||||
{
|
||||
return true;
|
||||
|
@ -47,13 +47,11 @@ require_once 'MIME/Type.php';
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class GetfileAction extends Action
|
||||
{
|
||||
/**
|
||||
* Path of file to return
|
||||
*/
|
||||
|
||||
var $path = null;
|
||||
|
||||
/**
|
||||
@ -63,7 +61,6 @@ class GetfileAction extends Action
|
||||
*
|
||||
* @return success flag
|
||||
*/
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
parent::prepare($args);
|
||||
@ -76,10 +73,12 @@ class GetfileAction extends Action
|
||||
}
|
||||
|
||||
if (empty($path) or !file_exists($path)) {
|
||||
// TRANS: Client error displayed when requesting a non-existent file.
|
||||
$this->clientError(_('No such file.'), 404);
|
||||
return false;
|
||||
}
|
||||
if (!is_readable($path)) {
|
||||
// TRANS: Client error displayed when requesting a file without having read access to it.
|
||||
$this->clientError(_('Cannot read file.'), 403);
|
||||
return false;
|
||||
}
|
||||
@ -93,7 +92,6 @@ class GetfileAction extends Action
|
||||
*
|
||||
* @return boolean true
|
||||
*/
|
||||
|
||||
function isReadOnly($args)
|
||||
{
|
||||
return true;
|
||||
@ -104,7 +102,6 @@ class GetfileAction extends Action
|
||||
*
|
||||
* @return int last-modified date as unix timestamp
|
||||
*/
|
||||
|
||||
function lastModified()
|
||||
{
|
||||
if (common_config('site', 'use_x_sendfile')) {
|
||||
@ -122,7 +119,6 @@ class GetfileAction extends Action
|
||||
*
|
||||
* @return string etag http header
|
||||
*/
|
||||
|
||||
function etag()
|
||||
{
|
||||
if (common_config('site', 'use_x_sendfile')) {
|
||||
@ -151,7 +147,6 @@ class GetfileAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($args)
|
||||
{
|
||||
// undo headers set by PHP sessions
|
||||
|
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Action class to sandbox an abusive user
|
||||
* Action class to grant user roles.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
@ -32,7 +32,7 @@ if (!defined('STATUSNET')) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sandbox a user.
|
||||
* Assign role to user.
|
||||
*
|
||||
* @category Action
|
||||
* @package StatusNet
|
||||
@ -40,7 +40,6 @@ if (!defined('STATUSNET')) {
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class GrantRoleAction extends ProfileFormAction
|
||||
{
|
||||
/**
|
||||
@ -50,19 +49,20 @@ class GrantRoleAction extends ProfileFormAction
|
||||
*
|
||||
* @return boolean success flag
|
||||
*/
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
if (!parent::prepare($args)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$this->role = $this->arg('role');
|
||||
if (!Profile_role::isValid($this->role)) {
|
||||
// TRANS: Client error displayed when trying to assign an invalid role to a user.
|
||||
$this->clientError(_('Invalid role.'));
|
||||
return false;
|
||||
}
|
||||
if (!Profile_role::isSettable($this->role)) {
|
||||
// TRANS: Client error displayed when trying to assign an reserved role to a user.
|
||||
$this->clientError(_('This role is reserved and cannot be set.'));
|
||||
return false;
|
||||
}
|
||||
@ -72,6 +72,7 @@ class GrantRoleAction extends ProfileFormAction
|
||||
assert(!empty($cur)); // checked by parent
|
||||
|
||||
if (!$cur->hasRight(Right::GRANTROLE)) {
|
||||
// TRANS: Client error displayed when trying to assign a role to a user while not being allowed to set roles.
|
||||
$this->clientError(_('You cannot grant user roles on this site.'));
|
||||
return false;
|
||||
}
|
||||
@ -79,6 +80,7 @@ class GrantRoleAction extends ProfileFormAction
|
||||
assert(!empty($this->profile)); // checked by parent
|
||||
|
||||
if ($this->profile->hasRole($this->role)) {
|
||||
// TRANS: Client error displayed when trying to assign a role to a user that already has that role.
|
||||
$this->clientError(_('User already has this role.'));
|
||||
return false;
|
||||
}
|
||||
@ -91,7 +93,6 @@ class GrantRoleAction extends ProfileFormAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handlePost()
|
||||
{
|
||||
$this->profile->grantRole($this->role);
|
||||
|
@ -40,7 +40,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class GroupblockAction extends RedirectingAction
|
||||
{
|
||||
var $profile = null;
|
||||
@ -53,11 +52,11 @@ class GroupblockAction extends RedirectingAction
|
||||
*
|
||||
* @return boolean success flag
|
||||
*/
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
parent::prepare($args);
|
||||
if (!common_logged_in()) {
|
||||
// TRANS: Client error displayed trying to block a user from a group while not logged in.
|
||||
$this->clientError(_('Not logged in.'));
|
||||
return false;
|
||||
}
|
||||
@ -68,35 +67,42 @@ class GroupblockAction extends RedirectingAction
|
||||
}
|
||||
$id = $this->trimmed('blockto');
|
||||
if (empty($id)) {
|
||||
// TRANS: Client error displayed trying to block a user from a group while not specifying a to be blocked user profile.
|
||||
$this->clientError(_('No profile specified.'));
|
||||
return false;
|
||||
}
|
||||
$this->profile = Profile::staticGet('id', $id);
|
||||
if (empty($this->profile)) {
|
||||
// TRANS: Client error displayed trying to block a user from a group while specifying a non-existing profile.
|
||||
$this->clientError(_('No profile with that ID.'));
|
||||
return false;
|
||||
}
|
||||
$group_id = $this->trimmed('blockgroup');
|
||||
if (empty($group_id)) {
|
||||
// TRANS: Client error displayed trying to block a user from a group while not specifying a group to block a profile from.
|
||||
$this->clientError(_('No group specified.'));
|
||||
return false;
|
||||
}
|
||||
$this->group = User_group::staticGet('id', $group_id);
|
||||
if (empty($this->group)) {
|
||||
// TRANS: Client error displayed trying to block a user from a group while specifying a non-existing group.
|
||||
$this->clientError(_('No such group.'));
|
||||
return false;
|
||||
}
|
||||
$user = common_current_user();
|
||||
if (!$user->isAdmin($this->group)) {
|
||||
// TRANS: Client error displayed trying to block a user from a group while not being an admin user.
|
||||
$this->clientError(_('Only an admin can block group members.'), 401);
|
||||
return false;
|
||||
}
|
||||
if (Group_block::isBlocked($this->group, $this->profile)) {
|
||||
// TRANS: Client error displayed trying to block a user from a group while user is already blocked from the given group.
|
||||
$this->clientError(_('User is already blocked from group.'));
|
||||
return false;
|
||||
}
|
||||
// XXX: could have proactive blocks, but we don't have UI for it.
|
||||
if (!$this->profile->isMember($this->group)) {
|
||||
// TRANS: Client error displayed trying to block a user from a group while user is not a member of given group.
|
||||
$this->clientError(_('User is not a member of group.'));
|
||||
return false;
|
||||
}
|
||||
@ -131,6 +137,7 @@ class GroupblockAction extends RedirectingAction
|
||||
}
|
||||
|
||||
function title() {
|
||||
// TRANS: Title for block user from group page.
|
||||
return _('Block user from group');
|
||||
}
|
||||
|
||||
@ -145,7 +152,6 @@ class GroupblockAction extends RedirectingAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function areYouSureForm()
|
||||
{
|
||||
$id = $this->profile->id;
|
||||
@ -155,8 +161,11 @@ class GroupblockAction extends RedirectingAction
|
||||
'action' => common_local_url('groupblock')));
|
||||
$this->elementStart('fieldset');
|
||||
$this->hidden('token', common_session_token());
|
||||
// TRANS: Fieldset legend for block user from group form.
|
||||
$this->element('legend', _('Block user'));
|
||||
$this->element('p', null,
|
||||
// TRANS: Explanatory text for block user from group form before setting the block.
|
||||
// TRANS: %1$s is that to be blocked user, %2$s is the group the user will be blocked from.
|
||||
sprintf(_('Are you sure you want to block user "%1$s" from the group "%2$s"? '.
|
||||
'They will be removed from the group, unable to post, and '.
|
||||
'unable to subscribe to the group in the future.'),
|
||||
@ -196,24 +205,24 @@ class GroupblockAction extends RedirectingAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function blockProfile()
|
||||
{
|
||||
$block = Group_block::blockProfile($this->group, $this->profile,
|
||||
common_current_user());
|
||||
|
||||
if (empty($block)) {
|
||||
// TRANS: Server error displayed when trying to block a user from a group fails because of an application error.
|
||||
$this->serverError(_("Database error blocking user from group."));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$this->returnToPrevious();
|
||||
}
|
||||
|
||||
/**
|
||||
* If we reached this form without returnto arguments, default to
|
||||
* the top of the group's member list.
|
||||
*
|
||||
*
|
||||
* @return string URL
|
||||
*/
|
||||
function defaultReturnTo()
|
||||
@ -227,6 +236,4 @@ class GroupblockAction extends RedirectingAction
|
||||
parent::showScripts();
|
||||
$this->autofocus('form_action-yes');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,6 @@ 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
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class GroupbyidAction extends Action
|
||||
{
|
||||
/** group we're viewing. */
|
||||
@ -58,7 +57,6 @@ class GroupbyidAction extends Action
|
||||
*
|
||||
* @return boolean true
|
||||
*/
|
||||
|
||||
function isReadOnly($args)
|
||||
{
|
||||
return true;
|
||||
@ -71,6 +69,7 @@ class GroupbyidAction extends Action
|
||||
$id = $this->arg('id');
|
||||
|
||||
if (!$id) {
|
||||
// TRANS: Client error displayed referring to a group's permalink without providing a group ID.
|
||||
$this->clientError(_('No ID.'));
|
||||
return false;
|
||||
}
|
||||
@ -80,6 +79,7 @@ class GroupbyidAction extends Action
|
||||
$this->group = User_group::staticGet('id', $id);
|
||||
|
||||
if (!$this->group) {
|
||||
// TRANS: Client error displayed referring to a group's permalink for a non-existing group ID.
|
||||
$this->clientError(_('No such group.'), 404);
|
||||
return false;
|
||||
}
|
||||
@ -95,9 +95,8 @@ class GroupbyidAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($args)
|
||||
{
|
||||
common_redirect($this->group->homeUrl(), 303);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Change user password
|
||||
* Saves a design for a given group.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
@ -46,7 +46,6 @@ require_once INSTALLDIR . '/lib/designsettings.php';
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class GroupDesignSettingsAction extends DesignSettingsAction
|
||||
{
|
||||
var $group = null;
|
||||
@ -59,12 +58,12 @@ class GroupDesignSettingsAction extends DesignSettingsAction
|
||||
*
|
||||
* @return boolean true
|
||||
*/
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
parent::prepare($args);
|
||||
|
||||
if (!common_logged_in()) {
|
||||
// TRANS: Client error displayed trying to change group design settings while not logged in.
|
||||
$this->clientError(_('You must be logged in to edit a group.'));
|
||||
return false;
|
||||
}
|
||||
@ -81,6 +80,7 @@ class GroupDesignSettingsAction extends DesignSettingsAction
|
||||
}
|
||||
|
||||
if (!$nickname) {
|
||||
// TRANS: Client error displayed trying to change group design settings without providing a group nickname.
|
||||
$this->clientError(_('No nickname.'), 404);
|
||||
return false;
|
||||
}
|
||||
@ -97,6 +97,7 @@ class GroupDesignSettingsAction extends DesignSettingsAction
|
||||
}
|
||||
|
||||
if (!$this->group) {
|
||||
// TRANS: Client error displayed trying to change group design settings while providing a nickname for a non-existing group.
|
||||
$this->clientError(_('No such group.'), 404);
|
||||
return false;
|
||||
}
|
||||
@ -104,6 +105,7 @@ class GroupDesignSettingsAction extends DesignSettingsAction
|
||||
$cur = common_current_user();
|
||||
|
||||
if (!$cur->isAdmin($this->group)) {
|
||||
// TRANS: Client error displayed trying to change group design settings without being a (group) admin.
|
||||
$this->clientError(_('You must be an admin to edit the group.'), 403);
|
||||
return false;
|
||||
}
|
||||
@ -122,7 +124,6 @@ class GroupDesignSettingsAction extends DesignSettingsAction
|
||||
*
|
||||
* @return Design a design object to use
|
||||
*/
|
||||
|
||||
function getDesign()
|
||||
{
|
||||
|
||||
@ -141,6 +142,7 @@ class GroupDesignSettingsAction extends DesignSettingsAction
|
||||
|
||||
function title()
|
||||
{
|
||||
// TRANS: Title group design settings page.
|
||||
return _('Group design');
|
||||
}
|
||||
|
||||
@ -149,9 +151,9 @@ class GroupDesignSettingsAction extends DesignSettingsAction
|
||||
*
|
||||
* @return instructions for use
|
||||
*/
|
||||
|
||||
function getInstructions()
|
||||
{
|
||||
// TRANS: Instructions for group design settings page.
|
||||
return _('Customize the way your group looks ' .
|
||||
'with a background image and a colour palette of your choice.');
|
||||
}
|
||||
@ -161,7 +163,6 @@ class GroupDesignSettingsAction extends DesignSettingsAction
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
|
||||
function showLocalNav()
|
||||
{
|
||||
$nav = new GroupNav($this, $this->group);
|
||||
@ -173,7 +174,6 @@ class GroupDesignSettingsAction extends DesignSettingsAction
|
||||
*
|
||||
* @return Design
|
||||
*/
|
||||
|
||||
function getWorkingDesign()
|
||||
{
|
||||
$design = null;
|
||||
@ -192,7 +192,6 @@ class GroupDesignSettingsAction extends DesignSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showContent()
|
||||
{
|
||||
$design = $this->getWorkingDesign();
|
||||
@ -209,17 +208,14 @@ class GroupDesignSettingsAction extends DesignSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function saveDesign()
|
||||
{
|
||||
try {
|
||||
|
||||
$bgcolor = new WebColor($this->trimmed('design_background'));
|
||||
$ccolor = new WebColor($this->trimmed('design_content'));
|
||||
$sbcolor = new WebColor($this->trimmed('design_sidebar'));
|
||||
$tcolor = new WebColor($this->trimmed('design_text'));
|
||||
$lcolor = new WebColor($this->trimmed('design_links'));
|
||||
|
||||
} catch (WebColorException $e) {
|
||||
$this->showForm($e->getMessage());
|
||||
return;
|
||||
@ -246,7 +242,6 @@ class GroupDesignSettingsAction extends DesignSettingsAction
|
||||
$design = $this->group->getDesign();
|
||||
|
||||
if (!empty($design)) {
|
||||
|
||||
// update design
|
||||
|
||||
$original = clone($design);
|
||||
@ -263,12 +258,11 @@ class GroupDesignSettingsAction extends DesignSettingsAction
|
||||
|
||||
if ($result === false) {
|
||||
common_log_db_error($design, 'UPDATE', __FILE__);
|
||||
$this->showForm(_('Couldn\'t update your design.'));
|
||||
// TRANS: Form validation error displayed when group design settings could not be updated because of an application issue.
|
||||
$this->showForm(_('Unable to update your design settings.'));
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$this->group->query('BEGIN');
|
||||
|
||||
// save new design
|
||||
@ -287,6 +281,7 @@ class GroupDesignSettingsAction extends DesignSettingsAction
|
||||
|
||||
if (empty($id)) {
|
||||
common_log_db_error($id, 'INSERT', __FILE__);
|
||||
// TRANS: Form validation error displayed when group design settings could not be saved because of an application issue.
|
||||
$this->showForm(_('Unable to save your design settings.'));
|
||||
return;
|
||||
}
|
||||
@ -297,18 +292,18 @@ class GroupDesignSettingsAction extends DesignSettingsAction
|
||||
|
||||
if (empty($result)) {
|
||||
common_log_db_error($original, 'UPDATE', __FILE__);
|
||||
// TRANS: Form validation error displayed when group design settings could not be saved because of an application issue.
|
||||
$this->showForm(_('Unable to save your design settings.'));
|
||||
$this->group->query('ROLLBACK');
|
||||
return;
|
||||
}
|
||||
|
||||
$this->group->query('COMMIT');
|
||||
|
||||
}
|
||||
|
||||
$this->saveBackgroundImage($design);
|
||||
|
||||
// TRANS: Form text to confirm saved group design settings.
|
||||
$this->showForm(_('Design preferences saved.'), true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -49,7 +49,6 @@ define('MAX_ORIGINAL', 480);
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class GrouplogoAction extends GroupDesignAction
|
||||
{
|
||||
var $mode = null;
|
||||
@ -61,12 +60,12 @@ class GrouplogoAction extends GroupDesignAction
|
||||
/**
|
||||
* Prepare to run
|
||||
*/
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
parent::prepare($args);
|
||||
|
||||
if (!common_logged_in()) {
|
||||
// TRANS: Client error displayed when trying to create a group while not logged in.
|
||||
$this->clientError(_('You must be logged in to create a group.'));
|
||||
return false;
|
||||
}
|
||||
@ -83,6 +82,7 @@ class GrouplogoAction extends GroupDesignAction
|
||||
}
|
||||
|
||||
if (!$nickname) {
|
||||
// TRANS: Client error displayed when trying to change group logo settings without providing a nickname.
|
||||
$this->clientError(_('No nickname.'), 404);
|
||||
return false;
|
||||
}
|
||||
@ -99,6 +99,7 @@ class GrouplogoAction extends GroupDesignAction
|
||||
}
|
||||
|
||||
if (!$this->group) {
|
||||
// TRANS: Client error displayed when trying to update logo settings for a non-existing group.
|
||||
$this->clientError(_('No such group.'), 404);
|
||||
return false;
|
||||
}
|
||||
@ -106,6 +107,7 @@ class GrouplogoAction extends GroupDesignAction
|
||||
$cur = common_current_user();
|
||||
|
||||
if (!$cur->isAdmin($this->group)) {
|
||||
// TRANS: Client error displayed when trying to change group logo settings while not being a group admin.
|
||||
$this->clientError(_('You must be an admin to edit the group.'), 403);
|
||||
return false;
|
||||
}
|
||||
@ -136,9 +138,9 @@ class GrouplogoAction extends GroupDesignAction
|
||||
*
|
||||
* @return string Title of the page
|
||||
*/
|
||||
|
||||
function title()
|
||||
{
|
||||
// TRANS: Title for group logo settings page.
|
||||
return _('Group logo');
|
||||
}
|
||||
|
||||
@ -147,9 +149,10 @@ class GrouplogoAction extends GroupDesignAction
|
||||
*
|
||||
* @return instructions for use
|
||||
*/
|
||||
|
||||
function getInstructions()
|
||||
{
|
||||
// TRANS: Instructions for group logo page.
|
||||
// TRANS: %s is the maximum file size for that site.
|
||||
return sprintf(_('You can upload a logo image for your group. The maximum file size is %s.'), ImageFile::maxFileSize());
|
||||
}
|
||||
|
||||
@ -160,7 +163,6 @@ class GrouplogoAction extends GroupDesignAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showContent()
|
||||
{
|
||||
if ($this->mode == 'crop') {
|
||||
@ -178,6 +180,7 @@ class GrouplogoAction extends GroupDesignAction
|
||||
|
||||
if (!$profile) {
|
||||
common_log_db_error($user, 'SELECT', __FILE__);
|
||||
// TRANS: Server error displayed coming across a request from a user without a profile.
|
||||
$this->serverError(_('User without matching profile.'));
|
||||
return;
|
||||
}
|
||||
@ -192,6 +195,7 @@ class GrouplogoAction extends GroupDesignAction
|
||||
common_local_url('grouplogo',
|
||||
array('nickname' => $this->group->nickname))));
|
||||
$this->elementStart('fieldset');
|
||||
// TRANS: Group logo form legend.
|
||||
$this->element('legend', null, _('Group logo'));
|
||||
$this->hidden('token', common_session_token());
|
||||
|
||||
@ -199,6 +203,7 @@ class GrouplogoAction extends GroupDesignAction
|
||||
if ($original) {
|
||||
$this->elementStart('li', array('id' => 'avatar_original',
|
||||
'class' => 'avatar_view'));
|
||||
// TRANS: Uploaded original file in group logo form.
|
||||
$this->element('h2', null, _("Original"));
|
||||
$this->elementStart('div', array('id'=>'avatar_original_view'));
|
||||
$this->element('img', array('src' => $this->group->original_logo,
|
||||
@ -210,6 +215,7 @@ class GrouplogoAction extends GroupDesignAction
|
||||
if ($this->group->homepage_logo) {
|
||||
$this->elementStart('li', array('id' => 'avatar_preview',
|
||||
'class' => 'avatar_view'));
|
||||
// TRANS: Header for preview of to be displayed group logo.
|
||||
$this->element('h2', null, _("Preview"));
|
||||
$this->elementStart('div', array('id'=>'avatar_preview_view'));
|
||||
$this->element('img', array('src' => $this->group->homepage_logo,
|
||||
@ -221,25 +227,25 @@ class GrouplogoAction extends GroupDesignAction
|
||||
}
|
||||
|
||||
$this->elementStart('li', array ('id' => 'settings_attach'));
|
||||
$this->element('input', array('name' => 'avatarfile',
|
||||
'type' => 'file',
|
||||
'id' => 'avatarfile'));
|
||||
$this->element('input', array('name' => 'MAX_FILE_SIZE',
|
||||
'type' => 'hidden',
|
||||
'id' => 'MAX_FILE_SIZE',
|
||||
'value' => ImageFile::maxFileSizeInt()));
|
||||
$this->element('input', array('name' => 'avatarfile',
|
||||
'type' => 'file',
|
||||
'id' => 'avatarfile'));
|
||||
$this->elementEnd('li');
|
||||
$this->elementEnd('ul');
|
||||
|
||||
$this->elementStart('ul', 'form_actions');
|
||||
$this->elementStart('li');
|
||||
// TRANS: Submit button for uploading a group logo.
|
||||
$this->submit('upload', _('Upload'));
|
||||
$this->elementEnd('li');
|
||||
$this->elementEnd('ul');
|
||||
|
||||
$this->elementEnd('fieldset');
|
||||
$this->elementEnd('form');
|
||||
|
||||
}
|
||||
|
||||
function showCropForm()
|
||||
@ -251,6 +257,7 @@ class GrouplogoAction extends GroupDesignAction
|
||||
common_local_url('grouplogo',
|
||||
array('nickname' => $this->group->nickname))));
|
||||
$this->elementStart('fieldset');
|
||||
// TRANS: Legend for group logo settings fieldset.
|
||||
$this->element('legend', null, _('Avatar settings'));
|
||||
$this->hidden('token', common_session_token());
|
||||
|
||||
@ -259,6 +266,7 @@ class GrouplogoAction extends GroupDesignAction
|
||||
$this->elementStart('li',
|
||||
array('id' => 'avatar_original',
|
||||
'class' => 'avatar_view'));
|
||||
// TRANS: Header for originally uploaded file before a crop on the group logo page.
|
||||
$this->element('h2', null, _("Original"));
|
||||
$this->elementStart('div', array('id'=>'avatar_original_view'));
|
||||
$this->element('img', array('src' => Avatar::url($this->filedata['filename']),
|
||||
@ -271,6 +279,7 @@ class GrouplogoAction extends GroupDesignAction
|
||||
$this->elementStart('li',
|
||||
array('id' => 'avatar_preview',
|
||||
'class' => 'avatar_view'));
|
||||
// TRANS: Header for the cropped group logo on the group logo page.
|
||||
$this->element('h2', null, _("Preview"));
|
||||
$this->elementStart('div', array('id'=>'avatar_preview_view'));
|
||||
$this->element('img', array('src' => Avatar::url($this->filedata['filename']),
|
||||
@ -286,13 +295,13 @@ class GrouplogoAction extends GroupDesignAction
|
||||
'id' => $crop_info));
|
||||
}
|
||||
|
||||
// TRANS: Button text for cropping an uploaded group logo.
|
||||
$this->submit('crop', _('Crop'));
|
||||
|
||||
$this->elementEnd('li');
|
||||
$this->elementEnd('ul');
|
||||
$this->elementEnd('fieldset');
|
||||
$this->elementEnd('form');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -302,13 +311,13 @@ class GrouplogoAction extends GroupDesignAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handlePost()
|
||||
{
|
||||
// CSRF protection
|
||||
|
||||
$token = $this->trimmed('token');
|
||||
if (!$token || $token != common_session_token()) {
|
||||
// TRANS: Form validation error message.
|
||||
$this->show_form(_('There was a problem with your session token. '.
|
||||
'Try again, please.'));
|
||||
return;
|
||||
@ -319,6 +328,7 @@ class GrouplogoAction extends GroupDesignAction
|
||||
} else if ($this->arg('crop')) {
|
||||
$this->cropLogo();
|
||||
} else {
|
||||
// TRANS: Form validation error message when an unsupported argument is used.
|
||||
$this->showForm(_('Unexpected form submission.'));
|
||||
}
|
||||
}
|
||||
@ -331,7 +341,6 @@ class GrouplogoAction extends GroupDesignAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function uploadLogo()
|
||||
{
|
||||
try {
|
||||
@ -341,20 +350,21 @@ class GrouplogoAction extends GroupDesignAction
|
||||
return;
|
||||
}
|
||||
|
||||
$type = $imagefile->preferredType();
|
||||
$filename = Avatar::filename($this->group->id,
|
||||
image_type_to_extension($imagefile->type),
|
||||
image_type_to_extension($type),
|
||||
null,
|
||||
'group-temp-'.common_timestamp());
|
||||
|
||||
$filepath = Avatar::path($filename);
|
||||
|
||||
move_uploaded_file($imagefile->filepath, $filepath);
|
||||
$imagefile->copyTo($filepath);
|
||||
|
||||
$filedata = array('filename' => $filename,
|
||||
'filepath' => $filepath,
|
||||
'width' => $imagefile->width,
|
||||
'height' => $imagefile->height,
|
||||
'type' => $imagefile->type);
|
||||
'type' => $type);
|
||||
|
||||
$_SESSION['FILEDATA'] = $filedata;
|
||||
|
||||
@ -362,6 +372,7 @@ class GrouplogoAction extends GroupDesignAction
|
||||
|
||||
$this->mode = 'crop';
|
||||
|
||||
// TRANS: Form instructions on the group logo page.
|
||||
$this->showForm(_('Pick a square area of the image to be the logo.'),
|
||||
true);
|
||||
}
|
||||
@ -371,12 +382,12 @@ class GrouplogoAction extends GroupDesignAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function cropLogo()
|
||||
{
|
||||
$filedata = $_SESSION['FILEDATA'];
|
||||
|
||||
if (!$filedata) {
|
||||
// TRANS: Server error displayed trying to crop an uploaded group logo that is no longer present.
|
||||
$this->serverError(_('Lost our file data.'));
|
||||
return;
|
||||
}
|
||||
@ -396,8 +407,10 @@ class GrouplogoAction extends GroupDesignAction
|
||||
@unlink($filedata['filepath']);
|
||||
unset($_SESSION['FILEDATA']);
|
||||
$this->mode = 'upload';
|
||||
// TRANS: Form success message after updating a group logo.
|
||||
$this->showForm(_('Logo updated.'), true);
|
||||
} else {
|
||||
// TRANS: Form failure message after failing to update a group logo.
|
||||
$this->showForm(_('Failed updating logo.'));
|
||||
}
|
||||
}
|
||||
@ -422,7 +435,6 @@ class GrouplogoAction extends GroupDesignAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showStylesheets()
|
||||
{
|
||||
parent::showStylesheets();
|
||||
@ -434,7 +446,6 @@ class GrouplogoAction extends GroupDesignAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showScripts()
|
||||
{
|
||||
parent::showScripts();
|
||||
|
@ -43,7 +43,6 @@ require_once INSTALLDIR.'/lib/publicgroupnav.php';
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class GroupmembersAction extends GroupDesignAction
|
||||
{
|
||||
var $page = null;
|
||||
@ -73,6 +72,7 @@ class GroupmembersAction extends GroupDesignAction
|
||||
}
|
||||
|
||||
if (!$nickname) {
|
||||
// TRANS: Client error displayed when trying to view group members without providing a group nickname.
|
||||
$this->clientError(_('No nickname.'), 404);
|
||||
return false;
|
||||
}
|
||||
@ -80,6 +80,7 @@ class GroupmembersAction extends GroupDesignAction
|
||||
$local = Local_group::staticGet('nickname', $nickname);
|
||||
|
||||
if (!$local) {
|
||||
// TRANS: Client error displayed when trying to view group members for a non-existing group.
|
||||
$this->clientError(_('No such group.'), 404);
|
||||
return false;
|
||||
}
|
||||
@ -87,6 +88,7 @@ class GroupmembersAction extends GroupDesignAction
|
||||
$this->group = User_group::staticGet('id', $local->group_id);
|
||||
|
||||
if (!$this->group) {
|
||||
// TRANS: Client error displayed when trying to view group members for an object that is not a group.
|
||||
$this->clientError(_('No such group.'), 404);
|
||||
return false;
|
||||
}
|
||||
@ -119,6 +121,7 @@ class GroupmembersAction extends GroupDesignAction
|
||||
function showPageNotice()
|
||||
{
|
||||
$this->element('p', 'instructions',
|
||||
// TRANS: Page notice for group members page.
|
||||
_('A list of the users in this group.'));
|
||||
}
|
||||
|
||||
@ -182,7 +185,8 @@ class GroupMemberListItem extends ProfileListItem
|
||||
{
|
||||
parent::showFullName();
|
||||
if ($this->profile->isAdmin($this->group)) {
|
||||
$this->out->text(' ');
|
||||
$this->out->text(' '); // for separating the classes.
|
||||
// TRANS: Indicator in group members list that this user is a group administrator.
|
||||
$this->out->element('span', 'role', _('Admin'));
|
||||
}
|
||||
}
|
||||
@ -254,7 +258,7 @@ class GroupMemberListItem extends ProfileListItem
|
||||
/**
|
||||
* Fetch necessary return-to arguments for the profile forms
|
||||
* to return to this list when they're done.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function returnToArgs()
|
||||
@ -281,7 +285,6 @@ class GroupMemberListItem extends ProfileListItem
|
||||
*
|
||||
* @see BlockForm
|
||||
*/
|
||||
|
||||
class GroupBlockForm extends Form
|
||||
{
|
||||
/**
|
||||
@ -310,7 +313,6 @@ class GroupBlockForm extends Form
|
||||
* @param User_group $group group to block user from
|
||||
* @param array $args return-to args
|
||||
*/
|
||||
|
||||
function __construct($out=null, $profile=null, $group=null, $args=null)
|
||||
{
|
||||
parent::__construct($out);
|
||||
@ -325,7 +327,6 @@ class GroupBlockForm extends Form
|
||||
*
|
||||
* @return int ID of the form
|
||||
*/
|
||||
|
||||
function id()
|
||||
{
|
||||
// This should be unique for the page.
|
||||
@ -337,7 +338,6 @@ class GroupBlockForm extends Form
|
||||
*
|
||||
* @return string class of the form
|
||||
*/
|
||||
|
||||
function formClass()
|
||||
{
|
||||
return 'form_group_block';
|
||||
@ -348,7 +348,6 @@ class GroupBlockForm extends Form
|
||||
*
|
||||
* @return string URL of the action
|
||||
*/
|
||||
|
||||
function action()
|
||||
{
|
||||
return common_local_url('groupblock');
|
||||
@ -361,6 +360,7 @@ class GroupBlockForm extends Form
|
||||
*/
|
||||
function formLegend()
|
||||
{
|
||||
// TRANS: Form legend for form to block user from a group.
|
||||
$this->out->element('legend', null, _('Block user from group'));
|
||||
}
|
||||
|
||||
@ -369,7 +369,6 @@ class GroupBlockForm extends Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formData()
|
||||
{
|
||||
$this->out->hidden('blockto-' . $this->profile->id,
|
||||
@ -390,7 +389,6 @@ class GroupBlockForm extends Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formActions()
|
||||
{
|
||||
$this->out->submit(
|
||||
@ -414,25 +412,21 @@ class GroupBlockForm extends Form
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class MakeAdminForm extends Form
|
||||
{
|
||||
/**
|
||||
* Profile of user to block
|
||||
*/
|
||||
|
||||
var $profile = null;
|
||||
|
||||
/**
|
||||
* Group to block the user from
|
||||
*/
|
||||
|
||||
var $group = null;
|
||||
|
||||
/**
|
||||
* Return-to args
|
||||
*/
|
||||
|
||||
var $args = null;
|
||||
|
||||
/**
|
||||
@ -443,7 +437,6 @@ class MakeAdminForm extends Form
|
||||
* @param User_group $group group to block user from
|
||||
* @param array $args return-to args
|
||||
*/
|
||||
|
||||
function __construct($out=null, $profile=null, $group=null, $args=null)
|
||||
{
|
||||
parent::__construct($out);
|
||||
@ -458,7 +451,6 @@ class MakeAdminForm extends Form
|
||||
*
|
||||
* @return int ID of the form
|
||||
*/
|
||||
|
||||
function id()
|
||||
{
|
||||
// This should be unique for the page.
|
||||
@ -470,7 +462,6 @@ class MakeAdminForm extends Form
|
||||
*
|
||||
* @return string class of the form
|
||||
*/
|
||||
|
||||
function formClass()
|
||||
{
|
||||
return 'form_make_admin';
|
||||
@ -481,7 +472,6 @@ class MakeAdminForm extends Form
|
||||
*
|
||||
* @return string URL of the action
|
||||
*/
|
||||
|
||||
function action()
|
||||
{
|
||||
return common_local_url('makeadmin', array('nickname' => $this->group->nickname));
|
||||
@ -492,9 +482,9 @@ class MakeAdminForm extends Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formLegend()
|
||||
{
|
||||
// TRANS: Form legend for form to make a user a group admin.
|
||||
$this->out->element('legend', null, _('Make user an admin of the group'));
|
||||
}
|
||||
|
||||
@ -503,7 +493,6 @@ class MakeAdminForm extends Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formData()
|
||||
{
|
||||
$this->out->hidden('profileid-' . $this->profile->id,
|
||||
@ -524,7 +513,6 @@ class MakeAdminForm extends Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formActions()
|
||||
{
|
||||
$this->out->submit(
|
||||
|
@ -45,7 +45,6 @@ define('MEMBERS_PER_SECTION', 27);
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class groupRssAction extends Rss10Action
|
||||
{
|
||||
/** group we're viewing. */
|
||||
@ -56,7 +55,6 @@ class groupRssAction extends Rss10Action
|
||||
*
|
||||
* @return boolean true
|
||||
*/
|
||||
|
||||
function isReadOnly($args)
|
||||
{
|
||||
return true;
|
||||
@ -71,7 +69,6 @@ class groupRssAction extends Rss10Action
|
||||
*
|
||||
* @return boolean success flag
|
||||
*/
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
parent::prepare($args);
|
||||
@ -88,6 +85,7 @@ class groupRssAction extends Rss10Action
|
||||
}
|
||||
|
||||
if (!$nickname) {
|
||||
// TRANS: Client error displayed when requesting a group RSS feed without providing a group nickname.
|
||||
$this->clientError(_('No nickname.'), 404);
|
||||
return false;
|
||||
}
|
||||
@ -95,6 +93,7 @@ class groupRssAction extends Rss10Action
|
||||
$local = Local_group::staticGet('nickname', $nickname);
|
||||
|
||||
if (!$local) {
|
||||
// TRANS: Client error displayed when requesting a group RSS feed for group that does not exist.
|
||||
$this->clientError(_('No such group.'), 404);
|
||||
return false;
|
||||
}
|
||||
@ -102,6 +101,7 @@ class groupRssAction extends Rss10Action
|
||||
$this->group = User_group::staticGet('id', $local->group_id);
|
||||
|
||||
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);
|
||||
return false;
|
||||
}
|
||||
@ -112,7 +112,6 @@ class groupRssAction extends Rss10Action
|
||||
|
||||
function getNotices($limit=0)
|
||||
{
|
||||
|
||||
$group = $this->group;
|
||||
|
||||
if (is_null($group)) {
|
||||
|
@ -45,7 +45,6 @@ require_once INSTALLDIR.'/lib/grouplist.php';
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class GroupsAction extends Action
|
||||
{
|
||||
var $page = null;
|
||||
@ -59,9 +58,12 @@ class GroupsAction extends Action
|
||||
function title()
|
||||
{
|
||||
if ($this->page == 1) {
|
||||
return _("Groups");
|
||||
// TRANS: Title for first page of the groups list.
|
||||
return _m('TITLE',"Groups");
|
||||
} else {
|
||||
return sprintf(_("Groups, page %d"), $this->page);
|
||||
// TRANS: Title for all but the first page of the groups list.
|
||||
// TRANS: %d is the page number.
|
||||
return sprintf(_m('TITLE',"Groups, page %d"), $this->page);
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,12 +89,15 @@ class GroupsAction extends Action
|
||||
function showPageNotice()
|
||||
{
|
||||
$notice =
|
||||
// TRANS: Page notice of group list. %%%%site.name%%%% is the StatusNet site name,
|
||||
// TRANS: %%%%action.groupsearch%%%% and %%%%action.newgroup%%%% are URLs. Do not change them.
|
||||
// TRANS: This message contains Markdown links in the form [link text](link).
|
||||
sprintf(_('%%%%site.name%%%% groups let you find and talk with ' .
|
||||
'people of similar interests. After you join a group ' .
|
||||
'you can send messages to all other members using the ' .
|
||||
'syntax "!groupname". Don\'t see a group you like? Try ' .
|
||||
'[searching for one](%%%%action.groupsearch%%%%) or ' .
|
||||
'[start your own!](%%%%action.newgroup%%%%)'));
|
||||
'[start your own](%%%%action.newgroup%%%%)!'));
|
||||
$this->elementStart('div', 'instructions');
|
||||
$this->raw(common_markup_to_html($notice));
|
||||
$this->elementEnd('div');
|
||||
@ -104,6 +109,7 @@ class GroupsAction extends Action
|
||||
$this->elementStart('p', array('id' => 'new_group'));
|
||||
$this->element('a', array('href' => common_local_url('newgroup'),
|
||||
'class' => 'more'),
|
||||
// TRANS: Link to create a new group on the group list page.
|
||||
_('Create a new group'));
|
||||
$this->elementEnd('p');
|
||||
}
|
||||
|
@ -49,12 +49,14 @@ class GroupsearchAction extends SearchAction
|
||||
{
|
||||
function getInstructions()
|
||||
{
|
||||
// TRANS: Instructions for page where groups can be searched. %%site.name%% is the name of the StatusNet site.
|
||||
return _('Search for groups on %%site.name%% by their name, location, or description. ' .
|
||||
'Separate the terms by spaces; they must be 3 characters or more.');
|
||||
}
|
||||
|
||||
function title()
|
||||
{
|
||||
// TRANS: Title for page where groups can be searched.
|
||||
return _('Group search');
|
||||
}
|
||||
|
||||
@ -76,12 +78,17 @@ class GroupsearchAction extends SearchAction
|
||||
$this->pagination($page > 1, $cnt > GROUPS_PER_PAGE,
|
||||
$page, 'groupsearch', array('q' => $q));
|
||||
} else {
|
||||
// TRANS: Text on page where groups can be searched if no results were found for a query.
|
||||
$this->element('p', 'error', _('No results.'));
|
||||
$this->searchSuggestions($q);
|
||||
if (common_logged_in()) {
|
||||
$message = _('If you can\'t find the group you\'re looking for, you can [create it](%%action.newgroup%%) yourself.');
|
||||
// TRANS: Additional text on page where groups can be searched if no results were found for a query for a logged in user.
|
||||
// TRANS: This message contains Markdown links in the form [link text](link).
|
||||
$message = _('If you cannot find the group you\'re looking for, you can [create it](%%action.newgroup%%) yourself.');
|
||||
}
|
||||
else {
|
||||
// TRANS: Additional text on page where groups can be searched if no results were found for a query for a not logged in user.
|
||||
// TRANS: This message contains Markdown links in the form [link text](link).
|
||||
$message = _('Why not [register an account](%%action.register%%) and [create the group](%%action.newgroup%%) yourself!');
|
||||
}
|
||||
$this->elementStart('div', 'guide');
|
||||
@ -116,4 +123,3 @@ class GroupSearchResults extends GroupList
|
||||
return preg_replace($this->pattern, '<strong>\\1</strong>', htmlspecialchars($text));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,6 +79,7 @@ class GroupunblockAction extends Action
|
||||
}
|
||||
$group_id = $this->trimmed('unblockgroup');
|
||||
if (empty($group_id)) {
|
||||
// TRANS: Client error displayed when trying to unblock a user from a group without providing a group.
|
||||
$this->clientError(_('No group specified.'));
|
||||
return false;
|
||||
}
|
||||
|
@ -40,7 +40,6 @@ if (!defined('STATUSNET')) {
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class HcardAction extends Action
|
||||
{
|
||||
var $user;
|
||||
@ -64,6 +63,7 @@ class HcardAction extends Action
|
||||
$this->user = User::staticGet('nickname', $nickname);
|
||||
|
||||
if (!$this->user) {
|
||||
// TRANS: Client error displayed when trying to get a user hCard for a non-existing user.
|
||||
$this->clientError(_('No such user.'), 404);
|
||||
return false;
|
||||
}
|
||||
@ -71,6 +71,7 @@ class HcardAction extends Action
|
||||
$this->profile = $this->user->getProfile();
|
||||
|
||||
if (!$this->profile) {
|
||||
// TRANS: Server error displayed when trying to get a user hCard for a user without a profile.
|
||||
$this->serverError(_('User has no profile.'));
|
||||
return false;
|
||||
}
|
||||
@ -117,4 +118,4 @@ class ShortUserProfile extends UserProfile
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,9 +28,9 @@ if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// @todo XXX: Add documentation.
|
||||
class HostMetaAction extends Action
|
||||
{
|
||||
|
||||
/**
|
||||
* Is read only?
|
||||
*
|
||||
@ -51,11 +51,11 @@ class HostMetaAction extends Action
|
||||
$xrd->host = $domain;
|
||||
|
||||
if(Event::handle('StartHostMetaLinks', array(&$xrd->links))) {
|
||||
$url = common_local_url('userxrd');
|
||||
$url.= '?uri={uri}';
|
||||
$xrd->links[] = array('rel' => Discovery::LRDD_REL,
|
||||
'template' => $url,
|
||||
'title' => array('Resource Descriptor'));
|
||||
$url = common_local_url('userxrd');
|
||||
$url.= '?uri={uri}';
|
||||
$xrd->links[] = array('rel' => Discovery::LRDD_REL,
|
||||
'template' => $url,
|
||||
'title' => array('Resource Descriptor'));
|
||||
Event::handle('EndHostMetaLinks', array(&$xrd->links));
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,6 @@ require_once INSTALLDIR.'/lib/jabber.php';
|
||||
*
|
||||
* @see SettingsAction
|
||||
*/
|
||||
|
||||
class ImsettingsAction extends ConnectSettingsAction
|
||||
{
|
||||
/**
|
||||
@ -53,10 +52,9 @@ class ImsettingsAction extends ConnectSettingsAction
|
||||
*
|
||||
* @return string Title of the page
|
||||
*/
|
||||
|
||||
function title()
|
||||
{
|
||||
// TRANS: Title for instance messaging settings.
|
||||
// TRANS: Title for Instant Messaging settings.
|
||||
return _('IM settings');
|
||||
}
|
||||
|
||||
@ -65,14 +63,13 @@ class ImsettingsAction extends ConnectSettingsAction
|
||||
*
|
||||
* @return instructions for use
|
||||
*/
|
||||
|
||||
function getInstructions()
|
||||
{
|
||||
// TRANS: Instant messaging settings page instructions.
|
||||
// TRANS: [instant messages] is link text, "(%%doc.im%%)" is the link.
|
||||
// TRANS: the order and formatting of link text and link should remain unchanged.
|
||||
return _('You can send and receive notices through '.
|
||||
'Jabber/GTalk [instant messages](%%doc.im%%). '.
|
||||
'Jabber/Google Talk [instant messages](%%doc.im%%). '.
|
||||
'Configure your address and settings below.');
|
||||
}
|
||||
|
||||
@ -85,12 +82,11 @@ class ImsettingsAction extends ConnectSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showContent()
|
||||
{
|
||||
if (!common_config('xmpp', 'enabled')) {
|
||||
$this->element('div', array('class' => 'error'),
|
||||
// TRANS: Message given in the IM settings if XMPP is not enabled on the site.
|
||||
// TRANS: Message given in the Instant Messaging settings if XMPP is not enabled on the site.
|
||||
_('IM is not available.'));
|
||||
return;
|
||||
}
|
||||
@ -102,88 +98,88 @@ class ImsettingsAction extends ConnectSettingsAction
|
||||
'action' =>
|
||||
common_local_url('imsettings')));
|
||||
$this->elementStart('fieldset', array('id' => 'settings_im_address'));
|
||||
// TRANS: Form legend for IM settings form.
|
||||
// TRANS: Form legend for Instant Messaging settings form.
|
||||
$this->element('legend', null, _('IM address'));
|
||||
$this->hidden('token', common_session_token());
|
||||
|
||||
if ($user->jabber) {
|
||||
$this->element('p', 'form_confirmed', $user->jabber);
|
||||
// TRANS: Form note in IM settings form.
|
||||
// TRANS: Form note in Instant Messaging settings form.
|
||||
$this->element('p', 'form_note',
|
||||
_('Current confirmed Jabber/GTalk address.'));
|
||||
_('Current confirmed Jabber/Google Talk address.'));
|
||||
$this->hidden('jabber', $user->jabber);
|
||||
// TRANS: Button label to remove a confirmed IM address.
|
||||
// TRANS: Button label to remove a confirmed Instant Messaging address.
|
||||
$this->submit('remove', _m('BUTTON','Remove'));
|
||||
} else {
|
||||
$confirm = $this->getConfirmation();
|
||||
if ($confirm) {
|
||||
$this->element('p', 'form_unconfirmed', $confirm->address);
|
||||
$this->element('p', 'form_note',
|
||||
// TRANS: Form note in IM settings form.
|
||||
// TRANS: %s is the IM address set for the site.
|
||||
// TRANS: Form note in Instant Messaging settings form.
|
||||
// TRANS: %s is the Instant Messaging address set for the site.
|
||||
sprintf(_('Awaiting confirmation on this address. '.
|
||||
'Check your Jabber/GTalk account for a '.
|
||||
'Check your Jabber/Google Talk account for a '.
|
||||
'message with further instructions. '.
|
||||
'(Did you add %s to your buddy list?)'),
|
||||
jabber_daemon_address()));
|
||||
$this->hidden('jabber', $confirm->address);
|
||||
// TRANS: Button label to cancel an IM address confirmation procedure.
|
||||
// TRANS: Button label to cancel an Instant Messaging address confirmation procedure.
|
||||
$this->submit('cancel', _m('BUTTON','Cancel'));
|
||||
} else {
|
||||
$this->elementStart('ul', 'form_data');
|
||||
$this->elementStart('li');
|
||||
// TRANS: Field label for IM address input in IM settings form.
|
||||
// TRANS: Field label for Instant Messaging address input in Instant Messaging settings form.
|
||||
$this->input('jabber', _('IM address'),
|
||||
($this->arg('jabber')) ? $this->arg('jabber') : null,
|
||||
// TRANS: IM address input field instructions in IM settings form.
|
||||
// TRANS: %s is the IM address set for the site.
|
||||
// TRANS: IM address input field instructions in Instant Messaging settings form.
|
||||
// TRANS: %s is the Instant Messaging address set for the site.
|
||||
// TRANS: Do not translate "example.org". It is one of the domain names reserved for use in examples by
|
||||
// TRANS: http://www.rfc-editor.org/rfc/rfc2606.txt. Any other domain may be owned by a legitimate
|
||||
// TRANS: person or organization.
|
||||
sprintf(_('Jabber or GTalk address, '.
|
||||
sprintf(_('Jabber or Google Talk address, '.
|
||||
'like "UserName@example.org". '.
|
||||
'First, make sure to add %s to your '.
|
||||
'buddy list in your IM client or on GTalk.'),
|
||||
'buddy list in your IM client or on Google Talk.'),
|
||||
jabber_daemon_address()));
|
||||
$this->elementEnd('li');
|
||||
$this->elementEnd('ul');
|
||||
// TRANS: Button label for adding an IM address in IM settings form.
|
||||
// TRANS: Button label for adding an Instant Messaging address in Instant Messaging settings form.
|
||||
$this->submit('add', _m('BUTTON','Add'));
|
||||
}
|
||||
}
|
||||
$this->elementEnd('fieldset');
|
||||
|
||||
|
||||
$this->elementStart('fieldset', array('id' => 'settings_im_preferences'));
|
||||
// TRANS: Form legend for IM preferences form.
|
||||
// TRANS: Form legend for Instant Messaging preferences form.
|
||||
$this->element('legend', null, _('IM preferences'));
|
||||
$this->elementStart('ul', 'form_data');
|
||||
$this->elementStart('li');
|
||||
$this->checkbox('jabbernotify',
|
||||
// TRANS: Checkbox label in IM preferences form.
|
||||
_('Send me notices through Jabber/GTalk.'),
|
||||
// TRANS: Checkbox label in Instant Messaging preferences form.
|
||||
_('Send me notices through Jabber/Google Talk.'),
|
||||
$user->jabbernotify);
|
||||
$this->elementEnd('li');
|
||||
$this->elementStart('li');
|
||||
$this->checkbox('updatefrompresence',
|
||||
// TRANS: Checkbox label in IM preferences form.
|
||||
_('Post a notice when my Jabber/GTalk status changes.'),
|
||||
// TRANS: Checkbox label in Instant Messaging preferences form.
|
||||
_('Post a notice when my Jabber/Google Talk status changes.'),
|
||||
$user->updatefrompresence);
|
||||
$this->elementEnd('li');
|
||||
$this->elementStart('li');
|
||||
$this->checkbox('jabberreplies',
|
||||
// TRANS: Checkbox label in IM preferences form.
|
||||
_('Send me replies through Jabber/GTalk '.
|
||||
// TRANS: Checkbox label in Instant Messaging preferences form.
|
||||
_('Send me replies through Jabber/Google Talk '.
|
||||
'from people I\'m not subscribed to.'),
|
||||
$user->jabberreplies);
|
||||
$this->elementEnd('li');
|
||||
$this->elementStart('li');
|
||||
$this->checkbox('jabbermicroid',
|
||||
// TRANS: Checkbox label in IM preferences form.
|
||||
_('Publish a MicroID for my Jabber/GTalk address.'),
|
||||
// TRANS: Checkbox label in Instant Messaging preferences form.
|
||||
_('Publish a MicroID for my Jabber/Google Talk address.'),
|
||||
$user->jabbermicroid);
|
||||
$this->elementEnd('li');
|
||||
$this->elementEnd('ul');
|
||||
// TRANS: Button label to save IM preferences.
|
||||
// TRANS: Button label to save Instant Messaging preferences.
|
||||
$this->submit('save', _m('BUTTON','Save'));
|
||||
$this->elementEnd('fieldset');
|
||||
$this->elementEnd('form');
|
||||
@ -194,7 +190,6 @@ class ImsettingsAction extends ConnectSettingsAction
|
||||
*
|
||||
* @return Confirm_address address object for this user
|
||||
*/
|
||||
|
||||
function getConfirmation()
|
||||
{
|
||||
$user = common_current_user();
|
||||
@ -221,7 +216,6 @@ class ImsettingsAction extends ConnectSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handlePost()
|
||||
{
|
||||
// CSRF protection
|
||||
@ -241,7 +235,7 @@ class ImsettingsAction extends ConnectSettingsAction
|
||||
} else if ($this->arg('remove')) {
|
||||
$this->removeAddress();
|
||||
} else {
|
||||
// TRANS: Message given submitting a form with an unknown action in IM settings.
|
||||
// TRANS: Message given submitting a form with an unknown action in Instant Messaging settings.
|
||||
$this->showForm(_('Unexpected form submission.'));
|
||||
}
|
||||
}
|
||||
@ -254,7 +248,6 @@ class ImsettingsAction extends ConnectSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function savePreferences()
|
||||
{
|
||||
$jabbernotify = $this->boolean('jabbernotify');
|
||||
@ -279,14 +272,14 @@ class ImsettingsAction extends ConnectSettingsAction
|
||||
|
||||
if ($result === false) {
|
||||
common_log_db_error($user, 'UPDATE', __FILE__);
|
||||
// TRANS: Server error thrown on database error updating IM preferences.
|
||||
$this->serverError(_('Couldn\'t update user.'));
|
||||
// TRANS: Server error thrown on database error updating Instant Messaging preferences.
|
||||
$this->serverError(_('Could not update user.'));
|
||||
return;
|
||||
}
|
||||
|
||||
$user->query('COMMIT');
|
||||
|
||||
// TRANS: Confirmation message for successful IM preferences save.
|
||||
// TRANS: Confirmation message for successful Instant Messaging preferences save.
|
||||
$this->showForm(_('Preferences saved.'), true);
|
||||
}
|
||||
|
||||
@ -298,7 +291,6 @@ class ImsettingsAction extends ConnectSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function addAddress()
|
||||
{
|
||||
$user = common_current_user();
|
||||
@ -308,7 +300,7 @@ class ImsettingsAction extends ConnectSettingsAction
|
||||
// Some validation
|
||||
|
||||
if (!$jabber) {
|
||||
// TRANS: Message given saving IM address without having provided one.
|
||||
// TRANS: Message given saving Instant Messaging address without having provided one.
|
||||
$this->showForm(_('No Jabber ID.'));
|
||||
return;
|
||||
}
|
||||
@ -316,20 +308,20 @@ class ImsettingsAction extends ConnectSettingsAction
|
||||
$jabber = jabber_normalize_jid($jabber);
|
||||
|
||||
if (!$jabber) {
|
||||
// TRANS: Message given saving IM address that cannot be normalised.
|
||||
$this->showForm(_('Cannot normalize that Jabber ID'));
|
||||
// TRANS: Message given saving Instant Messaging address that cannot be normalised.
|
||||
$this->showForm(_('Cannot normalize that Jabber ID.'));
|
||||
return;
|
||||
}
|
||||
if (!jabber_valid_base_jid($jabber, common_config('email', 'domain_check'))) {
|
||||
// TRANS: Message given saving IM address that not valid.
|
||||
$this->showForm(_('Not a valid Jabber ID'));
|
||||
// TRANS: Message given saving Instant Messaging address that not valid.
|
||||
$this->showForm(_('Not a valid Jabber ID.'));
|
||||
return;
|
||||
} else if ($user->jabber == $jabber) {
|
||||
// TRANS: Message given saving IM address that is already set.
|
||||
// TRANS: Message given saving Instant Messaging address that is already set.
|
||||
$this->showForm(_('That is already your Jabber ID.'));
|
||||
return;
|
||||
} else if ($this->jabberExists($jabber)) {
|
||||
// TRANS: Message given saving IM address that is already set for another user.
|
||||
// TRANS: Message given saving Instant Messaging address that is already set for another user.
|
||||
$this->showForm(_('Jabber ID already belongs to another user.'));
|
||||
return;
|
||||
}
|
||||
@ -347,8 +339,8 @@ class ImsettingsAction extends ConnectSettingsAction
|
||||
|
||||
if ($result === false) {
|
||||
common_log_db_error($confirm, 'INSERT', __FILE__);
|
||||
// TRANS: Server error thrown on database error adding IM confirmation code.
|
||||
$this->serverError(_('Couldn\'t insert confirmation code.'));
|
||||
// TRANS: Server error thrown on database error adding Instant Messaging confirmation code.
|
||||
$this->serverError(_('Could not insert confirmation code.'));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -356,8 +348,8 @@ class ImsettingsAction extends ConnectSettingsAction
|
||||
$user->nickname,
|
||||
$jabber);
|
||||
|
||||
// TRANS: Message given saving valid IM address that is to be confirmed.
|
||||
// TRANS: %s is the IM address set for the site.
|
||||
// TRANS: Message given saving valid Instant Messaging address that is to be confirmed.
|
||||
// TRANS: %s is the Instant Messaging address set for the site.
|
||||
$msg = sprintf(_('A confirmation code was sent '.
|
||||
'to the IM address you added. '.
|
||||
'You must approve %s for '.
|
||||
@ -374,7 +366,6 @@ class ImsettingsAction extends ConnectSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function cancelConfirmation()
|
||||
{
|
||||
$jabber = $this->arg('jabber');
|
||||
@ -382,12 +373,12 @@ class ImsettingsAction extends ConnectSettingsAction
|
||||
$confirm = $this->getConfirmation();
|
||||
|
||||
if (!$confirm) {
|
||||
// TRANS: Message given canceling IM address confirmation that is not pending.
|
||||
// TRANS: Message given canceling Instant Messaging address confirmation that is not pending.
|
||||
$this->showForm(_('No pending confirmation to cancel.'));
|
||||
return;
|
||||
}
|
||||
if ($confirm->address != $jabber) {
|
||||
// TRANS: Message given canceling IM address confirmation for the wrong IM address.
|
||||
// TRANS: Message given canceling Instant Messaging address confirmation for the wrong IM address.
|
||||
$this->showForm(_('That is the wrong IM address.'));
|
||||
return;
|
||||
}
|
||||
@ -396,12 +387,12 @@ class ImsettingsAction extends ConnectSettingsAction
|
||||
|
||||
if (!$result) {
|
||||
common_log_db_error($confirm, 'DELETE', __FILE__);
|
||||
// TRANS: Server error thrown on database error canceling IM address confirmation.
|
||||
$this->serverError(_('Couldn\'t delete IM confirmation.'));
|
||||
// TRANS: Server error thrown on database error canceling Instant Messaging address confirmation.
|
||||
$this->serverError(_('Could not delete IM confirmation.'));
|
||||
return;
|
||||
}
|
||||
|
||||
// TRANS: Message given after successfully canceling IM address confirmation.
|
||||
// TRANS: Message given after successfully canceling Instant Messaging address confirmation.
|
||||
$this->showForm(_('IM confirmation cancelled.'), true);
|
||||
}
|
||||
|
||||
@ -412,7 +403,6 @@ class ImsettingsAction extends ConnectSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function removeAddress()
|
||||
{
|
||||
$user = common_current_user();
|
||||
@ -422,7 +412,7 @@ class ImsettingsAction extends ConnectSettingsAction
|
||||
// Maybe an old tab open...?
|
||||
|
||||
if ($user->jabber != $jabber) {
|
||||
// TRANS: Message given trying to remove an IM address that is not
|
||||
// TRANS: Message given trying to remove an Instant Messaging address that is not
|
||||
// TRANS: registered for the active user.
|
||||
$this->showForm(_('That is not your Jabber ID.'));
|
||||
return;
|
||||
@ -438,15 +428,15 @@ class ImsettingsAction extends ConnectSettingsAction
|
||||
|
||||
if (!$result) {
|
||||
common_log_db_error($user, 'UPDATE', __FILE__);
|
||||
// TRANS: Server error thrown on database error removing a registered IM address.
|
||||
$this->serverError(_('Couldn\'t update user.'));
|
||||
// TRANS: Server error thrown on database error removing a registered Instant Messaging address.
|
||||
$this->serverError(_('Could not update user.'));
|
||||
return;
|
||||
}
|
||||
$user->query('COMMIT');
|
||||
|
||||
// XXX: unsubscribe to the old address
|
||||
|
||||
// TRANS: Message given after successfully removing a registered IM address.
|
||||
// TRANS: Message given after successfully removing a registered Instant Messaging address.
|
||||
$this->showForm(_('The IM address was removed.'), true);
|
||||
}
|
||||
|
||||
@ -459,7 +449,6 @@ class ImsettingsAction extends ConnectSettingsAction
|
||||
*
|
||||
* @return boolean whether the Jabber ID exists
|
||||
*/
|
||||
|
||||
function jabberExists($jabber)
|
||||
{
|
||||
$user = common_current_user();
|
||||
|
@ -43,7 +43,6 @@ require_once INSTALLDIR.'/lib/mailbox.php';
|
||||
* @link http://status.net/
|
||||
* @see MailboxAction
|
||||
*/
|
||||
|
||||
class InboxAction extends MailboxAction
|
||||
{
|
||||
|
||||
@ -52,13 +51,16 @@ class InboxAction extends MailboxAction
|
||||
*
|
||||
* @return string page title
|
||||
*/
|
||||
|
||||
function title()
|
||||
{
|
||||
if ($this->page > 1) {
|
||||
// TRANS: Title for all but the first page of the inbox page.
|
||||
// TRANS: %1$s is the user's nickname, %2$s is the page number.
|
||||
return sprintf(_('Inbox for %1$s - page %2$d'), $this->user->nickname,
|
||||
$this->page);
|
||||
} else {
|
||||
// TRANS: Title for the first page of the inbox page.
|
||||
// TRANS: %s is the user's nickname.
|
||||
return sprintf(_('Inbox for %s'), $this->user->nickname);
|
||||
}
|
||||
}
|
||||
@ -72,7 +74,6 @@ class InboxAction extends MailboxAction
|
||||
*
|
||||
* @see MailboxAction::getMessages()
|
||||
*/
|
||||
|
||||
function getMessages()
|
||||
{
|
||||
$message = new Message();
|
||||
@ -98,7 +99,6 @@ class InboxAction extends MailboxAction
|
||||
*
|
||||
* @return Profile The profile that matches the message
|
||||
*/
|
||||
|
||||
function getMessageProfile($message)
|
||||
{
|
||||
return $message->getFrom();
|
||||
@ -109,9 +109,9 @@ class InboxAction extends MailboxAction
|
||||
*
|
||||
* @return string localised instructions for using the page
|
||||
*/
|
||||
|
||||
function getInstructions()
|
||||
{
|
||||
// TRANS: Instructions for user inbox page.
|
||||
return _('This is your inbox, which lists your incoming private messages.');
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
|
||||
|
||||
// @todo XXX: Add documentation.
|
||||
class InviteAction extends CurrentUserDesignAction
|
||||
{
|
||||
var $mode = null;
|
||||
@ -217,7 +218,7 @@ class InviteAction extends CurrentUserDesignAction
|
||||
$this->textarea('addresses', _('Email addresses'),
|
||||
$this->trimmed('addresses'),
|
||||
// TRANS: Tooltip for field label for a list of e-mail addresses.
|
||||
_('Addresses of friends to invite (one per line)'));
|
||||
_('Addresses of friends to invite (one per line).'));
|
||||
$this->elementEnd('li');
|
||||
$this->elementStart('li');
|
||||
// TRANS: Field label for a personal message to send to invitees.
|
||||
|
@ -43,7 +43,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class JoingroupAction extends Action
|
||||
{
|
||||
var $group = null;
|
||||
@ -51,12 +50,12 @@ class JoingroupAction extends Action
|
||||
/**
|
||||
* Prepare to run
|
||||
*/
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
parent::prepare($args);
|
||||
|
||||
if (!common_logged_in()) {
|
||||
// TRANS: Client error displayed when trying to join a group while not logged in.
|
||||
$this->clientError(_('You must be logged in to join a group.'));
|
||||
return false;
|
||||
}
|
||||
@ -79,17 +78,20 @@ class JoingroupAction extends Action
|
||||
$local = Local_group::staticGet('nickname', $nickname);
|
||||
|
||||
if (!$local) {
|
||||
// TRANS: Client error displayed when trying to join a non-local group.
|
||||
$this->clientError(_('No such group.'), 404);
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->group = User_group::staticGet('id', $local->group_id);
|
||||
} else {
|
||||
// TRANS: Client error displayed when trying to join a group without providing a group name or group ID.
|
||||
$this->clientError(_('No nickname or ID.'), 404);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$this->group) {
|
||||
// TRANS: Client error displayed when trying to join a non-existing group.
|
||||
$this->clientError(_('No such group.'), 404);
|
||||
return false;
|
||||
}
|
||||
@ -97,11 +99,13 @@ class JoingroupAction extends Action
|
||||
$cur = common_current_user();
|
||||
|
||||
if ($cur->isMember($this->group)) {
|
||||
// TRANS: Client error displayed when trying to join a group while already a member.
|
||||
$this->clientError(_('You are already a member of that group.'), 403);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Group_block::isBlocked($this->group, $cur->getProfile())) {
|
||||
// TRANS: Client error displayed when trying to join a group while being blocked form joining it.
|
||||
$this->clientError(_('You have been blocked from that group by the admin.'), 403);
|
||||
return false;
|
||||
}
|
||||
@ -118,7 +122,6 @@ class JoingroupAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($args)
|
||||
{
|
||||
parent::handle($args);
|
||||
@ -131,6 +134,8 @@ class JoingroupAction extends Action
|
||||
Event::handle('EndJoinGroup', array($this->group, $cur));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
// TRANS: Server error displayed when joining a group failed in the database.
|
||||
// TRANS: %1$s is the joining user's nickname, $2$s is the group nickname for which the join failed.
|
||||
$this->serverError(sprintf(_('Could not join user %1$s to group %2$s.'),
|
||||
$cur->nickname, $this->group->nickname));
|
||||
}
|
||||
@ -138,7 +143,8 @@ class JoingroupAction extends Action
|
||||
if ($this->boolean('ajax')) {
|
||||
$this->startHTML('text/xml;charset=utf-8');
|
||||
$this->elementStart('head');
|
||||
$this->element('title', null, sprintf(_('%1$s joined group %2$s'),
|
||||
// TRANS: Title for join group page after joining.
|
||||
$this->element('title', null, sprintf(_m('TITLE','%1$s joined group %2$s'),
|
||||
$cur->nickname,
|
||||
$this->group->nickname));
|
||||
$this->elementEnd('head');
|
||||
@ -153,4 +159,4 @@ class JoingroupAction extends Action
|
||||
303);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class LeavegroupAction extends Action
|
||||
{
|
||||
var $group = null;
|
||||
@ -51,12 +50,12 @@ class LeavegroupAction extends Action
|
||||
/**
|
||||
* Prepare to run
|
||||
*/
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
parent::prepare($args);
|
||||
|
||||
if (!common_logged_in()) {
|
||||
// TRANS: Client error displayed when trying to leave a group while not logged in.
|
||||
$this->clientError(_('You must be logged in to leave a group.'));
|
||||
return false;
|
||||
}
|
||||
@ -79,17 +78,20 @@ class LeavegroupAction extends Action
|
||||
$local = Local_group::staticGet('nickname', $nickname);
|
||||
|
||||
if (!$local) {
|
||||
// TRANS: Client error displayed when trying to leave a non-local group.
|
||||
$this->clientError(_('No such group.'), 404);
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->group = User_group::staticGet('id', $local->group_id);
|
||||
} else {
|
||||
// TRANS: Client error displayed when trying to leave a group without providing a group name or group ID.
|
||||
$this->clientError(_('No nickname or ID.'), 404);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$this->group) {
|
||||
// TRANS: Client error displayed when trying to leave a non-existing group.
|
||||
$this->clientError(_('No such group.'), 404);
|
||||
return false;
|
||||
}
|
||||
@ -97,6 +99,7 @@ class LeavegroupAction extends Action
|
||||
$cur = common_current_user();
|
||||
|
||||
if (!$cur->isMember($this->group)) {
|
||||
// TRANS: Client error displayed when trying to join a group while already a member.
|
||||
$this->clientError(_('You are not a member of that group.'), 403);
|
||||
return false;
|
||||
}
|
||||
@ -113,7 +116,6 @@ class LeavegroupAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($args)
|
||||
{
|
||||
parent::handle($args);
|
||||
@ -126,6 +128,8 @@ class LeavegroupAction extends Action
|
||||
Event::handle('EndLeaveGroup', array($this->group, $cur));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
// TRANS: Server error displayed when leaving a group failed in the database.
|
||||
// TRANS: %1$s is the leaving user's nickname, $2$s is the group nickname for which the leave failed.
|
||||
$this->serverError(sprintf(_('Could not remove user %1$s from group %2$s.'),
|
||||
$cur->nickname, $this->group->nickname));
|
||||
return;
|
||||
@ -134,7 +138,8 @@ class LeavegroupAction extends Action
|
||||
if ($this->boolean('ajax')) {
|
||||
$this->startHTML('text/xml;charset=utf-8');
|
||||
$this->elementStart('head');
|
||||
$this->element('title', null, sprintf(_('%1$s left group %2$s'),
|
||||
// TRANS: Title for leave group page after leaving.
|
||||
$this->element('title', null, sprintf(_m('TITLE','%1$s left group %2$s'),
|
||||
$cur->nickname,
|
||||
$this->group->nickname));
|
||||
$this->elementEnd('head');
|
||||
|
@ -40,7 +40,6 @@ if (!defined('STATUSNET')) {
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class LicenseadminpanelAction extends AdminPanelAction
|
||||
{
|
||||
|
||||
@ -61,7 +60,6 @@ class LicenseadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return string instructions
|
||||
*/
|
||||
|
||||
function getInstructions()
|
||||
{
|
||||
return _('License for this StatusNet site');
|
||||
@ -72,7 +70,6 @@ class LicenseadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showForm()
|
||||
{
|
||||
$form = new LicenseAdminPanelForm($this);
|
||||
@ -85,7 +82,6 @@ class LicenseadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function saveSettings()
|
||||
{
|
||||
static $settings = array(
|
||||
@ -128,7 +124,6 @@ class LicenseadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
|
||||
function validate(&$values)
|
||||
{
|
||||
// Validate license type (shouldn't have to do it, but just in case)
|
||||
@ -197,7 +192,6 @@ class LicenseAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return int ID of the form
|
||||
*/
|
||||
|
||||
function id()
|
||||
{
|
||||
return 'licenseadminpanel';
|
||||
@ -208,7 +202,6 @@ class LicenseAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return string class of the form
|
||||
*/
|
||||
|
||||
function formClass()
|
||||
{
|
||||
return 'form_settings';
|
||||
@ -312,7 +305,6 @@ class LicenseAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formActions()
|
||||
{
|
||||
$this->out->submit(
|
||||
|
@ -55,7 +55,6 @@ class NewApplicationAction extends OwnerDesignAction
|
||||
/**
|
||||
* Prepare to run
|
||||
*/
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
parent::prepare($args);
|
||||
@ -78,7 +77,6 @@ class NewApplicationAction extends OwnerDesignAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($args)
|
||||
{
|
||||
parent::handle($args);
|
||||
@ -122,6 +120,7 @@ class NewApplicationAction extends OwnerDesignAction
|
||||
} elseif ($this->arg('save')) {
|
||||
$this->trySave();
|
||||
} else {
|
||||
// TRANS: Client error displayed when encountering an unexpected action on form submission.
|
||||
$this->clientError(_('Unexpected form submission.'));
|
||||
}
|
||||
}
|
||||
@ -144,6 +143,7 @@ class NewApplicationAction extends OwnerDesignAction
|
||||
$this->element('p', 'error', $this->msg);
|
||||
} else {
|
||||
$this->element('p', 'instructions',
|
||||
// TRANS: Form instructions for registering a new application.
|
||||
_('Use this form to register a new application.'));
|
||||
}
|
||||
}
|
||||
@ -160,15 +160,19 @@ class NewApplicationAction extends OwnerDesignAction
|
||||
$access_type = $this->arg('default_access_type');
|
||||
|
||||
if (empty($name)) {
|
||||
// TRANS: Validation error shown when not providing a name in the "New application" form.
|
||||
$this->showForm(_('Name is required.'));
|
||||
return;
|
||||
} else if ($this->nameExists($name)) {
|
||||
// TRANS: Validation error shown when providing a name for an application that already exists in the "New application" form.
|
||||
$this->showForm(_('Name already in use. Try another one.'));
|
||||
return;
|
||||
} elseif (mb_strlen($name) > 255) {
|
||||
// TRANS: Validation error shown when providing too long a name in the "New application" form.
|
||||
$this->showForm(_('Name is too long (maximum 255 characters).'));
|
||||
return;
|
||||
} elseif (empty($description)) {
|
||||
// TRANS: Validation error shown when not providing a description in the "New application" form.
|
||||
$this->showForm(_('Description is required.'));
|
||||
return;
|
||||
} elseif (Oauth_application::descriptionTooLong($description)) {
|
||||
@ -181,6 +185,7 @@ class NewApplicationAction extends OwnerDesignAction
|
||||
Oauth_application::maxDesc()));
|
||||
return;
|
||||
} elseif (empty($source_url)) {
|
||||
// TRANS: Validation error shown when not providing a source URL in the "New application" form.
|
||||
$this->showForm(_('Source URL is required.'));
|
||||
return;
|
||||
} elseif ((strlen($source_url) > 0)
|
||||
@ -190,15 +195,19 @@ class NewApplicationAction extends OwnerDesignAction
|
||||
)
|
||||
)
|
||||
{
|
||||
// TRANS: Validation error shown when providing an invalid source URL in the "New application" form.
|
||||
$this->showForm(_('Source URL is not valid.'));
|
||||
return;
|
||||
} elseif (empty($organization)) {
|
||||
// TRANS: Validation error shown when not providing an organisation in the "New application" form.
|
||||
$this->showForm(_('Organization is required.'));
|
||||
return;
|
||||
} elseif (mb_strlen($organization) > 255) {
|
||||
// TRANS: Validation error shown when providing too long an arganisation name in the "Edit application" form.
|
||||
$this->showForm(_('Organization is too long (maximum 255 characters).'));
|
||||
return;
|
||||
} elseif (empty($homepage)) {
|
||||
// TRANS: Form validation error show when an organisation name has not been provided in the new application form.
|
||||
$this->showForm(_('Organization homepage is required.'));
|
||||
return;
|
||||
} elseif ((strlen($homepage) > 0)
|
||||
@ -208,9 +217,11 @@ class NewApplicationAction extends OwnerDesignAction
|
||||
)
|
||||
)
|
||||
{
|
||||
// TRANS: Validation error shown when providing an invalid homepage URL in the "New application" form.
|
||||
$this->showForm(_('Homepage is not a valid URL.'));
|
||||
return;
|
||||
} elseif (mb_strlen($callback_url) > 255) {
|
||||
// TRANS: Validation error shown when providing too long a callback URL in the "New application" form.
|
||||
$this->showForm(_('Callback is too long.'));
|
||||
return;
|
||||
} elseif (strlen($callback_url) > 0
|
||||
@ -220,6 +231,7 @@ class NewApplicationAction extends OwnerDesignAction
|
||||
)
|
||||
)
|
||||
{
|
||||
// TRANS: Validation error shown when providing an invalid callback URL in the "New application" form.
|
||||
$this->showForm(_('Callback URL is not valid.'));
|
||||
return;
|
||||
}
|
||||
@ -263,6 +275,7 @@ class NewApplicationAction extends OwnerDesignAction
|
||||
|
||||
if (!$result) {
|
||||
common_log_db_error($consumer, 'INSERT', __FILE__);
|
||||
// TRANS: Server error displayed when an application could not be registered in the database through the "New application" form.
|
||||
$this->serverError(_('Could not create application.'));
|
||||
}
|
||||
|
||||
@ -272,6 +285,7 @@ class NewApplicationAction extends OwnerDesignAction
|
||||
|
||||
if (!$this->app_id) {
|
||||
common_log_db_error($app, 'INSERT', __FILE__);
|
||||
// TRANS: Server error displayed when an application could not be registered in the database through the "New application" form.
|
||||
$this->serverError(_('Could not create application.'));
|
||||
$app->query('ROLLBACK');
|
||||
}
|
||||
@ -281,7 +295,6 @@ class NewApplicationAction extends OwnerDesignAction
|
||||
$app->query('COMMIT');
|
||||
|
||||
common_redirect(common_local_url('oauthappssettings'), 303);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -294,12 +307,9 @@ class NewApplicationAction extends OwnerDesignAction
|
||||
*
|
||||
* @return boolean true if the name already exists
|
||||
*/
|
||||
|
||||
function nameExists($name)
|
||||
{
|
||||
$app = Oauth_application::staticGet('name', $name);
|
||||
return !empty($app);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -183,11 +183,12 @@ class NewgroupAction extends Action
|
||||
foreach ($aliases as $alias) {
|
||||
if (!Nickname::isValid($alias)) {
|
||||
// TRANS: Group create form validation error.
|
||||
// TRANS: %s is the invalid alias.
|
||||
$this->showForm(sprintf(_('Invalid alias: "%s"'), $alias));
|
||||
return;
|
||||
}
|
||||
if ($this->nicknameExists($alias)) {
|
||||
// TRANS: Group create form validation error.
|
||||
// TRANS: Group create form validation error. %s is the already used alias.
|
||||
$this->showForm(sprintf(_('Alias "%s" already in use. Try another one.'),
|
||||
$alias));
|
||||
return;
|
||||
@ -195,7 +196,7 @@ class NewgroupAction extends Action
|
||||
// XXX assumes alphanum nicknames
|
||||
if (strcmp($alias, $nickname) == 0) {
|
||||
// TRANS: Group create form validation error.
|
||||
$this->showForm(_('Alias can\'t be the same as nickname.'));
|
||||
$this->showForm(_('Alias cannot be the same as nickname.'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ class OthersettingsAction extends AccountSettingsAction
|
||||
if ($result === false) {
|
||||
common_log_db_error($user, 'UPDATE', __FILE__);
|
||||
// TRANS: Server error displayed when "Other" settings in user profile could not be updated on the server.
|
||||
$this->serverError(_('Couldn\'t update user.'));
|
||||
$this->serverError(_('Could not update user.'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,6 @@ require_once INSTALLDIR.'/lib/accountsettingsaction.php';
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class ProfilesettingsAction extends AccountSettingsAction
|
||||
{
|
||||
/**
|
||||
@ -54,7 +53,6 @@ class ProfilesettingsAction extends AccountSettingsAction
|
||||
*
|
||||
* @return string Title of the page
|
||||
*/
|
||||
|
||||
function title()
|
||||
{
|
||||
// TRANS: Page title for profile settings.
|
||||
@ -66,7 +64,6 @@ class ProfilesettingsAction extends AccountSettingsAction
|
||||
*
|
||||
* @return instructions for use
|
||||
*/
|
||||
|
||||
function getInstructions()
|
||||
{
|
||||
// TRANS: Usage instructions for profile settings.
|
||||
@ -87,7 +84,6 @@ class ProfilesettingsAction extends AccountSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showContent()
|
||||
{
|
||||
$user = common_current_user();
|
||||
@ -212,12 +208,12 @@ class ProfilesettingsAction extends AccountSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handlePost()
|
||||
{
|
||||
// CSRF protection
|
||||
$token = $this->trimmed('token');
|
||||
if (!$token || $token != common_session_token()) {
|
||||
// TRANS: Form validation error.
|
||||
$this->showForm(_('There was a problem with your session token. '.
|
||||
'Try again, please.'));
|
||||
return;
|
||||
@ -323,7 +319,7 @@ class ProfilesettingsAction extends AccountSettingsAction
|
||||
if ($result === false) {
|
||||
common_log_db_error($user, 'UPDATE', __FILE__);
|
||||
// TRANS: Server error thrown when user profile settings could not be updated.
|
||||
$this->serverError(_('Couldn\'t update user.'));
|
||||
$this->serverError(_('Could not update user.'));
|
||||
return;
|
||||
} else {
|
||||
// Re-initialize language environment if it changed
|
||||
@ -348,7 +344,7 @@ class ProfilesettingsAction extends AccountSettingsAction
|
||||
common_log_db_error($user, 'UPDATE', __FILE__);
|
||||
// TRANS: Server error thrown when user profile settings could not be updated to
|
||||
// TRANS: automatically subscribe to any subscriber.
|
||||
$this->serverError(_('Couldn\'t update user for autosubscribe.'));
|
||||
$this->serverError(_('Could not update user for autosubscribe.'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -406,7 +402,7 @@ class ProfilesettingsAction extends AccountSettingsAction
|
||||
if ($result === false) {
|
||||
common_log_db_error($prefs, ($exists) ? 'UPDATE' : 'INSERT', __FILE__);
|
||||
// TRANS: Server error thrown when user profile location preference settings could not be updated.
|
||||
$this->serverError(_('Couldn\'t save location prefs.'));
|
||||
$this->serverError(_('Could not save location prefs.'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -419,7 +415,7 @@ class ProfilesettingsAction extends AccountSettingsAction
|
||||
if ($result === false) {
|
||||
common_log_db_error($profile, 'UPDATE', __FILE__);
|
||||
// TRANS: Server error thrown when user profile settings could not be saved.
|
||||
$this->serverError(_('Couldn\'t save profile.'));
|
||||
$this->serverError(_('Could not save profile.'));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -428,7 +424,7 @@ class ProfilesettingsAction extends AccountSettingsAction
|
||||
|
||||
if (!$result) {
|
||||
// TRANS: Server error thrown when user profile settings tags could not be saved.
|
||||
$this->serverError(_('Couldn\'t save tags.'));
|
||||
$this->serverError(_('Could not save tags.'));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -467,6 +463,7 @@ class ProfilesettingsAction extends AccountSettingsAction
|
||||
$this->elementStart('li');
|
||||
$this->element('a',
|
||||
array('href' => common_local_url('backupaccount')),
|
||||
// TRANS: Option in profile settings to create a backup of the account of the currently logged in user.
|
||||
_('Backup account'));
|
||||
$this->elementEnd('li');
|
||||
}
|
||||
@ -474,6 +471,7 @@ class ProfilesettingsAction extends AccountSettingsAction
|
||||
$this->elementStart('li');
|
||||
$this->element('a',
|
||||
array('href' => common_local_url('deleteaccount')),
|
||||
// TRANS: Option in profile settings to delete the account of the currently logged in user.
|
||||
_('Delete account'));
|
||||
$this->elementEnd('li');
|
||||
}
|
||||
@ -481,6 +479,7 @@ class ProfilesettingsAction extends AccountSettingsAction
|
||||
$this->elementStart('li');
|
||||
$this->element('a',
|
||||
array('href' => common_local_url('restoreaccount')),
|
||||
// TRANS: Option in profile settings to restore the account of the currently logged in user from a backup.
|
||||
_('Restore account'));
|
||||
$this->elementEnd('li');
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ class RecoverpasswordAction extends Action
|
||||
{
|
||||
parent::handle($args);
|
||||
if (common_logged_in()) {
|
||||
// TRANS: Client error displayed trying to recover password while already logged in.
|
||||
$this->clientError(_('You are already logged in!'));
|
||||
return;
|
||||
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
@ -41,6 +42,7 @@ class RecoverpasswordAction extends Action
|
||||
} else if ($this->arg('reset')) {
|
||||
$this->resetPassword();
|
||||
} else {
|
||||
// TRANS: Client error displayed when unexpected data is posted in the password recovery form.
|
||||
$this->clientError(_('Unexpected form submission.'));
|
||||
}
|
||||
} else {
|
||||
@ -54,15 +56,16 @@ class RecoverpasswordAction extends Action
|
||||
|
||||
function checkCode()
|
||||
{
|
||||
|
||||
$code = $this->trimmed('code');
|
||||
$confirm = Confirm_address::staticGet('code', $code);
|
||||
|
||||
if (!$confirm) {
|
||||
// TRANS: Client error displayed when password recovery code is not correct.
|
||||
$this->clientError(_('No such recovery code.'));
|
||||
return;
|
||||
}
|
||||
if ($confirm->address_type != 'recover') {
|
||||
// TRANS: Client error displayed when no proper password recovery code was submitted.
|
||||
$this->clientError(_('Not a recovery code.'));
|
||||
return;
|
||||
}
|
||||
@ -70,6 +73,7 @@ class RecoverpasswordAction extends Action
|
||||
$user = User::staticGet($confirm->user_id);
|
||||
|
||||
if (!$user) {
|
||||
// TRANS: Server error displayed trying to recover password without providing a user.
|
||||
$this->serverError(_('Recovery code for unknown user.'));
|
||||
return;
|
||||
}
|
||||
@ -83,6 +87,7 @@ class RecoverpasswordAction extends Action
|
||||
|
||||
if (!$result) {
|
||||
common_log_db_error($confirm, 'DELETE', __FILE__);
|
||||
// TRANS: Server error displayed removing a password recovery code from the database.
|
||||
$this->serverError(_('Error with confirmation code.'));
|
||||
return;
|
||||
}
|
||||
@ -94,6 +99,7 @@ class RecoverpasswordAction extends Action
|
||||
common_log(LOG_WARNING,
|
||||
'Attempted redemption on recovery code ' .
|
||||
'that is ' . $touched . ' seconds old. ');
|
||||
// TRANS: Client error displayed trying to recover password with too old a recovery code.
|
||||
$this->clientError(_('This confirmation code is too old. ' .
|
||||
'Please start again.'));
|
||||
return;
|
||||
@ -108,6 +114,7 @@ class RecoverpasswordAction extends Action
|
||||
$result = $user->updateKeys($orig);
|
||||
if (!$result) {
|
||||
common_log_db_error($user, 'UPDATE', __FILE__);
|
||||
// TRANS: Server error displayed when updating a user's e-mail address in the database fails while recovering a password.
|
||||
$this->serverError(_('Could not update user with confirmed email address.'));
|
||||
return;
|
||||
}
|
||||
@ -149,14 +156,16 @@ class RecoverpasswordAction extends Action
|
||||
$this->elementStart('div', 'instructions');
|
||||
if ($this->mode == 'recover') {
|
||||
$this->element('p', null,
|
||||
// TRANS: Page notice for password recovery page.
|
||||
_('If you have forgotten or lost your' .
|
||||
' password, you can get a new one sent to' .
|
||||
' the email address you have stored' .
|
||||
' in your account.'));
|
||||
} else if ($this->mode == 'reset') {
|
||||
// TRANS: Page notice for password change page.
|
||||
$this->element('p', null,
|
||||
_('You have been identified. Enter a' .
|
||||
' new password below. '));
|
||||
' new password below.'));
|
||||
}
|
||||
$this->elementEnd('div');
|
||||
}
|
||||
@ -185,19 +194,24 @@ class RecoverpasswordAction extends Action
|
||||
'class' => 'form_settings',
|
||||
'action' => common_local_url('recoverpassword')));
|
||||
$this->elementStart('fieldset');
|
||||
// TRANS: Fieldset legend for password recovery page.
|
||||
$this->element('legend', null, _('Password recovery'));
|
||||
$this->elementStart('ul', 'form_data');
|
||||
$this->elementStart('li');
|
||||
// TRANS: Field label on password recovery page.
|
||||
$this->input('nicknameoremail', _('Nickname or email address'),
|
||||
$this->trimmed('nicknameoremail'),
|
||||
// TRANS: Title for field label on password recovery page.
|
||||
_('Your nickname on this server, ' .
|
||||
'or your registered email address.'));
|
||||
$this->elementEnd('li');
|
||||
$this->elementEnd('ul');
|
||||
$this->element('input', array('name' => 'recover',
|
||||
'type' => 'hidden',
|
||||
// TRANS: Field label on password recovery page.
|
||||
'value' => _('Recover')));
|
||||
$this->submit('recover', _('Recover'));
|
||||
// TRANS: Button text on password recovery page.
|
||||
$this->submit('recover', _m('BUTTON','Recover'));
|
||||
$this->elementEnd('fieldset');
|
||||
$this->elementEnd('form');
|
||||
}
|
||||
@ -205,11 +219,16 @@ class RecoverpasswordAction extends Action
|
||||
function title()
|
||||
{
|
||||
switch ($this->mode) {
|
||||
// TRANS: Title for password recovery page in password reset mode.
|
||||
case 'reset': return _('Reset password');
|
||||
// TRANS: Title for password recovery page in password recover mode.
|
||||
case 'recover': return _('Recover password');
|
||||
// TRANS: Title for password recovery page in email sent mode.
|
||||
case 'sent': return _('Password recovery requested');
|
||||
// TRANS: Title for password recovery page in password saved mode.
|
||||
case 'saved': return _('Password saved.');
|
||||
default:
|
||||
// TRANS: Title for password recovery page when an unknown action has been specified.
|
||||
return _('Unknown action');
|
||||
}
|
||||
}
|
||||
@ -228,19 +247,25 @@ class RecoverpasswordAction extends Action
|
||||
'class' => 'form_settings',
|
||||
'action' => common_local_url('recoverpassword')));
|
||||
$this->elementStart('fieldset');
|
||||
// TRANS: Fieldset legend for password reset form.
|
||||
$this->element('legend', null, _('Password change'));
|
||||
$this->hidden('token', common_session_token());
|
||||
$this->elementStart('ul', 'form_data');
|
||||
$this->elementStart('li');
|
||||
// TRANS: Field label for password reset form.
|
||||
$this->password('newpassword', _('New password'),
|
||||
_('6 or more characters, and don\'t forget it!'));
|
||||
// TRANS: Title for field label for password reset form.
|
||||
_('6 or more characters, and do not forget it!'));
|
||||
$this->elementEnd('li');
|
||||
$this->elementStart('li');
|
||||
// TRANS: Field label for password reset form where the password has to be typed again.
|
||||
$this->password('confirm', _('Confirm'),
|
||||
_('Same as password above'));
|
||||
// TRANS: Ttile for field label for password reset form where the password has to be typed again.
|
||||
_('Same as password above.'));
|
||||
$this->elementEnd('li');
|
||||
$this->elementEnd('ul');
|
||||
$this->submit('reset', _('Reset'));
|
||||
// TRANS: Button text for password reset form.
|
||||
$this->submit('reset', _m('BUTTON','Reset'));
|
||||
$this->elementEnd('fieldset');
|
||||
$this->elementEnd('form');
|
||||
}
|
||||
@ -249,6 +274,7 @@ class RecoverpasswordAction extends Action
|
||||
{
|
||||
$nore = $this->trimmed('nicknameoremail');
|
||||
if (!$nore) {
|
||||
// TRANS: Form instructions for password recovery form.
|
||||
$this->showForm(_('Enter a nickname or email address.'));
|
||||
return;
|
||||
}
|
||||
@ -279,6 +305,7 @@ class RecoverpasswordAction extends Action
|
||||
}
|
||||
|
||||
if (!$user) {
|
||||
// TRANS: Information on password recovery form if no known username or e-mail address was specified.
|
||||
$this->showForm(_('No user with that email address or username.'));
|
||||
return;
|
||||
}
|
||||
@ -296,6 +323,7 @@ class RecoverpasswordAction extends Action
|
||||
}
|
||||
|
||||
if (!$user->email && !$confirm_email) {
|
||||
// TRANS: Client error displayed on password recovery form if a user does not have a registered e-mail address.
|
||||
$this->clientError(_('No registered email address for that user.'));
|
||||
return;
|
||||
}
|
||||
@ -310,10 +338,12 @@ class RecoverpasswordAction extends Action
|
||||
|
||||
if (!$confirm->insert()) {
|
||||
common_log_db_error($confirm, 'INSERT', __FILE__);
|
||||
// TRANS: Server error displayed if e-mail address confirmation fails in the database on the password recovery form.
|
||||
$this->serverError(_('Error saving address confirmation.'));
|
||||
return;
|
||||
}
|
||||
|
||||
// @todo FIXME: needs i18n.
|
||||
$body = "Hey, $user->nickname.";
|
||||
$body .= "\n\n";
|
||||
$body .= 'Someone just asked for a new password ' .
|
||||
@ -332,9 +362,11 @@ class RecoverpasswordAction extends Action
|
||||
$body .= "\n";
|
||||
|
||||
$headers = _mail_prepare_headers('recoverpassword', $user->nickname, $user->nickname);
|
||||
// TRANS: Subject for password recovery e-mail.
|
||||
mail_to_user($user, _('Password recovery requested'), $body, $headers, $confirm->address);
|
||||
|
||||
$this->mode = 'sent';
|
||||
// TRANS: User notification after an e-mail with instructions was sent from the password recovery form.
|
||||
$this->msg = _('Instructions for recovering your password ' .
|
||||
'have been sent to the email address registered to your ' .
|
||||
'account.');
|
||||
@ -347,6 +379,7 @@ class RecoverpasswordAction extends Action
|
||||
# CSRF protection
|
||||
$token = $this->trimmed('token');
|
||||
if (!$token || $token != common_session_token()) {
|
||||
// TRANS: Form validation error message.
|
||||
$this->showForm(_('There was a problem with your session token. Try again, please.'));
|
||||
return;
|
||||
}
|
||||
@ -354,6 +387,7 @@ class RecoverpasswordAction extends Action
|
||||
$user = $this->getTempUser();
|
||||
|
||||
if (!$user) {
|
||||
// TRANS: Client error displayed when trying to reset as password without providing a user.
|
||||
$this->clientError(_('Unexpected password reset.'));
|
||||
return;
|
||||
}
|
||||
@ -362,10 +396,12 @@ class RecoverpasswordAction extends Action
|
||||
$confirm = $this->trimmed('confirm');
|
||||
|
||||
if (!$newpassword || strlen($newpassword) < 6) {
|
||||
// TRANS: Reset password form validation error message.
|
||||
$this->showPasswordForm(_('Password must be 6 characters or more.'));
|
||||
return;
|
||||
}
|
||||
if ($newpassword != $confirm) {
|
||||
// TRANS: Reset password form validation error message.
|
||||
$this->showPasswordForm(_('Password and confirmation do not match.'));
|
||||
return;
|
||||
}
|
||||
@ -378,13 +414,15 @@ class RecoverpasswordAction extends Action
|
||||
|
||||
if (!$user->update($original)) {
|
||||
common_log_db_error($user, 'UPDATE', __FILE__);
|
||||
$this->serverError(_('Can\'t save new password.'));
|
||||
// TRANS: Reset password form validation error message.
|
||||
$this->serverError(_('Cannot save new password.'));
|
||||
return;
|
||||
}
|
||||
|
||||
$this->clearTempUser();
|
||||
|
||||
if (!common_set_user($user->nickname)) {
|
||||
// TRANS: Server error displayed when something does wrong with the user object during password reset.
|
||||
$this->serverError(_('Error setting user.'));
|
||||
return;
|
||||
}
|
||||
@ -392,6 +430,7 @@ class RecoverpasswordAction extends Action
|
||||
common_real_login(true);
|
||||
|
||||
$this->mode = 'saved';
|
||||
// TRANS: Success message for user after password reset.
|
||||
$this->msg = _('New password successfully saved. ' .
|
||||
'You are now logged in.');
|
||||
$this->success = true;
|
||||
|
@ -430,16 +430,15 @@ class RegisterAction extends Action
|
||||
if (Event::handle('StartRegistrationFormData', array($this))) {
|
||||
$this->elementStart('li');
|
||||
$this->input('nickname', _('Nickname'), $this->trimmed('nickname'),
|
||||
_('1-64 lowercase letters or numbers, '.
|
||||
'no punctuation or spaces. Required.'));
|
||||
_('1-64 lowercase letters or numbers, no punctuation or spaces.'));
|
||||
$this->elementEnd('li');
|
||||
$this->elementStart('li');
|
||||
$this->password('password', _('Password'),
|
||||
_('6 or more characters. Required.'));
|
||||
_('6 or more characters.'));
|
||||
$this->elementEnd('li');
|
||||
$this->elementStart('li');
|
||||
$this->password('confirm', _('Confirm'),
|
||||
_('Same as password above. Required.'));
|
||||
_('Same as password above.'));
|
||||
$this->elementEnd('li');
|
||||
$this->elementStart('li');
|
||||
if ($this->invite && $this->invite->address_type == 'email') {
|
||||
|
@ -44,7 +44,6 @@ require_once INSTALLDIR.'/extlib/libomb/profile.php';
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class RemotesubscribeAction extends Action
|
||||
{
|
||||
var $nickname;
|
||||
@ -173,14 +172,14 @@ class RemotesubscribeAction extends Action
|
||||
if ($service->getServiceURI(OAUTH_ENDPOINT_REQUEST) ==
|
||||
common_local_url('requesttoken') ||
|
||||
User::staticGet('uri', $service->getRemoteUserURI())) {
|
||||
$this->showForm(_('That’s a local profile! Login to subscribe.'));
|
||||
$this->showForm(_('That is a local profile! Login to subscribe.'));
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$service->requestToken();
|
||||
} catch (OMB_RemoteServiceException $e) {
|
||||
$this->showForm(_('Couldn’t get a request token.'));
|
||||
$this->showForm(_('Could not get a request token.'));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -204,4 +203,3 @@ class RemotesubscribeAction extends Action
|
||||
common_redirect($target_url, 303);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -41,7 +41,6 @@ if (!defined('STATUSNET')) {
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class RepeatAction extends Action
|
||||
{
|
||||
var $user = null;
|
||||
@ -73,7 +72,7 @@ class RepeatAction extends Action
|
||||
}
|
||||
|
||||
if ($this->user->id == $this->notice->profile_id) {
|
||||
$this->clientError(_("You can't repeat your own notice."));
|
||||
$this->clientError(_("You cannot repeat your own notice."));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -101,7 +100,6 @@ class RepeatAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($args)
|
||||
{
|
||||
$repeat = $this->notice->repeat($this->user->id, 'web');
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Copyright (C) 2010, StatusNet, Inc.
|
||||
*
|
||||
* Restore a backup of your own account from the browser
|
||||
*
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@ -44,7 +44,6 @@ if (!defined('STATUSNET')) {
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class RestoreaccountAction extends Action
|
||||
{
|
||||
private $success = false;
|
||||
@ -52,12 +51,12 @@ class RestoreaccountAction extends Action
|
||||
|
||||
/**
|
||||
* Returns the title of the page
|
||||
*
|
||||
*
|
||||
* @return string page title
|
||||
*/
|
||||
|
||||
function title()
|
||||
{
|
||||
// TRANS: Page title for page where a user account can be restored from backup.
|
||||
return _("Restore account");
|
||||
}
|
||||
|
||||
@ -68,7 +67,6 @@ class RestoreaccountAction extends Action
|
||||
*
|
||||
* @return boolean true
|
||||
*/
|
||||
|
||||
function prepare($argarray)
|
||||
{
|
||||
parent::prepare($argarray);
|
||||
@ -76,10 +74,12 @@ class RestoreaccountAction extends Action
|
||||
$cur = common_current_user();
|
||||
|
||||
if (empty($cur)) {
|
||||
// TRANS: Client exception displayed when trying to restore an account while not logged in.
|
||||
throw new ClientException(_('Only logged-in users can restore their account.'), 403);
|
||||
}
|
||||
|
||||
if (!$cur->hasRight(Right::RESTOREACCOUNT)) {
|
||||
// TRANS: Client exception displayed when trying to restore an account without having restore rights.
|
||||
throw new ClientException(_('You may not restore your account.'), 403);
|
||||
}
|
||||
|
||||
@ -93,7 +93,6 @@ class RestoreaccountAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($argarray=null)
|
||||
{
|
||||
parent::handle($argarray);
|
||||
@ -108,17 +107,17 @@ class RestoreaccountAction extends Action
|
||||
|
||||
/**
|
||||
* Queue a file for restoration
|
||||
*
|
||||
*
|
||||
* Uses the UserActivityStream class; may take a long time!
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function restoreAccount()
|
||||
{
|
||||
$this->checkSessionToken();
|
||||
|
||||
if (!isset($_FILES['restorefile']['error'])) {
|
||||
// TRANS: Client exception displayed trying to restore an account while something went wrong uploading a file.
|
||||
throw new ClientException(_('No uploaded file.'));
|
||||
}
|
||||
|
||||
@ -143,7 +142,7 @@ class RestoreaccountAction extends Action
|
||||
' partially uploaded.'));
|
||||
return;
|
||||
case UPLOAD_ERR_NO_FILE:
|
||||
// No file; probably just a non-AJAX submission.
|
||||
// TRANS: Client exception. No file; probably just a non-AJAX submission.
|
||||
throw new ClientException(_('No uploaded file.'));
|
||||
return;
|
||||
case UPLOAD_ERR_NO_TMP_DIR:
|
||||
@ -170,18 +169,21 @@ class RestoreaccountAction extends Action
|
||||
|
||||
try {
|
||||
if (!file_exists($filename)) {
|
||||
throw new ServerException("No such file '$filename'.");
|
||||
// TRANS: Server exception thrown when an expected file upload could not be found.
|
||||
throw new ServerException(_("No such file '$filename'."));
|
||||
}
|
||||
|
||||
|
||||
if (!is_file($filename)) {
|
||||
throw new ServerException("Not a regular file: '$filename'.");
|
||||
// TRANS: Server exception thrown when an expected file upload is not an actual file.
|
||||
throw new ServerException(_("Not a regular file: '$filename'."));
|
||||
}
|
||||
|
||||
|
||||
if (!is_readable($filename)) {
|
||||
throw new ServerException("File '$filename' not readable.");
|
||||
// TRANS: Server exception thrown when an expected file upload could not be read.
|
||||
throw new ServerException(_("File '$filename' not readable."));
|
||||
}
|
||||
|
||||
common_debug(sprintf(_("Getting backup from file '%s'."), $filename));
|
||||
|
||||
common_debug(sprintf("Getting backup from file '%s'.", $filename));
|
||||
|
||||
$xml = file_get_contents($filename);
|
||||
|
||||
@ -201,7 +203,8 @@ class RestoreaccountAction extends Action
|
||||
if (!$feed ||
|
||||
$feed->namespaceURI != Activity::ATOM ||
|
||||
$feed->localName != 'feed') {
|
||||
throw new ClientException(_("Not an atom feed."));
|
||||
// TRANS: Client exception thrown when a feed is not an Atom feed.
|
||||
throw new ClientException(_("Not an Atom feed."));
|
||||
}
|
||||
|
||||
// Enqueue for processing.
|
||||
@ -230,21 +233,22 @@ class RestoreaccountAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showContent()
|
||||
{
|
||||
if ($this->success) {
|
||||
$this->element('p', null,
|
||||
// TRANS: Success message when a feed has been restored.
|
||||
_('Feed has been restored. Your old posts should now appear in search and your profile page.'));
|
||||
} else if ($this->inprogress) {
|
||||
$this->element('p', null,
|
||||
// TRANS: Message when a feed restore is in progress.
|
||||
_('Feed will be restored. Please wait a few minutes for results.'));
|
||||
} else {
|
||||
$form = new RestoreAccountForm($this);
|
||||
$form->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return true if read only.
|
||||
*
|
||||
@ -254,7 +258,6 @@ class RestoreaccountAction extends Action
|
||||
*
|
||||
* @return boolean is read only action?
|
||||
*/
|
||||
|
||||
function isReadOnly($args)
|
||||
{
|
||||
return false;
|
||||
@ -267,7 +270,6 @@ class RestoreaccountAction extends Action
|
||||
*
|
||||
* @return string last modified http header
|
||||
*/
|
||||
|
||||
function lastModified()
|
||||
{
|
||||
// For comparison with If-Last-Modified
|
||||
@ -282,7 +284,6 @@ class RestoreaccountAction extends Action
|
||||
*
|
||||
* @return string etag http header
|
||||
*/
|
||||
|
||||
function etag()
|
||||
{
|
||||
return null;
|
||||
@ -299,7 +300,6 @@ class RestoreaccountAction extends Action
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class RestoreAccountForm extends Form
|
||||
{
|
||||
function __construct($out=null) {
|
||||
@ -312,7 +312,6 @@ class RestoreAccountForm extends Form
|
||||
*
|
||||
* @return string the form's class
|
||||
*/
|
||||
|
||||
function formClass()
|
||||
{
|
||||
return 'form_profile_restore';
|
||||
@ -323,7 +322,6 @@ class RestoreAccountForm extends Form
|
||||
*
|
||||
* @return string the form's action URL
|
||||
*/
|
||||
|
||||
function action()
|
||||
{
|
||||
return common_local_url('restoreaccount');
|
||||
@ -331,19 +329,19 @@ class RestoreAccountForm extends Form
|
||||
|
||||
/**
|
||||
* Output form data
|
||||
*
|
||||
*
|
||||
* Really, just instructions for doing a backup.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formData()
|
||||
{
|
||||
$this->out->elementStart('p', 'instructions');
|
||||
|
||||
// TRANS: Form instructions for feed restore.
|
||||
$this->out->raw(_('You can upload a backed-up stream in '.
|
||||
'<a href="http://activitystrea.ms/">Activity Streams</a> format.'));
|
||||
|
||||
|
||||
$this->out->elementEnd('p');
|
||||
|
||||
$this->out->elementStart('ul', 'form_data');
|
||||
@ -359,18 +357,19 @@ class RestoreAccountForm extends Form
|
||||
|
||||
/**
|
||||
* Buttons for the form
|
||||
*
|
||||
*
|
||||
* In this case, a single submit button
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formActions()
|
||||
{
|
||||
$this->out->submit('submit',
|
||||
// TRANS: Submit button to confirm upload of a user backup file for account restore.
|
||||
_m('BUTTON', 'Upload'),
|
||||
'submit',
|
||||
null,
|
||||
// TRANS: Title for submit button to confirm upload of a user backup file for account restore.
|
||||
_('Upload the file'));
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,6 @@ 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
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class ShowfavoritesAction extends OwnerDesignAction
|
||||
{
|
||||
/** User we're getting the faves of */
|
||||
@ -57,7 +56,6 @@ class ShowfavoritesAction extends OwnerDesignAction
|
||||
*
|
||||
* @return boolean true
|
||||
*/
|
||||
|
||||
function isReadOnly($args)
|
||||
{
|
||||
return true;
|
||||
@ -70,12 +68,15 @@ class ShowfavoritesAction extends OwnerDesignAction
|
||||
*
|
||||
* @return string title of page
|
||||
*/
|
||||
|
||||
function title()
|
||||
{
|
||||
if ($this->page == 1) {
|
||||
// TRANS: Title for first page of favourite notices of a user.
|
||||
// TRANS: %s is the user for whom the favourite notices are displayed.
|
||||
return sprintf(_('%s\'s favorite notices'), $this->user->nickname);
|
||||
} else {
|
||||
// TRANS: Title for all but the first page of favourite notices of a user.
|
||||
// TRANS: %1$s is the user for whom the favourite notices are displayed, %2$d is the page number.
|
||||
return sprintf(_('%1$s\'s favorite notices, page %2$d'),
|
||||
$this->user->nickname,
|
||||
$this->page);
|
||||
@ -92,7 +93,6 @@ class ShowfavoritesAction extends OwnerDesignAction
|
||||
*
|
||||
* @return boolean success flag
|
||||
*/
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
parent::prepare($args);
|
||||
@ -102,6 +102,7 @@ class ShowfavoritesAction extends OwnerDesignAction
|
||||
$this->user = User::staticGet('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.'));
|
||||
return false;
|
||||
}
|
||||
@ -129,6 +130,7 @@ class ShowfavoritesAction extends OwnerDesignAction
|
||||
}
|
||||
|
||||
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.'));
|
||||
return;
|
||||
}
|
||||
@ -150,7 +152,6 @@ class ShowfavoritesAction extends OwnerDesignAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($args)
|
||||
{
|
||||
parent::handle($args);
|
||||
@ -162,12 +163,12 @@ class ShowfavoritesAction extends OwnerDesignAction
|
||||
*
|
||||
* @return array Feed objects to show
|
||||
*/
|
||||
|
||||
function getFeeds()
|
||||
{
|
||||
return array(new Feed(Feed::RSS1,
|
||||
common_local_url('favoritesrss',
|
||||
array('nickname' => $this->user->nickname)),
|
||||
// TRANS: Feed link text. %s is a username.
|
||||
sprintf(_('Feed for favorites of %s (RSS 1.0)'),
|
||||
$this->user->nickname)),
|
||||
new Feed(Feed::RSS2,
|
||||
@ -175,6 +176,7 @@ class ShowfavoritesAction extends OwnerDesignAction
|
||||
array(
|
||||
'id' => $this->user->nickname,
|
||||
'format' => 'rss')),
|
||||
// TRANS: Feed link text. %s is a username.
|
||||
sprintf(_('Feed for favorites of %s (RSS 2.0)'),
|
||||
$this->user->nickname)),
|
||||
new Feed(Feed::ATOM,
|
||||
@ -182,6 +184,7 @@ class ShowfavoritesAction extends OwnerDesignAction
|
||||
array(
|
||||
'id' => $this->user->nickname,
|
||||
'format' => 'atom')),
|
||||
// TRANS: Feed link text. %s is a username.
|
||||
sprintf(_('Feed for favorites of %s (Atom)'),
|
||||
$this->user->nickname)));
|
||||
}
|
||||
@ -191,7 +194,6 @@ class ShowfavoritesAction extends OwnerDesignAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showLocalNav()
|
||||
{
|
||||
$nav = new PersonalGroupNav($this);
|
||||
@ -203,12 +205,18 @@ class ShowfavoritesAction extends OwnerDesignAction
|
||||
if (common_logged_in()) {
|
||||
$current_user = common_current_user();
|
||||
if ($this->user->id === $current_user->id) {
|
||||
// TRANS: Text displayed instead of favourite notices for the current logged in user that has no favourites.
|
||||
$message = _('You haven\'t chosen any favorite notices yet. Click the fave button on notices you like to bookmark them for later or shed a spotlight on them.');
|
||||
} else {
|
||||
// TRANS: Text displayed instead of favourite notices for a user that has no favourites while logged in.
|
||||
// TRANS: %s is a username.
|
||||
$message = sprintf(_('%s hasn\'t added any favorite notices yet. Post something interesting they would add to their favorites :)'), $this->user->nickname);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// TRANS: Text displayed instead of favourite notices for a user that has no favourites while not logged in.
|
||||
// TRANS: %s is a username, %%%%action.register%%%% is a link to the user registration page.
|
||||
// TRANS: (link text)[link] is a Mark Down link.
|
||||
$message = sprintf(_('%s hasn\'t added any favorite notices yet. Why not [register an account](%%%%action.register%%%%) and then post something interesting they would add to their favorites :)'), $this->user->nickname);
|
||||
}
|
||||
|
||||
@ -224,7 +232,6 @@ class ShowfavoritesAction extends OwnerDesignAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showContent()
|
||||
{
|
||||
$nl = new FavoritesNoticeList($this->notice, $this);
|
||||
@ -240,6 +247,7 @@ class ShowfavoritesAction extends OwnerDesignAction
|
||||
}
|
||||
|
||||
function showPageNotice() {
|
||||
// TRANS: Page notice for show favourites page.
|
||||
$this->element('p', 'instructions', _('This is a way to share what you like.'));
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,6 @@ require_once INSTALLDIR.'/lib/connectsettingsaction.php';
|
||||
*
|
||||
* @see SettingsAction
|
||||
*/
|
||||
|
||||
class SmssettingsAction extends ConnectSettingsAction
|
||||
{
|
||||
/**
|
||||
@ -52,7 +51,6 @@ class SmssettingsAction extends ConnectSettingsAction
|
||||
*
|
||||
* @return string Title of the page
|
||||
*/
|
||||
|
||||
function title()
|
||||
{
|
||||
// TRANS: Title for SMS settings.
|
||||
@ -64,7 +62,6 @@ class SmssettingsAction extends ConnectSettingsAction
|
||||
*
|
||||
* @return instructions for use
|
||||
*/
|
||||
|
||||
function getInstructions()
|
||||
{
|
||||
// XXX: For consistency of parameters in messages, this should be a
|
||||
@ -88,7 +85,6 @@ class SmssettingsAction extends ConnectSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showContent()
|
||||
{
|
||||
if (!common_config('sms', 'enabled')) {
|
||||
@ -219,7 +215,6 @@ class SmssettingsAction extends ConnectSettingsAction
|
||||
*
|
||||
* @todo very similar to EmailsettingsAction::getConfirmation(); refactor?
|
||||
*/
|
||||
|
||||
function getConfirmation()
|
||||
{
|
||||
$user = common_current_user();
|
||||
@ -246,7 +241,6 @@ class SmssettingsAction extends ConnectSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handlePost()
|
||||
{
|
||||
// CSRF protection
|
||||
@ -285,7 +279,6 @@ class SmssettingsAction extends ConnectSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function savePreferences()
|
||||
{
|
||||
$smsnotify = $this->boolean('smsnotify');
|
||||
@ -305,7 +298,7 @@ class SmssettingsAction extends ConnectSettingsAction
|
||||
if ($result === false) {
|
||||
common_log_db_error($user, 'UPDATE', __FILE__);
|
||||
// TRANS: Server error thrown on database error updating SMS preferences.
|
||||
$this->serverError(_('Couldn\'t update user.'));
|
||||
$this->serverError(_('Could not update user.'));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -323,7 +316,6 @@ class SmssettingsAction extends ConnectSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function addAddress()
|
||||
{
|
||||
$user = common_current_user();
|
||||
@ -370,7 +362,7 @@ class SmssettingsAction extends ConnectSettingsAction
|
||||
if ($result === false) {
|
||||
common_log_db_error($confirm, 'INSERT', __FILE__);
|
||||
// TRANS: Server error thrown on database error adding SMS confirmation code.
|
||||
$this->serverError(_('Couldn\'t insert confirmation code.'));
|
||||
$this->serverError(_('Could not insert confirmation code.'));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -395,7 +387,6 @@ class SmssettingsAction extends ConnectSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function cancelConfirmation()
|
||||
{
|
||||
$sms = $this->trimmed('sms');
|
||||
@ -419,7 +410,7 @@ class SmssettingsAction extends ConnectSettingsAction
|
||||
if (!$result) {
|
||||
common_log_db_error($confirm, 'DELETE', __FILE__);
|
||||
// TRANS: Server error thrown on database error canceling SMS phone number confirmation.
|
||||
$this->serverError(_('Couldn\'t delete email confirmation.'));
|
||||
$this->serverError(_('Could not delete email confirmation.'));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -432,7 +423,6 @@ class SmssettingsAction extends ConnectSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function removeAddress()
|
||||
{
|
||||
$user = common_current_user();
|
||||
@ -461,7 +451,7 @@ class SmssettingsAction extends ConnectSettingsAction
|
||||
if (!$result) {
|
||||
common_log_db_error($user, 'UPDATE', __FILE__);
|
||||
// TRANS: Server error thrown on database error removing a registered SMS phone number.
|
||||
$this->serverError(_('Couldn\'t update user.'));
|
||||
$this->serverError(_('Could not update user.'));
|
||||
return;
|
||||
}
|
||||
$user->query('COMMIT');
|
||||
@ -479,7 +469,6 @@ class SmssettingsAction extends ConnectSettingsAction
|
||||
*
|
||||
* @return boolean does the number exist
|
||||
*/
|
||||
|
||||
function smsExists($sms)
|
||||
{
|
||||
$user = common_current_user();
|
||||
@ -498,7 +487,6 @@ class SmssettingsAction extends ConnectSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function carrierSelect()
|
||||
{
|
||||
$carrier = new Sms_carrier();
|
||||
@ -538,14 +526,13 @@ class SmssettingsAction extends ConnectSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function confirmCode()
|
||||
{
|
||||
$code = $this->trimmed('code');
|
||||
|
||||
if (!$code) {
|
||||
// TRANS: Message given saving SMS phone number confirmation code without having provided one.
|
||||
$this->showForm(_('No code entered'));
|
||||
$this->showForm(_('No code entered.'));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -559,12 +546,12 @@ class SmssettingsAction extends ConnectSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function removeIncoming()
|
||||
{
|
||||
$user = common_current_user();
|
||||
|
||||
if (!$user->incomingemail) {
|
||||
// TRANS: Form validation error displayed when trying to remove an incoming e-mail address while no address has been set.
|
||||
$this->showForm(_('No incoming email address.'));
|
||||
return;
|
||||
}
|
||||
@ -575,7 +562,7 @@ class SmssettingsAction extends ConnectSettingsAction
|
||||
|
||||
if (!$user->updateKeys($orig)) {
|
||||
common_log_db_error($user, 'UPDATE', __FILE__);
|
||||
$this->serverError(_("Couldn't update user record."));
|
||||
$this->serverError(_("Could not update user record."));
|
||||
}
|
||||
|
||||
$this->showForm(_('Incoming email address removed.'), true);
|
||||
@ -588,7 +575,6 @@ class SmssettingsAction extends ConnectSettingsAction
|
||||
*
|
||||
* @see Emailsettings::newIncoming
|
||||
*/
|
||||
|
||||
function newIncoming()
|
||||
{
|
||||
$user = common_current_user();
|
||||
@ -599,7 +585,7 @@ class SmssettingsAction extends ConnectSettingsAction
|
||||
|
||||
if (!$user->updateKeys($orig)) {
|
||||
common_log_db_error($user, 'UPDATE', __FILE__);
|
||||
$this->serverError(_("Couldn't update user record."));
|
||||
$this->serverError(_("Could not update user record."));
|
||||
}
|
||||
|
||||
$this->showForm(_('New incoming email address added.'), true);
|
||||
|
@ -167,15 +167,14 @@ class SubscriptionsAction extends GalleryAction
|
||||
*
|
||||
* @return array of Feed objects
|
||||
*/
|
||||
|
||||
function getFeeds()
|
||||
{
|
||||
return array(new Feed(Feed::ATOM,
|
||||
common_local_url('AtomPubSubscriptionFeed',
|
||||
array('subscriber' => $this->profile->id)),
|
||||
// TRANS: Atom feed title. %s is a profile nickname.
|
||||
sprintf(_('Subscription feed for %s (Atom)'),
|
||||
$this->profile->nickname)));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -261,5 +260,4 @@ class SubscriptionsListItem extends SubscriptionListItem
|
||||
$this->out->elementEnd('form');
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -46,7 +46,6 @@ require_once INSTALLDIR . '/lib/designsettings.php';
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class UserDesignSettingsAction extends DesignSettingsAction
|
||||
{
|
||||
/**
|
||||
@ -70,7 +69,6 @@ class UserDesignSettingsAction extends DesignSettingsAction
|
||||
*
|
||||
* @return string Title of the page
|
||||
*/
|
||||
|
||||
function title()
|
||||
{
|
||||
return _('Profile design');
|
||||
@ -81,7 +79,6 @@ class UserDesignSettingsAction extends DesignSettingsAction
|
||||
*
|
||||
* @return instructions for use
|
||||
*/
|
||||
|
||||
function getInstructions()
|
||||
{
|
||||
return _('Customize the way your profile looks ' .
|
||||
@ -93,7 +90,6 @@ class UserDesignSettingsAction extends DesignSettingsAction
|
||||
*
|
||||
* @return Design
|
||||
*/
|
||||
|
||||
function getWorkingDesign()
|
||||
{
|
||||
$user = common_current_user();
|
||||
@ -108,7 +104,6 @@ class UserDesignSettingsAction extends DesignSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showContent()
|
||||
{
|
||||
$design = $this->getWorkingDesign();
|
||||
@ -125,7 +120,6 @@ class UserDesignSettingsAction extends DesignSettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function saveDesign()
|
||||
{
|
||||
foreach ($this->args as $key => $val) {
|
||||
@ -168,7 +162,6 @@ class UserDesignSettingsAction extends DesignSettingsAction
|
||||
$design = $user->getDesign();
|
||||
|
||||
if (!empty($design)) {
|
||||
|
||||
$original = clone($design);
|
||||
|
||||
$design->backgroundcolor = $bgcolor->intValue();
|
||||
@ -183,13 +176,11 @@ class UserDesignSettingsAction extends DesignSettingsAction
|
||||
|
||||
if ($result === false) {
|
||||
common_log_db_error($design, 'UPDATE', __FILE__);
|
||||
$this->showForm(_('Couldn\'t update your design.'));
|
||||
$this->showForm(_('Could not update your design.'));
|
||||
return;
|
||||
}
|
||||
|
||||
// update design
|
||||
} else {
|
||||
|
||||
$user->query('BEGIN');
|
||||
|
||||
// save new design
|
||||
@ -236,7 +227,6 @@ class UserDesignSettingsAction extends DesignSettingsAction
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
|
||||
function sethd()
|
||||
{
|
||||
|
||||
@ -281,5 +271,4 @@ class UserDesignSettingsAction extends DesignSettingsAction
|
||||
|
||||
$this->showForm(_('Enjoy your hotdog!'), true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -55,14 +55,20 @@ class File extends Memcached_DataObject
|
||||
return 'http://www.facebook.com/login.php' === $url;
|
||||
}
|
||||
|
||||
function getAttachments($post_id) {
|
||||
$query = "select file.* from file join file_to_post on (file_id = file.id) join notice on (post_id = notice.id) where post_id = " . $this->escape($post_id);
|
||||
$this->query($query);
|
||||
/**
|
||||
* Get the attachments for a particlar notice.
|
||||
*
|
||||
* @param int $post_id
|
||||
* @return array of File objects
|
||||
*/
|
||||
static function getAttachments($post_id) {
|
||||
$file = new File();
|
||||
$query = "select file.* from file join file_to_post on (file_id = file.id) where post_id = " . $file->escape($post_id);
|
||||
$file = Memcached_DataObject::cachedQuery('File', $query);
|
||||
$att = array();
|
||||
while ($this->fetch()) {
|
||||
$att[] = clone($this);
|
||||
while ($file->fetch()) {
|
||||
$att[] = clone($file);
|
||||
}
|
||||
$this->free();
|
||||
return $att;
|
||||
}
|
||||
|
||||
|
@ -340,6 +340,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
$start = microtime(true);
|
||||
$result = null;
|
||||
if (Event::handle('StartDBQuery', array($this, $string, &$result))) {
|
||||
common_perf_counter('query', $string);
|
||||
$result = parent::_query($string);
|
||||
Event::handle('EndDBQuery', array($this, $string, &$result));
|
||||
}
|
||||
@ -480,6 +481,10 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
}
|
||||
}
|
||||
}
|
||||
// Needed to make timestamp values usefully comparable.
|
||||
if (common_config('db', 'type') == 'mysql') {
|
||||
parent::_query("set time_zone='+0:00'");
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
@ -241,7 +241,7 @@ class Notice extends Memcached_DataObject
|
||||
* array 'urls' list of attached/referred URLs to save with the
|
||||
* notice in place of extracting links from content
|
||||
* boolean 'distribute' whether to distribute the notice, default true
|
||||
*
|
||||
*
|
||||
* @fixme tag override
|
||||
*
|
||||
* @return Notice
|
||||
@ -819,9 +819,18 @@ class Notice extends Memcached_DataObject
|
||||
|
||||
// Exclude any deleted, non-local, or blocking recipients.
|
||||
$profile = $this->getProfile();
|
||||
$originalProfile = null;
|
||||
if ($this->repeat_of) {
|
||||
// Check blocks against the original notice's poster as well.
|
||||
$original = Notice::staticGet('id', $this->repeat_of);
|
||||
if ($original) {
|
||||
$originalProfile = $original->getProfile();
|
||||
}
|
||||
}
|
||||
foreach ($ni as $id => $source) {
|
||||
$user = User::staticGet('id', $id);
|
||||
if (empty($user) || $user->hasBlocked($profile)) {
|
||||
if (empty($user) || $user->hasBlocked($profile) ||
|
||||
($originalProfile && $user->hasBlocked($originalProfile))) {
|
||||
unset($ni[$id]);
|
||||
}
|
||||
}
|
||||
@ -1231,7 +1240,7 @@ class Notice extends Memcached_DataObject
|
||||
* Convert a notice into an activity for export.
|
||||
*
|
||||
* @param User $cur Current user
|
||||
*
|
||||
*
|
||||
* @return Activity activity object representing this Notice.
|
||||
*/
|
||||
|
||||
@ -1244,11 +1253,11 @@ class Notice extends Memcached_DataObject
|
||||
}
|
||||
|
||||
$act = new Activity();
|
||||
|
||||
|
||||
if (Event::handle('StartNoticeAsActivity', array($this, &$act))) {
|
||||
|
||||
$profile = $this->getProfile();
|
||||
|
||||
|
||||
$act->actor = ActivityObject::fromProfile($profile);
|
||||
$act->verb = ActivityVerb::POST;
|
||||
$act->objects[] = ActivityObject::fromNotice($this);
|
||||
@ -1257,7 +1266,7 @@ class Notice extends Memcached_DataObject
|
||||
|
||||
$act->time = strtotime($this->created);
|
||||
$act->link = $this->bestUrl();
|
||||
|
||||
|
||||
$act->content = common_xml_safe_str($this->rendered);
|
||||
$act->id = $this->uri;
|
||||
$act->title = common_xml_safe_str($this->content);
|
||||
@ -1284,9 +1293,9 @@ class Notice extends Memcached_DataObject
|
||||
$act->enclosures[] = $enclosure;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$ctx = new ActivityContext();
|
||||
|
||||
|
||||
if (!empty($this->reply_to)) {
|
||||
$reply = Notice::staticGet('id', $this->reply_to);
|
||||
if (!empty($reply)) {
|
||||
@ -1294,29 +1303,29 @@ class Notice extends Memcached_DataObject
|
||||
$ctx->replyToUrl = $reply->bestUrl();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$ctx->location = $this->getLocation();
|
||||
|
||||
|
||||
$conv = null;
|
||||
|
||||
|
||||
if (!empty($this->conversation)) {
|
||||
$conv = Conversation::staticGet('id', $this->conversation);
|
||||
if (!empty($conv)) {
|
||||
$ctx->conversation = $conv->uri;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$reply_ids = $this->getReplies();
|
||||
|
||||
|
||||
foreach ($reply_ids as $id) {
|
||||
$profile = Profile::staticGet('id', $id);
|
||||
if (!empty($profile)) {
|
||||
$ctx->attention[] = $profile->getUri();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$groups = $this->getGroups();
|
||||
|
||||
|
||||
foreach ($groups as $group) {
|
||||
$ctx->attention[] = $group->uri;
|
||||
}
|
||||
@ -1330,7 +1339,7 @@ class Notice extends Memcached_DataObject
|
||||
$ctx->forwardID = $repeat->uri;
|
||||
$ctx->forwardUrl = $repeat->bestUrl();
|
||||
}
|
||||
|
||||
|
||||
$act->context = $ctx;
|
||||
|
||||
// Source
|
||||
@ -1340,7 +1349,7 @@ class Notice extends Memcached_DataObject
|
||||
if (!empty($atom_feed)) {
|
||||
|
||||
$act->source = new ActivitySource();
|
||||
|
||||
|
||||
// XXX: we should store the actual feed ID
|
||||
|
||||
$act->source->id = $atom_feed;
|
||||
@ -1353,7 +1362,7 @@ class Notice extends Memcached_DataObject
|
||||
$act->source->links['self'] = $atom_feed;
|
||||
|
||||
$act->source->icon = $profile->avatarUrl(AVATAR_PROFILE_SIZE);
|
||||
|
||||
|
||||
$notice = $profile->getCurrentNotice();
|
||||
|
||||
if (!empty($notice)) {
|
||||
@ -1375,7 +1384,7 @@ class Notice extends Memcached_DataObject
|
||||
|
||||
Event::handle('EndNoticeAsActivity', array($this, &$act));
|
||||
}
|
||||
|
||||
|
||||
self::cacheSet(Cache::codeKey('notice:as-activity:'.$this->id), $act);
|
||||
|
||||
return $act;
|
||||
@ -1386,7 +1395,7 @@ class Notice extends Memcached_DataObject
|
||||
|
||||
function asAtomEntry($namespace=false,
|
||||
$source=false,
|
||||
$author=true,
|
||||
$author=true,
|
||||
$cur=null)
|
||||
{
|
||||
$act = $this->asActivity();
|
||||
@ -1396,7 +1405,7 @@ class Notice extends Memcached_DataObject
|
||||
|
||||
/**
|
||||
* Extra notice info for atom entries
|
||||
*
|
||||
*
|
||||
* Clients use some extra notice info in the atom stream.
|
||||
* This gives it to them.
|
||||
*
|
||||
|
@ -156,6 +156,13 @@ class Session extends Memcached_DataObject
|
||||
$session->selectAdd();
|
||||
$session->selectAdd('id');
|
||||
|
||||
$limit = common_config('sessions', 'gc_limit');
|
||||
if ($limit > 0) {
|
||||
// On large sites, too many sessions to expire
|
||||
// at once will just result in failure.
|
||||
$session->limit($limit);
|
||||
}
|
||||
|
||||
$session->find();
|
||||
|
||||
while ($session->fetch()) {
|
||||
|
@ -975,7 +975,7 @@ class User extends Memcached_DataObject
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a list of OAuth client application that have access to this
|
||||
* Get a list of OAuth client applications that have access to this
|
||||
* user's account.
|
||||
*/
|
||||
function getConnectedApps($offset = 0, $limit = null)
|
||||
|
@ -24,6 +24,7 @@ VALUES
|
||||
('HelloTxt','HelloTxt','http://hellotxt.com/', now()),
|
||||
('identicatools','Laconica Tools','http://bitbucketlabs.net/laconica-tools/', now()),
|
||||
('identichat','identichat','http://identichat.prosody.im/', now()),
|
||||
('IdentiCurse','IdentiCurse','http://identicurse.net/', now()),
|
||||
('IdentiFox','IdentiFox','http://www.bitbucket.org/uncryptic/identifox/', now()),
|
||||
('identitwitch','IdentiTwitch','http://richfish.org/identitwitch/', now()),
|
||||
('Jiminy','Jiminy','http://code.google.com/p/jiminy/', now()),
|
||||
|
@ -62,4 +62,5 @@ VALUES
|
||||
(100114, 'Vodafone Germany', '%s@vodafone-sms.de', now()),
|
||||
(100115, 'E-Plus', '%s@smsmail.eplus.de', now()),
|
||||
(100116, 'Cellular South', '%s@csouth1.com', now()),
|
||||
(100117, 'ChinaMobile (139)', '%s@139.com', now());
|
||||
(100117, 'ChinaMobile (139)', '%s@139.com', now()),
|
||||
(100118, 'Dialog Axiata', '%s@dialog.lk', now());
|
||||
|
@ -37,12 +37,17 @@
|
||||
* @license GNU Affero General Public License http://www.gnu.org/licenses/
|
||||
*/
|
||||
|
||||
$_startTime = microtime(true);
|
||||
$_perfCounters = array();
|
||||
|
||||
define('INSTALLDIR', dirname(__FILE__));
|
||||
define('STATUSNET', true);
|
||||
define('LACONICA', true); // compatibility
|
||||
|
||||
require_once INSTALLDIR . '/lib/common.php';
|
||||
|
||||
register_shutdown_function('common_log_perf_counters');
|
||||
|
||||
$user = null;
|
||||
$action = null;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*!
|
||||
* jQuery Form Plugin
|
||||
* version: 2.49 (18-OCT-2010)
|
||||
* version: 2.63 (29-JAN-2011)
|
||||
* @requires jQuery v1.3.2 or later
|
||||
*
|
||||
* Examples and documentation at: http://malsup.com/jquery/form/
|
||||
@ -54,7 +54,8 @@ $.fn.ajaxSubmit = function(options) {
|
||||
options = { success: options };
|
||||
}
|
||||
|
||||
var url = $.trim(this.attr('action'));
|
||||
var action = this.attr('action');
|
||||
var url = (typeof action === 'string') ? $.trim(action) : '';
|
||||
if (url) {
|
||||
// clean url (don't include hash vaue)
|
||||
url = (url.match(/^([^#]+)/)||[])[1];
|
||||
@ -63,7 +64,7 @@ $.fn.ajaxSubmit = function(options) {
|
||||
|
||||
options = $.extend(true, {
|
||||
url: url,
|
||||
type: this.attr('method') || 'GET',
|
||||
type: this[0].getAttribute('method') || 'GET', // IE7 massage (see issue 57)
|
||||
iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank'
|
||||
}, options);
|
||||
|
||||
@ -167,7 +168,7 @@ $.fn.ajaxSubmit = function(options) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
$.ajax(options);
|
||||
$.ajax(options);
|
||||
}
|
||||
|
||||
// fire 'notify' event
|
||||
@ -189,15 +190,7 @@ $.fn.ajaxSubmit = function(options) {
|
||||
var s = $.extend(true, {}, $.ajaxSettings, options);
|
||||
s.context = s.context || s;
|
||||
var id = 'jqFormIO' + (new Date().getTime()), fn = '_'+id;
|
||||
window[fn] = function() {
|
||||
var f = $io.data('form-plugin-onload');
|
||||
if (f) {
|
||||
f();
|
||||
window[fn] = undefined;
|
||||
try { delete window[fn]; } catch(e){}
|
||||
}
|
||||
}
|
||||
var $io = $('<iframe id="' + id + '" name="' + id + '" src="'+ s.iframeSrc +'" onload="window[\'_\'+this.id]()" />');
|
||||
var $io = $('<iframe id="' + id + '" name="' + id + '" src="'+ s.iframeSrc +'" />');
|
||||
var io = $io[0];
|
||||
|
||||
$io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
|
||||
@ -236,7 +229,6 @@ $.fn.ajaxSubmit = function(options) {
|
||||
return;
|
||||
}
|
||||
|
||||
var cbInvoked = false;
|
||||
var timedOut = 0;
|
||||
|
||||
// add submitting element to data if we know it
|
||||
@ -293,7 +285,7 @@ $.fn.ajaxSubmit = function(options) {
|
||||
|
||||
// add iframe to doc and submit the form
|
||||
$io.appendTo('body');
|
||||
$io.data('form-plugin-onload', cb);
|
||||
io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false);
|
||||
form.submit();
|
||||
}
|
||||
finally {
|
||||
@ -318,20 +310,19 @@ $.fn.ajaxSubmit = function(options) {
|
||||
var data, doc, domCheckCount = 50;
|
||||
|
||||
function cb() {
|
||||
if (cbInvoked) {
|
||||
doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;
|
||||
if (!doc || doc.location.href == s.iframeSrc) {
|
||||
// response not received yet
|
||||
return;
|
||||
}
|
||||
io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false);
|
||||
|
||||
$io.removeData('form-plugin-onload');
|
||||
|
||||
var ok = true;
|
||||
try {
|
||||
if (timedOut) {
|
||||
throw 'timeout';
|
||||
}
|
||||
// extract the server response from the iframe
|
||||
doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;
|
||||
|
||||
|
||||
var isXml = s.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc);
|
||||
log('isXml='+isXml);
|
||||
if (!isXml && window.opera && (doc.body == null || doc.body.innerHTML == '')) {
|
||||
@ -348,8 +339,7 @@ $.fn.ajaxSubmit = function(options) {
|
||||
}
|
||||
|
||||
//log('response detected');
|
||||
cbInvoked = true;
|
||||
xhr.responseText = doc.documentElement ? doc.documentElement.innerHTML : null;
|
||||
xhr.responseText = doc.body ? doc.body.innerHTML : doc.documentElement ? doc.documentElement.innerHTML : null;
|
||||
xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
|
||||
xhr.getResponseHeader = function(header){
|
||||
var headers = {'content-type': s.dataType};
|
||||
@ -368,7 +358,7 @@ $.fn.ajaxSubmit = function(options) {
|
||||
var pre = doc.getElementsByTagName('pre')[0];
|
||||
var b = doc.getElementsByTagName('body')[0];
|
||||
if (pre) {
|
||||
xhr.responseText = pre.innerHTML;
|
||||
xhr.responseText = pre.textContent;
|
||||
}
|
||||
else if (b) {
|
||||
xhr.responseText = b.innerHTML;
|
||||
@ -378,31 +368,35 @@ $.fn.ajaxSubmit = function(options) {
|
||||
else if (s.dataType == 'xml' && !xhr.responseXML && xhr.responseText != null) {
|
||||
xhr.responseXML = toXml(xhr.responseText);
|
||||
}
|
||||
data = $.httpData(xhr, s.dataType);
|
||||
|
||||
data = httpData(xhr, s.dataType, s);
|
||||
}
|
||||
catch(e){
|
||||
log('error caught:',e);
|
||||
ok = false;
|
||||
xhr.error = e;
|
||||
$.handleError(s, xhr, 'error', e);
|
||||
s.error.call(s.context, xhr, 'error', e);
|
||||
g && $.event.trigger("ajaxError", [xhr, s, e]);
|
||||
}
|
||||
|
||||
if (xhr.aborted) {
|
||||
log('upload aborted');
|
||||
ok = false;
|
||||
}
|
||||
|
||||
// ordering of these callbacks/triggers is odd, but that's how $.ajax does it
|
||||
if (ok) {
|
||||
s.success.call(s.context, data, 'success', xhr);
|
||||
if (g) {
|
||||
$.event.trigger("ajaxSuccess", [xhr, s]);
|
||||
}
|
||||
}
|
||||
if (g) {
|
||||
$.event.trigger("ajaxComplete", [xhr, s]);
|
||||
g && $.event.trigger("ajaxSuccess", [xhr, s]);
|
||||
}
|
||||
|
||||
g && $.event.trigger("ajaxComplete", [xhr, s]);
|
||||
|
||||
if (g && ! --$.active) {
|
||||
$.event.trigger("ajaxStop");
|
||||
}
|
||||
if (s.complete) {
|
||||
s.complete.call(s.context, xhr, ok ? 'success' : 'error');
|
||||
}
|
||||
|
||||
s.complete && s.complete.call(s.context, xhr, ok ? 'success' : 'error');
|
||||
|
||||
// clean up
|
||||
setTimeout(function() {
|
||||
@ -412,7 +406,7 @@ $.fn.ajaxSubmit = function(options) {
|
||||
}, 100);
|
||||
}
|
||||
|
||||
function toXml(s, doc) {
|
||||
var toXml = $.parseXML || function(s, doc) { // use parseXML if available (jQuery 1.5+)
|
||||
if (window.ActiveXObject) {
|
||||
doc = new ActiveXObject('Microsoft.XMLDOM');
|
||||
doc.async = 'false';
|
||||
@ -421,8 +415,32 @@ $.fn.ajaxSubmit = function(options) {
|
||||
else {
|
||||
doc = (new DOMParser()).parseFromString(s, 'text/xml');
|
||||
}
|
||||
return (doc && doc.documentElement && doc.documentElement.tagName != 'parsererror') ? doc : null;
|
||||
}
|
||||
return (doc && doc.documentElement && doc.documentElement.nodeName != 'parsererror') ? doc : null;
|
||||
};
|
||||
var parseJSON = $.parseJSON || function(s) {
|
||||
return window['eval']('(' + s + ')');
|
||||
};
|
||||
|
||||
var httpData = function( xhr, type, s ) { // mostly lifted from jq1.4.4
|
||||
var ct = xhr.getResponseHeader('content-type') || '',
|
||||
xml = type === 'xml' || !type && ct.indexOf('xml') >= 0,
|
||||
data = xml ? xhr.responseXML : xhr.responseText;
|
||||
|
||||
if (xml && data.documentElement.nodeName === 'parsererror') {
|
||||
$.error && $.error('parsererror');
|
||||
}
|
||||
if (s && s.dataFilter) {
|
||||
data = s.dataFilter(data, type);
|
||||
}
|
||||
if (typeof data === 'string') {
|
||||
if (type === 'json' || !type && ct.indexOf('json') >= 0) {
|
||||
data = parseJSON(data);
|
||||
} else if (type === "script" || !type && ct.indexOf("javascript") >= 0) {
|
||||
$.globalEval(data);
|
||||
}
|
||||
}
|
||||
return data;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
4
js/jquery.form.min.js
vendored
4
js/jquery.form.min.js
vendored
File diff suppressed because one or more lines are too long
55
js/util.js
55
js/util.js
@ -718,8 +718,16 @@ var SN = { // StatusNet
|
||||
*/
|
||||
NoticeDataAttach: function() {
|
||||
NDA = $('#'+SN.C.S.NoticeDataAttach);
|
||||
NDA.change(function() {
|
||||
S = '<div id="'+SN.C.S.NoticeDataAttachSelected+'" class="'+SN.C.S.Success+'"><code>'+$(this).val()+'</code> <button class="close">×</button></div>';
|
||||
NDA.change(function(event) {
|
||||
var filename = $(this).val();
|
||||
if (!filename) {
|
||||
// No file -- we've been tricked!
|
||||
$('#'+SN.C.S.NoticeDataAttachSelected).remove();
|
||||
return false;
|
||||
}
|
||||
|
||||
// @fixme appending filename straight in is potentially unsafe
|
||||
S = '<div id="'+SN.C.S.NoticeDataAttachSelected+'" class="'+SN.C.S.Success+'"><code>'+filename+'</code> <button class="close">×</button></div>';
|
||||
NDAS = $('#'+SN.C.S.NoticeDataAttachSelected);
|
||||
if (NDAS.length > 0) {
|
||||
NDAS.replaceWith(S);
|
||||
@ -742,6 +750,22 @@ var SN = { // StatusNet
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Get PHP's MAX_FILE_SIZE setting for this form;
|
||||
* used to apply client-side file size limit checks.
|
||||
*
|
||||
* @param {jQuery} form
|
||||
* @return int max size in bytes; 0 or negative means no limit
|
||||
*/
|
||||
maxFileSize: function(form) {
|
||||
var max = $(form).find('input[name=MAX_FILE_SIZE]').attr('value');
|
||||
if (max) {
|
||||
return parseInt(max);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* For browsers with FileAPI support: make a thumbnail if possible,
|
||||
* and append it into the attachment display widget.
|
||||
@ -1217,6 +1241,32 @@ var SN = { // StatusNet
|
||||
SN.U.StatusNetInstance.Set({Nickname: $('#form_login #nickname').val()});
|
||||
return true;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Add logic to any file upload forms to handle file size limits,
|
||||
* on browsers that support basic FileAPI.
|
||||
*/
|
||||
UploadForms: function () {
|
||||
$('input[type=file]').change(function(event) {
|
||||
if (typeof this.files == "object" && this.files.length > 0) {
|
||||
var size = 0;
|
||||
for (var i = 0; i < this.files.length; i++) {
|
||||
size += this.files[i].size;
|
||||
}
|
||||
|
||||
var max = SN.U.maxFileSize($(this.form));
|
||||
if (max > 0 && size > max) {
|
||||
var msg = 'File too large: maximum upload size is %d bytes.';
|
||||
alert(msg.replace('%d', max));
|
||||
|
||||
// Clear the files.
|
||||
$(this).val('');
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1229,6 +1279,7 @@ var SN = { // StatusNet
|
||||
* don't start them loading until after DOM-ready time!
|
||||
*/
|
||||
$(document).ready(function(){
|
||||
SN.Init.UploadForms();
|
||||
if ($('.'+SN.C.S.FormNotice).length > 0) {
|
||||
SN.Init.NoticeForm();
|
||||
}
|
||||
|
2
js/util.min.js
vendored
2
js/util.min.js
vendored
File diff suppressed because one or more lines are too long
151
lib/accountmover.php
Normal file
151
lib/accountmover.php
Normal file
@ -0,0 +1,151 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2010, StatusNet, Inc.
|
||||
*
|
||||
* A class for moving an account to a new server
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* 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 Account
|
||||
* @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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves an account from this server to another
|
||||
*
|
||||
* @category Account
|
||||
* @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/
|
||||
*/
|
||||
class AccountMover extends QueueHandler
|
||||
{
|
||||
function transport()
|
||||
{
|
||||
return 'acctmove';
|
||||
}
|
||||
|
||||
function handle($object)
|
||||
{
|
||||
list($user, $remote, $password) = $object;
|
||||
|
||||
$remote = Discovery::normalize($remote);
|
||||
|
||||
$oprofile = Ostatus_profile::ensureProfileURI($remote);
|
||||
|
||||
if (empty($oprofile)) {
|
||||
// TRANS: Exception thrown when an account could not be located when it should be moved.
|
||||
// TRANS: %s is the remote site.
|
||||
throw new Exception(sprintf(_("Cannot locate account %s."),$remote));
|
||||
}
|
||||
|
||||
list($svcDocUrl, $username) = self::getServiceDocument($remote);
|
||||
|
||||
$sink = new ActivitySink($svcDocUrl, $username, $password);
|
||||
|
||||
$this->log(LOG_INFO,
|
||||
"Moving user {$user->nickname} ".
|
||||
"to {$remote}.");
|
||||
|
||||
$stream = new UserActivityStream($user);
|
||||
|
||||
// Reverse activities to run in correct chron order
|
||||
|
||||
$acts = array_reverse($stream->activities);
|
||||
|
||||
$this->log(LOG_INFO,
|
||||
"Got ".count($acts)." activities ".
|
||||
"for {$user->nickname}.");
|
||||
|
||||
$qm = QueueManager::get();
|
||||
|
||||
foreach ($acts as $act) {
|
||||
$qm->enqueue(array($act, $sink, $user->uri, $remote), 'actmove');
|
||||
}
|
||||
|
||||
$this->log(LOG_INFO,
|
||||
"Finished moving user {$user->nickname} ".
|
||||
"to {$remote}.");
|
||||
}
|
||||
|
||||
static function getServiceDocument($remote)
|
||||
{
|
||||
$discovery = new Discovery();
|
||||
|
||||
$xrd = $discovery->lookup($remote);
|
||||
|
||||
if (empty($xrd)) {
|
||||
// TRANS: Exception thrown when a service document could not be located account move.
|
||||
// TRANS: %s is the remote site.
|
||||
throw new Exception(sprintf(_("Cannot find XRD for %s."),$remote));
|
||||
}
|
||||
|
||||
$svcDocUrl = null;
|
||||
$username = null;
|
||||
|
||||
foreach ($xrd->links as $link) {
|
||||
if ($link['rel'] == 'http://apinamespace.org/atom' &&
|
||||
$link['type'] == 'application/atomsvc+xml') {
|
||||
$svcDocUrl = $link['href'];
|
||||
if (!empty($link['property'])) {
|
||||
foreach ($link['property'] as $property) {
|
||||
if ($property['type'] == 'http://apinamespace.org/atom/username') {
|
||||
$username = $property['value'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($svcDocUrl)) {
|
||||
// TRANS: Exception thrown when an account could not be located when it should be moved.
|
||||
// TRANS: %s is the remote site.
|
||||
throw new Exception(sprintf(_("No AtomPub API service for %s."),$remote));
|
||||
}
|
||||
|
||||
return array($svcDocUrl, $username);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log some data
|
||||
*
|
||||
* Add a header for our class so we know who did it.
|
||||
*
|
||||
* @param int $level Log level, like LOG_ERR or LOG_INFO
|
||||
* @param string $message Message to log
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function log($level, $message)
|
||||
{
|
||||
common_log($level, "AccountMover: " . $message);
|
||||
}
|
||||
}
|
@ -111,6 +111,19 @@ class Action extends HTMLOutputter // lawsuit
|
||||
}
|
||||
}
|
||||
|
||||
function endHTML()
|
||||
{
|
||||
global $_startTime;
|
||||
|
||||
if (isset($_startTime)) {
|
||||
$endTime = microtime(true);
|
||||
$diff = round(($endTime - $_startTime) * 1000);
|
||||
$this->raw("<!-- ${diff}ms -->");
|
||||
}
|
||||
|
||||
return parent::endHTML();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show head, a template method.
|
||||
*
|
||||
@ -300,11 +313,11 @@ class Action extends HTMLOutputter // lawsuit
|
||||
* events and appending to the array. Try to avoid adding strings that won't be used, as
|
||||
* they'll be added to HTML output.
|
||||
*/
|
||||
|
||||
|
||||
function showScriptMessages()
|
||||
{
|
||||
$messages = array();
|
||||
|
||||
|
||||
if (Event::handle('StartScriptMessages', array($this, &$messages))) {
|
||||
// Common messages needed for timeline views etc...
|
||||
|
||||
@ -312,14 +325,14 @@ class Action extends HTMLOutputter // lawsuit
|
||||
$messages['showmore_tooltip'] = _m('TOOLTIP', 'Show more');
|
||||
|
||||
$messages = array_merge($messages, $this->getScriptMessages());
|
||||
|
||||
|
||||
Event::handle('EndScriptMessages', array($this, &$messages));
|
||||
}
|
||||
|
||||
|
||||
if (!empty($messages)) {
|
||||
$this->inlineScript('SN.messages=' . json_encode($messages));
|
||||
}
|
||||
|
||||
|
||||
return $messages;
|
||||
}
|
||||
|
||||
@ -533,33 +546,33 @@ class Action extends HTMLOutputter // lawsuit
|
||||
$this->elementStart('ul', array('class' => 'nav'));
|
||||
if (Event::handle('StartPrimaryNav', array($this))) {
|
||||
if ($user) {
|
||||
// TRANS: Tooltip for main menu option "Personal"
|
||||
// TRANS: Tooltip for main menu option "Personal".
|
||||
$tooltip = _m('TOOLTIP', 'Personal profile and friends timeline');
|
||||
$this->menuItem(common_local_url('all', array('nickname' => $user->nickname)),
|
||||
// TRANS: Main menu option when logged in for access to personal profile and friends timeline
|
||||
// TRANS: Main menu option when logged in for access to personal profile and friends timeline.
|
||||
_m('MENU', 'Personal'), $tooltip, false, 'nav_home');
|
||||
// TRANS: Tooltip for main menu option "Account"
|
||||
// TRANS: Tooltip for main menu option "Account".
|
||||
$tooltip = _m('TOOLTIP', 'Change your email, avatar, password, profile');
|
||||
$this->menuItem(common_local_url('profilesettings'),
|
||||
// TRANS: Main menu option when logged in for access to user settings
|
||||
// TRANS: Main menu option when logged in for access to user settings.
|
||||
_('Account'), $tooltip, false, 'nav_account');
|
||||
// TRANS: Tooltip for main menu option "Services"
|
||||
// TRANS: Tooltip for main menu option "Services".
|
||||
$tooltip = _m('TOOLTIP', 'Connect to services');
|
||||
$this->menuItem(common_local_url('oauthconnectionssettings'),
|
||||
// TRANS: Main menu option when logged in and connection are possible for access to options to connect to other services
|
||||
// TRANS: Main menu option when logged in and connection are possible for access to options to connect to other services.
|
||||
_('Connect'), $tooltip, false, 'nav_connect');
|
||||
if ($user->hasRight(Right::CONFIGURESITE)) {
|
||||
// TRANS: Tooltip for menu option "Admin"
|
||||
// TRANS: Tooltip for menu option "Admin".
|
||||
$tooltip = _m('TOOLTIP', 'Change site configuration');
|
||||
$this->menuItem(common_local_url('siteadminpanel'),
|
||||
// TRANS: Main menu option when logged in and site admin for access to site configuration
|
||||
// TRANS: Main menu option when logged in and site admin for access to site configuration.
|
||||
_m('MENU', 'Admin'), $tooltip, false, 'nav_admin');
|
||||
}
|
||||
if (common_config('invite', 'enabled')) {
|
||||
// TRANS: Tooltip for main menu option "Invite"
|
||||
// TRANS: Tooltip for main menu option "Invite".
|
||||
$tooltip = _m('TOOLTIP', 'Invite friends and colleagues to join you on %s');
|
||||
$this->menuItem(common_local_url('invite'),
|
||||
// TRANS: Main menu option when logged in and invitations are allowed for inviting new users
|
||||
// TRANS: Main menu option when logged in and invitations are allowed for inviting new users.
|
||||
_m('MENU', 'Invite'),
|
||||
sprintf($tooltip,
|
||||
common_config('site', 'name')),
|
||||
@ -568,33 +581,33 @@ class Action extends HTMLOutputter // lawsuit
|
||||
// TRANS: Tooltip for main menu option "Logout"
|
||||
$tooltip = _m('TOOLTIP', 'Logout from the site');
|
||||
$this->menuItem(common_local_url('logout'),
|
||||
// TRANS: Main menu option when logged in to log out the current user
|
||||
// TRANS: Main menu option when logged in to log out the current user.
|
||||
_m('MENU', 'Logout'), $tooltip, false, 'nav_logout');
|
||||
}
|
||||
else {
|
||||
if (!common_config('site', 'closed') && !common_config('site', 'inviteonly')) {
|
||||
// TRANS: Tooltip for main menu option "Register"
|
||||
// TRANS: Tooltip for main menu option "Register".
|
||||
$tooltip = _m('TOOLTIP', 'Create an account');
|
||||
$this->menuItem(common_local_url('register'),
|
||||
// TRANS: Main menu option when not logged in to register a new account
|
||||
// TRANS: Main menu option when not logged in to register a new account.
|
||||
_m('MENU', 'Register'), $tooltip, false, 'nav_register');
|
||||
}
|
||||
// TRANS: Tooltip for main menu option "Login"
|
||||
// TRANS: Tooltip for main menu option "Login".
|
||||
$tooltip = _m('TOOLTIP', 'Login to the site');
|
||||
$this->menuItem(common_local_url('login'),
|
||||
// TRANS: Main menu option when not logged in to log in
|
||||
// TRANS: Main menu option when not logged in to log in.
|
||||
_m('MENU', 'Login'), $tooltip, false, 'nav_login');
|
||||
}
|
||||
// TRANS: Tooltip for main menu option "Help"
|
||||
// TRANS: Tooltip for main menu option "Help".
|
||||
$tooltip = _m('TOOLTIP', 'Help me!');
|
||||
$this->menuItem(common_local_url('doc', array('title' => 'help')),
|
||||
// TRANS: Main menu option for help on the StatusNet site
|
||||
// TRANS: Main menu option for help on the StatusNet site.
|
||||
_m('MENU', 'Help'), $tooltip, false, 'nav_help');
|
||||
if ($user || !common_config('site', 'private')) {
|
||||
// TRANS: Tooltip for main menu option "Search"
|
||||
// TRANS: Tooltip for main menu option "Search".
|
||||
$tooltip = _m('TOOLTIP', 'Search for people or text');
|
||||
$this->menuItem(common_local_url('peoplesearch'),
|
||||
// TRANS: Main menu option when logged in or when the StatusNet instance is not private
|
||||
// TRANS: Main menu option when logged in or when the StatusNet instance is not private.
|
||||
_m('MENU', 'Search'), $tooltip, false, 'nav_search');
|
||||
}
|
||||
Event::handle('EndPrimaryNav', array($this));
|
||||
|
@ -330,6 +330,7 @@ class Activity
|
||||
*
|
||||
* @return DOMElement Atom entry
|
||||
*/
|
||||
|
||||
function toAtomEntry()
|
||||
{
|
||||
return null;
|
||||
@ -338,7 +339,12 @@ class Activity
|
||||
function asString($namespace=false, $author=true, $source=false)
|
||||
{
|
||||
$xs = new XMLStringer(true);
|
||||
$this->outputTo($xs, $namespace, $author, $source);
|
||||
return $xs->getString();
|
||||
}
|
||||
|
||||
function outputTo($xs, $namespace=false, $author=true, $source=false)
|
||||
{
|
||||
if ($namespace) {
|
||||
$attrs = array('xmlns' => 'http://www.w3.org/2005/Atom',
|
||||
'xmlns:thr' => 'http://purl.org/syndication/thread/1.0',
|
||||
@ -364,11 +370,11 @@ class Activity
|
||||
$xs->element('title', null, $this->title);
|
||||
|
||||
$xs->element('content', array('type' => 'html'), $this->content);
|
||||
|
||||
|
||||
if (!empty($this->summary)) {
|
||||
$xs->element('summary', null, $this->summary);
|
||||
}
|
||||
|
||||
|
||||
if (!empty($this->link)) {
|
||||
$xs->element('link', array('rel' => 'alternate',
|
||||
'type' => 'text/html'),
|
||||
@ -380,10 +386,10 @@ class Activity
|
||||
$xs->element('activity:verb', null, $this->verb);
|
||||
|
||||
$published = self::iso8601Date($this->time);
|
||||
|
||||
|
||||
$xs->element('published', null, $published);
|
||||
$xs->element('updated', null, $published);
|
||||
|
||||
|
||||
if ($author) {
|
||||
$this->actor->outputTo($xs, 'author');
|
||||
}
|
||||
@ -452,7 +458,7 @@ class Activity
|
||||
}
|
||||
|
||||
// can be either URLs or enclosure objects
|
||||
|
||||
|
||||
foreach ($this->enclosures as $enclosure) {
|
||||
if (is_string($enclosure)) {
|
||||
$xs->element('link', array('rel' => 'enclosure',
|
||||
@ -473,7 +479,7 @@ class Activity
|
||||
|
||||
if ($source && !empty($this->source)) {
|
||||
$xs->elementStart('source');
|
||||
|
||||
|
||||
$xs->element('id', null, $this->source->id);
|
||||
$xs->element('title', null, $this->source->title);
|
||||
|
||||
@ -482,7 +488,7 @@ class Activity
|
||||
'type' => 'text/html',
|
||||
'href' => $this->source->links['alternate']));
|
||||
}
|
||||
|
||||
|
||||
if (array_key_exists('self', $this->source->links)) {
|
||||
$xs->element('link', array('rel' => 'self',
|
||||
'type' => 'application/atom+xml',
|
||||
@ -501,7 +507,7 @@ class Activity
|
||||
if (!empty($this->source->updated)) {
|
||||
$xs->element('updated', null, $this->source->updated);
|
||||
}
|
||||
|
||||
|
||||
$xs->elementEnd('source');
|
||||
}
|
||||
|
||||
@ -518,7 +524,7 @@ class Activity
|
||||
}
|
||||
|
||||
// For throwing in extra elements; used for statusnet:notice_info
|
||||
|
||||
|
||||
foreach ($this->extra as $el) {
|
||||
list($tag, $attrs, $content) = $el;
|
||||
$xs->element($tag, $attrs, $content);
|
||||
@ -526,9 +532,7 @@ class Activity
|
||||
|
||||
$xs->elementEnd('entry');
|
||||
|
||||
$str = $xs->getString();
|
||||
|
||||
return $str;
|
||||
return;
|
||||
}
|
||||
|
||||
private function _child($element, $tag, $namespace=self::SPEC)
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Copyright (C) 2010, StatusNet, Inc.
|
||||
*
|
||||
* class to import activities as part of a user's timeline
|
||||
*
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@ -44,7 +44,6 @@ if (!defined('STATUSNET')) {
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class ActivityImporter extends QueueHandler
|
||||
{
|
||||
private $trusted = false;
|
||||
@ -56,7 +55,6 @@ class ActivityImporter extends QueueHandler
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
function handle($data)
|
||||
{
|
||||
list($user, $author, $activity, $trusted) = $data;
|
||||
@ -65,9 +63,8 @@ class ActivityImporter extends QueueHandler
|
||||
|
||||
$done = null;
|
||||
|
||||
if (Event::handle('StartImportActivity',
|
||||
if (Event::handle('StartImportActivity',
|
||||
array($user, $author, $activity, $trusted, &$done))) {
|
||||
|
||||
try {
|
||||
switch ($activity->verb) {
|
||||
case ActivityVerb::FOLLOW:
|
||||
@ -80,9 +77,10 @@ class ActivityImporter extends QueueHandler
|
||||
$this->postNote($user, $author, $activity);
|
||||
break;
|
||||
default:
|
||||
throw new ClientException("Unknown verb: {$activity->verb}");
|
||||
// TRANS: Client exception thrown when using an unknown verb for the activity importer.
|
||||
throw new ClientException(sprintf(_("Unknown verb: \"%s\"."),$activity->verb));
|
||||
}
|
||||
Event::handle('EndImportActivity',
|
||||
Event::handle('EndImportActivity',
|
||||
array($user, $author, $activity, $trusted));
|
||||
$done = true;
|
||||
} catch (ClientException $ce) {
|
||||
@ -98,31 +96,31 @@ class ActivityImporter extends QueueHandler
|
||||
}
|
||||
return $done;
|
||||
}
|
||||
|
||||
|
||||
function subscribeProfile($user, $author, $activity)
|
||||
{
|
||||
$profile = $user->getProfile();
|
||||
|
||||
if ($activity->objects[0]->id == $author->id) {
|
||||
|
||||
if (!$this->trusted) {
|
||||
throw new ClientException(_("Can't force subscription for untrusted user."));
|
||||
// TRANS: Client exception thrown when trying to force a subscription for an untrusted user.
|
||||
throw new ClientException(_("Cannot force subscription for untrusted user."));
|
||||
}
|
||||
|
||||
$other = $activity->actor;
|
||||
$otherUser = User::staticGet('uri', $other->id);
|
||||
|
||||
|
||||
if (!empty($otherUser)) {
|
||||
$otherProfile = $otherUser->getProfile();
|
||||
} else {
|
||||
throw new Exception("Can't force remote user to subscribe.");
|
||||
// TRANS: Client exception thrown when trying to for a remote user to subscribe.
|
||||
throw new Exception(_("Cannot force remote user to subscribe."));
|
||||
}
|
||||
|
||||
// XXX: don't do this for untrusted input!
|
||||
|
||||
Subscription::start($otherProfile, $profile);
|
||||
|
||||
} else if (empty($activity->actor)
|
||||
} else if (empty($activity->actor)
|
||||
|| $activity->actor->id == $author->id) {
|
||||
|
||||
$other = $activity->objects[0];
|
||||
@ -130,12 +128,14 @@ class ActivityImporter extends QueueHandler
|
||||
$otherProfile = Profile::fromUri($other->id);
|
||||
|
||||
if (empty($otherProfile)) {
|
||||
// TRANS: Client exception thrown when trying to subscribe to an unknown profile.
|
||||
throw new ClientException(_("Unknown profile."));
|
||||
}
|
||||
|
||||
Subscription::start($profile, $otherProfile);
|
||||
} else {
|
||||
throw new Exception("This activity seems unrelated to our user.");
|
||||
// TRANS: Client exception thrown when trying to import an event not related to the importing user.
|
||||
throw new Exception(_("This activity seems unrelated to our user."));
|
||||
}
|
||||
}
|
||||
|
||||
@ -150,7 +150,8 @@ class ActivityImporter extends QueueHandler
|
||||
if (empty($group)) {
|
||||
$oprofile = Ostatus_profile::ensureActivityObjectProfile($activity->objects[0]);
|
||||
if (!$oprofile->isGroup()) {
|
||||
throw new ClientException("Remote profile is not a group!");
|
||||
// TRANS: Client exception thrown when trying to join a remote group that is not a group.
|
||||
throw new ClientException(_("Remote profile is not a group!"));
|
||||
}
|
||||
$group = $oprofile->localGroup();
|
||||
}
|
||||
@ -158,7 +159,8 @@ class ActivityImporter extends QueueHandler
|
||||
assert(!empty($group));
|
||||
|
||||
if ($user->isMember($group)) {
|
||||
throw new ClientException("User is already a member of this group.");
|
||||
// TRANS: Client exception thrown when trying to join a group the importing user is already a member of.
|
||||
throw new ClientException(_("User is already a member of this group."));
|
||||
}
|
||||
|
||||
if (Event::handle('StartJoinGroup', array($group, $user))) {
|
||||
@ -178,7 +180,7 @@ class ActivityImporter extends QueueHandler
|
||||
$notice = Notice::staticGet('uri', $sourceUri);
|
||||
|
||||
if (!empty($notice)) {
|
||||
|
||||
|
||||
common_log(LOG_INFO, "Notice {$sourceUri} already exists.");
|
||||
|
||||
if ($this->trusted) {
|
||||
@ -194,12 +196,15 @@ class ActivityImporter extends QueueHandler
|
||||
$notice->update($orig);
|
||||
return;
|
||||
} else {
|
||||
throw new ClientException(sprintf(_("Already know about notice %s and ".
|
||||
" it's got a different author %s."),
|
||||
// TRANS: Client exception thrown when trying to import a notice by another user.
|
||||
// TRANS: %1$s is the source URI of the notice, %2$s is the URI of the author.
|
||||
throw new ClientException(sprintf(_('Already know about notice %1$s and '.
|
||||
' it has a different author %2$s.'),
|
||||
$sourceUri, $uri));
|
||||
}
|
||||
} else {
|
||||
throw new ClientException("Not overwriting author info for non-trusted user.");
|
||||
// TRANS: Client exception thrown when trying to overwrite the author information for a non-trusted user during import.
|
||||
throw new ClientException(_("Not overwriting author info for non-trusted user."));
|
||||
}
|
||||
}
|
||||
|
||||
@ -213,8 +218,9 @@ class ActivityImporter extends QueueHandler
|
||||
$sourceContent = $note->title;
|
||||
} else {
|
||||
// @fixme fetch from $sourceUrl?
|
||||
// @todo i18n FIXME: use sprintf and add i18n.
|
||||
throw new ClientException("No content for notice {$sourceUri}.");
|
||||
// TRANS: Client exception thrown when trying to import a notice without content.
|
||||
// TRANS: %s is the notice URI.
|
||||
throw new ClientException(sprintf(_("No content for notice %s."),$sourceUri));
|
||||
}
|
||||
|
||||
// Get (safe!) HTML and text versions of the content
|
||||
@ -345,7 +351,7 @@ class ActivityImporter extends QueueHandler
|
||||
|
||||
return array($groups, $replies);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function purify($content)
|
||||
{
|
||||
|
166
lib/activitymover.php
Normal file
166
lib/activitymover.php
Normal file
@ -0,0 +1,166 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2010, StatusNet, Inc.
|
||||
*
|
||||
* Title of module
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* 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 Cache
|
||||
* @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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Class comment
|
||||
*
|
||||
* @category General
|
||||
* @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/
|
||||
*/
|
||||
class ActivityMover extends QueueHandler
|
||||
{
|
||||
function transport()
|
||||
{
|
||||
return 'actmove';
|
||||
}
|
||||
|
||||
function handle($data)
|
||||
{
|
||||
list ($act, $sink, $userURI, $remoteURI) = $data;
|
||||
|
||||
$user = User::staticGet('uri', $userURI);
|
||||
$remote = Profile::fromURI($remoteURI);
|
||||
|
||||
try {
|
||||
$this->moveActivity($act, $sink, $user, $remote);
|
||||
} catch (ClientException $cex) {
|
||||
$this->log(LOG_WARNING,
|
||||
$cex->getMessage());
|
||||
// "don't retry me"
|
||||
return true;
|
||||
} catch (ServerException $sex) {
|
||||
$this->log(LOG_WARNING,
|
||||
$sex->getMessage());
|
||||
// "retry me" (because we think the server might handle it next time)
|
||||
return false;
|
||||
} catch (Exception $ex) {
|
||||
$this->log(LOG_WARNING,
|
||||
$ex->getMessage());
|
||||
// "don't retry me"
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function moveActivity($act, $sink, $user, $remote)
|
||||
{
|
||||
if (empty($user)) {
|
||||
throw new Exception(sprintf(_("No such user %s."),$act->actor->id));
|
||||
}
|
||||
|
||||
switch ($act->verb) {
|
||||
case ActivityVerb::FAVORITE:
|
||||
$this->log(LOG_INFO,
|
||||
"Moving favorite of {$act->objects[0]->id} by ".
|
||||
"{$act->actor->id} to {$remote->nickname}.");
|
||||
// push it, then delete local
|
||||
$sink->postActivity($act);
|
||||
$notice = Notice::staticGet('uri', $act->objects[0]->id);
|
||||
if (!empty($notice)) {
|
||||
$fave = Fave::pkeyGet(array('user_id' => $user->id,
|
||||
'notice_id' => $notice->id));
|
||||
$fave->delete();
|
||||
}
|
||||
break;
|
||||
case ActivityVerb::POST:
|
||||
$this->log(LOG_INFO,
|
||||
"Moving notice {$act->objects[0]->id} by ".
|
||||
"{$act->actor->id} to {$remote->nickname}.");
|
||||
// XXX: send a reshare, not a post
|
||||
$sink->postActivity($act);
|
||||
$notice = Notice::staticGet('uri', $act->objects[0]->id);
|
||||
if (!empty($notice)) {
|
||||
$notice->delete();
|
||||
}
|
||||
break;
|
||||
case ActivityVerb::JOIN:
|
||||
$this->log(LOG_INFO,
|
||||
"Moving group join of {$act->objects[0]->id} by ".
|
||||
"{$act->actor->id} to {$remote->nickname}.");
|
||||
$sink->postActivity($act);
|
||||
$group = User_group::staticGet('uri', $act->objects[0]->id);
|
||||
if (!empty($group)) {
|
||||
Group_member::leave($group->id, $user->id);
|
||||
}
|
||||
break;
|
||||
case ActivityVerb::FOLLOW:
|
||||
if ($act->actor->id == $user->uri) {
|
||||
$this->log(LOG_INFO,
|
||||
"Moving subscription to {$act->objects[0]->id} by ".
|
||||
"{$act->actor->id} to {$remote->nickname}.");
|
||||
$sink->postActivity($act);
|
||||
$other = Profile::fromURI($act->objects[0]->id);
|
||||
if (!empty($other)) {
|
||||
Subscription::cancel($user->getProfile(), $other);
|
||||
}
|
||||
} else {
|
||||
$otherUser = User::staticGet('uri', $act->actor->id);
|
||||
if (!empty($otherUser)) {
|
||||
$this->log(LOG_INFO,
|
||||
"Changing sub to {$act->objects[0]->id}".
|
||||
"by {$act->actor->id} to {$remote->nickname}.");
|
||||
$otherProfile = $otherUser->getProfile();
|
||||
Subscription::start($otherProfile, $remote);
|
||||
Subscription::cancel($otherProfile, $user->getProfile());
|
||||
} else {
|
||||
$this->log(LOG_NOTICE,
|
||||
"Not changing sub to {$act->objects[0]->id}".
|
||||
"by remote {$act->actor->id} ".
|
||||
"to {$remote->nickname}.");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log some data
|
||||
*
|
||||
* Add a header for our class so we know who did it.
|
||||
*
|
||||
* @param int $level Log level, like LOG_ERR or LOG_INFO
|
||||
* @param string $message Message to log
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function log($level, $message)
|
||||
{
|
||||
common_log($level, "ActivityMover: " . $message);
|
||||
}
|
||||
}
|
175
lib/activitysink.php
Normal file
175
lib/activitysink.php
Normal file
@ -0,0 +1,175 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2010, StatusNet, Inc.
|
||||
*
|
||||
* A remote, atompub-receiving service
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* 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 AtomPub
|
||||
* @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);
|
||||
}
|
||||
|
||||
/**
|
||||
* A remote service that supports AtomPub
|
||||
*
|
||||
* @category AtomPub
|
||||
* @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/
|
||||
*/
|
||||
class ActivitySink
|
||||
{
|
||||
protected $svcDocUrl = null;
|
||||
protected $username = null;
|
||||
protected $password = null;
|
||||
protected $collections = array();
|
||||
|
||||
function __construct($svcDocUrl, $username, $password)
|
||||
{
|
||||
$this->svcDocUrl = $svcDocUrl;
|
||||
$this->username = $username;
|
||||
$this->password = $password;
|
||||
|
||||
$this->_parseSvcDoc();
|
||||
}
|
||||
|
||||
private function _parseSvcDoc()
|
||||
{
|
||||
$client = new HTTPClient();
|
||||
$response = $client->get($this->svcDocUrl);
|
||||
|
||||
if ($response->getStatus() != 200) {
|
||||
throw new Exception("Can't get {$this->svcDocUrl}; response status " . $response->getStatus());
|
||||
}
|
||||
|
||||
$xml = $response->getBody();
|
||||
|
||||
$dom = new DOMDocument();
|
||||
|
||||
// We don't want to bother with white spaces
|
||||
$dom->preserveWhiteSpace = false;
|
||||
|
||||
// Don't spew XML warnings to output
|
||||
$old = error_reporting();
|
||||
error_reporting($old & ~E_WARNING);
|
||||
$ok = $dom->loadXML($xml);
|
||||
error_reporting($old);
|
||||
|
||||
$path = new DOMXPath($dom);
|
||||
|
||||
$path->registerNamespace('atom', 'http://www.w3.org/2005/Atom');
|
||||
$path->registerNamespace('app', 'http://www.w3.org/2007/app');
|
||||
$path->registerNamespace('activity', 'http://activitystrea.ms/spec/1.0/');
|
||||
|
||||
$collections = $path->query('//app:collection');
|
||||
|
||||
for ($i = 0; $i < $collections->length; $i++) {
|
||||
$collection = $collections->item($i);
|
||||
$url = $collection->getAttribute('href');
|
||||
$takesEntries = false;
|
||||
$accepts = $path->query('app:accept', $collection);
|
||||
for ($j = 0; $j < $accepts->length; $j++) {
|
||||
$accept = $accepts->item($j);
|
||||
$acceptValue = $accept->nodeValue;
|
||||
if (preg_match('#application/atom\+xml(;\s*type=entry)?#', $acceptValue)) {
|
||||
$takesEntries = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$takesEntries) {
|
||||
continue;
|
||||
}
|
||||
$verbs = $path->query('activity:verb', $collection);
|
||||
if ($verbs->length == 0) {
|
||||
$this->_addCollection(ActivityVerb::POST, $url);
|
||||
} else {
|
||||
for ($k = 0; $k < $verbs->length; $k++) {
|
||||
$verb = $verbs->item($k);
|
||||
$this->_addCollection($verb->nodeValue, $url);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function _addCollection($verb, $url)
|
||||
{
|
||||
if (array_key_exists($verb, $this->collections)) {
|
||||
$this->collections[$verb][] = $url;
|
||||
} else {
|
||||
$this->collections[$verb] = array($url);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
function postActivity($activity)
|
||||
{
|
||||
if (!array_key_exists($activity->verb, $this->collections)) {
|
||||
throw new Exception("No collection for verb {$activity->verb}");
|
||||
} else {
|
||||
if (count($this->collections[$activity->verb]) > 1) {
|
||||
common_log(LOG_NOTICE, "More than one collection for verb {$activity->verb}");
|
||||
}
|
||||
$this->postToCollection($this->collections[$activity->verb][0], $activity);
|
||||
}
|
||||
}
|
||||
|
||||
function postToCollection($url, $activity)
|
||||
{
|
||||
$client = new HTTPClient($url);
|
||||
|
||||
$client->setMethod('POST');
|
||||
$client->setAuth($this->username, $this->password);
|
||||
$client->setHeader('Content-Type', 'application/atom+xml;type=entry');
|
||||
$client->setBody($activity->asString(true, true, true));
|
||||
|
||||
$response = $client->send();
|
||||
|
||||
$status = $response->getStatus();
|
||||
$reason = $response->getReasonPhrase();
|
||||
|
||||
if ($status >= 200 && $status < 300) {
|
||||
return true;
|
||||
} else if ($status >= 400 && $status < 500) {
|
||||
// TRANS: Client exception thrown when post to collection fails with a 400 status.
|
||||
// TRANS: %1$s is a URL, %2$s is the status, %s$s is the fail reason.
|
||||
throw new ClientException(sprintf(_m('URLSTATUSREASON','%1$s %2$s %3$s'), $url, $status, $reason));
|
||||
} else if ($status >= 500 && $status < 600) {
|
||||
// TRANS: Server exception thrown when post to collection fails with a 500 status.
|
||||
// TRANS: %1$s is a URL, %2$s is the status, %s$s is the fail reason.
|
||||
throw new ServerException(sprintf(_m('URLSTATUSREASON','%1$s %2$s %3$s'), $url, $status, $reason));
|
||||
} else {
|
||||
// That's unexpected.
|
||||
// TRANS: Exception thrown when post to collection fails with a status that is not handled.
|
||||
// TRANS: %1$s is a URL, %2$s is the status, %s$s is the fail reason.
|
||||
throw new Exception(sprintf(_m('URLSTATUSREASON','%1$s %2$s %3$s'), $url, $status, $reason));
|
||||
}
|
||||
}
|
||||
}
|
@ -412,7 +412,7 @@ class ApiAction extends Action
|
||||
{
|
||||
$twitter_group = array();
|
||||
|
||||
$twitter_group['id'] = $group->id;
|
||||
$twitter_group['id'] = intval($group->id);
|
||||
$twitter_group['url'] = $group->permalink();
|
||||
$twitter_group['nickname'] = $group->nickname;
|
||||
$twitter_group['fullname'] = $group->fullname;
|
||||
@ -561,7 +561,7 @@ class ApiAction extends Action
|
||||
|
||||
$details['notifications_enabled'] = $notifications;
|
||||
$details['blocking'] = $source->hasBlocked($target);
|
||||
$details['id'] = $source->id;
|
||||
$details['id'] = intval($source->id);
|
||||
|
||||
return $details;
|
||||
}
|
||||
@ -945,10 +945,10 @@ class ApiAction extends Action
|
||||
$from_profile = $message->getFrom();
|
||||
$to_profile = $message->getTo();
|
||||
|
||||
$dmsg['id'] = $message->id;
|
||||
$dmsg['sender_id'] = $message->from_profile;
|
||||
$dmsg['id'] = intval($message->id);
|
||||
$dmsg['sender_id'] = intval($from_profile);
|
||||
$dmsg['text'] = trim($message->content);
|
||||
$dmsg['recipient_id'] = $message->to_profile;
|
||||
$dmsg['recipient_id'] = intval($to_profile);
|
||||
$dmsg['created_at'] = $this->dateTwitter($message->created);
|
||||
$dmsg['sender_screen_name'] = $from_profile->nickname;
|
||||
$dmsg['recipient_screen_name'] = $to_profile->nickname;
|
||||
@ -1236,9 +1236,12 @@ class ApiAction extends Action
|
||||
return;
|
||||
}
|
||||
|
||||
function clientError($msg, $code = 400, $format = 'xml')
|
||||
function clientError($msg, $code = 400, $format = null)
|
||||
{
|
||||
$action = $this->trimmed('action');
|
||||
if ($format === null) {
|
||||
$format = $this->format;
|
||||
}
|
||||
|
||||
common_debug("User error '$code' on '$action': $msg", __FILE__);
|
||||
|
||||
@ -1278,9 +1281,12 @@ class ApiAction extends Action
|
||||
}
|
||||
}
|
||||
|
||||
function serverError($msg, $code = 500, $content_type = 'xml')
|
||||
function serverError($msg, $code = 500, $content_type = null)
|
||||
{
|
||||
$action = $this->trimmed('action');
|
||||
if ($content_type === null) {
|
||||
$content_type = $this->format;
|
||||
}
|
||||
|
||||
common_debug("Server error '$code' on '$action': $msg", __FILE__);
|
||||
|
||||
|
@ -337,7 +337,7 @@ class ApiAuthAction extends ApiAction
|
||||
}
|
||||
|
||||
/**
|
||||
* Log an API authentication failer. Collect the proxy and IP
|
||||
* Log an API authentication failure. Collect the proxy and IP
|
||||
* and log them
|
||||
*
|
||||
* @param string $logMsg additional log message
|
||||
|
@ -152,8 +152,11 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore
|
||||
);
|
||||
}
|
||||
|
||||
// check to see if we have previously issued an access token for this application
|
||||
// and profile
|
||||
// Check to see if we have previously issued an access token for
|
||||
// this application and profile; if so we can just return the
|
||||
// existing access token. That seems to be the best practice. It
|
||||
// makes it so users only have to authorize the app once per
|
||||
// machine.
|
||||
|
||||
$appUser = new Oauth_application_user();
|
||||
|
||||
@ -172,19 +175,40 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore
|
||||
)
|
||||
);
|
||||
|
||||
$at = new Token();
|
||||
$at = null;
|
||||
|
||||
// fetch the full access token
|
||||
$at->consumer_key = $consumer->key;
|
||||
$at->tok = $appUser->token;
|
||||
// Special case: we used to store request tokens in the
|
||||
// Oauth_application_user record, and the access_type would
|
||||
// always be 0 (no access) as a failsafe until an access
|
||||
// token was issued and replaced the request token. There could
|
||||
// be a few old Oauth_application_user records storing request
|
||||
// tokens still around, and we don't want to accidentally
|
||||
// return a useless request token instead of a new access
|
||||
// token. So if we find one, we generate a new access token
|
||||
// and update the existing Oauth_application_user record before
|
||||
// returning the new access token. This should be rare.
|
||||
|
||||
$result = $at->find(true);
|
||||
if ($appUser->access_type == 0) {
|
||||
|
||||
if (!$result) {
|
||||
throw new Exception(
|
||||
// TRANS: Exception thrown when no access token can be issued.
|
||||
_('Could not issue access token.')
|
||||
);
|
||||
$at = $this->generateNewAccessToken($consumer, $rt, $verifier);
|
||||
$this->updateAppUser($appUser, $app, $at);
|
||||
|
||||
} else {
|
||||
|
||||
$at = new Token();
|
||||
|
||||
// fetch the full access token
|
||||
$at->consumer_key = $consumer->key;
|
||||
$at->tok = $appUser->token;
|
||||
|
||||
$result = $at->find(true);
|
||||
|
||||
if (!$result) {
|
||||
throw new Exception(
|
||||
// TRANS: Exception thrown when no access token can be issued.
|
||||
_('Could not issue access token.')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Yay, we can re-issue the access token
|
||||
@ -200,48 +224,8 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore
|
||||
)
|
||||
);
|
||||
|
||||
// make a brand new access token
|
||||
$at = new Token();
|
||||
|
||||
$at->consumer_key = $consumer->key;
|
||||
$at->tok = common_good_rand(16);
|
||||
$at->secret = common_good_rand(16);
|
||||
$at->type = 1; // access
|
||||
$at->verifier = $verifier;
|
||||
$at->verified_callback = $rt->verified_callback; // 1.0a
|
||||
$at->created = common_sql_now();
|
||||
|
||||
if (!$at->insert()) {
|
||||
$e = $at->_lastError;
|
||||
common_debug('access token "' . $at->tok . '" not inserted: "' . $e->message . '"', __FILE__);
|
||||
return null;
|
||||
} else {
|
||||
common_debug('access token "' . $at->tok . '" inserted', __FILE__);
|
||||
// burn the old one
|
||||
$orig_rt = clone($rt);
|
||||
$rt->state = 2; // used
|
||||
if (!$rt->update($orig_rt)) {
|
||||
return null;
|
||||
}
|
||||
common_debug('request token "' . $rt->tok . '" updated', __FILE__);
|
||||
}
|
||||
|
||||
// insert a new Oauth_application_user record w/access token
|
||||
$appUser = new Oauth_application_user();
|
||||
|
||||
$appUser->profile_id = $tokenAssoc->profile_id;;
|
||||
$appUser->application_id = $app->id;
|
||||
$appUser->access_type = $app->access_type;
|
||||
$appUser->token = $at->tok;
|
||||
$appUser->created = common_sql_now();
|
||||
|
||||
$result = $appUser->insert();
|
||||
|
||||
if (!$result) {
|
||||
common_log_db_error($appUser, 'INSERT', __FILE__);
|
||||
// TRANS: Server error displayed when a database error occurs.
|
||||
$this->serverError(_('Database error inserting OAuth application user.'));
|
||||
}
|
||||
$at = $this->generateNewAccessToken($consumer, $rt, $verifier);
|
||||
$this->newAppUser($tokenAssoc, $app, $at);
|
||||
|
||||
// Okay, good
|
||||
return new OAuthToken($at->tok, $at->secret);
|
||||
@ -261,6 +245,108 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Generate a new access token and save it to the database
|
||||
*
|
||||
* @param Consumer $consumer the OAuth consumer
|
||||
* @param Token $rt the authorized request token
|
||||
* @param string $verifier the OAuth 1.0a verifier
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @return Token $at the new access token
|
||||
*/
|
||||
private function generateNewAccessToken($consumer, $rt, $verifier)
|
||||
{
|
||||
$at = new Token();
|
||||
|
||||
$at->consumer_key = $consumer->key;
|
||||
$at->tok = common_good_rand(16);
|
||||
$at->secret = common_good_rand(16);
|
||||
$at->type = 1; // access
|
||||
$at->verifier = $verifier;
|
||||
$at->verified_callback = $rt->verified_callback; // 1.0a
|
||||
$at->created = common_sql_now();
|
||||
|
||||
if (!$at->insert()) {
|
||||
$e = $at->_lastError;
|
||||
common_debug('access token "' . $at->tok . '" not inserted: "' . $e->message . '"', __FILE__);
|
||||
return null;
|
||||
} else {
|
||||
common_debug('access token "' . $at->tok . '" inserted', __FILE__);
|
||||
// burn the old one
|
||||
$orig_rt = clone($rt);
|
||||
$rt->state = 2; // used
|
||||
if (!$rt->update($orig_rt)) {
|
||||
return null;
|
||||
}
|
||||
common_debug('request token "' . $rt->tok . '" updated', __FILE__);
|
||||
}
|
||||
|
||||
return $at;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add a new app user (Oauth_application_user) record
|
||||
*
|
||||
* @param Oauth_token_association $tokenAssoc token-to-app association
|
||||
* @param Oauth_application $app the OAuth client app
|
||||
* @param Token $at the access token
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function newAppUser($tokenAssoc, $app, $at)
|
||||
{
|
||||
$appUser = new Oauth_application_user();
|
||||
|
||||
$appUser->profile_id = $tokenAssoc->profile_id;
|
||||
$appUser->application_id = $app->id;
|
||||
$appUser->access_type = $app->access_type;
|
||||
$appUser->token = $at->tok;
|
||||
$appUser->created = common_sql_now();
|
||||
|
||||
$result = $appUser->insert();
|
||||
|
||||
if (!$result) {
|
||||
common_log_db_error($appUser, 'INSERT', __FILE__);
|
||||
|
||||
// TRANS: Server error displayed when a database error occurs.
|
||||
throw new Exception(
|
||||
_('Database error inserting OAuth application user.')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Update an existing app user (Oauth_application_user) record
|
||||
*
|
||||
* @param Oauth_application_user $appUser existing app user rec
|
||||
* @param Oauth_application $app the OAuth client app
|
||||
* @param Token $at the access token
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function updateAppUser($appUser, $app, $at)
|
||||
{
|
||||
$original = clone($appUser);
|
||||
$appUser->access_type = $app->access_type;
|
||||
$appUser->token = $at->tok;
|
||||
|
||||
$result = $appUser->update($original);
|
||||
|
||||
if (!$result) {
|
||||
common_log_db_error($appUser, 'UPDATE', __FILE__);
|
||||
// TRANS: Server error displayed when a database error occurs.
|
||||
throw new Exception(
|
||||
_('Database error updating OAuth application user.')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Revoke specified access token
|
||||
*
|
||||
|
@ -168,6 +168,10 @@ class ApplicationEditForm extends Form
|
||||
$this->out->element('img', array('src' => $icon));
|
||||
}
|
||||
|
||||
$this->out->element('input', array('name' => 'MAX_FILE_SIZE',
|
||||
'type' => 'hidden',
|
||||
'id' => 'MAX_FILE_SIZE',
|
||||
'value' => ImageFile::maxFileSizeInt()));
|
||||
$this->out->element('label', array('for' => 'app_icon'),
|
||||
// TRANS: Form input field label for application icon.
|
||||
_('Icon'));
|
||||
@ -176,10 +180,6 @@ class ApplicationEditForm extends Form
|
||||
'id' => 'app_icon'));
|
||||
// TRANS: Form guide.
|
||||
$this->out->element('p', 'form_guide', _('Icon for this application'));
|
||||
$this->out->element('input', array('name' => 'MAX_FILE_SIZE',
|
||||
'type' => 'hidden',
|
||||
'id' => 'MAX_FILE_SIZE',
|
||||
'value' => ImageFile::maxFileSizeInt()));
|
||||
$this->out->elementEnd('li');
|
||||
|
||||
$this->out->elementStart('li');
|
||||
|
@ -108,8 +108,9 @@ class Atom10Feed extends XMLStringer
|
||||
if (!empty($name)) {
|
||||
$xs->element('name', null, $name);
|
||||
} else {
|
||||
// TRANS: Atom feed exception thrown when an author element does not contain a name element.
|
||||
throw new Atom10FeedException(
|
||||
_('author element must contain a name element.')
|
||||
_('Author element must contain a name element.')
|
||||
);
|
||||
}
|
||||
|
||||
@ -155,7 +156,8 @@ class Atom10Feed extends XMLStringer
|
||||
|
||||
function setActivitySubject($xmlSubject)
|
||||
{
|
||||
throw new ServerException(_('Don\'t use this method!'));
|
||||
// TRANS: Server exception thrown when using the method setActivitySubject() in the class Atom10Feed.
|
||||
throw new ServerException(_('Do not use this method!'));
|
||||
}
|
||||
|
||||
function getNamespaces()
|
||||
|
@ -76,8 +76,7 @@ class AttachmentList extends Widget
|
||||
*/
|
||||
function show()
|
||||
{
|
||||
$atts = new File;
|
||||
$att = $atts->getAttachments($this->notice->id);
|
||||
$att = File::getAttachments($this->notice->id);
|
||||
if (empty($att)) return 0;
|
||||
$this->showListStart();
|
||||
|
||||
|
@ -164,6 +164,7 @@ class Cache
|
||||
{
|
||||
$value = false;
|
||||
|
||||
common_perf_counter('Cache::get', $key);
|
||||
if (Event::handle('StartCacheGet', array(&$key, &$value))) {
|
||||
if (array_key_exists($key, $this->_items)) {
|
||||
$value = unserialize($this->_items[$key]);
|
||||
@ -188,6 +189,7 @@ class Cache
|
||||
{
|
||||
$success = false;
|
||||
|
||||
common_perf_counter('Cache::set', $key);
|
||||
if (Event::handle('StartCacheSet', array(&$key, &$value, &$flag,
|
||||
&$expiry, &$success))) {
|
||||
|
||||
@ -214,6 +216,7 @@ class Cache
|
||||
function increment($key, $step=1)
|
||||
{
|
||||
$value = false;
|
||||
common_perf_counter('Cache::increment', $key);
|
||||
if (Event::handle('StartCacheIncrement', array(&$key, &$step, &$value))) {
|
||||
// Fallback is not guaranteed to be atomic,
|
||||
// and may original expiry value.
|
||||
@ -239,6 +242,7 @@ class Cache
|
||||
{
|
||||
$success = false;
|
||||
|
||||
common_perf_counter('Cache::delete', $key);
|
||||
if (Event::handle('StartCacheDelete', array(&$key, &$success))) {
|
||||
if (array_key_exists($key, $this->_items)) {
|
||||
unset($this->_items[$key]);
|
||||
|
@ -63,8 +63,13 @@ if (!function_exists('dl')) {
|
||||
// Fortunately trying to call the disabled one will only trigger
|
||||
// a warning, not a fatal, so it's safe to leave it for our case.
|
||||
// Callers will be suppressing warnings anyway.
|
||||
$disabled = array_filter(array_map('trim', explode(',', ini_get('disable_functions'))));
|
||||
if (!in_array('dl', $disabled)) {
|
||||
try {
|
||||
// Reading the ini setting is hard as we don't know PHP's parsing,
|
||||
// but we can check if it is disabled through reflection.
|
||||
$dl = new ReflectionFunction('dl');
|
||||
// $disabled = $dl->isDisabled(); // don't need to check this now
|
||||
} catch (ReflectionException $e) {
|
||||
// Ok, it *really* doesn't exist!
|
||||
function dl($library) {
|
||||
return false;
|
||||
}
|
||||
|
@ -39,6 +39,8 @@ $default =
|
||||
'logo' => null,
|
||||
'ssllogo' => null,
|
||||
'logdebug' => false,
|
||||
'logperf' => false, // Enable to dump performance counters to syslog
|
||||
'logperf_detail' => false, // Enable to dump every counter hit
|
||||
'fancy' => false,
|
||||
'locale_path' => INSTALLDIR.'/locale',
|
||||
'language' => 'en',
|
||||
@ -269,8 +271,9 @@ $default =
|
||||
'search' =>
|
||||
array('type' => 'fulltext'),
|
||||
'sessions' =>
|
||||
array('handle' => false, // whether to handle sessions ourselves
|
||||
'debug' => false), // debugging output for sessions
|
||||
array('handle' => false, // whether to handle sessions ourselves
|
||||
'debug' => false, // debugging output for sessions
|
||||
'gc_limit' => 1000), // max sessions to expire at a time
|
||||
'design' =>
|
||||
array('backgroundcolor' => null, // null -> 'use theme default'
|
||||
'contentcolor' => null,
|
||||
|
@ -41,7 +41,6 @@ if (!defined('STATUSNET')) {
|
||||
* @link http://status.net/
|
||||
*
|
||||
*/
|
||||
|
||||
class DeleteUserForm extends ProfileActionForm
|
||||
{
|
||||
/**
|
||||
@ -49,7 +48,6 @@ class DeleteUserForm extends ProfileActionForm
|
||||
*
|
||||
* @return string Name of the action, lowercased.
|
||||
*/
|
||||
|
||||
function target()
|
||||
{
|
||||
return 'deleteuser';
|
||||
@ -60,9 +58,9 @@ class DeleteUserForm extends ProfileActionForm
|
||||
*
|
||||
* @return string Title of the form, internationalized
|
||||
*/
|
||||
|
||||
function title()
|
||||
{
|
||||
// TRANS: Title of form for deleting a user.
|
||||
return _('Delete');
|
||||
}
|
||||
|
||||
@ -71,9 +69,9 @@ class DeleteUserForm extends ProfileActionForm
|
||||
*
|
||||
* @return string description of the form, internationalized
|
||||
*/
|
||||
|
||||
function description()
|
||||
{
|
||||
// TRANS: Description of form for deleting a user.
|
||||
return _('Delete this user');
|
||||
}
|
||||
}
|
||||
|
@ -98,6 +98,10 @@ class DesignSettingsAction extends AccountSettingsAction
|
||||
$this->element('legend', null, _('Change background image'));
|
||||
$this->elementStart('ul', 'form_data');
|
||||
$this->elementStart('li');
|
||||
$this->element('input', array('name' => 'MAX_FILE_SIZE',
|
||||
'type' => 'hidden',
|
||||
'id' => 'MAX_FILE_SIZE',
|
||||
'value' => ImageFile::maxFileSizeInt()));
|
||||
$this->element('label', array('for' => 'design_background-image_file'),
|
||||
// TRANS: Label in form on profile design page.
|
||||
// TRANS: Field contains file name on user's computer that could be that user's custom profile background image.
|
||||
@ -108,10 +112,6 @@ class DesignSettingsAction extends AccountSettingsAction
|
||||
// TRANS: Instructions for form on profile design page.
|
||||
$this->element('p', 'form_guide', _('You can upload your personal ' .
|
||||
'background image. The maximum file size is 2MB.'));
|
||||
$this->element('input', array('name' => 'MAX_FILE_SIZE',
|
||||
'type' => 'hidden',
|
||||
'id' => 'MAX_FILE_SIZE',
|
||||
'value' => ImageFile::maxFileSizeInt()));
|
||||
$this->elementEnd('li');
|
||||
|
||||
if (!empty($design->backgroundimage)) {
|
||||
|
@ -3,7 +3,7 @@
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2010, StatusNet, Inc.
|
||||
*
|
||||
* A sample module to show best practices for StatusNet plugins
|
||||
* Use Hammer discovery stack to find out interesting things about an URI
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* 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 Discovery
|
||||
* @package StatusNet
|
||||
* @author James Walker <james@status.net>
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
@ -27,22 +28,40 @@
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* This class implements LRDD-based service discovery based on the "Hammer Draft"
|
||||
* (including webfinger)
|
||||
*
|
||||
* @see http://groups.google.com/group/webfinger/browse_thread/thread/9f3d93a479e91bbf
|
||||
* @category Discovery
|
||||
* @package StatusNet
|
||||
* @author James Walker <james@status.net>
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*
|
||||
* @see http://groups.google.com/group/webfinger/browse_thread/thread/9f3d93a479e91bbf
|
||||
*/
|
||||
class Discovery
|
||||
{
|
||||
|
||||
const LRDD_REL = 'lrdd';
|
||||
const LRDD_REL = 'lrdd';
|
||||
const PROFILEPAGE = 'http://webfinger.net/rel/profile-page';
|
||||
const UPDATESFROM = 'http://schemas.google.com/g/2010#updates-from';
|
||||
const HCARD = 'http://microformats.org/profile/hcard';
|
||||
const HCARD = 'http://microformats.org/profile/hcard';
|
||||
|
||||
public $methods = array();
|
||||
|
||||
/**
|
||||
* Constructor for a discovery object
|
||||
*
|
||||
* Registers different discovery methods.
|
||||
*
|
||||
* @return Discovery this
|
||||
*/
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->registerMethod('Discovery_LRDD_Host_Meta');
|
||||
@ -50,6 +69,13 @@ class Discovery
|
||||
$this->registerMethod('Discovery_LRDD_Link_HTML');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a discovery class
|
||||
*
|
||||
* @param string $class Class name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function registerMethod($class)
|
||||
{
|
||||
$this->methods[] = $class;
|
||||
@ -58,6 +84,10 @@ class Discovery
|
||||
/**
|
||||
* Given a "user id" make sure it's normalized to either a webfinger
|
||||
* acct: uri or a profile HTTP URL.
|
||||
*
|
||||
* @param string $user_id User ID to normalize
|
||||
*
|
||||
* @return string normalized acct: or http(s)?: URI
|
||||
*/
|
||||
public static function normalize($user_id)
|
||||
{
|
||||
@ -67,13 +97,22 @@ class Discovery
|
||||
return $user_id;
|
||||
}
|
||||
|
||||
if (strpos($user_id, '@') !== FALSE) {
|
||||
if (strpos($user_id, '@') !== false) {
|
||||
return 'acct:' . $user_id;
|
||||
}
|
||||
|
||||
return 'http://' . $user_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a string is a Webfinger ID
|
||||
*
|
||||
* Webfinger IDs look like foo@example.com or acct:foo@example.com
|
||||
*
|
||||
* @param string $user_id ID to check
|
||||
*
|
||||
* @return boolean true if $user_id is a Webfinger, else false
|
||||
*/
|
||||
public static function isWebfinger($user_id)
|
||||
{
|
||||
$uri = Discovery::normalize($user_id);
|
||||
@ -82,7 +121,11 @@ class Discovery
|
||||
}
|
||||
|
||||
/**
|
||||
* This implements the actual lookup procedure
|
||||
* Given a user ID, return the first available XRD
|
||||
*
|
||||
* @param string $id User ID URI
|
||||
*
|
||||
* @return XRD XRD object for the user
|
||||
*/
|
||||
public function lookup($id)
|
||||
{
|
||||
@ -106,11 +149,20 @@ class Discovery
|
||||
}
|
||||
}
|
||||
|
||||
// TRANS: Exception.
|
||||
throw new Exception(sprintf(_m('Unable to find services for %s.'),$id));
|
||||
// TRANS: Exception. %s is an ID.
|
||||
throw new Exception(sprintf(_('Unable to find services for %s.'), $id));
|
||||
}
|
||||
|
||||
public static function getService($links, $service) {
|
||||
/**
|
||||
* Given an array of links, returns the matching service
|
||||
*
|
||||
* @param array $links Links to check
|
||||
* @param string $service Service to find
|
||||
*
|
||||
* @return array $link assoc array representing the link
|
||||
*/
|
||||
public static function getService($links, $service)
|
||||
{
|
||||
if (!is_array($links)) {
|
||||
return false;
|
||||
}
|
||||
@ -122,6 +174,16 @@ class Discovery
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply a template using an ID
|
||||
*
|
||||
* Replaces {uri} in template string with the ID given.
|
||||
*
|
||||
* @param string $template Template to match
|
||||
* @param string $id User ID to replace with
|
||||
*
|
||||
* @return string replaced values
|
||||
*/
|
||||
public static function applyTemplate($template, $id)
|
||||
{
|
||||
$template = str_replace('{uri}', urlencode($id), $template);
|
||||
@ -129,10 +191,17 @@ class Discovery
|
||||
return $template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch an XRD file and parse
|
||||
*
|
||||
* @param string $url URL of the XRD
|
||||
*
|
||||
* @return XRD object representing the XRD file
|
||||
*/
|
||||
public static function fetchXrd($url)
|
||||
{
|
||||
try {
|
||||
$client = new HTTPClient();
|
||||
$client = new HTTPClient();
|
||||
$response = $client->get($url);
|
||||
} catch (HTTP_Request2_Exception $e) {
|
||||
return false;
|
||||
@ -146,13 +215,56 @@ class Discovery
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract interface for discovery
|
||||
*
|
||||
* Objects that implement this interface can retrieve an array of
|
||||
* XRD links for the URI.
|
||||
*
|
||||
* @category Discovery
|
||||
* @package StatusNet
|
||||
* @author James Walker <james@status.net>
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
interface Discovery_LRDD
|
||||
{
|
||||
/**
|
||||
* Discover interesting info about the URI
|
||||
*
|
||||
* @param string $uri URI to inquire about
|
||||
*
|
||||
* @return array Links in the XRD file
|
||||
*/
|
||||
public function discover($uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of discovery using host-meta file
|
||||
*
|
||||
* Discovers XRD file for a user by going to the organization's
|
||||
* host-meta file and trying to find a template for LRDD.
|
||||
*
|
||||
* @category Discovery
|
||||
* @package StatusNet
|
||||
* @author James Walker <james@status.net>
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class Discovery_LRDD_Host_Meta implements Discovery_LRDD
|
||||
{
|
||||
/**
|
||||
* Discovery core method
|
||||
*
|
||||
* For Webfinger and HTTP URIs, fetch the host-meta file
|
||||
* and look for LRDD templates
|
||||
*
|
||||
* @param string $uri URI to inquire about
|
||||
*
|
||||
* @return array Links in the XRD file
|
||||
*/
|
||||
public function discover($uri)
|
||||
{
|
||||
if (Discovery::isWebfinger($uri)) {
|
||||
@ -176,12 +288,36 @@ class Discovery_LRDD_Host_Meta implements Discovery_LRDD
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of discovery using HTTP Link header
|
||||
*
|
||||
* Discovers XRD file for a user by fetching the URL and reading any
|
||||
* Link: headers in the HTTP response.
|
||||
*
|
||||
* @category Discovery
|
||||
* @package StatusNet
|
||||
* @author James Walker <james@status.net>
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class Discovery_LRDD_Link_Header implements Discovery_LRDD
|
||||
{
|
||||
/**
|
||||
* Discovery core method
|
||||
*
|
||||
* For HTTP IDs fetch the URL and look for Link headers.
|
||||
*
|
||||
* @param string $uri URI to inquire about
|
||||
*
|
||||
* @return array Links in the XRD file
|
||||
*
|
||||
* @todo fail out of Webfinger URIs faster
|
||||
*/
|
||||
public function discover($uri)
|
||||
{
|
||||
try {
|
||||
$client = new HTTPClient();
|
||||
$client = new HTTPClient();
|
||||
$response = $client->get($uri);
|
||||
} catch (HTTP_Request2_Exception $e) {
|
||||
return false;
|
||||
@ -199,6 +335,13 @@ class Discovery_LRDD_Link_Header implements Discovery_LRDD
|
||||
return array(Discovery_LRDD_Link_Header::parseHeader($link_header));
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a string or array of headers, returns XRD-like assoc array
|
||||
*
|
||||
* @param string|array $header string or array of strings for headers
|
||||
*
|
||||
* @return array Link header in XRD-like format
|
||||
*/
|
||||
protected static function parseHeader($header)
|
||||
{
|
||||
$lh = new LinkHeader($header);
|
||||
@ -209,12 +352,37 @@ class Discovery_LRDD_Link_Header implements Discovery_LRDD
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of discovery using HTML <link> element
|
||||
*
|
||||
* Discovers XRD file for a user by fetching the URL and reading any
|
||||
* <link> elements in the HTML response.
|
||||
*
|
||||
* @category Discovery
|
||||
* @package StatusNet
|
||||
* @author James Walker <james@status.net>
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class Discovery_LRDD_Link_HTML implements Discovery_LRDD
|
||||
{
|
||||
/**
|
||||
* Discovery core method
|
||||
*
|
||||
* For HTTP IDs, fetch the URL and look for <link> elements
|
||||
* in the HTML response.
|
||||
*
|
||||
* @param string $uri URI to inquire about
|
||||
*
|
||||
* @return array Links in XRD-ish assoc array
|
||||
*
|
||||
* @todo fail out of Webfinger URIs faster
|
||||
*/
|
||||
public function discover($uri)
|
||||
{
|
||||
try {
|
||||
$client = new HTTPClient();
|
||||
$client = new HTTPClient();
|
||||
$response = $client->get($uri);
|
||||
} catch (HTTP_Request2_Exception $e) {
|
||||
return false;
|
||||
@ -227,6 +395,15 @@ class Discovery_LRDD_Link_HTML implements Discovery_LRDD
|
||||
return Discovery_LRDD_Link_HTML::parse($response->getBody());
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse HTML and return <link> elements
|
||||
*
|
||||
* Given an HTML string, scans the string for <link> elements
|
||||
*
|
||||
* @param string $html HTML to scan
|
||||
*
|
||||
* @return array array of associative arrays in XRD-ish format
|
||||
*/
|
||||
public function parse($html)
|
||||
{
|
||||
$links = array();
|
||||
@ -237,8 +414,8 @@ class Discovery_LRDD_Link_HTML implements Discovery_LRDD
|
||||
preg_match_all('/<link\s[^>]*>/i', $head_html, $link_matches);
|
||||
|
||||
foreach ($link_matches[0] as $link_html) {
|
||||
$link_url = null;
|
||||
$link_rel = null;
|
||||
$link_url = null;
|
||||
$link_rel = null;
|
||||
$link_type = null;
|
||||
|
||||
preg_match('/\srel=(("|\')([^\\2]*?)\\2|[^"\'\s]+)/i', $link_html, $rel_matches);
|
@ -46,13 +46,11 @@ require_once INSTALLDIR.'/lib/form.php';
|
||||
*
|
||||
* @see FavorForm
|
||||
*/
|
||||
|
||||
class DisfavorForm extends Form
|
||||
{
|
||||
/**
|
||||
* Notice to disfavor
|
||||
*/
|
||||
|
||||
var $notice = null;
|
||||
|
||||
/**
|
||||
@ -61,7 +59,6 @@ class DisfavorForm extends Form
|
||||
* @param HTMLOutputter $out output channel
|
||||
* @param Notice $notice notice to disfavor
|
||||
*/
|
||||
|
||||
function __construct($out=null, $notice=null)
|
||||
{
|
||||
parent::__construct($out);
|
||||
@ -74,7 +71,6 @@ class DisfavorForm extends Form
|
||||
*
|
||||
* @return int ID of the form
|
||||
*/
|
||||
|
||||
function id()
|
||||
{
|
||||
return 'disfavor-' . $this->notice->id;
|
||||
@ -85,7 +81,6 @@ class DisfavorForm extends Form
|
||||
*
|
||||
* @return string URL of the action
|
||||
*/
|
||||
|
||||
function action()
|
||||
{
|
||||
return common_local_url('disfavor');
|
||||
@ -96,14 +91,12 @@ class DisfavorForm extends Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function sessionToken()
|
||||
{
|
||||
$this->out->hidden('token-' . $this->notice->id,
|
||||
common_session_token());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Legend of the Form
|
||||
*
|
||||
@ -111,10 +104,10 @@ class DisfavorForm extends Form
|
||||
*/
|
||||
function formLegend()
|
||||
{
|
||||
// TRANS: Form legend for removing the favourite status for a favourite notice.
|
||||
$this->out->element('legend', null, _('Disfavor this notice'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Data elements
|
||||
*
|
||||
@ -129,7 +122,6 @@ class DisfavorForm extends Form
|
||||
'notice');
|
||||
Event::handle('EndDisFavorNoticeForm', array($this, $this->notice));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -137,22 +129,24 @@ class DisfavorForm extends Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formActions()
|
||||
{
|
||||
$this->out->submit('disfavor-submit-' . $this->notice->id,
|
||||
_('Disfavor favorite'), 'submit', null, _('Disfavor this notice'));
|
||||
// TRANS: Button text for removing the favourite status for a favourite notice.
|
||||
_m('BUTTON','Disfavor favorite'),
|
||||
'submit',
|
||||
null,
|
||||
// TRANS: Title for button text for removing the favourite status for a favourite notice.
|
||||
_('Disfavor this notice'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Class of the form.
|
||||
*
|
||||
* @return string the form's class
|
||||
*/
|
||||
|
||||
function formClass()
|
||||
{
|
||||
return 'form_disfavor';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -46,13 +46,11 @@ require_once INSTALLDIR.'/lib/form.php';
|
||||
*
|
||||
* @see DisfavorForm
|
||||
*/
|
||||
|
||||
class FavorForm extends Form
|
||||
{
|
||||
/**
|
||||
* Notice to favor
|
||||
*/
|
||||
|
||||
var $notice = null;
|
||||
|
||||
/**
|
||||
@ -61,7 +59,6 @@ class FavorForm extends Form
|
||||
* @param HTMLOutputter $out output channel
|
||||
* @param Notice $notice notice to favor
|
||||
*/
|
||||
|
||||
function __construct($out=null, $notice=null)
|
||||
{
|
||||
parent::__construct($out);
|
||||
@ -74,7 +71,6 @@ class FavorForm extends Form
|
||||
*
|
||||
* @return int ID of the form
|
||||
*/
|
||||
|
||||
function id()
|
||||
{
|
||||
return 'favor-' . $this->notice->id;
|
||||
@ -85,7 +81,6 @@ class FavorForm extends Form
|
||||
*
|
||||
* @return string URL of the action
|
||||
*/
|
||||
|
||||
function action()
|
||||
{
|
||||
return common_local_url('favor');
|
||||
@ -96,14 +91,12 @@ class FavorForm extends Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function sessionToken()
|
||||
{
|
||||
$this->out->hidden('token-' . $this->notice->id,
|
||||
common_session_token());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Legend of the Form
|
||||
*
|
||||
@ -111,16 +104,15 @@ class FavorForm extends Form
|
||||
*/
|
||||
function formLegend()
|
||||
{
|
||||
// TRANS: Form legend for adding the favourite status to a notice.
|
||||
$this->out->element('legend', null, _('Favor this notice'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Data elements
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formData()
|
||||
{
|
||||
if (Event::handle('StartFavorNoticeForm', array($this, $this->notice))) {
|
||||
@ -136,19 +128,22 @@ class FavorForm extends Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formActions()
|
||||
{
|
||||
$this->out->submit('favor-submit-' . $this->notice->id,
|
||||
_('Favor'), 'submit', null, _('Favor this notice'));
|
||||
// TRANS: Button text for adding the favourite status to a notice.
|
||||
_m('BUTTON','Favor'),
|
||||
'submit',
|
||||
null,
|
||||
// TRANS: Title for button text for adding the favourite status to a notice.
|
||||
_('Favor this notice'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Class of the form.
|
||||
*
|
||||
* @return string the form's class
|
||||
*/
|
||||
|
||||
function formClass()
|
||||
{
|
||||
return 'form_favor';
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user