]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch 'testing' into moveaccount
authorBrion Vibber <brion@pobox.com>
Wed, 19 Jan 2011 18:41:14 +0000 (10:41 -0800)
committerBrion Vibber <brion@pobox.com>
Wed, 19 Jan 2011 18:41:14 +0000 (10:41 -0800)
16 files changed:
actions/profilesettings.php
db/notice_source.sql
lib/accountsettingsaction.php
lib/connectsettingsaction.php
lib/logingroupnav.php
lib/profileaction.php
lib/userprofile.php
plugins/CasAuthentication/CasAuthenticationPlugin.php
plugins/Facebook/FacebookPlugin.php
plugins/FacebookBridge/FacebookBridgePlugin.php
plugins/NewMenu/NewMenuPlugin.php
plugins/OpenID/OpenIDPlugin.php
plugins/SubMirror/SubMirrorPlugin.php
plugins/SubMirror/actions/mirrorsettings.php
plugins/TwitterBridge/TwitterBridgePlugin.php
plugins/UserFlag/UserFlagPlugin.php

index 19fbdbd29336d3d7393a3157b4c8c9d498ba9115..303bb0ad9bbd76be81fa193fb1adec3de72df680 100644 (file)
@@ -458,6 +458,9 @@ class ProfilesettingsAction extends AccountSettingsAction
 
         $this->elementStart('div', array('id' => 'aside_primary',
                                          'class' => 'aside'));
+
+        $this->elementStart('div', array('id' => 'account_actions',
+                                         'class' => 'section'));
         $this->elementStart('ul');
         if (Event::handle('StartProfileSettingsActions', array($this))) {
             if ($user->hasRight(Right::BACKUPACCOUNT)) {
@@ -485,5 +488,6 @@ class ProfilesettingsAction extends AccountSettingsAction
         }
         $this->elementEnd('ul');
         $this->elementEnd('div');
+        $this->elementEnd('div');
     }
 }
index 82074077b4b93a41160dcb6d2bc44d48b12a2c8e..b13cfb3e3b8cf835bb15fa467aed672bf101e2f4 100644 (file)
@@ -77,4 +77,5 @@ VALUES
     ('twitvim','TwitVim','http://vim.sourceforge.net/scripts/script.php?script_id=2204', now()),
     ('Updating.Me','Updating.Me','http://updating.me/', now()),
     ('urfastr','urfastr','http://urfastr.net/', now()),
-    ('yatca','Yatca','http://www.yatca.com/', now());
+    ('yatca','Yatca','http://www.yatca.com/', now()),
+    ('rss.me', 'rss.me', 'http://rss.me/', now());
index 7991c9002c0fa287f8d2a0d25b34f69c9dd008f0..b1ea998bfab2b21d233d6250391794627a02e675 100644 (file)
@@ -96,7 +96,7 @@ class AccountSettingsNav extends Widget
         $action_name = $this->action->trimmed('action');
         $this->action->elementStart('ul', array('class' => 'nav'));
 
-        if (Event::handle('StartAccountSettingsNav', array(&$this->action))) {
+        if (Event::handle('StartAccountSettingsNav', array($this->action))) {
             $user = common_current_user();
 
             if(Event::handle('StartAccountSettingsProfileMenuItem', array($this, &$menu))){
@@ -142,7 +142,7 @@ class AccountSettingsNav extends Widget
                 Event::handle('EndAccountSettingsOtherMenuItem', array($this, &$menu));
             }
 
-            Event::handle('EndAccountSettingsNav', array(&$this->action));
+            Event::handle('EndAccountSettingsNav', array($this->action));
         }
 
         $this->action->elementEnd('ul');
index 325276c5fcd2a1c9643bd9c0df95821f4aa32289..20f18ef0d97485ddf91dd9611d00aa5d55267c4a 100644 (file)
@@ -96,7 +96,7 @@ class ConnectSettingsNav extends Widget
         $action_name = $this->action->trimmed('action');
         $this->action->elementStart('ul', array('class' => 'nav'));
 
-        if (Event::handle('StartConnectSettingsNav', array(&$this->action))) {
+        if (Event::handle('StartConnectSettingsNav', array($this->action))) {
 
             # action => array('prompt', 'title')
             $menu = array();
@@ -129,7 +129,7 @@ class ConnectSettingsNav extends Widget
                         $action_name === $menuaction);
             }
 
-            Event::handle('EndConnectSettingsNav', array(&$this->action));
+            Event::handle('EndConnectSettingsNav', array($this->action));
         }
 
         $this->action->elementEnd('ul');
