]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/RSSCloud/RSSCloudPlugin.php
Merge remote branch 'gitorious/1.0.x' into 1.0.x
[quix0rs-gnu-social.git] / plugins / RSSCloud / RSSCloudPlugin.php
index db2cdd74d780d4085311138532954a852c2c6a1a..7d9c39a67da139c9fa093b63e4d7898a6ca266e6 100644 (file)
@@ -31,6 +31,8 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
+define('RSSCLOUDPLUGIN_VERSION', '0.1');
+
 /**
  * Plugin class for adding RSSCloud capabilities to StatusNet
  *
@@ -70,7 +72,7 @@ class RSSCloudPlugin extends Plugin
 
         // set defaults
 
-        $local_server = parse_url(common_path('/main/rsscloud/request_notify'));
+        $local_server = parse_url(common_path('main/rsscloud/request_notify'));
 
         if (empty($this->domain)) {
             $this->domain = $local_server['host'];
@@ -81,7 +83,7 @@ class RSSCloudPlugin extends Plugin
         }
 
         if (empty($this->path)) {
-            $this->path = '/main/rsscloud/request_notify';
+            $this->path = $local_server['path'];
         }
 
         if (empty($this->funct)) {
@@ -98,12 +100,12 @@ class RSSCloudPlugin extends Plugin
      *
      * Hook for RouterInitialized event.
      *
-     * @param Mapper &$m URL parser and mapper
+     * @param Mapper $m URL parser and mapper
      *
      * @return boolean hook return
      */
 
-    function onRouterInitialized(&$m)
+    function onRouterInitialized($m)
     {
         $m->connect('/main/rsscloud/request_notify',
                     array('action' => 'RSSCloudRequestNotify'));
@@ -136,6 +138,9 @@ class RSSCloudPlugin extends Plugin
         case 'RSSCloudNotifier':
             include_once INSTALLDIR . '/plugins/RSSCloud/RSSCloudNotifier.php';
             return false;
+        case 'RSSCloudQueueHandler':
+            include_once INSTALLDIR . '/plugins/RSSCloud/RSSCloudQueueHandler.php';
+            return false;
         case 'RSSCloudRequestNotifyAction':
         case 'LoggingAggregatorAction':
             include_once INSTALLDIR . '/plugins/RSSCloud/' .
@@ -187,50 +192,12 @@ class RSSCloudPlugin extends Plugin
 
     function onStartEnqueueNotice($notice, &$transports)
     {
-        array_push($transports, 'rsscloud');
-        return true;
-    }
-
-    /**
-     * broadcast the message when not using queuehandler
-     *
-     * @param Notice &$notice the notice
-     * @param array  $queue   destination queue
-     *
-     * @return boolean hook return
-     */
-
-    function onUnqueueHandleNotice(&$notice, $queue)
-    {
-        if (($queue == 'rsscloud') && ($this->_isLocal($notice))) {
-
-            common_debug('broadcasting rssCloud bound notice ' . $notice->id);
-
-            $profile = $notice->getProfile();
-
-            $notifier = new RSSCloudNotifier();
-            $notifier->notify($profile);
-
-            return false;
+        if ($notice->isLocal()) {
+            array_push($transports, 'rsscloud');
         }
-
         return true;
     }
 
-    /**
-     * Determine whether the notice was locally created
-     *
-     * @param Notice $notice the notice in question
-     *
-     * @return boolean locality
-     */
-
-    function _isLocal($notice)
-    {
-        return ($notice->is_local == Notice::LOCAL_PUBLIC ||
-                $notice->is_local == Notice::LOCAL_NONPUBLIC);
-    }
-
     /**
      * Create the rsscloud_subscription table if it's not
      * already in the DB
@@ -242,38 +209,44 @@ class RSSCloudPlugin extends Plugin
     {
         $schema = Schema::get();
         $schema->ensureTable('rsscloud_subscription',
-                             array(new ColumnDef('subscribed', 'integer',
-                                                 null, false, 'PRI'),
-                                   new ColumnDef('url', 'varchar',
-                                                 '255', false, 'PRI'),
-                                   new ColumnDef('failures', 'integer',
-                                                 null, false, null, 0),
-                                   new ColumnDef('created', 'datetime',
-                                                 null, false),
-                                   new ColumnDef('modified', 'timestamp',
-                                                 null, false, null,
-                                                 'CURRENT_TIMESTAMP',
-                                                 'on update CURRENT_TIMESTAMP')
-                                   ));
+            array(
+                'fields' => array(
+                    'subscribed' => array('type' => 'int', 'not null' => true),
+                    'url' => array('type' => 'varchar', 'length' => '255', 'not null' => true),
+                    'failures' => array('type' => 'int', 'not null' => true, 'default' => 0),
+                    'created' => array('type' => 'datetime', 'not null' => true),
+                    'modified' => array('type' => 'timestamp', 'not null' => true),
+                ),
+                'primary key' => array('subscribed', 'url'),
+            ));
          return true;
     }
 
     /**
-     * Add RSSCloudQueueHandler to the list of valid daemons to
-     * start
+     * Register RSSCloud notice queue handler
      *
-     * @param array $daemons the list of daemons to run
+     * @param QueueManager $manager
      *
      * @return boolean hook return
-     *
      */
+    function onEndInitializeQueueManager($manager)
+    {
+        $manager->connect('rsscloud', 'RSSCloudQueueHandler');
+        return true;
+    }
 
-    function onGetValidDaemons($daemons)
+    function onPluginVersion(&$versions)
     {
-        array_push($daemons, INSTALLDIR .
-                   '/plugins/RSSCloud/RSSCloudQueueHandler.php');
+        $versions[] = array('name' => 'RSSCloud',
+                            'version' => RSSCLOUDPLUGIN_VERSION,
+                            'author' => 'Zach Copley',
+                            'homepage' => 'http://status.net/wiki/Plugin:RSSCloud',
+                            'rawdescription' =>
+                            _m('The RSSCloud plugin enables your StatusNet instance to publish ' .
+                               'real-time updates for profile RSS feeds using the ' .
+                               '<a href="http://rsscloud.org/">RSSCloud protocol</a>.'));
+
         return true;
     }
 
 }
-