X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FSubMirror%2FSubMirrorPlugin.php;h=38a4c40d481aeea69e3f5a15e426221f65d7acb6;hb=5bf0c9f610d2fe7852ffafbcd51436c9e057b0a7;hp=8678cc3dd0be92bb57bc2eb51e98b5422e9aeb07;hpb=300ed65d301d21c33a5f0a196d6acfe762a34f29;p=quix0rs-gnu-social.git
diff --git a/plugins/SubMirror/SubMirrorPlugin.php b/plugins/SubMirror/SubMirrorPlugin.php
index 8678cc3dd0..38a4c40d48 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
{
/**
@@ -95,15 +93,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 +119,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;
}
@@ -140,10 +142,59 @@ class SubMirrorPlugin extends Plugin
$transports[] = 'mirror';
}
- function onStartShowSubscriptionsContent($action)
+ /**
+ * Let the OStatus subscription garbage collection know if we're
+ * making use of a remote feed, so it doesn't get dropped out
+ * from under us.
+ *
+ * @param Ostatus_profile $oprofile
+ * @param int $count in/out
+ * @return mixed hook return value
+ */
+ function onOstatus_profileSubscriberCount($oprofile, &$count)
+ {
+ if ($oprofile->profile_id) {
+ $mirror = new SubMirror();
+ $mirror->subscribed = $oprofile->profile_id;
+ if ($mirror->find()) {
+ while ($mirror->fetch()) {
+ $count++;
+ }
+ }
+ }
+ 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)
{
- $action->element('a',
- array('href' => common_local_url('mirrorsettings')),
- _m('Set up mirroring options...'));
+ $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;
}
}