index b545fbf26914e7fbc44d6e2c83468b6fa9630f0b..0fd0f45c7d623a035a93a7a58a55829a5a826d02 100644 (file)
@@ -73,7 +73,7 @@ class LoginGroupNav extends Widget
 
         $this->action->elementStart('ul', array('class' => 'nav'));
 
-        if (Event::handle('StartLoginGroupNav', array(&$this->action))) {
+        if (Event::handle('StartLoginGroupNav', array($this->action))) {
 
             $this->action->menuItem(common_local_url('login'),
                                     _('Login'),
@@ -87,7 +87,7 @@ class LoginGroupNav extends Widget
                                         $action_name === 'register');
             }
 
-            Event::handle('EndLoginGroupNav', array(&$this->action));
+            Event::handle('EndLoginGroupNav', array($this->action));
         }
 
         $this->action->elementEnd('ul');
index 4bfc4d48d900b042020cadd0b1247f1535f87b1f..5e4e0f52a0e14bf1b4cc12988d6976d7934d89e0 100644 (file)
@@ -99,6 +99,21 @@ class ProfileAction extends OwnerDesignAction
         $this->showStatistics();
     }
 
+    /**
+     * Convenience function for common pattern of links to subscription/groups sections.
+     *
+     * @param string $actionClass
+     * @param string $title
+     * @param string $cssClass
+     */
+    private function statsSectionLink($actionClass, $title, $cssClass='')
+    {
+        $this->element('a', array('href' => common_local_url($actionClass,
+                                                             array('nickname' => $this->profile->nickname)),
+                                  'class' => $cssClass),
+                       $title);
+    }
+
     function showSubscriptions()
     {
         $profile = $this->profile->getSubscriptions(0, PROFILES_PER_MINILIST + 1);
@@ -106,7 +121,9 @@ class ProfileAction extends OwnerDesignAction
         $this->elementStart('div', array('id' => 'entity_subscriptions',
                                          'class' => 'section'));
         if (Event::handle('StartShowSubscriptionsMiniList', array($this))) {
-            $this->element('h2', null, _('Subscriptions'));
+            $this->elementStart('h2');
+            $this->statsSectionLink('subscriptions', _('Subscriptions'));
+            $this->elementEnd('h2');
 
             $cnt = 0;
 
@@ -120,10 +137,7 @@ class ProfileAction extends OwnerDesignAction
 
             if ($cnt > PROFILES_PER_MINILIST) {
                 $this->elementStart('p');
-                $this->element('a', array('href' => common_local_url('subscriptions',
-                                                                     array('nickname' => $this->profile->nickname)),
-                                          'class' => 'more'),
-                               _('All subscriptions'));
+                $this->statsSectionLink('subscriptions', _('All subscriptions'), 'more');
                 $this->elementEnd('p');
             }
 
@@ -141,7 +155,9 @@ class ProfileAction extends OwnerDesignAction
 
         if (Event::handle('StartShowSubscribersMiniList', array($this))) {
 
-            $this->element('h2', null, _('Subscribers'));
+            $this->elementStart('h2');
+            $this->statsSectionLink('subscribers', _('Subscribers'));
+            $this->elementEnd('h2');
 
             $cnt = 0;
 
@@ -155,10 +171,7 @@ class ProfileAction extends OwnerDesignAction
 
             if ($cnt > PROFILES_PER_MINILIST) {
                 $this->elementStart('p');
-                $this->element('a', array('href' => common_local_url('subscribers',
-                                                                     array('nickname' => $this->profile->nickname)),
-                                          'class' => 'more'),
-                               _('All subscribers'));
+                $this->statsSectionLink('subscribers', _('All subscribers'), 'more');
                 $this->elementEnd('p');
             }
 
@@ -170,10 +183,7 @@ class ProfileAction extends OwnerDesignAction
 
     function showStatistics()
     {
-        $subs_count   = $this->profile->subscriptionCount();
-        $subbed_count = $this->profile->subscriberCount();
         $notice_count = $this->profile->noticeCount();
-        $group_count  = $this->profile->getGroups()->N;
         $age_days     = (time() - strtotime($this->profile->created)) / 86400;
         if ($age_days < 1) {
             // Rather than extrapolating out to a bajillion...
@@ -186,57 +196,71 @@ class ProfileAction extends OwnerDesignAction
 
         $this->element('h2', null, _('Statistics'));
 
-        // Other stats...?
-        $this->elementStart('dl', 'entity_user-id');
-        $this->element('dt', null, _('User ID'));
-        $this->element('dd', null, $this->profile->id);
-        $this->elementEnd('dl');
-
-        $this->elementStart('dl', 'entity_member-since');
-        $this->element('dt', null, _('Member since'));
-        $this->element('dd', null, date('j M Y',
-                                        strtotime($this->profile->created)));
-        $this->elementEnd('dl');
-
-        $this->elementStart('dl', 'entity_subscriptions');
-        $this->elementStart('dt');
-        $this->element('a', array('href' => common_local_url('subscriptions',
-                                                             array('nickname' => $this->profile->nickname))),
-                       _('Subscriptions'));
-        $this->elementEnd('dt');
-        $this->element('dd', null, $subs_count);
-        $this->elementEnd('dl');
-
-        $this->elementStart('dl', 'entity_subscribers');
-        $this->elementStart('dt');
-        $this->element('a', array('href' => common_local_url('subscribers',
-                                                             array('nickname' => $this->profile->nickname))),
-                       _('Subscribers'));
-        $this->elementEnd('dt');
-        $this->element('dd', 'subscribers', $subbed_count);
-        $this->elementEnd('dl');
+        $profile = $this->profile;
+        $actionParams = array('nickname' => $profile->nickname);
+        $stats = array(
+            array(
+                'id' => 'user-id',
+                'label' => _('User ID'),
+                'value' => $profile->id,
+            ),
+            array(
+                'id' => 'member-since',
+                'label' => _('Member since'),
+                'value' => date('j M Y', strtotime($profile->created))
+            ),
+            array(
+                'id' => 'subscriptions',
+                'label' => _('Subscriptions'),
+                'link' => common_local_url('subscriptions', $actionParams),
+                'value' => $profile->subscriptionCount(),
+            ),
+            array(
+                'id' => 'subscribers',
+                'label' => _('Subscribers'),
+                'link' => common_local_url('subscribers', $actionParams),
+                'value' => $profile->subscriberCount(),
+            ),
+            array(
+                'id' => 'groups',
+                'label' => _('Groups'),
+                'link' => common_local_url('usergroups', $actionParams),
+                'value' => $profile->getGroups()->N,
+            ),
+            array(
+                'id' => 'notices',
+                'label' => _('Notices'),
+                'value' => $notice_count,
+            ),
+            array(
+                'id' => 'daily_notices',
+                // TRANS: Average count of posts made per day since account registration
+                'label' => _('Daily average'),
+                'value' => $daily_count
+            )
+        );
+
+        // Give plugins a chance to add stats entries
+        Event::handle('ProfileStats', array($profile, &$stats));
+
+        foreach ($stats as $row) {
+            $this->showStatsRow($row);
+        }
+        $this->elementEnd('div');
+    }
 
-        $this->elementStart('dl', 'entity_groups');
+    private function showStatsRow($row)
+    {
+        $this->elementStart('dl', 'entity_' . $row['id']);
         $this->elementStart('dt');
-        $this->element('a', array('href' => common_local_url('usergroups',
-                                                             array('nickname' => $this->profile->nickname))),
-                       _('Groups'));
+        if (!empty($row['link'])) {
+            $this->element('a', array('href' => $row['link']), $row['label']);
+        } else {
+            $this->text($row['label']);
+        }
         $this->elementEnd('dt');
-        $this->element('dd', 'groups', $group_count);
+        $this->element('dd', null, $row['value']);
         $this->elementEnd('dl');
-
-        $this->elementStart('dl', 'entity_notices');
-        $this->element('dt', null, _('Notices'));
-        $this->element('dd', null, $notice_count);
-        $this->elementEnd('dl');
-
-        $this->elementStart('dl', 'entity_daily_notices');
-        // TRANS: Average count of posts made per day since account registration
-        $this->element('dt', null, _('Daily average'));
-        $this->element('dd', null, $daily_count);
-        $this->elementEnd('dl');
-
-        $this->elementEnd('div');
     }
 
     function showGroups()
@@ -246,7 +270,9 @@ class ProfileAction extends OwnerDesignAction
         $this->elementStart('div', array('id' => 'entity_groups',
                                          'class' => 'section'));
         if (Event::handle('StartShowGroupsMiniList', array($this))) {
-            $this->element('h2', null, _('Groups'));
+            $this->elementStart('h2');
+            $this->statsSectionLink('usergroups', _('Groups'));
+            $this->elementEnd('h2');
 
             if ($groups) {
                 $gml = new GroupMiniList($groups, $this->profile, $this);
@@ -258,10 +284,7 @@ class ProfileAction extends OwnerDesignAction
 
             if ($cnt > GROUPS_PER_MINILIST) {
                 $this->elementStart('p');
-                $this->element('a', array('href' => common_local_url('usergroups',
-                                                                     array('nickname' => $this->profile->nickname)),
-                                          'class' => 'more'),
-                               _('All groups'));
+                $this->statsSectionLink('usergroups', _('All groups'), 'more');
                 $this->elementEnd('p');
             }
 
index 2813f735eabad3efc1b2cebabfcc44cda81921b0..91c5fb413a94a999f42960017ce459153e33bb56 100644 (file)
@@ -242,7 +242,7 @@ class UserProfile extends Widget
             $this->out->elementEnd('div');
             return;
         }
-        if (Event::handle('StartProfilePageActionsSection', array(&$this->out, $this->profile))) {
+        if (Event::handle('StartProfilePageActionsSection', array($this->out, $this->profile))) {
 
             $cur = common_current_user();
 
@@ -250,13 +250,13 @@ class UserProfile extends Widget
             $this->out->element('h2', null, _('User actions'));
             $this->out->elementStart('ul');
 
-            if (Event::handle('StartProfilePageActionsElements', array(&$this->out, $this->profile))) {
+            if (Event::handle('StartProfilePageActionsElements', array($this->out, $this->profile))) {
                 if (empty($cur)) { // not logged in
-                    if (Event::handle('StartProfileRemoteSubscribe', array(&$this->out, $this->profile))) {
+                    if (Event::handle('StartProfileRemoteSubscribe', array($this->out, $this->profile))) {
                         $this->out->elementStart('li', 'entity_subscribe');
                         $this->showRemoteSubscribeLink();
                         $this->out->elementEnd('li');
-                        Event::handle('EndProfileRemoteSubscribe', array(&$this->out, $this->profile));
+                        Event::handle('EndProfileRemoteSubscribe', array($this->out, $this->profile));
                     }
                 } else {
                     if ($cur->id == $this->profile->id) { // your own page
@@ -376,13 +376,13 @@ class UserProfile extends Widget
                     }
                 }
 
-                Event::handle('EndProfilePageActionsElements', array(&$this->out, $this->profile));
+                Event::handle('EndProfilePageActionsElements', array($this->out, $this->profile));
             }
 
             $this->out->elementEnd('ul');
             $this->out->elementEnd('div');
 
-            Event::handle('EndProfilePageActionsSection', array(&$this->out, $this->profile));
+            Event::handle('EndProfilePageActionsSection', array($this->out, $this->profile));
         }
     }
 
index 71e54d41f9127e8a6a5f67d41c0e0e73913213d0..3196bd94a7a622f6d0e186b698e0a8ea0d297040 100644 (file)
@@ -74,7 +74,7 @@ class CasAuthenticationPlugin extends AuthenticationPlugin
         return true;
     }
 
-    function onEndLoginGroupNav(&$action)
+    function onEndLoginGroupNav($action)
     {
         $action_name = $action->trimmed('action');
 
index 798009817c9805e8e7f1ca510d91f3e4eaf5b0ae..e877d300b6ea3610dfc6fe402dea9c7b516237c5 100644 (file)
@@ -446,11 +446,11 @@ class FacebookPlugin extends Plugin
     /*
      * Add a login tab for Facebook Connect
      *
-     * @param Action &action the current action
+     * @param Action $action the current action
      *
      * @return void
      */
-    function onEndLoginGroupNav(&$action)
+    function onEndLoginGroupNav($action)
     {
         if (self::hasKeys()) {
             $action_name = $action->trimmed('action');
@@ -470,11 +470,11 @@ class FacebookPlugin extends Plugin
     /*
      * Add a tab for managing Facebook Connect settings
      *
-     * @param Action &action the current action
+     * @param Action $action the current action
      *
      * @return void
      */
-    function onEndConnectSettingsNav(&$action)
+    function onEndConnectSettingsNav($action)
     {
         if (self::hasKeys()) {
             $action_name = $action->trimmed('action');
index 8b5d05e98359251aadf3e317a28779d3a9603628..000b214ff4e91b96d60c9df1a23245b963c737b1 100644 (file)
@@ -186,11 +186,11 @@ class FacebookBridgePlugin extends Plugin
      * Add a login tab for Facebook, but only if there's a Facebook
      * application defined for the plugin to use.
      *
-     * @param Action &action the current action
+     * @param Action $action the current action
      *
      * @return void
      */
-    function onEndLoginGroupNav(&$action)
+    function onEndLoginGroupNav($action)
     {
         $action_name = $action->trimmed('action');
 
@@ -252,11 +252,11 @@ class FacebookBridgePlugin extends Plugin
      * Add a tab for user-level Facebook settings if the user
      * has a link to Facebook
      *
-     * @param Action &action the current action
+     * @param Action $action the current action
      *
      * @return void
      */
-    function onEndConnectSettingsNav(&$action)
+    function onEndConnectSettingsNav($action)
     {
         if ($this->hasApplication()) {
             $action_name = $action->trimmed('action');
index cdcea5cd928559c91f49cf5488a66ff2fd4fec46..14950ab079887911a9bb74b79afefe358279d80a 100644 (file)
@@ -279,19 +279,19 @@ class NewMenuPlugin extends Plugin
         return true;
     }
 
-    function onStartAccountSettingsNav(&$action)
+    function onStartAccountSettingsNav($action)
     {
         $this->_settingsMenu($action);
         return false;
     }
 
-    function onStartConnectSettingsNav(&$action)
+    function onStartConnectSettingsNav($action)
     {
         $this->_settingsMenu($action);
         return false;
     }
 
-    private function _settingsMenu(&$action)
+    private function _settingsMenu($action)
     {
         $actionName = $action->trimmed('action');
 
@@ -325,7 +325,7 @@ class NewMenuPlugin extends Plugin
                           _('Other options'),
                           $actionName == 'othersettings');
 
-        Event::handle('EndAccountSettingsNav', array(&$action));
+        Event::handle('EndAccountSettingsNav', array($action));
         
         if (common_config('xmpp', 'enabled')) {
             $action->menuItem(common_local_url('imsettings'),
@@ -346,7 +346,7 @@ class NewMenuPlugin extends Plugin
                           _('Authorized connected applications'),
                           $actionName == 'oauthconnectionsettings');
 
-        Event::handle('EndConnectSettingsNav', array(&$action));
+        Event::handle('EndConnectSettingsNav', array($action));
     }
 
     function onEndShowStyles($action)
index d5a8c1bf029a450c0bb58d17a933469ec54cba94..2635cb7c9d09211d7b7c2bc26bf60526f586fde1 100644 (file)
@@ -248,11 +248,11 @@ class OpenIDPlugin extends Plugin
      *
      * If we're in openidOnly mode, we disable the menu for all other login.
      *
-     * @param Action &$action Action being executed
+     * @param Action $action Action being executed
      *
      * @return boolean hook return
      */
-    function onStartLoginGroupNav(&$action)
+    function onStartLoginGroupNav($action)
     {
         if (common_config('site', 'openidonly')) {
             $this->showOpenIDLoginTab($action);
@@ -268,11 +268,11 @@ class OpenIDPlugin extends Plugin
     /**
      * Menu item for login
      *
-     * @param Action &$action Action being executed
+     * @param Action $action Action being executed
      *
      * @return boolean hook return
      */
-    function onEndLoginGroupNav(&$action)
+    function onEndLoginGroupNav($action)
     {
         $this->showOpenIDLoginTab($action);
 
@@ -318,11 +318,11 @@ class OpenIDPlugin extends Plugin
     /**
      * Menu item for OpenID settings
      *
-     * @param Action &$action Action being executed
+     * @param Action $action Action being executed
      *
      * @return boolean hook return
      */
-    function onEndAccountSettingsNav(&$action)
+    function onEndAccountSettingsNav($action)
     {
         $action_name = $action->trimmed('action');
 
index 578ef6607c5fc846d3156f5f25ab15652425a28f..38a4c40d481aeea69e3f5a15e426221f65d7acb6 100644 (file)
@@ -93,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'),
@@ -163,4 +164,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;
+    }
 }
index a828b26feb68b07399662f83904f399af1a0cd8b..20e1807b3de286ed4e14aa2c3ba8532dd9fddae2 100644 (file)
@@ -102,4 +102,10 @@ class MirrorSettingsAction extends AccountSettingsAction
     function handlePost()
     {
     }
+
+    function showLocalNav()
+    {
+        $nav = new SubGroupNav($this, common_current_user());
+        $nav->show();
+    }
 }
index b2dce6f1c092148c7b2502fb6370bc1676723762..048daad98f4d1315bb53cebad71af498d58875a2 100644 (file)
@@ -137,11 +137,11 @@ class TwitterBridgePlugin extends Plugin
     /*
      * Add a login tab for 'Sign in with Twitter'
      *
-     * @param Action &action the current action
+     * @param Action $action the current action
      *
      * @return void
      */
-    function onEndLoginGroupNav(&$action)
+    function onEndLoginGroupNav($action)
     {
         $action_name = $action->trimmed('action');
 
@@ -160,11 +160,11 @@ class TwitterBridgePlugin extends Plugin
     /**
      * Add the Twitter Settings page to the Connect Settings menu
      *
-     * @param Action &$action The calling page
+     * @param Action $action The calling page
      *
      * @return boolean hook return
      */
-    function onEndConnectSettingsNav(&$action)
+    function onEndConnectSettingsNav($action)
     {
         if (self::hasKeys()) {
             $action_name = $action->trimmed('action');
index fc7698841ecf70e35568bbb4774ba615dfb7baa4..a375717ccd59dc175d2f878cdc2c64ab75506d62 100644 (file)
@@ -121,12 +121,12 @@ class UserFlagPlugin extends Plugin
     /**
      * Add a 'flag' button to profile page
      *
-     * @param Action  &$action The action being called
+     * @param Action  $action The action being called
      * @param Profile $profile Profile being shown
      *
      * @return boolean hook result
      */
-    function onEndProfilePageActionsElements(&$action, $profile)
+    function onEndProfilePageActionsElements($action, $profile)
     {
         $this->showFlagButton($action, $profile,
                               array('action' => 'showstream',