$this->showEmptyListMessage();
}
+ $args = array('nickname' => $this->user->nickname);
+ if (!empty($this->tag))
+ {
+ $args['tag'] = $this->tag;
+ }
$this->pagination($this->page>1, $cnt>NOTICES_PER_PAGE, $this->page,
- 'showstream', array('nickname' => $this->user->nickname));
+ 'showstream', $args);
}
function showAnonymousMessage()
$other = $this->get_profile($id);
$user = $apidata['user']; // Alwyas the auth user
+ if ($user->id == $other->id) {
+ $this->clientError(_("You cannot unfollow yourself!"),
+ 403, $apidata['content-type']);
+ return;
+ }
+
$sub = new Subscription();
$sub->subscriber = $user->id;
$sub->subscribed = $other->id;
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
- function &pkeyGet($kv)
- {
- return Memcached_DataObject::pkeyGet('Profile', $kv);
- }
-
function getAvatar($width, $height=null)
{
if (is_null($height)) {
('identichat','identichat','http://identichat.prosody.im/', 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()),
('LaTwit','LaTwit','http://latwit.mac65.com/', now()),
('LiveTweeter', 'LiveTweeter', 'http://addons.songbirdnest.com/addon/1204', now()),
('livetweeter', 'livetweeter', 'http://addons.songbirdnest.com/addon/1204', now()),
*
* @package Stomp
* @author Hiram Chirino <hiram@hiramchirino.com>
- * @author Dejan Bosanac <dejan@nighttale.net>
+ * @author Dejan Bosanac <dejan@nighttale.net>
* @author Michael Caplan <mcaplan@labnet.net>
* @version $Revision: 43 $
*/
*
* @var int
*/
- public $prefetchSize = 1;
-
- /**
+ public $prefetchSize = 1;
+
+ /**
* Client id used for durable subscriptions
*
* @var string
*/
- public $clientId = null;
-
+ public $clientId = null;
+
protected $_brokerUri = null;
protected $_socket = null;
protected $_hosts = array();
protected $_sessionId;
protected $_read_timeout_seconds = 60;
protected $_read_timeout_milliseconds = 0;
-
+
/**
* Constructor
*
require_once 'Stomp/Exception.php';
throw new Stomp_Exception("No broker defined");
}
-
+
// force disconnect, if previous established connection exists
$this->disconnect();
-
+
$i = $this->_currentHost;
$att = 0;
$connected = false;
if ($password != '') {
$this->_password = $password;
}
- $headers = array('login' => $this->_username , 'passcode' => $this->_password);
- if ($this->clientId != null) {
- $headers["client-id"] = $this->clientId;
- }
- $frame = new Stomp_Frame("CONNECT", $headers);
+ $headers = array('login' => $this->_username , 'passcode' => $this->_password);
+ if ($this->clientId != null) {
+ $headers["client-id"] = $this->clientId;
+ }
+ $frame = new Stomp_Frame("CONNECT", $headers);
$this->_writeFrame($frame);
$frame = $this->readFrame();
if ($frame instanceof Stomp_Frame && $frame->command == 'CONNECTED') {
}
}
}
-
+
/**
* Check if client session has ben established
*
return $this->_sessionId;
}
/**
- * Send a message to a destination in the messaging system
+ * Send a message to a destination in the messaging system
*
* @param string $destination Destination queue
* @param string|Stomp_Frame $msg Message
* @param boolean $sync Perform request synchronously
* @return boolean
*/
- public function send ($destination, $msg, $properties = array(), $sync = null)
+ public function send ($destination, $msg, $properties = null, $sync = null)
{
if ($msg instanceof Stomp_Frame) {
$msg->headers['destination'] = $destination;
public function subscribe ($destination, $properties = null, $sync = null)
{
$headers = array('ack' => 'client');
- // FIXME: this seems to be activemq specific, but not hurting rabbitmq?
- $headers['activemq.prefetchSize'] = $this->prefetchSize;
- if ($this->clientId != null) {
- // FIXME: this seems to be activemq specific, but not hurting rabbitmq?
- $headers["activemq.subcriptionName"] = $this->clientId;
- }
+ $headers['activemq.prefetchSize'] = $this->prefetchSize;
+ if ($this->clientId != null) {
+ $headers["activemq.subcriptionName"] = $this->clientId;
+ }
if (isset($properties)) {
foreach ($properties as $name => $value) {
$headers[$name] = $value;
}
/**
* Acknowledge consumption of a message from a subscription
- * Note: This operation is always asynchronous
+ * Note: This operation is always asynchronous
*
* @param string|Stomp_Frame $messageMessage ID
* @param string $transactionId
*/
public function ack ($message, $transactionId = null)
{
- // Handle the headers,
- $headers = array();
-
if ($message instanceof Stomp_Frame) {
- // Copy headers from the object
- // FIXME: at least content-length can be wrong here (set to 3 sometimes).
- $headers = $message->headers;
+ $frame = new Stomp_Frame('ACK', $message->headers);
+ $this->_writeFrame($frame);
+ return true;
} else {
+ $headers = array();
if (isset($transactionId)) {
$headers['transaction'] = $transactionId;
}
$headers['message-id'] = $message;
+ $frame = new Stomp_Frame('ACK', $headers);
+ $this->_writeFrame($frame);
+ return true;
}
- // An ACK has no content
- $headers['content-length'] = 0;
-
- // Create it and write it out
- $frame = new Stomp_Frame('ACK', $headers);
- $this->_writeFrame($frame);
- return true;
}
/**
* Graceful disconnect from the server
*/
public function disconnect ()
{
- $headers = array();
+ $headers = array();
- if ($this->clientId != null) {
- $headers["client-id"] = $this->clientId;
- }
+ if ($this->clientId != null) {
+ $headers["client-id"] = $this->clientId;
+ }
if (is_resource($this->_socket)) {
$this->_writeFrame(new Stomp_Frame('DISCONNECT', $headers));
$this->_writeFrame($stompFrame);
}
}
-
+
/**
* Set timeout to wait for content to read
*
* @param int $seconds_to_wait Seconds to wait for a frame
* @param int $milliseconds Milliseconds to wait for a frame
*/
- public function setReadTimeout($seconds, $milliseconds = 0)
+ public function setReadTimeout($seconds, $milliseconds = 0)
{
$this->_read_timeout_seconds = $seconds;
$this->_read_timeout_milliseconds = $milliseconds;
}
-
+
/**
* Read responce frame from server
*
if (!$this->hasFrameToRead()) {
return false;
}
-
+
$rb = 1024;
$data = '';
- do {
- $read = fread($this->_socket, $rb);
- if ($read === false) {
- $this->_reconnect();
- return $this->readFrame();
- }
- $data .= $read;
- $len = strlen($data);
-
- $continue = true;
- // ActiveMq apparently add \n after 0 char
- if($data[$len - 2] == "\x00" && $data[$len - 1] == "\n") {
- $continue = false;
- }
-
- // RabbitMq does not
- if($data[$len - 1] == "\x00") {
- $continue = false;
- }
- } while ( $continue );
+ do {
+ $read = fgets($this->_socket, $rb);
+ if ($read === false) {
+ $this->_reconnect();
+ return $this->readFrame();
+ }
+ $data .= $read;
+ $len = strlen($data);
+ } while (($len < 2 || ! ($data[$len - 2] == "\x00" && $data[$len - 1] == "\n")));
+
list ($header, $body) = explode("\n\n", $data, 2);
$header = explode("\n", $header);
$headers = array();
return $frame;
}
}
-
+
/**
* Check if there is a frame to read
*
$read = array($this->_socket);
$write = null;
$except = null;
-
+
$has_frame_to_read = stream_select($read, $write, $except, $this->_read_timeout_seconds, $this->_read_timeout_milliseconds);
if ($has_frame_to_read === false) {
} else if ($has_frame_to_read > 0) {
return true;
} else {
- return false;
+ return false;
}
}
-
+
/**
* Reconnects and renews subscriptions (if there were any)
- * Call this method when you detect connection problems
+ * Call this method when you detect connection problems
*/
protected function _reconnect ()
{
$subscriptions = $this->_subscriptions;
-
+
$this->connect($this->_username, $this->_password);
foreach ($subscriptions as $dest => $properties) {
$this->subscribe($dest, $properties);
*/
/* vim: set expandtab tabstop=3 shiftwidth=3: */
-
-/**
- * Stomp Frames are messages that are sent and received on a StompConnection.
- *
- * @package Stomp
- * @author Hiram Chirino <hiram@hiramchirino.com>
- * @author Dejan Bosanac <dejan@nighttale.net>
- * @author Michael Caplan <mcaplan@labnet.net>
- * @version $Revision: 36 $
- */
-class Stomp_Frame
-{
- public $command;
- public $headers = array();
- public $body;
-
- /**
- * Constructor
- *
- * @param string $command
- * @param array $headers
- * @param string $body
- */
- public function __construct ($command = null, $headers = null, $body = null)
- {
- $this->_init($command, $headers, $body);
- }
-
- protected function _init ($command = null, $headers = null, $body = null)
- {
- $this->command = $command;
- if ($headers != null) {
- $this->headers = $headers;
- }
- $this->body = $body;
-
- if ($this->command == 'ERROR') {
- require_once 'Stomp/Exception.php';
- throw new Stomp_Exception($this->headers['message'], 0, $this->body);
- }
+\r
+/**\r
+ * Stomp Frames are messages that are sent and received on a StompConnection.\r
+ *\r
+ * @package Stomp\r
+ * @author Hiram Chirino <hiram@hiramchirino.com>\r
+ * @author Dejan Bosanac <dejan@nighttale.net>\r
+ * @author Michael Caplan <mcaplan@labnet.net>\r
+ * @version $Revision: 36 $\r
+ */\r
+class Stomp_Frame\r
+{\r
+ public $command;\r
+ public $headers = array();\r
+ public $body;\r
+ \r
+ /**\r
+ * Constructor\r
+ *\r
+ * @param string $command\r
+ * @param array $headers\r
+ * @param string $body\r
+ */\r
+ public function __construct ($command = null, $headers = null, $body = null)\r
+ {\r
+ $this->_init($command, $headers, $body);\r
+ }\r
+ \r
+ protected function _init ($command = null, $headers = null, $body = null)\r
+ {\r
+ $this->command = $command;\r
+ if ($headers != null) {\r
+ $this->headers = $headers;\r
+ }\r
+ $this->body = $body;\r
+ \r
+ if ($this->command == 'ERROR') {\r
+ require_once 'Stomp/Exception.php';\r
+ throw new Stomp_Exception($this->headers['message'], 0, $this->body);\r
+ }\r
}
/**
$data .= "\n";
$data .= $this->body;
- $data .= "\x00\n"; // Should there really be a linefeed here?
- return $data;
- }
-}
+ return $data .= "\x00\n";
+ }\r
+}\r
?>
\ No newline at end of file
*/
class Stomp_Message extends Stomp_Frame
{
- public function __construct ($body, $headers = array())
+ public function __construct ($body, $headers = null)
{
- if(!isset($headers['content-length'])) {
- // TODO: log this, to see if this is correct
- $headers['content-length'] = strlen($body);
- }
$this->_init("SEND", $headers, $body);
}
}
!$etag ||
$this->_hasEtag($etag, $if_none_match)) {
header('HTTP/1.1 304 Not Modified');
- header('Content-Length: 0');
// Better way to do this?
exit(0);
}
header('ETag: ' . $etag);
if($if_none_match && $this->_hasEtag($etag, $if_none_match)) {
header('HTTP/1.1 304 Not Modified');
- header('Content-Length: 0');
// Better way to do this?
exit(0);
}
$this->con->ack($frame);
} else {
if ($handler->handle_notice($notice)) {
- $this->_log(LOG_INFO, 'Successfully handled notice '. $notice->id .' originally posted at ' . $notice->created . ' in queue '. $queue);
-
+ $this->_log(LOG_INFO, 'Successfully handled notice '. $notice->id .' posted at ' . $frame->headers['created'] . ' in queue '. $queue);
$this->con->ack($frame);
} else {
- $this->_log(LOG_WARNING, 'Failed handling notice '. $notice->id .' originally posted at ' . $notice->created . ' in queue '. $queue);
+ $this->_log(LOG_WARNING, 'Failed handling notice '. $notice->id .' posted at ' . $frame->headers['created'] . ' in queue '. $queue);
// FIXME we probably shouldn't have to do
// this kind of queue management ourselves
$this->con->ack($frame);
$user->whereAdd('nickname like \'' . trim($user->escape($q), '\'') . '%\'');
$user->find();
while($user->fetch()) {
- $profile = Profile::pkeyGet(array('id' => $user->id));
+ $profile = Profile::staticGet($user->id);
$this->results[]=array('nickname' => $user->nickname, 'fullname'=> $profile->fullname, 'type'=>'user');
}
}
class PiwikAnalyticsPlugin extends Plugin
{
/** the base of your Piwik installation */
- var $piwikroot = null;
+ public $piwikroot = null;
/** the Piwik Id of your statusnet installation */
- var $piwikId = null;
+ public $piwikId = null;
/**
* constructor
</script>
<script type="text/javascript">
try {
- var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", $this->piwikId);
+ var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", {$this->piwikId});
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
// add a notice encoded as JSON into the current timeline
//
+// TODO: i18n
RealtimeUpdate = {
-
_userid: 0,
_replyurl: '',
_favorurl: '',
"<p class=\"entry-content\">"+html+"</p>"+
"</div>"+
"<div class=\"entry-content\">"+
- "<dl class=\"timestamp\">"+
- "<dt>Published</dt>"+
- "<dd>"+
- "<a rel=\"bookmark\" href=\""+data['url']+"\" >"+
+ "<a class=\"timestamp\" rel=\"bookmark\" href=\""+data['url']+"\" >"+
"<abbr class=\"published\" title=\""+data['created_at']+"\">a few seconds ago</abbr>"+
"</a> "+
- "</dd>"+
- "</dl>"+
- "<dl class=\"device\">"+
- "<dt>From</dt> "+
- "<dd>"+source+"</dd>"+ // may have a link, I think
- "</dl>";
-
+ "<span class=\"source\">"+
+ "from "+
+ "<span class=\"device\">"+source+"</span>"+ // may have a link
+ "</span>";
if (data['in_reply_to_status_id']) {
- ni = ni+" <dl class=\"response\">"+
- "<dt>To</dt>"+
- "<dd>"+
- "<a href=\""+data['in_reply_to_status_url']+"\" rel=\"in-reply-to\">in reply to</a>"+
- "</dd>"+
- "</dl>";
+ ni = ni+" <a class=\"response\" href=\""+data['in_reply_to_status_url']+"\">in context</a>";
}
ni = ni+"</div>"+
ff = "<form id=\"favor-"+id+"\" class=\"form_favor\" method=\"post\" action=\""+RealtimeUpdate._favorurl+"\">"+
"<fieldset>"+
- "<legend>Favor this notice</legend>"+ // XXX: i18n
+ "<legend>Favor this notice</legend>"+
"<input name=\"token-"+id+"\" type=\"hidden\" id=\"token-"+id+"\" value=\""+session_key+"\"/>"+
"<input name=\"notice\" type=\"hidden\" id=\"notice-n"+id+"\" value=\""+id+"\"/>"+
"<input type=\"submit\" id=\"favor-submit-"+id+"\" name=\"favor-submit-"+id+"\" class=\"submit\" value=\"Favor\" title=\"Favor this notice\"/>"+
makeReplyLink: function(id, nickname)
{
var rl;
- rl = "<dl class=\"notice_reply\">"+
- "<dt>Reply to this notice</dt>"+
- "<dd>"+
- "<a href=\""+RealtimeUpdate._replyurl+"?replyto="+nickname+"\" title=\"Reply to this notice\">Reply <span class=\"notice_id\">"+id+"</span>"+
- "</a>"+
- "</dd>"+
- "</dl>";
+ rl = "<a class=\"notice_reply\" href=\""+RealtimeUpdate._replyurl+"?replyto="+nickname+"\" title=\"Reply to this notice\">Reply <span class=\"notice_id\">"+id+"</span></a>";
return rl;
},
var dl, delurl;
delurl = RealtimeUpdate._deleteurl.replace("0000000000", id);
- dl = "<dl class=\"notice_delete\">"+
- "<dt>Delete this notice</dt>"+
- "<dd>"+
- "<a href=\""+delurl+"\" title=\"Delete this notice\">Delete</a>"+
- "</dd>"+
- "</dl>";
+ dl = "<a class=\"notice_delete\" href=\""+delurl+"\" title=\"Delete this notice\">Delete</a>";
return dl;
},