diff options
author | Brion Vibber <brion@pobox.com> | 2010-01-25 09:07:24 -0800 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-01-25 09:07:24 -0800 |
commit | c10d5320dd5b308795c5a5bda2441fabfe278a84 (patch) | |
tree | 8b4ad2470a5411edf4ef2d9c72f14872d5861ae4 /plugins | |
parent | 73f6250b9d8a1f65bfcbf76b05f087bd6e118bea (diff) |
Disable PubSubHubBub hub pings automatically on private site (hub wouldn't be able to read feeds anyway)
[Might be good to think of a core way to mark a plugin as disabled when it initializes.]
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/PubSubHubBub/PubSubHubBubPlugin.php | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/plugins/PubSubHubBub/PubSubHubBubPlugin.php b/plugins/PubSubHubBub/PubSubHubBubPlugin.php index ce6086df9..a880dc866 100644 --- a/plugins/PubSubHubBub/PubSubHubBubPlugin.php +++ b/plugins/PubSubHubBub/PubSubHubBubPlugin.php @@ -80,6 +80,21 @@ class PubSubHubBubPlugin extends Plugin } /** + * Check if plugin should be active; may be mass-enabled. + * @return boolean + */ + + function enabled() + { + if (common_config('site', 'private')) { + // PuSH relies on public feeds + return false; + } + // @fixme check for being on a private network? + return true; + } + + /** * Hooks the StartApiAtom event * * Adds the necessary bits to advertise PubSubHubBub @@ -92,8 +107,9 @@ class PubSubHubBubPlugin extends Plugin function onStartApiAtom($action) { - $action->element('link', array('rel' => 'hub', 'href' => $this->hub), null); - + if ($this->enabled()) { + $action->element('link', array('rel' => 'hub', 'href' => $this->hub), null); + } return true; } @@ -110,9 +126,11 @@ class PubSubHubBubPlugin extends Plugin function onStartApiRss($action) { - $action->element('atom:link', array('rel' => 'hub', - 'href' => $this->hub), - null); + if ($this->enabled()) { + $action->element('atom:link', array('rel' => 'hub', + 'href' => $this->hub), + null); + } return true; } @@ -130,6 +148,9 @@ class PubSubHubBubPlugin extends Plugin function onHandleQueuedNotice($notice) { + if (!$this->enabled()) { + return false; + } $publisher = new Publisher($this->hub); $feeds = array(); @@ -243,16 +264,21 @@ class PubSubHubBubPlugin extends Plugin function onPluginVersion(&$versions) { + $about = _m('The PubSubHubBub plugin pushes RSS/Atom updates '. + 'to a <a href = "'. + 'http://pubsubhubbub.googlecode.com/'. + '">PubSubHubBub</a> hub.'); + if (!$this->enabled()) { + $about = '<span class="disabled" style="color:gray">' . $about . '</span> ' . + _m('(inactive on private site)'); + } $versions[] = array('name' => 'PubSubHubBub', 'version' => STATUSNET_VERSION, 'author' => 'Craig Andrews', 'homepage' => 'http://status.net/wiki/Plugin:PubSubHubBub', 'rawdescription' => - _m('The PubSubHubBub plugin pushes RSS/Atom updates '. - 'to a <a href = "'. - 'http://pubsubhubbub.googlecode.com/'. - '">PubSubHubBub</a> hub.')); + $about); return true; } |