X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=plugins%2FSubMirror%2FSubMirrorPlugin.php;h=a9cb2315b45e040cb1726914b41dafc10e7e1c86;hb=c97048d01bea468e0cf8865b60c3c250b4515c39;hp=7289e77938c90cb48f0b475b5a8c5a540617ce33;hpb=10f72f62af400f9b0edc6bc8a3f6a850395e3699;p=quix0rs-gnu-social.git
diff --git a/plugins/SubMirror/SubMirrorPlugin.php b/plugins/SubMirror/SubMirrorPlugin.php
index 7289e77938..a9cb2315b4 100644
--- a/plugins/SubMirror/SubMirrorPlugin.php
+++ b/plugins/SubMirror/SubMirrorPlugin.php
@@ -17,14 +17,12 @@
* along with this program. If not, see .
*/
+if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
+
/**
* @package SubMirrorPlugin
* @maintainer Brion Vibber
*/
-
-if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
-
-
class SubMirrorPlugin extends Plugin
{
/**
@@ -37,6 +35,9 @@ class SubMirrorPlugin extends Plugin
{
$m->connect('settings/mirror',
array('action' => 'mirrorsettings'));
+ $m->connect('settings/mirror/add/:provider',
+ array('action' => 'mirrorsettings'),
+ array('provider' => '[A-Za-z0-9_-]+'));
$m->connect('settings/mirror/add',
array('action' => 'addmirror'));
$m->connect('settings/mirror/edit',
@@ -95,15 +96,16 @@ class SubMirrorPlugin extends Plugin
}
/**
- * Menu item for settings
+ * Menu item for personal subscriptions/groups area
*
- * @param Action &$action Action being executed
+ * @param Widget $widget Widget being executed
*
* @return boolean hook return
*/
- function onEndAccountSettingsNav(&$action)
+ function onEndSubGroupNav($widget)
{
+ $action = $widget->out;
$action_name = $action->trimmed('action');
$action->menuItem(common_local_url('mirrorsettings'),
@@ -120,6 +122,9 @@ class SubMirrorPlugin extends Plugin
{
$schema = Schema::get();
$schema->ensureTable('submirror', SubMirror::schemaDef());
+
+ // @hack until key definition support is merged
+ SubMirror::fixIndexes($schema);
return true;
}
@@ -162,4 +167,37 @@ class SubMirrorPlugin extends Plugin
}
return true;
}
+
+ /**
+ * Add a count of mirrored feeds into a user's profile sidebar stats.
+ *
+ * @param Profile $profile
+ * @param array $stats
+ * @return boolean hook return value
+ */
+ function onProfileStats($profile, &$stats)
+ {
+ $cur = common_current_user();
+ if (!empty($cur) && $cur->id == $profile->id) {
+ $mirror = new SubMirror();
+ $mirror->subscriber = $profile->id;
+ $entry = array(
+ 'id' => 'mirrors',
+ 'label' => _m('Mirrored feeds'),
+ 'link' => common_local_url('mirrorsettings'),
+ 'value' => $mirror->count(),
+ );
+
+ $insertAt = count($stats);
+ foreach ($stats as $i => $row) {
+ if ($row['id'] == 'groups') {
+ // Slip us in after them.
+ $insertAt = $i + 1;
+ break;
+ }
+ }
+ array_splice($stats, $insertAt, 0, array($entry));
+ }
+ return true;
+ }
}