Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x
This commit is contained in:
commit
fd8941df85
@ -250,7 +250,6 @@ class EditgroupAction extends GroupDesignAction
|
|||||||
$this->group->homepage = $homepage;
|
$this->group->homepage = $homepage;
|
||||||
$this->group->description = $description;
|
$this->group->description = $description;
|
||||||
$this->group->location = $location;
|
$this->group->location = $location;
|
||||||
$this->group->created = common_sql_now();
|
|
||||||
|
|
||||||
$result = $this->group->update($orig);
|
$result = $this->group->update($orig);
|
||||||
|
|
||||||
|
@ -255,13 +255,6 @@ class NewnoticeAction extends Action
|
|||||||
$notice = Notice::saveNew($user->id, $content_shortened, 'web', 1,
|
$notice = Notice::saveNew($user->id, $content_shortened, 'web', 1,
|
||||||
($replyto == 'false') ? null : $replyto);
|
($replyto == 'false') ? null : $replyto);
|
||||||
|
|
||||||
if (is_string($notice)) {
|
|
||||||
if (isset($filename)) {
|
|
||||||
$this->deleteFile($filename);
|
|
||||||
}
|
|
||||||
$this->clientError($notice);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($mimetype)) {
|
if (isset($mimetype)) {
|
||||||
$this->attachFile($notice, $fileRecord);
|
$this->attachFile($notice, $fileRecord);
|
||||||
}
|
}
|
||||||
|
@ -297,11 +297,6 @@ class TwitapistatusesAction extends TwitterapiAction
|
|||||||
html_entity_decode($status, ENT_NOQUOTES, 'UTF-8'),
|
html_entity_decode($status, ENT_NOQUOTES, 'UTF-8'),
|
||||||
$source, 1, $reply_to);
|
$source, 1, $reply_to);
|
||||||
|
|
||||||
if (is_string($notice)) {
|
|
||||||
$this->serverError($notice);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
common_broadcast_notice($notice);
|
common_broadcast_notice($notice);
|
||||||
$apidata['api_arg'] = $notice->id;
|
$apidata['api_arg'] = $notice->id;
|
||||||
}
|
}
|
||||||
|
@ -153,30 +153,30 @@ class Notice extends Memcached_DataObject
|
|||||||
$final = common_shorten_links($content);
|
$final = common_shorten_links($content);
|
||||||
|
|
||||||
if (Notice::contentTooLong($final)) {
|
if (Notice::contentTooLong($final)) {
|
||||||
common_log(LOG_INFO, 'Rejecting notice that is too long.');
|
throw new ClientException(_('Problem saving notice. Too long.'));
|
||||||
return _('Problem saving notice. Too long.');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$profile) {
|
if (!$profile) {
|
||||||
common_log(LOG_ERR, 'Problem saving notice. Unknown user.');
|
throw new ClientException(_('Problem saving notice. Unknown user.'));
|
||||||
return _('Problem saving notice. Unknown user.');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (common_config('throttle', 'enabled') && !Notice::checkEditThrottle($profile_id)) {
|
if (common_config('throttle', 'enabled') && !Notice::checkEditThrottle($profile_id)) {
|
||||||
common_log(LOG_WARNING, 'Excessive posting by profile #' . $profile_id . '; throttled.');
|
common_log(LOG_WARNING, 'Excessive posting by profile #' . $profile_id . '; throttled.');
|
||||||
return _('Too many notices too fast; take a breather and post again in a few minutes.');
|
throw new ClientException(_('Too many notices too fast; take a breather '.
|
||||||
|
'and post again in a few minutes.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (common_config('site', 'dupelimit') > 0 && !Notice::checkDupes($profile_id, $final)) {
|
if (common_config('site', 'dupelimit') > 0 && !Notice::checkDupes($profile_id, $final)) {
|
||||||
common_log(LOG_WARNING, 'Dupe posting by profile #' . $profile_id . '; throttled.');
|
common_log(LOG_WARNING, 'Dupe posting by profile #' . $profile_id . '; throttled.');
|
||||||
return _('Too many duplicate messages too quickly; take a breather and post again in a few minutes.');
|
throw new ClientException(_('Too many duplicate messages too quickly;'.
|
||||||
|
' take a breather and post again in a few minutes.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$banned = common_config('profile', 'banned');
|
$banned = common_config('profile', 'banned');
|
||||||
|
|
||||||
if ( in_array($profile_id, $banned) || in_array($profile->nickname, $banned)) {
|
if ( in_array($profile_id, $banned) || in_array($profile->nickname, $banned)) {
|
||||||
common_log(LOG_WARNING, "Attempted post from banned user: $profile->nickname (user id = $profile_id).");
|
common_log(LOG_WARNING, "Attempted post from banned user: $profile->nickname (user id = $profile_id).");
|
||||||
return _('You are banned from posting notices on this site.');
|
throw new ClientException(_('You are banned from posting notices on this site.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$notice = new Notice();
|
$notice = new Notice();
|
||||||
@ -222,7 +222,7 @@ class Notice extends Memcached_DataObject
|
|||||||
|
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
common_log_db_error($notice, 'INSERT', __FILE__);
|
common_log_db_error($notice, 'INSERT', __FILE__);
|
||||||
return _('Problem saving notice.');
|
throw new ServerException(_('Problem saving notice.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update ID-dependent columns: URI, conversation
|
// Update ID-dependent columns: URI, conversation
|
||||||
@ -247,7 +247,7 @@ class Notice extends Memcached_DataObject
|
|||||||
if ($changed) {
|
if ($changed) {
|
||||||
if (!$notice->update($orig)) {
|
if (!$notice->update($orig)) {
|
||||||
common_log_db_error($notice, 'UPDATE', __FILE__);
|
common_log_db_error($notice, 'UPDATE', __FILE__);
|
||||||
return _('Problem saving notice.');
|
throw new ServerException(_('Problem saving notice.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,28 +46,28 @@ require_once INSTALLDIR.'/lib/error.php';
|
|||||||
*/
|
*/
|
||||||
class ClientErrorAction extends ErrorAction
|
class ClientErrorAction extends ErrorAction
|
||||||
{
|
{
|
||||||
|
static $status = array(400 => 'Bad Request',
|
||||||
|
401 => 'Unauthorized',
|
||||||
|
402 => 'Payment Required',
|
||||||
|
403 => 'Forbidden',
|
||||||
|
404 => 'Not Found',
|
||||||
|
405 => 'Method Not Allowed',
|
||||||
|
406 => 'Not Acceptable',
|
||||||
|
407 => 'Proxy Authentication Required',
|
||||||
|
408 => 'Request Timeout',
|
||||||
|
409 => 'Conflict',
|
||||||
|
410 => 'Gone',
|
||||||
|
411 => 'Length Required',
|
||||||
|
412 => 'Precondition Failed',
|
||||||
|
413 => 'Request Entity Too Large',
|
||||||
|
414 => 'Request-URI Too Long',
|
||||||
|
415 => 'Unsupported Media Type',
|
||||||
|
416 => 'Requested Range Not Satisfiable',
|
||||||
|
417 => 'Expectation Failed');
|
||||||
|
|
||||||
function __construct($message='Error', $code=400)
|
function __construct($message='Error', $code=400)
|
||||||
{
|
{
|
||||||
parent::__construct($message, $code);
|
parent::__construct($message, $code);
|
||||||
|
|
||||||
$this->status = array(400 => 'Bad Request',
|
|
||||||
401 => 'Unauthorized',
|
|
||||||
402 => 'Payment Required',
|
|
||||||
403 => 'Forbidden',
|
|
||||||
404 => 'Not Found',
|
|
||||||
405 => 'Method Not Allowed',
|
|
||||||
406 => 'Not Acceptable',
|
|
||||||
407 => 'Proxy Authentication Required',
|
|
||||||
408 => 'Request Timeout',
|
|
||||||
409 => 'Conflict',
|
|
||||||
410 => 'Gone',
|
|
||||||
411 => 'Length Required',
|
|
||||||
412 => 'Precondition Failed',
|
|
||||||
413 => 'Request Entity Too Large',
|
|
||||||
414 => 'Request-URI Too Long',
|
|
||||||
415 => 'Unsupported Media Type',
|
|
||||||
416 => 'Requested Range Not Satisfiable',
|
|
||||||
417 => 'Expectation Failed');
|
|
||||||
$this->default = 400;
|
$this->default = 400;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,9 +91,4 @@ class ClientErrorAction extends ErrorAction
|
|||||||
|
|
||||||
$this->showPage();
|
$this->showPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
function title()
|
|
||||||
{
|
|
||||||
return $this->status[$this->code];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -44,9 +44,10 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
|||||||
*/
|
*/
|
||||||
class ErrorAction extends Action
|
class ErrorAction extends Action
|
||||||
{
|
{
|
||||||
|
static $status = array();
|
||||||
|
|
||||||
var $code = null;
|
var $code = null;
|
||||||
var $message = null;
|
var $message = null;
|
||||||
var $status = null;
|
|
||||||
var $default = null;
|
var $default = null;
|
||||||
|
|
||||||
function __construct($message, $code, $output='php://output', $indent=true)
|
function __construct($message, $code, $output='php://output', $indent=true)
|
||||||
@ -88,9 +89,10 @@ class ErrorAction extends Action
|
|||||||
*
|
*
|
||||||
* @return page title
|
* @return page title
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function title()
|
function title()
|
||||||
{
|
{
|
||||||
return $this->message;
|
return self::$status[$this->code];
|
||||||
}
|
}
|
||||||
|
|
||||||
function isReadOnly($args)
|
function isReadOnly($args)
|
||||||
|
@ -468,11 +468,11 @@ class FacebookAction extends Action
|
|||||||
|
|
||||||
$replyto = $this->trimmed('inreplyto');
|
$replyto = $this->trimmed('inreplyto');
|
||||||
|
|
||||||
$notice = Notice::saveNew($user->id, $content,
|
try {
|
||||||
'web', 1, ($replyto == 'false') ? null : $replyto);
|
$notice = Notice::saveNew($user->id, $content,
|
||||||
|
'web', 1, ($replyto == 'false') ? null : $replyto);
|
||||||
if (is_string($notice)) {
|
} catch (Exception $e) {
|
||||||
$this->showPage($notice);
|
$this->showPage($e->getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +156,6 @@ class StatusNetOAuthDataStore extends OAuthDataStore
|
|||||||
return $this->new_access_token($consumer);
|
return $this->new_access_token($consumer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Revoke specified OAuth token
|
* Revoke specified OAuth token
|
||||||
*
|
*
|
||||||
@ -363,9 +362,7 @@ class StatusNetOAuthDataStore extends OAuthDataStore
|
|||||||
false,
|
false,
|
||||||
null,
|
null,
|
||||||
$omb_notice->getIdentifierURI());
|
$omb_notice->getIdentifierURI());
|
||||||
if (is_string($notice)) {
|
|
||||||
throw new Exception($notice);
|
|
||||||
}
|
|
||||||
common_broadcast_notice($notice, true);
|
common_broadcast_notice($notice, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,17 +55,17 @@ require_once INSTALLDIR.'/lib/error.php';
|
|||||||
|
|
||||||
class ServerErrorAction extends ErrorAction
|
class ServerErrorAction extends ErrorAction
|
||||||
{
|
{
|
||||||
|
static $status = array(500 => 'Internal Server Error',
|
||||||
|
501 => 'Not Implemented',
|
||||||
|
502 => 'Bad Gateway',
|
||||||
|
503 => 'Service Unavailable',
|
||||||
|
504 => 'Gateway Timeout',
|
||||||
|
505 => 'HTTP Version Not Supported');
|
||||||
|
|
||||||
function __construct($message='Error', $code=500)
|
function __construct($message='Error', $code=500)
|
||||||
{
|
{
|
||||||
parent::__construct($message, $code);
|
parent::__construct($message, $code);
|
||||||
|
|
||||||
$this->status = array(500 => 'Internal Server Error',
|
|
||||||
501 => 'Not Implemented',
|
|
||||||
502 => 'Bad Gateway',
|
|
||||||
503 => 'Service Unavailable',
|
|
||||||
504 => 'Gateway Timeout',
|
|
||||||
505 => 'HTTP Version Not Supported');
|
|
||||||
|
|
||||||
$this->default = 500;
|
$this->default = 500;
|
||||||
|
|
||||||
// Server errors must be logged.
|
// Server errors must be logged.
|
||||||
@ -93,9 +93,4 @@ class ServerErrorAction extends ErrorAction
|
|||||||
|
|
||||||
$this->showPage();
|
$this->showPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
function title()
|
|
||||||
{
|
|
||||||
return $this->status[$this->code];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -502,7 +502,7 @@ class TwitterapiAction extends Action
|
|||||||
$enclosure = $entry['enclosures'][0];
|
$enclosure = $entry['enclosures'][0];
|
||||||
$this->element('enclosure', array('url'=>$enclosure['url'],'type'=>$enclosure['mimetype'],'length'=>$enclosure['size']), null);
|
$this->element('enclosure', array('url'=>$enclosure['url'],'type'=>$enclosure['mimetype'],'length'=>$enclosure['size']), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(array_key_exists('tags', $entry)){
|
if(array_key_exists('tags', $entry)){
|
||||||
foreach($entry['tags'] as $tag){
|
foreach($entry['tags'] as $tag){
|
||||||
$this->element('category', null,$tag);
|
$this->element('category', null,$tag);
|
||||||
@ -936,35 +936,16 @@ class TwitterapiAction extends Action
|
|||||||
|
|
||||||
function clientError($msg, $code = 400, $content_type = 'json')
|
function clientError($msg, $code = 400, $content_type = 'json')
|
||||||
{
|
{
|
||||||
|
|
||||||
static $status = array(400 => 'Bad Request',
|
|
||||||
401 => 'Unauthorized',
|
|
||||||
402 => 'Payment Required',
|
|
||||||
403 => 'Forbidden',
|
|
||||||
404 => 'Not Found',
|
|
||||||
405 => 'Method Not Allowed',
|
|
||||||
406 => 'Not Acceptable',
|
|
||||||
407 => 'Proxy Authentication Required',
|
|
||||||
408 => 'Request Timeout',
|
|
||||||
409 => 'Conflict',
|
|
||||||
410 => 'Gone',
|
|
||||||
411 => 'Length Required',
|
|
||||||
412 => 'Precondition Failed',
|
|
||||||
413 => 'Request Entity Too Large',
|
|
||||||
414 => 'Request-URI Too Long',
|
|
||||||
415 => 'Unsupported Media Type',
|
|
||||||
416 => 'Requested Range Not Satisfiable',
|
|
||||||
417 => 'Expectation Failed');
|
|
||||||
|
|
||||||
$action = $this->trimmed('action');
|
$action = $this->trimmed('action');
|
||||||
|
|
||||||
common_debug("User error '$code' on '$action': $msg", __FILE__);
|
common_debug("User error '$code' on '$action': $msg", __FILE__);
|
||||||
|
|
||||||
if (!array_key_exists($code, $status)) {
|
if (!array_key_exists($code, ClientErrorAction::$status)) {
|
||||||
$code = 400;
|
$code = 400;
|
||||||
}
|
}
|
||||||
|
|
||||||
$status_string = $status[$code];
|
$status_string = ClientErrorAction::$status[$code];
|
||||||
|
|
||||||
header('HTTP/1.1 '.$code.' '.$status_string);
|
header('HTTP/1.1 '.$code.' '.$status_string);
|
||||||
|
|
||||||
if ($content_type == 'xml') {
|
if ($content_type == 'xml') {
|
||||||
@ -983,6 +964,35 @@ class TwitterapiAction extends Action
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function serverError($msg, $code = 500, $content_type = 'json')
|
||||||
|
{
|
||||||
|
$action = $this->trimmed('action');
|
||||||
|
|
||||||
|
common_debug("Server error '$code' on '$action': $msg", __FILE__);
|
||||||
|
|
||||||
|
if (!array_key_exists($code, ServerErrorAction::$status)) {
|
||||||
|
$code = 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
$status_string = ServerErrorAction::$status[$code];
|
||||||
|
|
||||||
|
header('HTTP/1.1 '.$code.' '.$status_string);
|
||||||
|
|
||||||
|
if ($content_type == 'xml') {
|
||||||
|
$this->init_document('xml');
|
||||||
|
$this->elementStart('hash');
|
||||||
|
$this->element('error', null, $msg);
|
||||||
|
$this->element('request', null, $_SERVER['REQUEST_URI']);
|
||||||
|
$this->elementEnd('hash');
|
||||||
|
$this->end_document('xml');
|
||||||
|
} else {
|
||||||
|
$this->init_document('json');
|
||||||
|
$error_array = array('error' => $msg, 'request' => $_SERVER['REQUEST_URI']);
|
||||||
|
print(json_encode($error_array));
|
||||||
|
$this->end_document('json');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function init_twitter_rss()
|
function init_twitter_rss()
|
||||||
{
|
{
|
||||||
$this->startXML();
|
$this->startXML();
|
||||||
|
@ -125,7 +125,7 @@ RealtimeUpdate = {
|
|||||||
|
|
||||||
addPopup: function(url, timeline, iconurl)
|
addPopup: function(url, timeline, iconurl)
|
||||||
{
|
{
|
||||||
$('#content').prepend('<button id="realtime_timeline" title="Realtime window">Realtime</button>');
|
$('#content').prepend('<button id="realtime_timeline" title="Pop up in a window">Pop up</button>');
|
||||||
|
|
||||||
$('#realtime_timeline').css({
|
$('#realtime_timeline').css({
|
||||||
'margin':'0 0 18px 0',
|
'margin':'0 0 18px 0',
|
||||||
|
@ -260,10 +260,11 @@ class MailerDaemon
|
|||||||
|
|
||||||
function add_notice($user, $msg, $fileRecords)
|
function add_notice($user, $msg, $fileRecords)
|
||||||
{
|
{
|
||||||
$notice = Notice::saveNew($user->id, $msg, 'mail');
|
try {
|
||||||
if (is_string($notice)) {
|
$notice = Notice::saveNew($user->id, $msg, 'mail');
|
||||||
$this->log(LOG_ERR, $notice);
|
} catch (Exception $e) {
|
||||||
return $notice;
|
$this->log(LOG_ERR, $e->getMessage());
|
||||||
|
return $e->getMessage();
|
||||||
}
|
}
|
||||||
foreach($fileRecords as $fileRecord){
|
foreach($fileRecords as $fileRecord){
|
||||||
$this->attachFile($notice, $fileRecord);
|
$this->attachFile($notice, $fileRecord);
|
||||||
|
@ -323,12 +323,15 @@ class XMPPDaemon extends Daemon
|
|||||||
mb_strlen($content_shortened)));
|
mb_strlen($content_shortened)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$notice = Notice::saveNew($user->id, $content_shortened, 'xmpp');
|
|
||||||
if (is_string($notice)) {
|
try {
|
||||||
$this->log(LOG_ERR, $notice);
|
$notice = Notice::saveNew($user->id, $content_shortened, 'xmpp');
|
||||||
$this->from_site($user->jabber, $notice);
|
} catch (Exception $e) {
|
||||||
|
$this->log(LOG_ERR, $e->getMessage());
|
||||||
|
$this->from_site($user->jabber, $e->getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
common_broadcast_notice($notice);
|
common_broadcast_notice($notice);
|
||||||
$this->log(LOG_INFO,
|
$this->log(LOG_INFO,
|
||||||
'Added notice ' . $notice->id . ' from user ' . $user->nickname);
|
'Added notice ' . $notice->id . ' from user ' . $user->nickname);
|
||||||
|
Loading…
Reference in New Issue
Block a user