]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/RSSCloud/RSSCloudPlugin.php
added readme
[quix0rs-gnu-social.git] / plugins / RSSCloud / RSSCloudPlugin.php
index 8c0bfa904017e3971a3ad86f360c7b0baf6f28dd..661c32141faedf7a3f23c4edf86036543b3365df 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,15 +100,20 @@ class RSSCloudPlugin extends Plugin
      *
      * Hook for RouterInitialized event.
      *
+     * @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'));
+        $m->connect('/main/rsscloud/request_notify',
+                    array('action' => 'RSSCloudRequestNotify'));
 
-        // XXX: This is just for end-to-end testing
-        $m->connect('/main/rsscloud/notify', array('action' => 'LoggingAggregator'));
+        // XXX: This is just for end-to-end testing. Uncomment if you need to pretend
+        //      to be a cloud hub for some reason.
+        //$m->connect('/main/rsscloud/notify',
+        //            array('action' => 'LoggingAggregator'));
 
         return true;
     }
@@ -125,17 +132,21 @@ class RSSCloudPlugin extends Plugin
     {
         switch ($cls)
         {
-         case 'RSSCloudSubscription':
-            include_once(INSTALLDIR . '/plugins/RSSCloud/RSSCloudSubscription.php');
+        case 'RSSCloudSubscription':
+            include_once INSTALLDIR . '/plugins/RSSCloud/RSSCloudSubscription.php';
             return false;
-         case 'RSSCloudNotifier':
-            include_once(INSTALLDIR . '/plugins/RSSCloud/RSSCloudNotifier.php');
+        case 'RSSCloudNotifier':
+            include_once INSTALLDIR . '/plugins/RSSCloud/RSSCloudNotifier.php';
             return false;
-         case 'RSSCloudRequestNotifyAction':
-         case 'LoggingAggregatorAction':
-            include_once(INSTALLDIR . '/plugins/RSSCloud/' . mb_substr($cls, 0, -6) . '.php');
+        case 'RSSCloudQueueHandler':
+            include_once INSTALLDIR . '/plugins/RSSCloud/RSSCloudQueueHandler.php';
             return false;
-         default:
+        case 'RSSCloudRequestNotifyAction':
+        case 'LoggingAggregatorAction':
+            include_once INSTALLDIR . '/plugins/RSSCloud/' .
+              mb_substr($cls, 0, -6) . '.php';
+            return false;
+        default:
             return true;
         }
     }
@@ -144,7 +155,7 @@ class RSSCloudPlugin extends Plugin
      * Add a <cloud> element to the RSS feed (after the rss <channel>
      * element is started).
      *
-     * @param Action $action
+     * @param Action $action the ApiAction
      *
      * @return void
      */
@@ -185,36 +196,10 @@ class RSSCloudPlugin extends Plugin
         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;
-        }
-
-        return true;
-    }
-
     /**
      * Determine whether the notice was locally created
      *
-     * @param Notice $notice
+     * @param Notice $notice the notice in question
      *
      * @return boolean locality
      */
@@ -232,7 +217,8 @@ class RSSCloudPlugin extends Plugin
      * @return boolean hook return
      */
 
-    function onCheckSchema() {
+    function onCheckSchema()
+    {
         $schema = Schema::get();
         $schema->ensureTable('rsscloud_subscription',
                              array(new ColumnDef('subscribed', 'integer',
@@ -247,25 +233,34 @@ class RSSCloudPlugin extends Plugin
                                                  null, false, null,
                                                  'CURRENT_TIMESTAMP',
                                                  'on update CURRENT_TIMESTAMP')
-                                  )
-                            );
+                                   ));
          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;
     }