Merge remote branch 'gitorious/0.9.x' into 0.9.x
This commit is contained in:
commit
dc8068fa9e
@ -840,6 +840,9 @@ class Action extends HTMLOutputter // lawsuit
|
||||
$this->elementStart('dd', null);
|
||||
if (common_config('site', 'broughtby')) {
|
||||
// TRANS: First sentence of the StatusNet site license. Used if 'broughtby' is set.
|
||||
// TRANS: Text between [] is a link description, text between () is the link itself.
|
||||
// TRANS: Make sure there is no whitespace between "]" and "(".
|
||||
// TRANS: "%%site.broughtby%%" is the value of the variable site.broughtby
|
||||
$instr = _('**%%site.name%%** is a microblogging service brought to you by [%%site.broughtby%%](%%site.broughtbyurl%%).');
|
||||
} else {
|
||||
// TRANS: First sentence of the StatusNet site license. Used if 'broughtby' is not set.
|
||||
@ -847,6 +850,9 @@ class Action extends HTMLOutputter // lawsuit
|
||||
}
|
||||
$instr .= ' ';
|
||||
// TRANS: Second sentence of the StatusNet site license. Mentions the StatusNet source code license.
|
||||
// TRANS: Make sure there is no whitespace between "]" and "(".
|
||||
// TRANS: Text between [] is a link description, text between () is the link itself.
|
||||
// TRANS: %s is the version of StatusNet that is being used.
|
||||
$instr .= sprintf(_('It runs the [StatusNet](http://status.net/) microblogging software, version %s, available under the [GNU Affero General Public License](http://www.fsf.org/licensing/licenses/agpl-3.0.html).'), STATUSNET_VERSION);
|
||||
$output = common_markup_to_html($instr);
|
||||
$this->raw($output);
|
||||
@ -893,7 +899,8 @@ class Action extends HTMLOutputter // lawsuit
|
||||
'width' => '80',
|
||||
'height' => '15'));
|
||||
$this->text(' ');
|
||||
// TRANS: license message in footer. %1$s is the site name, %2$s is a link to the license URL, with a licence name set in configuration.
|
||||
// TRANS: license message in footer.
|
||||
// TRANS: %1$s is the site name, %2$s is a link to the license URL, with a licence name set in configuration.
|
||||
$notice = _('All %1$s content and data are available under the %2$s license.');
|
||||
$link = "<a class=\"license\" rel=\"external license\" href=\"" .
|
||||
htmlspecialchars(common_config('license', 'url')) .
|
||||
@ -1304,6 +1311,7 @@ class Action extends HTMLOutputter // lawsuit
|
||||
// CSRF protection
|
||||
$token = $this->trimmed('token');
|
||||
if (empty($token) || $token != common_session_token()) {
|
||||
// TRANS: Client error text when there is a problem with the session token.
|
||||
$this->clientError(_('There was a problem with your session token.'));
|
||||
}
|
||||
}
|
||||
|
@ -387,4 +387,3 @@ class Activity
|
||||
return ActivityUtils::child($element, $tag, $namespace);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,6 @@ class ActivityContext
|
||||
|
||||
$attention = array();
|
||||
for ($i = 0; $i < $links->length; $i++) {
|
||||
|
||||
$link = $links->item($i);
|
||||
|
||||
$linkRel = $link->getAttribute(ActivityUtils::REL);
|
||||
|
@ -168,7 +168,6 @@ class ActivityObject
|
||||
ActivityObject::MEDIA_DESCRIPTION,
|
||||
Activity::MEDIA
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -418,7 +417,6 @@ class ActivityObject
|
||||
);
|
||||
|
||||
foreach ($sizes as $size) {
|
||||
|
||||
$alink = null;
|
||||
$avatar = $profile->getAvatar($size);
|
||||
|
||||
|
@ -46,7 +46,6 @@ if (!defined('STATUSNET')) {
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class ActivityUtils
|
||||
{
|
||||
const ATOM = 'http://www.w3.org/2005/Atom';
|
||||
@ -66,7 +65,6 @@ class ActivityUtils
|
||||
*
|
||||
* @return string related link, if any
|
||||
*/
|
||||
|
||||
static function getPermalink($element)
|
||||
{
|
||||
return self::getLink($element, 'alternate', 'text/html');
|
||||
@ -79,7 +77,6 @@ class ActivityUtils
|
||||
*
|
||||
* @return string related link, if any
|
||||
*/
|
||||
|
||||
static function getLink(DOMNode $element, $rel, $type=null)
|
||||
{
|
||||
$els = $element->childNodes;
|
||||
@ -135,7 +132,6 @@ class ActivityUtils
|
||||
*
|
||||
* @return DOMElement found element or null
|
||||
*/
|
||||
|
||||
static function child(DOMNode $element, $tag, $namespace=self::ATOM)
|
||||
{
|
||||
$els = $element->childNodes;
|
||||
@ -160,7 +156,6 @@ class ActivityUtils
|
||||
*
|
||||
* @return string content of the child
|
||||
*/
|
||||
|
||||
static function childContent(DOMNode $element, $tag, $namespace=self::ATOM)
|
||||
{
|
||||
$el = self::child($element, $tag, $namespace);
|
||||
@ -194,7 +189,6 @@ class ActivityUtils
|
||||
* @todo handle embedded XML mime types
|
||||
* @todo handle base64-encoded non-XML and non-text mime types
|
||||
*/
|
||||
|
||||
static function getContent($element)
|
||||
{
|
||||
return self::childHtmlContent($element, self::CONTENT, self::ATOM);
|
||||
@ -205,6 +199,7 @@ class ActivityUtils
|
||||
$src = $el->getAttribute(self::SRC);
|
||||
|
||||
if (!empty($src)) {
|
||||
// TRANS: Client exception thrown when there is no source attribute.
|
||||
throw new ClientException(_("Can't handle remote content yet."));
|
||||
}
|
||||
|
||||
@ -241,10 +236,12 @@ class ActivityUtils
|
||||
return trim($text);
|
||||
} else if (in_array($type, array('text/xml', 'application/xml')) ||
|
||||
preg_match('#(+|/)xml$#', $type)) {
|
||||
// TRANS: Client exception thrown when there embedded XML content is found that cannot be processed yet.
|
||||
throw new ClientException(_("Can't handle embedded XML content yet."));
|
||||
} else if (strncasecmp($type, 'text/', 5)) {
|
||||
return $el->textContent;
|
||||
} else {
|
||||
// TRANS: Client exception thrown when base64 encoded content is found that cannot be processed yet.
|
||||
throw new ClientException(_("Can't handle embedded Base64 content yet."));
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,6 @@ if (!defined('STATUSNET')) {
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class ActivityVerb
|
||||
{
|
||||
const POST = 'http://activitystrea.ms/schema/1.0/post';
|
||||
|
@ -45,7 +45,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
*
|
||||
* @see Form
|
||||
*/
|
||||
|
||||
class AdminForm extends Form
|
||||
{
|
||||
/**
|
||||
@ -59,7 +58,6 @@ class AdminForm extends Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function input($setting, $title, $instructions, $section='site')
|
||||
{
|
||||
$this->out->input($setting, $title, $this->value($setting, $section), $instructions);
|
||||
@ -73,7 +71,6 @@ class AdminForm extends Form
|
||||
*
|
||||
* @return string param value if posted, or current config value
|
||||
*/
|
||||
|
||||
function value($setting, $main='site')
|
||||
{
|
||||
$value = $this->out->trimmed($setting);
|
||||
|
@ -44,7 +44,6 @@ if (!defined('STATUSNET')) {
|
||||
*
|
||||
* @todo Find some commonalities with SettingsAction and combine
|
||||
*/
|
||||
|
||||
class AdminPanelAction extends Action
|
||||
{
|
||||
var $success = true;
|
||||
@ -61,7 +60,6 @@ class AdminPanelAction extends Action
|
||||
*
|
||||
* @return boolean success flag
|
||||
*/
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
parent::prepare($args);
|
||||
@ -124,7 +122,6 @@ class AdminPanelAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($args)
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
@ -155,7 +152,6 @@ class AdminPanelAction extends Action
|
||||
* @return void
|
||||
* @see AdminPanelNav
|
||||
*/
|
||||
|
||||
function showLocalNav()
|
||||
{
|
||||
$nav = new AdminPanelNav($this);
|
||||
@ -169,7 +165,6 @@ class AdminPanelAction extends Action
|
||||
*
|
||||
* @return void.
|
||||
*/
|
||||
|
||||
function showContent()
|
||||
{
|
||||
$this->showForm();
|
||||
@ -199,7 +194,6 @@ class AdminPanelAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showPageNotice()
|
||||
{
|
||||
if ($this->msg) {
|
||||
@ -222,7 +216,6 @@ class AdminPanelAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showForm()
|
||||
{
|
||||
// TRANS: Client error message.
|
||||
@ -239,7 +232,6 @@ class AdminPanelAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function getInstructions()
|
||||
{
|
||||
return '';
|
||||
@ -252,7 +244,6 @@ class AdminPanelAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function saveSettings()
|
||||
{
|
||||
// TRANS: Client error message
|
||||
@ -267,7 +258,6 @@ class AdminPanelAction extends Action
|
||||
*
|
||||
* @return mixed $result false if something didn't work
|
||||
*/
|
||||
|
||||
function deleteSetting($section, $setting)
|
||||
{
|
||||
$config = new Config();
|
||||
@ -314,7 +304,6 @@ class AdminPanelAction extends Action
|
||||
*
|
||||
* @see Widget
|
||||
*/
|
||||
|
||||
class AdminPanelNav extends Widget
|
||||
{
|
||||
var $action = null;
|
||||
@ -324,7 +313,6 @@ class AdminPanelNav extends Widget
|
||||
*
|
||||
* @param Action $action current action, used for output
|
||||
*/
|
||||
|
||||
function __construct($action=null)
|
||||
{
|
||||
parent::__construct($action);
|
||||
@ -336,7 +324,6 @@ class AdminPanelNav extends Widget
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function show()
|
||||
{
|
||||
$action_name = $this->action->trimmed('action');
|
||||
@ -413,5 +400,4 @@ class AdminPanelNav extends Widget
|
||||
}
|
||||
$this->action->elementEnd('ul');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -112,7 +112,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 ApiAction extends Action
|
||||
{
|
||||
const READ_ONLY = 1;
|
||||
@ -139,7 +138,6 @@ class ApiAction extends Action
|
||||
*
|
||||
* @return boolean false if user doesn't exist
|
||||
*/
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
StatusNet::setApi(true); // reduce exception reports to aid in debugging
|
||||
@ -172,7 +170,6 @@ class ApiAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($args)
|
||||
{
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
@ -862,7 +859,6 @@ class ApiAction extends Action
|
||||
}
|
||||
|
||||
$this->endDocument('atom');
|
||||
|
||||
}
|
||||
|
||||
function showRssGroups($group, $title, $link, $subtitle)
|
||||
@ -1015,7 +1011,6 @@ class ApiAction extends Action
|
||||
|
||||
function showAtomGroups($group, $title, $id, $link, $subtitle=null, $selfuri=null)
|
||||
{
|
||||
|
||||
$this->initDocument('atom');
|
||||
|
||||
$this->element('title', null, common_xml_safe_str($title));
|
||||
@ -1046,7 +1041,6 @@ class ApiAction extends Action
|
||||
|
||||
function showJsonTimeline($notice)
|
||||
{
|
||||
|
||||
$this->initDocument('json');
|
||||
|
||||
$statuses = array();
|
||||
@ -1072,7 +1066,6 @@ class ApiAction extends Action
|
||||
|
||||
function showJsonGroups($group)
|
||||
{
|
||||
|
||||
$this->initDocument('json');
|
||||
|
||||
$groups = array();
|
||||
@ -1118,7 +1111,6 @@ class ApiAction extends Action
|
||||
|
||||
function showTwitterXmlUsers($user)
|
||||
{
|
||||
|
||||
$this->initDocument('xml');
|
||||
$this->elementStart('users', array('type' => 'array',
|
||||
'xmlns:statusnet' => 'http://status.net/schema/api/1/'));
|
||||
@ -1141,7 +1133,6 @@ class ApiAction extends Action
|
||||
|
||||
function showJsonUsers($user)
|
||||
{
|
||||
|
||||
$this->initDocument('json');
|
||||
|
||||
$users = array();
|
||||
@ -1226,7 +1217,6 @@ class ApiAction extends Action
|
||||
$this->endXML();
|
||||
break;
|
||||
case 'json':
|
||||
|
||||
// Check for JSONP callback
|
||||
if (isset($this->callback)) {
|
||||
print ')';
|
||||
@ -1483,7 +1473,6 @@ class ApiAction extends Action
|
||||
*/
|
||||
function arg($key, $def=null)
|
||||
{
|
||||
|
||||
// XXX: Do even more input validation/scrubbing?
|
||||
|
||||
if (array_key_exists($key, $this->args)) {
|
||||
@ -1550,5 +1539,4 @@ class ApiAction extends Action
|
||||
|
||||
return $uri;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -68,7 +68,6 @@ require_once INSTALLDIR . '/lib/apioauth.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 ApiAuthAction extends ApiAction
|
||||
{
|
||||
var $auth_user_nickname = null;
|
||||
@ -83,7 +82,6 @@ class ApiAuthAction extends ApiAction
|
||||
* @return boolean success flag
|
||||
*
|
||||
*/
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
parent::prepare($args);
|
||||
@ -126,7 +124,6 @@ class ApiAuthAction extends ApiAction
|
||||
*
|
||||
* @return mixed the OAuthRequest or false
|
||||
*/
|
||||
|
||||
function getOAuthRequest()
|
||||
{
|
||||
ApiOauthAction::cleanRequest();
|
||||
@ -154,7 +151,6 @@ class ApiAuthAction extends ApiAction
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
|
||||
function checkOAuthRequest($request)
|
||||
{
|
||||
$datastore = new ApiStatusNetOAuthDataStore();
|
||||
@ -164,7 +160,6 @@ class ApiAuthAction extends ApiAction
|
||||
$server->add_signature_method($hmac_method);
|
||||
|
||||
try {
|
||||
|
||||
$server->verify_request($request);
|
||||
|
||||
$consumer = $request->get_parameter('oauth_consumer_key');
|
||||
@ -176,7 +171,8 @@ class ApiAuthAction extends ApiAction
|
||||
common_log(LOG_WARNING,
|
||||
'Couldn\'t find the OAuth app for consumer key: ' .
|
||||
$consumer);
|
||||
throw new OAuthException('No application for that consumer key.');
|
||||
// TRANS: OAuth exception thrown when no application is found for a given consumer key.
|
||||
throw new OAuthException(_('No application for that consumer key.'));
|
||||
}
|
||||
|
||||
// set the source attr
|
||||
@ -186,19 +182,15 @@ class ApiAuthAction extends ApiAction
|
||||
$appUser = Oauth_application_user::staticGet('token', $access_token);
|
||||
|
||||
if (!empty($appUser)) {
|
||||
|
||||
// If access_type == 0 we have either a request token
|
||||
// or a bad / revoked access token
|
||||
|
||||
if ($appUser->access_type != 0) {
|
||||
|
||||
// Set the access level for the api call
|
||||
|
||||
$this->access = ($appUser->access_type & Oauth_application::$writeAccess)
|
||||
? self::READ_WRITE : self::READ_ONLY;
|
||||
|
||||
// Set the auth user
|
||||
|
||||
if (Event::handle('StartSetApiUser', array(&$user))) {
|
||||
$this->auth_user = User::staticGet('id', $appUser->profile_id);
|
||||
Event::handle('EndSetApiUser', array($user));
|
||||
@ -216,13 +208,13 @@ class ApiAuthAction extends ApiAction
|
||||
'read-write' : 'read-only'
|
||||
));
|
||||
} else {
|
||||
throw new OAuthException('Bad access token.');
|
||||
// TRANS: OAuth exception given when an incorrect access token was given for a user.
|
||||
throw new OAuthException(_('Bad access token.'));
|
||||
}
|
||||
} else {
|
||||
|
||||
// Also should not happen
|
||||
|
||||
throw new OAuthException('No user for that token.');
|
||||
// TRANS: OAuth exception given when no user was found for a given token (no token was found).
|
||||
throw new OAuthException(_('No user for that token.'));
|
||||
}
|
||||
|
||||
} catch (OAuthException $e) {
|
||||
@ -237,7 +229,6 @@ class ApiAuthAction extends ApiAction
|
||||
*
|
||||
* @return boolean true
|
||||
*/
|
||||
|
||||
function requiresAuth()
|
||||
{
|
||||
return true;
|
||||
@ -249,7 +240,6 @@ class ApiAuthAction extends ApiAction
|
||||
*
|
||||
* @return boolean true or false
|
||||
*/
|
||||
|
||||
function checkBasicAuthUser($required = true)
|
||||
{
|
||||
$this->basicAuthProcessHeader();
|
||||
@ -264,8 +254,8 @@ class ApiAuthAction extends ApiAction
|
||||
header('WWW-Authenticate: Basic realm="' . $realm . '"');
|
||||
|
||||
// show error if the user clicks 'cancel'
|
||||
|
||||
$this->clientError("Could not authenticate you.", 401, $this->format);
|
||||
// TRANS: Client error thrown when authentication fails becaus a user clicked "Cancel".
|
||||
$this->clientError(_("Could not authenticate you."), 401, $this->format);
|
||||
exit;
|
||||
|
||||
} else {
|
||||
@ -283,13 +273,11 @@ class ApiAuthAction extends ApiAction
|
||||
}
|
||||
|
||||
// By default, basic auth users have rw access
|
||||
|
||||
$this->access = self::READ_WRITE;
|
||||
|
||||
if (empty($this->auth_user) && ($required || isset($_SERVER['PHP_AUTH_USER']))) {
|
||||
|
||||
// basic authentication failed
|
||||
|
||||
list($proxy, $ip) = common_client_ip();
|
||||
|
||||
$msg = sprintf( 'Failed API auth attempt, nickname = %1$s, ' .
|
||||
@ -298,7 +286,8 @@ class ApiAuthAction extends ApiAction
|
||||
$proxy,
|
||||
$ip);
|
||||
common_log(LOG_WARNING, $msg);
|
||||
$this->clientError("Could not authenticate you.", 401, $this->format);
|
||||
// TRANS: Client error thrown when authentication fails.
|
||||
$this->clientError(_("Could not authenticate you."), 401, $this->format);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@ -310,7 +299,6 @@ class ApiAuthAction extends ApiAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function basicAuthProcessHeader()
|
||||
{
|
||||
$authHeaders = array('AUTHORIZATION',
|
||||
@ -332,7 +320,6 @@ class ApiAuthAction extends ApiAction
|
||||
|
||||
// Decode the HTTP_AUTHORIZATION header on php-cgi server self
|
||||
// on fcgid server the header name is AUTHORIZATION
|
||||
|
||||
$auth_hash = base64_decode(substr($authorization_header, 6));
|
||||
list($this->auth_user_nickname,
|
||||
$this->auth_user_password) = explode(':', $auth_hash);
|
||||
|
@ -60,7 +60,6 @@ require_once INSTALLDIR.'/lib/apiauth.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 ApiBareAuthAction extends ApiAuthAction
|
||||
{
|
||||
|
||||
@ -72,7 +71,6 @@ class ApiBareAuthAction extends ApiAuthAction
|
||||
* @return boolean success flag
|
||||
*
|
||||
*/
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
parent::prepare($args);
|
||||
@ -84,18 +82,15 @@ class ApiBareAuthAction extends ApiAuthAction
|
||||
*
|
||||
* @return boolean true or false
|
||||
*/
|
||||
|
||||
function requiresAuth()
|
||||
{
|
||||
// If the site is "private", all API methods except statusnet/config
|
||||
// need authentication
|
||||
|
||||
if (common_config('site', 'private')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// check whether a user has been specified somehow
|
||||
|
||||
$id = $this->arg('id');
|
||||
$user_id = $this->arg('user_id');
|
||||
$screen_name = $this->arg('screen_name');
|
||||
@ -106,5 +101,4 @@ class ApiBareAuthAction extends ApiAuthAction
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -44,7 +44,6 @@ require_once INSTALLDIR . '/lib/apioauthstore.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 ApiOauthAction extends Action
|
||||
{
|
||||
/**
|
||||
@ -52,7 +51,6 @@ class ApiOauthAction extends Action
|
||||
*
|
||||
* @return boolean false
|
||||
*/
|
||||
|
||||
function isReadOnly($args)
|
||||
{
|
||||
return false;
|
||||
@ -73,7 +71,6 @@ class ApiOauthAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($args)
|
||||
{
|
||||
parent::handle($args);
|
||||
@ -83,7 +80,6 @@ class ApiOauthAction extends Action
|
||||
static function cleanRequest()
|
||||
{
|
||||
// kill evil effects of magical slashing
|
||||
|
||||
if (get_magic_quotes_gpc() == 1) {
|
||||
$_POST = array_map('stripslashes', $_POST);
|
||||
$_GET = array_map('stripslashes', $_GET);
|
||||
@ -93,7 +89,6 @@ class ApiOauthAction extends Action
|
||||
|
||||
// XXX: should we strip anything else? Or alternatively
|
||||
// only allow a known list of params?
|
||||
|
||||
unset($_GET['p']);
|
||||
unset($_POST['p']);
|
||||
}
|
||||
@ -118,5 +113,4 @@ class ApiOauthAction extends Action
|
||||
return ($url . '&' . $k . '=' . $v);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ require_once INSTALLDIR . '/lib/oauthstore.php';
|
||||
|
||||
class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore
|
||||
{
|
||||
|
||||
function lookup_consumer($consumer_key)
|
||||
{
|
||||
$con = Consumer::staticGet('consumer_key', $consumer_key);
|
||||
@ -39,7 +38,6 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore
|
||||
function getAppByRequestToken($token_key)
|
||||
{
|
||||
// Look up the full req tokenx
|
||||
|
||||
$req_token = $this->lookup_token(null,
|
||||
'request',
|
||||
$token_key);
|
||||
@ -50,7 +48,6 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore
|
||||
}
|
||||
|
||||
// Look up the full Token
|
||||
|
||||
$token = new Token();
|
||||
$token->tok = $req_token->key;
|
||||
$result = $token->find(true);
|
||||
@ -150,7 +147,6 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore
|
||||
}
|
||||
|
||||
// Okay, good
|
||||
|
||||
return new OAuthToken($at->tok, $at->secret);
|
||||
}
|
||||
|
||||
@ -172,19 +168,18 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function revoke_token($token_key, $type = 0) {
|
||||
$rt = new Token();
|
||||
$rt->tok = $token_key;
|
||||
$rt->type = $type;
|
||||
$rt->state = 0;
|
||||
if (!$rt->find(true)) {
|
||||
throw new Exception('Tried to revoke unknown token');
|
||||
// TRANS: Exception thrown when an attempt is made to revoke an unknown token.
|
||||
throw new Exception(_('Tried to revoke unknown token'));
|
||||
}
|
||||
if (!$rt->delete()) {
|
||||
throw new Exception('Failed to delete revoked token');
|
||||
// TRANS: Exception thrown when an attempt is made to remove a revoked token.
|
||||
throw new Exception(_('Failed to delete revoked token'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -58,26 +58,21 @@ require_once INSTALLDIR.'/lib/apiauth.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 ApiPrivateAuthAction extends ApiAuthAction
|
||||
{
|
||||
|
||||
/**
|
||||
* Does this API resource require authentication?
|
||||
*
|
||||
* @return boolean true or false
|
||||
*/
|
||||
|
||||
function requiresAuth()
|
||||
{
|
||||
// If the site is "private", all API methods except statusnet/config
|
||||
// need authentication
|
||||
|
||||
if (common_config('site', 'private')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -43,13 +43,11 @@ require_once INSTALLDIR . '/lib/form.php';
|
||||
* @link http://status.net/
|
||||
*
|
||||
*/
|
||||
|
||||
class ApplicationEditForm extends Form
|
||||
{
|
||||
/**
|
||||
* group for user to join
|
||||
*/
|
||||
|
||||
var $application = null;
|
||||
|
||||
/**
|
||||
@ -58,7 +56,6 @@ class ApplicationEditForm extends Form
|
||||
* @param Action $out output channel
|
||||
* @param User_group $group group to join
|
||||
*/
|
||||
|
||||
function __construct($out=null, $application=null)
|
||||
{
|
||||
parent::__construct($out);
|
||||
@ -71,7 +68,6 @@ class ApplicationEditForm extends Form
|
||||
*
|
||||
* @return string ID of the form
|
||||
*/
|
||||
|
||||
function id()
|
||||
{
|
||||
if ($this->application) {
|
||||
@ -89,7 +85,6 @@ class ApplicationEditForm extends Form
|
||||
*
|
||||
* @return string the method to use for submitting
|
||||
*/
|
||||
|
||||
function method()
|
||||
{
|
||||
$this->enctype = 'multipart/form-data';
|
||||
@ -101,7 +96,6 @@ class ApplicationEditForm extends Form
|
||||
*
|
||||
* @return string of the form class
|
||||
*/
|
||||
|
||||
function formClass()
|
||||
{
|
||||
return 'form_settings';
|
||||
@ -112,7 +106,6 @@ class ApplicationEditForm extends Form
|
||||
*
|
||||
* @return string URL of the action
|
||||
*/
|
||||
|
||||
function action()
|
||||
{
|
||||
$cur = common_current_user();
|
||||
@ -130,7 +123,6 @@ class ApplicationEditForm extends Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formLegend()
|
||||
{
|
||||
// TRANS: Form legend.
|
||||
@ -142,7 +134,6 @@ class ApplicationEditForm extends Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formData()
|
||||
{
|
||||
if ($this->application) {
|
||||
@ -350,16 +341,15 @@ class ApplicationEditForm extends Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formActions()
|
||||
{
|
||||
// TRANS: Button label
|
||||
// TRANS: Button label in the "Edit application" form.
|
||||
$this->out->submit('cancel', _m('BUTTON','Cancel'), 'submit form_action-primary',
|
||||
// TRANS: Submit button title
|
||||
// TRANS: Submit button title.
|
||||
'cancel', _('Cancel'));
|
||||
// TRANS: Button label
|
||||
// TRANS: Button label in the "Edit application" form.
|
||||
$this->out->submit('save', _m('BUTTON','Save'), 'submit form_action-secondary',
|
||||
// TRANS: Submit button title
|
||||
// TRANS: Submit button title.
|
||||
'save', _('Save'));
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,6 @@ define('APPS_PER_PAGE', 20);
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class ApplicationList extends Widget
|
||||
{
|
||||
/** Current application, application query */
|
||||
@ -164,10 +163,8 @@ class ApplicationList extends Widget
|
||||
}
|
||||
|
||||
/* Override this in subclasses. */
|
||||
|
||||
function showOwnerControls()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ class AttachmentNoticeSection extends NoticeSection
|
||||
|
||||
function title()
|
||||
{
|
||||
// TRANS: Title.
|
||||
return _('Notices where this attachment appears');
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,7 @@ class AttachmentTagCloudSection extends TagCloudSection
|
||||
{
|
||||
function title()
|
||||
{
|
||||
// TRANS: Title.
|
||||
return _('Tags for this attachment');
|
||||
}
|
||||
|
||||
|
@ -831,7 +831,7 @@ class SubscriptionsCommand extends Command
|
||||
$out=_('You are not subscribed to anyone.');
|
||||
}else{
|
||||
// TRANS: Text shown after requesting other users a user is subscribed to.
|
||||
// TRANS: This message support plural forms. This message is followed by a
|
||||
// TRANS: This message supports plural forms. This message is followed by a
|
||||
// TRANS: hard coded space and a comma separated list of subscribed users.
|
||||
$out = ngettext('You are subscribed to this person:',
|
||||
'You are subscribed to these people:',
|
||||
@ -858,7 +858,7 @@ class SubscribersCommand extends Command
|
||||
$out=_('No one is subscribed to you.');
|
||||
}else{
|
||||
// TRANS: Text shown after requesting other users that are subscribed to a user (followers).
|
||||
// TRANS: This message support plural forms. This message is followed by a
|
||||
// TRANS: This message supports plural forms. This message is followed by a
|
||||
// TRANS: hard coded space and a comma separated list of subscribing users.
|
||||
$out = ngettext('This person is subscribed to you:',
|
||||
'These people are subscribed to you:',
|
||||
@ -885,7 +885,7 @@ class GroupsCommand extends Command
|
||||
$out=_('You are not a member of any groups.');
|
||||
}else{
|
||||
// TRANS: Text shown after requesting groups a user is subscribed to.
|
||||
// TRANS: This message support plural forms. This message is followed by a
|
||||
// TRANS: This message supports plural forms. This message is followed by a
|
||||
// TRANS: hard coded space and a comma separated list of subscribed groups.
|
||||
$out = ngettext('You are a member of this group:',
|
||||
'You are a member of these groups:',
|
||||
@ -900,8 +900,8 @@ class HelpCommand extends Command
|
||||
{
|
||||
function handle($channel)
|
||||
{
|
||||
// TRANS: Help text for commands.
|
||||
$channel->output($this->user,
|
||||
// TRANS: Help text for commands.
|
||||
_("Commands:\n".
|
||||
"on - turn on notifications\n".
|
||||
"off - turn off notifications\n".
|
||||
|
81
lib/util.php
81
lib/util.php
@ -19,15 +19,18 @@
|
||||
|
||||
/* XXX: break up into separate modules (HTTP, user, files) */
|
||||
|
||||
// Show a server error
|
||||
|
||||
/**
|
||||
* Show a server error.
|
||||
*/
|
||||
function common_server_error($msg, $code=500)
|
||||
{
|
||||
$err = new ServerErrorAction($msg, $code);
|
||||
$err->showPage();
|
||||
}
|
||||
|
||||
// Show a user error
|
||||
/**
|
||||
* Show a user error.
|
||||
*/
|
||||
function common_user_error($msg, $code=400)
|
||||
{
|
||||
$err = new ClientErrorAction($msg, $code);
|
||||
@ -157,7 +160,6 @@ function common_timezone()
|
||||
|
||||
function common_language()
|
||||
{
|
||||
|
||||
// If there is a user logged in and they've set a language preference
|
||||
// then return that one...
|
||||
if (_have_config() && common_logged_in()) {
|
||||
@ -189,8 +191,10 @@ function common_language()
|
||||
// Finally, if none of the above worked, use the site's default...
|
||||
return common_config('site', 'language');
|
||||
}
|
||||
// salted, hashed passwords are stored in the DB
|
||||
|
||||
/**
|
||||
* Salted, hashed passwords are stored in the DB.
|
||||
*/
|
||||
function common_munge_password($password, $id)
|
||||
{
|
||||
if (is_object($id) || is_object($password)) {
|
||||
@ -201,8 +205,9 @@ function common_munge_password($password, $id)
|
||||
return md5($password . $id);
|
||||
}
|
||||
|
||||
// check if a username exists and has matching password
|
||||
|
||||
/**
|
||||
* Check if a username exists and has matching password.
|
||||
*/
|
||||
function common_check_user($nickname, $password)
|
||||
{
|
||||
// empty nickname always unacceptable
|
||||
@ -229,7 +234,9 @@ function common_check_user($nickname, $password)
|
||||
return $authenticatedUser;
|
||||
}
|
||||
|
||||
// is the current user logged in?
|
||||
/**
|
||||
* Is the current user logged in?
|
||||
*/
|
||||
function common_logged_in()
|
||||
{
|
||||
return (!is_null(common_current_user()));
|
||||
@ -275,12 +282,10 @@ function common_ensure_session()
|
||||
// 3) null to clear
|
||||
|
||||
// Initialize to false; set to null if none found
|
||||
|
||||
$_cur = false;
|
||||
|
||||
function common_set_user($user)
|
||||
{
|
||||
|
||||
global $_cur;
|
||||
|
||||
if (is_null($user) && common_have_session()) {
|
||||
@ -366,7 +371,6 @@ function common_rememberme($user=null)
|
||||
|
||||
function common_remembered_user()
|
||||
{
|
||||
|
||||
$user = null;
|
||||
|
||||
$packed = isset($_COOKIE[REMEMBERME]) ? $_COOKIE[REMEMBERME] : null;
|
||||
@ -428,14 +432,17 @@ function common_remembered_user()
|
||||
return $user;
|
||||
}
|
||||
|
||||
// must be called with a valid user!
|
||||
|
||||
/**
|
||||
* must be called with a valid user!
|
||||
*/
|
||||
function common_forgetme()
|
||||
{
|
||||
common_set_cookie(REMEMBERME, '', 0);
|
||||
}
|
||||
|
||||
// who is the current user?
|
||||
/**
|
||||
* Who is the current user?
|
||||
*/
|
||||
function common_current_user()
|
||||
{
|
||||
global $_cur;
|
||||
@ -471,10 +478,11 @@ function common_current_user()
|
||||
return $_cur;
|
||||
}
|
||||
|
||||
// Logins that are 'remembered' aren't 'real' -- they're subject to
|
||||
// cookie-stealing. So, we don't let them do certain things. New reg,
|
||||
// OpenID, and password logins _are_ real.
|
||||
|
||||
/**
|
||||
* Logins that are 'remembered' aren't 'real' -- they're subject to
|
||||
* cookie-stealing. So, we don't let them do certain things. New reg,
|
||||
* OpenID, and password logins _are_ real.
|
||||
*/
|
||||
function common_real_login($real=true)
|
||||
{
|
||||
common_ensure_session();
|
||||
@ -577,9 +585,7 @@ function common_find_mentions($text, $notice)
|
||||
}
|
||||
|
||||
if (Event::handle('StartFindMentions', array($sender, $text, &$mentions))) {
|
||||
|
||||
// Get the context of the original notice, if any
|
||||
|
||||
$originalAuthor = null;
|
||||
$originalNotice = null;
|
||||
$originalMentions = array();
|
||||
@ -615,7 +621,6 @@ function common_find_mentions($text, $notice)
|
||||
$matches = array_merge($tmatches[1], $atmatches[1]);
|
||||
|
||||
foreach ($matches as $match) {
|
||||
|
||||
$nickname = common_canonical_nickname($match[0]);
|
||||
|
||||
// Try to get a profile for this nickname.
|
||||
@ -623,19 +628,15 @@ function common_find_mentions($text, $notice)
|
||||
// sender context.
|
||||
|
||||
if (!empty($originalAuthor) && $originalAuthor->nickname == $nickname) {
|
||||
|
||||
$mentioned = $originalAuthor;
|
||||
|
||||
} else if (!empty($originalMentions) &&
|
||||
array_key_exists($nickname, $originalMentions)) {
|
||||
|
||||
$mentioned = $originalMentions[$nickname];
|
||||
} else {
|
||||
$mentioned = common_relative_profile($sender, $nickname);
|
||||
}
|
||||
|
||||
if (!empty($mentioned)) {
|
||||
|
||||
$user = User::staticGet('id', $mentioned->id);
|
||||
|
||||
if ($user) {
|
||||
@ -1104,30 +1105,26 @@ function common_date_string($dt)
|
||||
// TRANS: Used in notices to indicate when the notice was made compared to now.
|
||||
return _('about a minute ago');
|
||||
} else if ($diff < 3300) {
|
||||
// XXX: should support plural.
|
||||
// TRANS: Used in notices to indicate when the notice was made compared to now.
|
||||
return sprintf(_('about %d minutes ago'), round($diff/60));
|
||||
return sprintf( ngettext('about one minute ago', 'about %d minutes ago'), round($diff/60));
|
||||
} else if ($diff < 5400) {
|
||||
// TRANS: Used in notices to indicate when the notice was made compared to now.
|
||||
return _('about an hour ago');
|
||||
} else if ($diff < 22 * 3600) {
|
||||
// XXX: should support plural.
|
||||
// TRANS: Used in notices to indicate when the notice was made compared to now.
|
||||
return sprintf(_('about %d hours ago'), round($diff/3600));
|
||||
return sprintf( ngettext('about one hour ago', 'about %d hours ago'), round($diff/3600));
|
||||
} else if ($diff < 37 * 3600) {
|
||||
// TRANS: Used in notices to indicate when the notice was made compared to now.
|
||||
return _('about a day ago');
|
||||
} else if ($diff < 24 * 24 * 3600) {
|
||||
// XXX: should support plural.
|
||||
// TRANS: Used in notices to indicate when the notice was made compared to now.
|
||||
return sprintf(_('about %d days ago'), round($diff/(24*3600)));
|
||||
return sprintf( ngettext('about one day ago', 'about %d days ago'), round($diff/(24*3600)));
|
||||
} else if ($diff < 46 * 24 * 3600) {
|
||||
// TRANS: Used in notices to indicate when the notice was made compared to now.
|
||||
return _('about a month ago');
|
||||
} else if ($diff < 330 * 24 * 3600) {
|
||||
// XXX: should support plural.
|
||||
// TRANS: Used in notices to indicate when the notice was made compared to now.
|
||||
return sprintf(_('about %d months ago'), round($diff/(30*24*3600)));
|
||||
return sprintf( ngettext('about one month ago', 'about %d months ago'), round($diff/(30*24*3600)));
|
||||
} else if ($diff < 480 * 24 * 3600) {
|
||||
// TRANS: Used in notices to indicate when the notice was made compared to now.
|
||||
return _('about a year ago');
|
||||
@ -1230,8 +1227,9 @@ function common_broadcast_notice($notice, $remote=false)
|
||||
// DO NOTHING!
|
||||
}
|
||||
|
||||
// Stick the notice on the queue
|
||||
|
||||
/**
|
||||
* Stick the notice on the queue.
|
||||
*/
|
||||
function common_enqueue_notice($notice)
|
||||
{
|
||||
static $localTransports = array('omb',
|
||||
@ -1293,8 +1291,9 @@ function common_profile_url($nickname)
|
||||
null, null, false);
|
||||
}
|
||||
|
||||
// Should make up a reasonable root URL
|
||||
|
||||
/**
|
||||
* Should make up a reasonable root URL
|
||||
*/
|
||||
function common_root_url($ssl=false)
|
||||
{
|
||||
$url = common_path('', $ssl, false);
|
||||
@ -1305,9 +1304,10 @@ function common_root_url($ssl=false)
|
||||
return $url;
|
||||
}
|
||||
|
||||
// returns $bytes bytes of random data as a hexadecimal string
|
||||
// "good" here is a goal and not a guarantee
|
||||
|
||||
/**
|
||||
* returns $bytes bytes of random data as a hexadecimal string
|
||||
* "good" here is a goal and not a guarantee
|
||||
*/
|
||||
function common_good_rand($bytes)
|
||||
{
|
||||
// XXX: use random.org...?
|
||||
@ -1826,7 +1826,6 @@ function common_compatible_license($from, $to)
|
||||
*/
|
||||
function common_database_tablename($tablename)
|
||||
{
|
||||
|
||||
if(common_config('db','quote_identifiers')) {
|
||||
$tablename = '"'. $tablename .'"';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user