We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 6a1afda2 authored by Evan Prodromou's avatar Evan Prodromou

Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x

Conflicts:
	classes/statusnet.ini
parents d59af029 75c00f00
......@@ -92,7 +92,7 @@ class ApiGroupIsMemberAction extends ApiBareAuthAction
}
if (empty($this->group)) {
$this->clientError('Group not found!', 404, $this->format);
$this->clientError(_('Group not found!'), 404, $this->format);
return false;
}
......
......@@ -101,7 +101,7 @@ class ApiGroupJoinAction extends ApiAuthAction
}
if (empty($this->group)) {
$this->clientError('Group not found!', 404, $this->format);
$this->clientError(_('Group not found!'), 404, $this->format);
return false;
}
......
......@@ -101,7 +101,7 @@ class ApiGroupLeaveAction extends ApiAuthAction
}
if (empty($this->group)) {
$this->clientError('Group not found!', 404, $this->format);
$this->clientError(_('Group not found!'), 404, $this->format);
return false;
}
......
......@@ -87,6 +87,11 @@ class ApiGroupMembershipAction extends ApiPrivateAuthAction
{
parent::handle($args);
if (empty($this->group)) {
$this->clientError(_('Group not found!'), 404, $this->format);
return false;
}
// XXX: RSS and Atom
switch($this->format) {
......
......@@ -87,7 +87,7 @@ class ApiGroupShowAction extends ApiPrivateAuthAction
if (empty($this->group)) {
$this->clientError(
'Group not found!',
_('Group not found!'),
404,
$this->format
);
......
......@@ -69,7 +69,6 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
parent::prepare($args);
$this->group = $this->getTargetGroup($this->arg('id'));
$this->notices = $this->getNotices();
return true;
}
......@@ -87,6 +86,13 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
function handle($args)
{
parent::handle($args);
if (empty($this->group)) {
$this->clientError(_('Group not found!'), 404, $this->format);
return false;
}
$this->notices = $this->getNotices();
$this->showTimeline();
}
......
......@@ -74,8 +74,11 @@ class UserbyidAction extends Action
$this->clientError(_('No such user.'));
}
// support redirecting to FOAF rdf/xml if the agent prefers it
$page_prefs = 'application/rdf+xml,text/html,application/xhtml+xml,application/xml;q=0.3,text/xml;q=0.2';
// Support redirecting to FOAF rdf/xml if the agent prefers it...
// Internet Explorer doesn't specify "text/html" and does list "*/*"
// at least through version 8. We need to list text/html up front to
// ensure that only user-agents who specifically ask for RDF get it.
$page_prefs = 'text/html,application/xhtml+xml,application/rdf+xml,application/xml;q=0.3,text/xml;q=0.2';
$httpaccept = isset($_SERVER['HTTP_ACCEPT'])
? $_SERVER['HTTP_ACCEPT'] : null;
$type = common_negotiate_type(common_accept_to_prefs($httpaccept),
......
<?php
/*
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2008, 2009, StatusNet, Inc.
*
* 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/>.
*/
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
abstract class Plugin_DataObject extends Memcached_DataObject
{
function table() {
static $table = null;
if($table == null) {
$table = array();
$DB = $this->getDatabaseConnection();
$dbtype = $DB->phptype;
$tableDef = $this->tableDef();
foreach($tableDef->columns as $columnDef){
switch(strtoupper($columnDef->type)) {
/*shamelessly copied from DB_DataObject_Generator*/
case 'INT':
case 'INT2': // postgres
case 'INT4': // postgres
case 'INT8': // postgres
case 'SERIAL4': // postgres
case 'SERIAL8': // postgres
case 'INTEGER':
case 'TINYINT':
case 'SMALLINT':
case 'MEDIUMINT':
case 'BIGINT':
$type = DB_DATAOBJECT_INT;
if ($columnDef->size == 1) {
$type += DB_DATAOBJECT_BOOL;
}
break;
case 'REAL':
case 'DOUBLE':
case 'DOUBLE PRECISION': // double precision (firebird)
case 'FLOAT':
case 'FLOAT4': // real (postgres)
case 'FLOAT8': // double precision (postgres)
case 'DECIMAL':
case 'MONEY': // mssql and maybe others
case 'NUMERIC':
case 'NUMBER': // oci8
$type = DB_DATAOBJECT_INT; // should really by FLOAT!!! / MONEY...
break;
case 'YEAR':
$type = DB_DATAOBJECT_INT;
break;
case 'BIT':
case 'BOOL':
case 'BOOLEAN':
$type = DB_DATAOBJECT_BOOL;
// postgres needs to quote '0'
if ($dbtype == 'pgsql') {
$type += DB_DATAOBJECT_STR;
}
break;
case 'STRING':
case 'CHAR':
case 'VARCHAR':
case 'VARCHAR2':
case 'TINYTEXT':
case 'ENUM':
case 'SET': // not really but oh well
case 'POINT': // mysql geometry stuff - not really string - but will do..
case 'TIMESTAMPTZ': // postgres
case 'BPCHAR': // postgres
case 'INTERVAL': // postgres (eg. '12 days')
case 'CIDR': // postgres IP net spec
case 'INET': // postgres IP
case 'MACADDR': // postgress network Mac address.
case 'INTEGER[]': // postgres type
case 'BOOLEAN[]': // postgres type
$type = DB_DATAOBJECT_STR;
break;
case 'TEXT':
case 'MEDIUMTEXT':
case 'LONGTEXT':
$type = DB_DATAOBJECT_STR + DB_DATAOBJECT_TXT;
break;
case 'DATE':
$type = DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE;
break;
case 'TIME':
$type = DB_DATAOBJECT_STR + DB_DATAOBJECT_TIME;
break;
case 'DATETIME':
$type = DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME;
break;
case 'TIMESTAMP': // do other databases use this???
$type = ($dbtype == 'mysql') ?
DB_DATAOBJECT_MYSQLTIMESTAMP :
DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME;
break;
case 'BLOB': /// these should really be ignored!!!???
case 'TINYBLOB':
case 'MEDIUMBLOB':
case 'LONGBLOB':
case 'CLOB': // oracle character lob support
case 'BYTEA': // postgres blob support..
$type = DB_DATAOBJECT_STR + DB_DATAOBJECT_BLOB;
break;
default:
throw new Exception("Cannot handle datatype: $columnDef->type");
}
if(! $columnDef->nullable) {
$type+=DB_DATAOBJECT_NOTNULL;
}
$table[$columnDef->name]=$type;
}
}
return $table;
}
function keys() {
static $keys = null;
if($keys == null) {
$keys = array();
$tableDef = $this->tableDef();
foreach($tableDef->columns as $columnDef){
if($columnDef->key != null){
$keys[] = $columnDef->name;
}
}
}
return $keys;
}
function sequenceKey() {
static $sequenceKey = null;
if($sequenceKey == null) {
$sequenceKey = array(false,false);
$tableDef = $this->tableDef();
foreach($tableDef->columns as $columnDef){
if($columnDef->key == 'PRI' && $columnDef->auto_increment){
$sequenceKey=array($columnDef->name,true);
}
}
}
return $sequenceKey;
}
/**
* Get the TableDef object that represents the table backing this class
* Ideally, this function would a static function, but PHP doesn't allow
* abstract static functions
* @return TableDef TableDef instance
*/
abstract function tableDef();
}
......@@ -310,10 +310,12 @@ class Profile extends Memcached_DataObject
'AND subscription.subscribed != subscription.subscriber ' .
'ORDER BY subscription.created DESC ';
if (common_config('db','type') == 'pgsql') {
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
if ($offset>0 && !is_null($limit)){
if (common_config('db','type') == 'pgsql') {
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
}
}
$profile = new Profile();
......@@ -333,11 +335,13 @@ class Profile extends Memcached_DataObject
'AND subscription.subscribed != subscription.subscriber ' .
'ORDER BY subscription.created DESC ';
if ($offset) {
if (common_config('db','type') == 'pgsql') {
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
if ($offset>0 && !is_null($limit)){
if ($offset) {
if (common_config('db','type') == 'pgsql') {
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
}
}
}
......
......@@ -577,11 +577,13 @@ class User extends Memcached_DataObject
'WHERE group_member.profile_id = %d ' .
'ORDER BY group_member.created DESC ';
if ($offset) {
if (common_config('db','type') == 'pgsql') {
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
if ($offset>0 && !is_null($limit)) {
if ($offset) {
if (common_config('db','type') == 'pgsql') {
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
}
}
}
......
......@@ -542,4 +542,4 @@ created = 142
modified = 384
[user_group__keys]
id = N
id = N
\ No newline at end of file
......@@ -746,7 +746,7 @@ class PEAR
{
if (!extension_loaded($ext)) {
// if either returns true dl() will produce a FATAL error, stop that
if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1) || !function_exists('dl')) {
if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1)) {
return false;
}
if (OS_WINDOWS) {
......
......@@ -66,12 +66,13 @@ class Stomp
protected $_sessionId;
protected $_read_timeout_seconds = 60;
protected $_read_timeout_milliseconds = 0;
protected $_connect_timeout_seconds = 60;
/**
* Constructor
*
* @param string $brokerUri Broker URL
* @throws Stomp_Exception
* @throws StompException
*/
public function __construct ($brokerUri)
{
......@@ -81,7 +82,7 @@ class Stomp
/**
* Initialize connection
*
* @throws Stomp_Exception
* @throws StompException
*/
protected function _init ()
{
......@@ -103,14 +104,14 @@ class Stomp
}
} else {
require_once 'Stomp/Exception.php';
throw new Stomp_Exception("Bad Broker URL {$this->_brokerUri}");
throw new StompException("Bad Broker URL {$this->_brokerUri}");
}
}
/**
* Process broker URL
*
* @param string $url Broker URL
* @throws Stomp_Exception
* @throws StompException
* @return boolean
*/
protected function _processUrl ($url)
......@@ -120,19 +121,19 @@ class Stomp
array_push($this->_hosts, array($parsed['host'] , $parsed['port'] , $parsed['scheme']));
} else {
require_once 'Stomp/Exception.php';
throw new Stomp_Exception("Bad Broker URL $url");
throw new StompException("Bad Broker URL $url");
}
}
/**
* Make socket connection to the server
*
* @throws Stomp_Exception
* @throws StompException
*/
protected function _makeConnection ()
{
if (count($this->_hosts) == 0) {
require_once 'Stomp/Exception.php';
throw new Stomp_Exception("No broker defined");
throw new StompException("No broker defined");
}
// force disconnect, if previous established connection exists
......@@ -141,6 +142,9 @@ class Stomp
$i = $this->_currentHost;
$att = 0;
$connected = false;
$connect_errno = null;
$connect_errstr = null;
while (! $connected && $att ++ < $this->_attempts) {
if (isset($this->_params['randomize']) && $this->_params['randomize'] == 'true') {
$i = rand(0, count($this->_hosts) - 1);
......@@ -158,10 +162,10 @@ class Stomp
fclose($this->_socket);
$this->_socket = null;
}
$this->_socket = @fsockopen($scheme . '://' . $host, $port);
$this->_socket = @fsockopen($scheme . '://' . $host, $port, $connect_errno, $connect_errstr, $this->_connect_timeout_seconds);
if (!is_resource($this->_socket) && $att >= $this->_attempts && !array_key_exists($i + 1, $this->_hosts)) {
require_once 'Stomp/Exception.php';
throw new Stomp_Exception("Could not connect to $host:$port ($att/{$this->_attempts})");
throw new StompException("Could not connect to $host:$port ($att/{$this->_attempts})");
} else if (is_resource($this->_socket)) {
$connected = true;
$this->_currentHost = $i;
......@@ -170,7 +174,7 @@ class Stomp
}
if (! $connected) {
require_once 'Stomp/Exception.php';
throw new Stomp_Exception("Could not connect to a broker");
throw new StompException("Could not connect to a broker");
}
}
/**
......@@ -179,7 +183,7 @@ class Stomp
* @param string $username
* @param string $password
* @return boolean
* @throws Stomp_Exception
* @throws StompException
*/
public function connect ($username = '', $password = '')
{
......@@ -194,18 +198,18 @@ class Stomp
if ($this->clientId != null) {
$headers["client-id"] = $this->clientId;
}
$frame = new Stomp_Frame("CONNECT", $headers);
$frame = new StompFrame("CONNECT", $headers);
$this->_writeFrame($frame);
$frame = $this->readFrame();
if ($frame instanceof Stomp_Frame && $frame->command == 'CONNECTED') {
if ($frame instanceof StompFrame && $frame->command == 'CONNECTED') {
$this->_sessionId = $frame->headers["session"];
return true;
} else {
require_once 'Stomp/Exception.php';
if ($frame instanceof Stomp_Frame) {
throw new Stomp_Exception("Unexpected command: {$frame->command}", 0, $frame->body);
if ($frame instanceof StompFrame) {
throw new StompException("Unexpected command: {$frame->command}", 0, $frame->body);
} else {
throw new Stomp_Exception("Connection not acknowledged");
throw new StompException("Connection not acknowledged");
}
}
}
......@@ -232,21 +236,21 @@ class Stomp
* Send a message to a destination in the messaging system
*
* @param string $destination Destination queue
* @param string|Stomp_Frame $msg Message
* @param string|StompFrame $msg Message
* @param array $properties
* @param boolean $sync Perform request synchronously
* @return boolean
*/
public function send ($destination, $msg, $properties = null, $sync = null)
public function send ($destination, $msg, $properties = array(), $sync = null)
{
if ($msg instanceof Stomp_Frame) {
if ($msg instanceof StompFrame) {
$msg->headers['destination'] = $destination;
$msg->headers = array_merge($msg->headers, $properties);
if (is_array($properties)) $msg->headers = array_merge($msg->headers, $properties);
$frame = $msg;
} else {
$headers = $properties;
$headers['destination'] = $destination;
$frame = new Stomp_Frame('SEND', $headers, $msg);
$frame = new StompFrame('SEND', $headers, $msg);
}
$this->_prepareReceipt($frame, $sync);
$this->_writeFrame($frame);
......@@ -255,10 +259,10 @@ class Stomp
/**
* Prepair frame receipt
*
* @param Stomp_Frame $frame
* @param StompFrame $frame
* @param boolean $sync
*/
protected function _prepareReceipt (Stomp_Frame $frame, $sync)
protected function _prepareReceipt (StompFrame $frame, $sync)
{
$receive = $this->sync;
if ($sync !== null) {
......@@ -271,12 +275,12 @@ class Stomp
/**
* Wait for receipt
*
* @param Stomp_Frame $frame
* @param StompFrame $frame
* @param boolean $sync
* @return boolean
* @throws Stomp_Exception
* @throws StompException
*/
protected function _waitForReceipt (Stomp_Frame $frame, $sync)
protected function _waitForReceipt (StompFrame $frame, $sync)
{
$receive = $this->sync;
......@@ -289,19 +293,19 @@ class Stomp
return true;
}
$frame = $this->readFrame();
if ($frame instanceof Stomp_Frame && $frame->command == 'RECEIPT') {
if ($frame instanceof StompFrame && $frame->command == 'RECEIPT') {
if ($frame->headers['receipt-id'] == $id) {
return true;
} else {
require_once 'Stomp/Exception.php';
throw new Stomp_Exception("Unexpected receipt id {$frame->headers['receipt-id']}", 0, $frame->body);
throw new StompException("Unexpected receipt id {$frame->headers['receipt-id']}", 0, $frame->body);
}
} else {
require_once 'Stomp/Exception.php';
if ($frame instanceof Stomp_Frame) {
throw new Stomp_Exception("Unexpected command {$frame->command}", 0, $frame->body);
if ($frame instanceof StompFrame) {
throw new StompException("Unexpected command {$frame->command}", 0, $frame->body);
} else {
throw new Stomp_Exception("Receipt not received");
throw new StompException("Receipt not received");
}
}
}
......@@ -314,7 +318,7 @@ class Stomp
* @param array $properties
* @param boolean $sync Perform request synchronously
* @return boolean
* @throws Stomp_Exception
* @throws StompException
*/
public function subscribe ($destination, $properties = null, $sync = null)
{
......@@ -329,7 +333,7 @@ class Stomp
}
}
$headers['destination'] = $destination;
$frame = new Stomp_Frame('SUBSCRIBE', $headers);
$frame = new StompFrame('SUBSCRIBE', $headers);
$this->_prepareReceipt($frame, $sync);
$this->_writeFrame($frame);
if ($this->_waitForReceipt($frame, $sync) == true) {
......@@ -346,7 +350,7 @@ class Stomp
* @param array $properties
* @param boolean $sync Perform request synchronously
* @return boolean
* @throws Stomp_Exception
* @throws StompException
*/
public function unsubscribe ($destination, $properties = null, $sync = null)
{
......@@ -357,7 +361,7 @@ class Stomp
}
}
$headers['destination'] = $destination;
$frame = new Stomp_Frame('UNSUBSCRIBE', $headers);
$frame = new StompFrame('UNSUBSCRIBE', $headers);
$this->_prepareReceipt($frame, $sync);
$this->_writeFrame($frame);
if ($this->_waitForReceipt($frame, $sync) == true) {
......@@ -373,7 +377,7 @@ class Stomp
* @param string $transactionId
* @param boolean $sync Perform request synchronously
* @return boolean
* @throws Stomp_Exception
* @throws StompException
*/
public function begin ($transactionId = null, $sync = null)
{
......@@ -381,7 +385,7 @@ class Stomp
if (isset($transactionId)) {
$headers['transaction'] = $transactionId;
}
$frame = new Stomp_Frame('BEGIN', $headers);
$frame = new StompFrame('BEGIN', $headers);
$this->_prepareReceipt($frame, $sync);
$this->_writeFrame($frame