]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Comet/CometPlugin.php
Updated default theme to use the CSS Sprites method for common icons
[quix0rs-gnu-social.git] / plugins / Comet / CometPlugin.php
index 3e4f493b6523e0e5d86fe3a866a2340a140c428f..300d1e9a2488e7430becd87e7c5f0a95cafae092 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Laconica, the distributed open-source microblogging tool
+ * StatusNet, the distributed open-source microblogging tool
  *
  * Plugin to do "real time" updates using Comet/Bayeux
  *
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  * @category  Plugin
- * @package   Laconica
- * @author    Evan Prodromou <evan@controlyourself.ca>
- * @copyright 2009 Control Yourself, Inc.
+ * @package   StatusNet
+ * @author    Evan Prodromou <evan@status.net>
+ * @copyright 2009 StatusNet, Inc.
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link      http://laconi.ca/
+ * @link      http://status.net/
  */
 
-if (!defined('LACONICA')) {
+if (!defined('STATUSNET') && !defined('LACONICA')) {
     exit(1);
 }
 
@@ -37,10 +37,10 @@ require_once INSTALLDIR.'/plugins/Realtime/RealtimePlugin.php';
  * Plugin to do realtime updates using Comet
  *
  * @category Plugin
- * @package  Laconica
- * @author   Evan Prodromou <evan@controlyourself.ca>
+ * @package  StatusNet
+ * @author   Evan Prodromou <evan@status.net>
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link     http://laconi.ca/
+ * @link     http://status.net/
  */
 
 class CometPlugin extends RealtimePlugin
@@ -48,13 +48,15 @@ class CometPlugin extends RealtimePlugin
     public $server   = null;
     public $username = null;
     public $password = null;
+    public $prefix   = null;
     protected $bay   = null;
 
-    function __construct($server=null, $username=null, $password=null)
+    function __construct($server=null, $username=null, $password=null, $prefix=null)
     {
         $this->server   = $server;
         $this->username = $username;
         $this->password = $password;
+        $this->prefix   = $prefix;
 
         parent::__construct();
     }
@@ -74,11 +76,13 @@ class CometPlugin extends RealtimePlugin
 
     function _updateInitialize($timeline, $user_id)
     {
-        return "CometUpdate.init(\"$this->server\", \"$timeline\", $user_id, \"$this->replyurl\", \"$this->favorurl\", \"$this->deleteurl\");";
+        $script = parent::_updateInitialize($timeline, $user_id);
+        return $script." CometUpdate.init(\"$this->server\", \"$timeline\", $user_id, \"$this->replyurl\", \"$this->favorurl\", \"$this->deleteurl\");";
     }
 
     function _connect()
     {
+        require_once INSTALLDIR.'/plugins/Comet/bayeux.class.inc.php';
         // Bayeux? Comet? Huh? These terms confuse me
         $this->bay = new Bayeux($this->server, $this->user, $this->password);
     }
@@ -92,4 +96,12 @@ class CometPlugin extends RealtimePlugin
     {
         unset($this->bay);
     }
+
+    function _pathToChannel($path)
+    {
+        if (!empty($this->prefix)) {
+            array_unshift($path, $this->prefix);
+        }
+        return '/' . implode('/', $path);
+    }
 }