X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FRSSCloud%2FRSSCloudPlugin.php;h=bba0be515d4e068959656e023e784b6c7cfde18c;hb=0f1fc36a05c8d858827718255bef20e8d0c0d3f6;hp=b9187d86c0fe0fa42d429c0d5f8cdd65cee18e5a;hpb=d091d061151749feddd3751f953f9bec48e382f2;p=quix0rs-gnu-social.git diff --git a/plugins/RSSCloud/RSSCloudPlugin.php b/plugins/RSSCloud/RSSCloudPlugin.php index b9187d86c0..bba0be515d 100644 --- a/plugins/RSSCloud/RSSCloudPlugin.php +++ b/plugins/RSSCloud/RSSCloudPlugin.php @@ -33,13 +33,35 @@ if (!defined('STATUSNET')) { define('RSSCLOUDPLUGIN_VERSION', '0.1'); +/** + * Plugin class for adding RSSCloud capabilities to StatusNet + * + * @category Plugin + * @package StatusNet + * @author Zach Copley + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + **/ + class RSSCloudPlugin extends Plugin { + /** + * Our friend, the constructor + * + * @return void + */ function __construct() { parent::__construct(); } + /** + * Setup the info for the subscription handler. Allow overriding + * to point at another cloud hub (not currently used). + * + * @return void + */ + function onInitializePlugin() { $this->domain = common_config('rsscloud', 'domain'); @@ -50,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']; @@ -61,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)) { @@ -78,42 +100,68 @@ 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; } + /** + * Automatically load the actions and libraries used by + * the RSSCloud plugin + * + * @param Class $cls the class + * + * @return boolean hook return + * + */ + function onAutoload($cls) { 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'; return false; - case 'RSSCloudNotifier': - include_once(INSTALLDIR . '/plugins/RSSCloud/RSSCloudNotifier.php'); + case 'RSSCloudQueueHandler': + include_once INSTALLDIR . '/plugins/RSSCloud/RSSCloudQueueHandler.php'; return false; - case 'RSSCloudRequestNotifyAction': - case 'LoggingAggregatorAction': - include_once(INSTALLDIR . '/plugins/RSSCloud/' . mb_substr($cls, 0, -6) . '.php'); + case 'RSSCloudRequestNotifyAction': + case 'LoggingAggregatorAction': + include_once INSTALLDIR . '/plugins/RSSCloud/' . + mb_substr($cls, 0, -6) . '.php'; return false; - default: + default: return true; } } + /** + * Add a element to the RSS feed (after the rss + * element is started). + * + * @param Action $action the ApiAction + * + * @return void + */ + function onStartApiRss($action) { - // XXX: Add RSS 1.0 user feeds - if (get_class($action) == 'ApiTimelineUserAction') { $attrs = array('domain' => $this->domain, @@ -141,51 +189,24 @@ class RSSCloudPlugin extends Plugin * * @return boolean hook return */ + function onStartEnqueueNotice($notice, &$transports) { - array_push($transports, 'rsscloud'); + if ($notice->isLocal()) { + array_push($transports, 'rsscloud'); + } return true; } /** - * broadcast the message when not using queuehandler - * - * @param Notice &$notice the notice - * @param array $queue destination queue + * Create the rsscloud_subscription table if it's not + * already in the DB * * @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 - * - * @return boolean locality - */ - function _isLocal($notice) + function onCheckSchema() { - return ($notice->is_local == Notice::LOCAL_PUBLIC || - $notice->is_local == Notice::LOCAL_NONPUBLIC); - } - - function onCheckSchema() { $schema = Schema::get(); $schema->ensureTable('rsscloud_subscription', array(new ColumnDef('subscribed', 'integer', @@ -200,10 +221,35 @@ class RSSCloudPlugin extends Plugin null, false, null, 'CURRENT_TIMESTAMP', 'on update CURRENT_TIMESTAMP') - ) - ); + )); return true; } -} + /** + * Register RSSCloud notice queue handler + * + * @param QueueManager $manager + * + * @return boolean hook return + */ + function onEndInitializeQueueManager($manager) + { + $manager->connect('rsscloud', 'RSSCloudQueueHandler'); + return true; + } + + function onPluginVersion(&$versions) + { + $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 ' . + 'RSSCloud protocol.')); + return true; + } + +}