]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch 'testing'
authorEvan Prodromou <evan@status.net>
Wed, 3 Mar 2010 23:20:45 +0000 (18:20 -0500)
committerEvan Prodromou <evan@status.net>
Wed, 3 Mar 2010 23:20:45 +0000 (18:20 -0500)
21 files changed:
EVENTS.txt
actions/apitimelinegroup.php
actions/oauthconnectionssettings.php
actions/showgroup.php
actions/siteadminpanel.php
actions/sitenoticeadminpanel.php [new file with mode: 0644]
actions/subscribers.php
actions/usergroups.php
classes/User_group.php
index.php
lib/adminpanelaction.php
lib/default.php
lib/router.php
lib/util.php
plugins/OStatus/OStatusPlugin.php
plugins/OStatus/actions/ostatusgroup.php [new file with mode: 0644]
plugins/OStatus/actions/ostatusinit.php
plugins/OStatus/actions/ostatussub.php
plugins/OStatus/theme/base/css/ostatus.css
plugins/TwitterBridge/twitteradminpanel.php
theme/base/css/display.css

index 47c67512ac88d87027969870281372a17206e9b8..2da6f3da61b1e89438e269424c8ad2fdc2f3f307 100644 (file)
@@ -778,6 +778,12 @@ StartShowSubscriptionsContent: before showing the subscriptions content
 EndShowSubscriptionsContent: after showing the subscriptions content
 - $action: the current action
 
+StartShowUserGroupsContent: before showing the user groups content
+- $action: the current action
+
+EndShowUserGroupsContent: after showing the user groups content
+- $action: the current action
+
 StartShowAllContent: before showing the all (you and friends) content
 - $action: the current action
 
index d0af49844c64957dadd3cc0902d192051b9e8088..e30a08fb5d0db7830c7928d8fa5d1d6b6e474947 100644 (file)
@@ -140,7 +140,7 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
 
                 // @todo set all this Atom junk up inside the feed class
 
-                $atom->setId($id);
+                #$atom->setId($id);
                 $atom->setTitle($title);
                 $atom->setSubtitle($subtitle);
                 $atom->setLogo($logo);
index b1467f0d04b5ea35a2e24f211f242d26e0a8773d..f125f4c63101f222b740da552ad0390be8377ecd 100644 (file)
@@ -99,7 +99,7 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction
 
         $application = $profile->getApplications($offset, $limit);
 
-        $cnt == 0;
+        $cnt = 0;
 
         if (!empty($application)) {
             $al = new ApplicationList($application, $user, $this, true);
@@ -112,7 +112,7 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction
 
         $this->pagination($this->page > 1, $cnt > APPS_PER_PAGE,
                           $this->page, 'connectionssettings',
-                          array('nickname' => $this->user->nickname));
+                          array('nickname' => $user->nickname));
     }
 
     /**
index a1dc3865bdbae98931adc47b59d2a48aa0ccfdbb..5704b13d140758f46fa51641bcce03171afa489b 100644 (file)
@@ -300,8 +300,8 @@ class ShowgroupAction extends GroupDesignAction
         $this->elementStart('div', 'entity_actions');
         $this->element('h2', null, _('Group actions'));
         $this->elementStart('ul');
+        $this->elementStart('li', 'entity_subscribe');
         if (Event::handle('StartGroupSubscribe', array($this, $this->group))) {
-            $this->elementStart('li', 'entity_subscribe');
             $cur = common_current_user();
             if ($cur) {
                 if ($cur->isMember($this->group)) {
@@ -312,10 +312,9 @@ class ShowgroupAction extends GroupDesignAction
                     $jf->show();
                 }
             }
-            $this->elementEnd('li');
             Event::handle('EndGroupSubscribe', array($this, $this->group));
         }
-
+        $this->elementEnd('li');
         $this->elementEnd('ul');
         $this->elementEnd('div');
     }
index 8c8f8b3742bf5c28590281c59dc14504c828b521..4b29819b71b0d68532c0e4c691dd60b47213c574 100644 (file)
@@ -277,8 +277,8 @@ class SiteAdminPanelForm extends AdminForm
         $this->unli();
 
         $this->li();
-        $this->out->dropdown('language', _('Language'),
-                             get_nice_language_list(), _('Default site language'),
+        $this->out->dropdown('language', _('Default language'),
+                             get_nice_language_list(), _('Site language when autodetection from browser settings is not available'),
                              false, $this->value('language'));
         $this->unli();
 
diff --git a/actions/sitenoticeadminpanel.php b/actions/sitenoticeadminpanel.php
new file mode 100644 (file)
index 0000000..613a2e9
--- /dev/null
@@ -0,0 +1,201 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Site notice administration panel
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category  Settings
+ * @package   StatusNet
+ * @author    Zach Copley <zach@status.net>
+ * @copyright 2010 StatusNet, Inc.
+ * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link      http://status.net/
+ */
+
+if (!defined('STATUSNET')) {
+    exit(1);
+}
+
+require_once INSTALLDIR.'/extlib/htmLawed/htmLawed.php';
+
+/**
+ * Update the site-wide notice text
+ *
+ * @category Admin
+ * @package  StatusNet
+ * @author   Zach Copley <zach@status.net>
+ * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link     http://status.net/
+ */
+
+class SitenoticeadminpanelAction extends AdminPanelAction
+{
+    /**
+     * Returns the page title
+     *
+     * @return string page title
+     */
+
+    function title()
+    {
+        return _('Site Notice');
+    }
+
+    /**
+     * Instructions for using this form.
+     *
+     * @return string instructions
+     */
+
+    function getInstructions()
+    {
+        return _('Edit site-wide message');
+    }
+
+    /**
+     * Show the site notice admin panel form
+     *
+     * @return void
+     */
+
+    function showForm()
+    {
+        $form = new SiteNoticeAdminPanelForm($this);
+        $form->show();
+        return;
+    }
+
+    /**
+     * Save settings from the form
+     *
+     * @return void
+     */
+
+    function saveSettings()
+    {
+        $siteNotice = $this->trimmed('site-notice');
+
+        // assert(all values are valid);
+        // This throws an exception on validation errors
+
+        $this->validate(&$siteNotice);
+
+        $config = new Config();
+
+        $result = Config::save('site', 'notice', $siteNotice);
+
+        if (!result) {
+            $this->ServerError(_("Unable to save site notice."));
+        }
+    }
+
+    function validate(&$siteNotice)
+    {
+        // Validate notice text
+
+        if (mb_strlen($siteNotice) > 255)  {
+            $this->clientError(
+                _('Max length for the site-wide notice is 255 chars')
+            );
+        }
+
+        // scrub HTML input
+
+        $config = array(
+            'safe' => 1,
+            'deny_attribute' => 'id,style,on*'
+        );
+
+        $siteNotice = htmLawed($siteNotice, $config);
+    }
+}
+
+class SiteNoticeAdminPanelForm extends AdminForm
+{
+    /**
+     * ID of the form
+     *
+     * @return int ID of the form
+     */
+
+    function id()
+    {
+        return 'form_site_notice_admin_panel';
+    }
+
+    /**
+     * class of the form
+     *
+     * @return string class of the form
+     */
+
+    function formClass()
+    {
+        return 'form_settings';
+    }
+
+    /**
+     * Action of the form
+     *
+     * @return string URL of the action
+     */
+
+    function action()
+    {
+        return common_local_url('sitenoticeadminpanel');
+    }
+
+    /**
+     * Data elements of the form
+     *
+     * @return void
+     */
+
+    function formData()
+    {
+        $this->out->elementStart('ul', 'form_data');
+
+        $this->out->elementStart('li');
+        $this->out->textarea(
+            'site-notice',
+            _('Site notice text'),
+            common_config('site', 'notice'),
+            _('Site-wide notice text (255 chars max; HTML okay)')
+        );
+        $this->out->elementEnd('li');
+
+        $this->out->elementEnd('ul');
+    }
+
+    /**
+     * Action elements
+     *
+     * @return void
+     */
+
+    function formActions()
+    {
+        $this->out->submit(
+            'submit',
+            _('Save'),
+            'submit',
+            null,
+            _('Save site notice')
+        );
+    }
+}
index cd3e2ee5bedd136190ddea88971c526345c98b73..4bced62840dcda4f3f8a28d591583b901729ccc1 100644 (file)
@@ -143,9 +143,12 @@ class SubscribersListItem extends SubscriptionListItem
     function showActions()
     {
         $this->startActions();
-        $this->showSubscribeButton();
-        // Relevant code!
-        $this->showBlockForm();
+        if (Event::handle('StartProfileListItemActionElements', array($this))) {
+            $this->showSubscribeButton();
+            // Relevant code!
+            $this->showBlockForm();
+            Event::handle('EndProfileListItemActionElements', array($this));
+        }
         $this->endActions();
     }
 
index 97faabae65ad9cd7f02ab1c5cc0cba3d04a21fa1..29bda0a765c289dc107316bd1f1a4a5135346472 100644 (file)
@@ -130,22 +130,26 @@ class UsergroupsAction extends OwnerDesignAction
                        _('Search for more groups'));
         $this->elementEnd('p');
 
-        $offset = ($this->page-1) * GROUPS_PER_PAGE;
-        $limit =  GROUPS_PER_PAGE + 1;
+        if (Event::handle('StartShowUserGroupsContent', array($this))) {
+            $offset = ($this->page-1) * GROUPS_PER_PAGE;
+            $limit =  GROUPS_PER_PAGE + 1;
+
+            $groups = $this->user->getGroups($offset, $limit);
+
+            if ($groups) {
+                $gl = new GroupList($groups, $this->user, $this);
+                $cnt = $gl->show();
+                if (0 == $cnt) {
+                    $this->showEmptyListMessage();
+                }
+            }
 
-        $groups = $this->user->getGroups($offset, $limit);
+            $this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE,
+                              $this->page, 'usergroups',
+                              array('nickname' => $this->user->nickname));
 
-        if ($groups) {
-            $gl = new GroupList($groups, $this->user, $this);
-            $cnt = $gl->show();
-            if (0 == $cnt) {
-                $this->showEmptyListMessage();
-            }
+            Event::handle('EndShowUserGroupsContent', array($this));
         }
-
-        $this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE,
-                          $this->page, 'usergroups',
-                          array('nickname' => $this->user->nickname));
     }
 
     function showEmptyListMessage()
index 1a5ddf2533477ba9122ea858052ef748f8c36c47..0460c9870a34cb318ed1c21a34429ea46059720e 100644 (file)
@@ -455,6 +455,11 @@ class User_group extends Memcached_DataObject
         $group = new User_group();
 
         $group->query('BEGIN');
+        
+        if (empty($uri)) {
+            // fill in later...
+            $uri = null;
+        }
 
         $group->nickname    = $nickname;
         $group->fullname    = $fullname;
index 06ff9900fd5bff24466be4cbd6ee5ffaeb87ac6e..36ba3a0d2163915fa700ef0373b5ee65fa317c63 100644 (file)
--- a/index.php
+++ b/index.php
@@ -185,7 +185,7 @@ function checkMirror($action_obj, $args)
 
 function isLoginAction($action)
 {
-    static $loginActions =  array('login', 'recoverpassword', 'api', 'doc', 'register', 'publicxrds');
+    static $loginActions =  array('login', 'recoverpassword', 'api', 'doc', 'register', 'publicxrds', 'otp');
 
     $login = null;
 
index 536d97cdf5d440329a4a0a16681289840020b026..eb622871e7cb0cfea282754356cff9d34e8ed4fc 100644 (file)
@@ -171,6 +171,34 @@ class AdminPanelAction extends Action
         $this->showForm();
     }
 
+    /**
+     * Show content block. Overrided just to add a special class
+     * to the content div to allow styling.
+     *
+     * @return nothing
+     */
+    function showContentBlock()
+    {
+        $this->elementStart('div', array('id' => 'content', 'class' => 'admin'));
+        $this->showPageTitle();
+        $this->showPageNoticeBlock();
+        $this->elementStart('div', array('id' => 'content_inner'));
+        // show the actual content (forms, lists, whatever)
+        $this->showContent();
+        $this->elementEnd('div');
+        $this->elementEnd('div');
+    }
+
+    /**
+     * There is no data for aside, so, we don't output
+     *
+     * @return nothing
+     */
+    function showAside()
+    {
+
+    }
+
     /**
      * show human-readable instructions for the page, or
      * a success/failure on save.
@@ -330,22 +358,27 @@ class AdminPanelNav extends Widget
 
             if (AdminPanelAction::canAdmin('user')) {
                 $this->out->menuItem(common_local_url('useradminpanel'), _('User'),
-                                     _('User configuration'), $action_name == 'useradminpanel', 'nav_design_admin_panel');
+                                     _('User configuration'), $action_name == 'useradminpanel', 'nav_user_admin_panel');
             }
 
             if (AdminPanelAction::canAdmin('access')) {
                 $this->out->menuItem(common_local_url('accessadminpanel'), _('Access'),
-                                     _('Access configuration'), $action_name == 'accessadminpanel', 'nav_design_admin_panel');
+                                     _('Access configuration'), $action_name == 'accessadminpanel', 'nav_access_admin_panel');
             }
 
             if (AdminPanelAction::canAdmin('paths')) {
                 $this->out->menuItem(common_local_url('pathsadminpanel'), _('Paths'),
-                                    _('Paths configuration'), $action_name == 'pathsadminpanel', 'nav_design_admin_panel');
+                                    _('Paths configuration'), $action_name == 'pathsadminpanel', 'nav_paths_admin_panel');
             }
 
             if (AdminPanelAction::canAdmin('sessions')) {
                 $this->out->menuItem(common_local_url('sessionsadminpanel'), _('Sessions'),
-                                     _('Sessions configuration'), $action_name == 'sessionsadminpanel', 'nav_design_admin_panel');
+                                     _('Sessions configuration'), $action_name == 'sessionsadminpanel', 'nav_sessions_admin_panel');
+            }
+
+            if (AdminPanelAction::canAdmin('sitenotice')) {
+                $this->out->menuItem(common_local_url('sitenoticeadminpanel'), _('Site notice'),
+                                     _('Edit site notice'), $action_name == 'sitenoticeadminpanel', 'nav_sitenotice_admin_panel');
             }
 
             Event::handle('EndAdminPanelNav', array($this));
index 7b50242ae27f9ff5b37996f86348e6d2c7485545..8e99a0e1c31727ace1e25c8750beb677517b63a5 100644 (file)
@@ -40,7 +40,8 @@ $default =
               'logdebug' => false,
               'fancy' => false,
               'locale_path' => INSTALLDIR.'/locale',
-              'language' => 'en_US',
+              'language' => 'en',
+              'langdetect' => true,
               'languages' => get_all_languages(),
               'email' =>
               array_key_exists('SERVER_ADMIN', $_SERVER) ? $_SERVER['SERVER_ADMIN'] : null,
@@ -53,10 +54,11 @@ $default =
               'ssl' => 'never',
               'sslserver' => null,
               'shorturllength' => 30,
-              'dupelimit' => 60, # default for same person saying the same thing
+              'dupelimit' => 60, // default for same person saying the same thing
               'textlimit' => 140,
               'indent' => true,
-              'use_x_sendfile' => false
+              'use_x_sendfile' => false,
+              'notice' => null // site wide notice text
               ),
         'db' =>
         array('database' => 'YOU HAVE TO SET THIS IN config.php',
@@ -282,7 +284,7 @@ $default =
                                  'OpenID' => null),
               ),
         'admin' =>
-        array('panels' => array('design', 'site', 'user', 'paths', 'access', 'sessions')),
+        array('panels' => array('design', 'site', 'user', 'paths', 'access', 'sessions', 'sitenotice')),
         'singleuser' =>
         array('enabled' => false,
               'nickname' => null),
index abbce041dbfe5ac5ac504491fa1c4e5b128708b0..7e8e22a7dba0985c89a33f72439044c01d3e7994 100644 (file)
@@ -649,6 +649,7 @@ class Router
                $m->connect('admin/access', array('action' => 'accessadminpanel'));
             $m->connect('admin/paths', array('action' => 'pathsadminpanel'));
             $m->connect('admin/sessions', array('action' => 'sessionsadminpanel'));
+            $m->connect('admin/sitenotice', array('action' => 'sitenoticeadminpanel'));
 
             $m->connect('getfile/:filename',
                         array('action' => 'getfile'),
index 46be920fa7940aa671155985170cf5552af77c64..da2799d4f92d23766c464b1e15b4c66ab6704217 100644 (file)
@@ -105,11 +105,13 @@ function common_language()
 
     // Otherwise, find the best match for the languages requested by the
     // user's browser...
-    $httplang = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : null;
-    if (!empty($httplang)) {
-        $language = client_prefered_language($httplang);
-        if ($language)
-          return $language;
+    if (common_config('site', 'langdetect')) {
+        $httplang = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : null;
+        if (!empty($httplang)) {
+            $language = client_prefered_language($httplang);
+            if ($language)
+              return $language;
+        }
     }
 
     // Finally, if none of the above worked, use the site's default...
index da7ca2fe2b0dba8d0dd54645adfe65ece16dffa0..cc7e7597646d63c2e7cd8390538f2643d0a6d380 100644 (file)
@@ -49,10 +49,12 @@ class OStatusPlugin extends Plugin
                     array('action' => 'ostatusinit'));
         $m->connect('main/ostatus?nickname=:nickname',
                   array('action' => 'ostatusinit'), array('nickname' => '[A-Za-z0-9_-]+'));
+        $m->connect('main/ostatus?group=:group',
+                  array('action' => 'ostatusinit'), array('group' => '[A-Za-z0-9_-]+'));
         $m->connect('main/ostatussub',
                     array('action' => 'ostatussub'));
-        $m->connect('main/ostatussub',
-                    array('action' => 'ostatussub'), array('feed' => '[A-Za-z0-9\.\/\:]+'));
+        $m->connect('main/ostatusgroup',
+                    array('action' => 'ostatusgroup'));
 
         // PuSH actions
         $m->connect('main/push/hub', array('action' => 'pushhub'));
@@ -216,17 +218,14 @@ class OStatusPlugin extends Plugin
 
         if (empty($cur)) {
             // Add an OStatus subscribe
-            $output->elementStart('li', 'entity_subscribe');
             $url = common_local_url('ostatusinit',
-                                    array('nickname' => $group->nickname));
+                                    array('group' => $group->nickname));
             $output->element('a', array('href' => $url,
                                         'class' => 'entity_remote_subscribe'),
                                 _m('Join'));
-
-            $output->elementEnd('li');
         }
 
-        return false;
+        return true;
     }
 
     /**
@@ -729,6 +728,13 @@ class OStatusPlugin extends Plugin
         return true;
     }
 
+    function onStartShowUserGroupsContent($action)
+    {
+        $this->showEntityRemoteSubscribe($action, 'ostatusgroup');
+
+        return true;
+    }
+
     function onEndShowSubscriptionsMiniList($action)
     {
         $this->showEntityRemoteSubscribe($action);
@@ -738,19 +744,19 @@ class OStatusPlugin extends Plugin
 
     function onEndShowGroupsMiniList($action)
     {
-        $this->showEntityRemoteSubscribe($action);
+        $this->showEntityRemoteSubscribe($action, 'ostatusgroup');
 
         return true;
     }
 
-    function showEntityRemoteSubscribe($action)
+    function showEntityRemoteSubscribe($action, $target='ostatussub')
     {
         $user = common_current_user();
         if ($user && ($user->id == $action->profile->id)) {
             $action->elementStart('div', 'entity_actions');
             $action->elementStart('p', array('id' => 'entity_remote_subscribe',
                                              'class' => 'entity_subscribe'));
-            $action->element('a', array('href' => common_local_url('ostatussub'),
+            $action->element('a', array('href' => common_local_url($target),
                                         'class' => 'entity_remote_subscribe')
                                 , _m('Remote'));
             $action->elementEnd('p');
diff --git a/plugins/OStatus/actions/ostatusgroup.php b/plugins/OStatus/actions/ostatusgroup.php
new file mode 100644 (file)
index 0000000..4fcd0eb
--- /dev/null
@@ -0,0 +1,181 @@
+<?php
+/*
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2009-2010, StatusNet, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * @package OStatusPlugin
+ * @maintainer Brion Vibber <brion@status.net>
+ */
+
+if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
+
+/**
+ * Key UI methods:
+ *
+ *  showInputForm() - form asking for a remote profile account or URL
+ *                    We end up back here on errors
+ *
+ *  showPreviewForm() - surrounding form for preview-and-confirm
+ *    preview() - display profile for a remote group
+ *
+ *  success() - redirects to groups page on join
+ */
+class OStatusGroupAction extends OStatusSubAction
+{
+    protected $profile_uri; // provided acct: or URI of remote entity
+    protected $oprofile; // Ostatus_profile of remote entity, if valid
+
+
+    function validateRemoteProfile()
+    {
+        if (!$this->oprofile->isGroup()) {
+            // Send us to the user subscription form for conf
+            $target = common_local_url('ostatussub', array(), array('profile' => $this->profile_uri));
+            common_redirect($target, 303);
+        }
+    }
+
+    /**
+     * Show the initial form, when we haven't yet been given a valid
+     * remote profile.
+     */
+    function showInputForm()
+    {
+        $user = common_current_user();
+
+        $profile = $user->getProfile();
+
+        $this->elementStart('form', array('method' => 'post',
+                                          'id' => 'form_ostatus_sub',
+                                          'class' => 'form_settings',
+                                          'action' => $this->selfLink()));
+
+        $this->hidden('token', common_session_token());
+
+        $this->elementStart('fieldset', array('id' => 'settings_feeds'));
+
+        $this->elementStart('ul', 'form_data');
+        $this->elementStart('li');
+        $this->input('profile',
+                     _m('Group profile URL'),
+                     $this->profile_uri,
+                     _m('Enter the profile URL of a group on another StatusNet site'));
+        $this->elementEnd('li');
+        $this->elementEnd('ul');
+
+        $this->submit('validate', _m('Continue'));
+
+        $this->elementEnd('fieldset');
+
+        $this->elementEnd('form');
+    }
+
+    /**
+     * Show a preview for a remote group's profile
+     * @return boolean true if we're ok to try joining
+     */
+    function preview()
+    {
+        $oprofile = $this->oprofile;
+        $group = $oprofile->localGroup();
+
+        $cur = common_current_user();
+        if ($cur->isMember($group)) {
+            $this->element('div', array('class' => 'error'),
+                           _m("You are already a member of this group."));
+            $ok = false;
+        } else {
+            $ok = true;
+        }
+
+        $this->showEntity($group,
+                          $group->getProfileUrl(),
+                          $group->homepage_logo,
+                          $group->description);
+        return $ok;
+    }
+
+    /**
+     * Redirect on successful remote group join
+     */
+    function success()
+    {
+        $cur = common_current_user();
+        $url = common_local_url('usergroups', array('nickname' => $cur->nickname));
+        common_redirect($url, 303);
+    }
+
+    /**
+     * Attempt to finalize subscription.
+     * validateFeed must have been run first.
+     *
+     * Calls showForm on failure or success on success.
+     */
+    function saveFeed()
+    {
+        $user = common_current_user();
+        $group = $this->oprofile->localGroup();
+        if ($user->isMember($group)) {
+            // TRANS: OStatus remote group subscription dialog error.
+            $this->showForm(_m('Already a member!'));
+            return;
+        }
+
+        if (Event::handle('StartJoinGroup', array($group, $user))) {
+            $ok = Group_member::join($this->oprofile->group_id, $user->id);
+            if ($ok) {
+                Event::handle('EndJoinGroup', array($group, $user));
+                $this->success();
+            } else {
+                // TRANS: OStatus remote group subscription dialog error.
+                $this->showForm(_m('Remote group join failed!'));
+            }
+        } else {
+            // TRANS: OStatus remote group subscription dialog error.
+            $this->showForm(_m('Remote group join aborted!'));
+        }
+    }
+
+    /**
+     * Title of the page
+     *
+     * @return string Title of the page
+     */
+
+    function title()
+    {
+        // TRANS: Page title for OStatus remote group join form
+        return _m('Confirm joining remote group');
+    }
+
+    /**
+     * Instructions for use
+     *
+     * @return instructions for use
+     */
+
+    function getInstructions()
+    {
+        return _m('You can subscribe to groups from other supported sites. Paste the group\'s profile URI below:');
+    }
+
+    function selfLink()
+    {
+        return common_local_url('ostatusgroup');
+    }
+}
index 8ba8dcdcc7514ae18dd84fcd02f9f9e51fce7260..1e45025b09ec19ffc8de44a10d0a2e3cd26d2e23 100644 (file)
@@ -29,6 +29,7 @@ class OStatusInitAction extends Action
 {
 
     var $nickname;
+    var $group;
     var $profile;
     var $err;
 
@@ -41,8 +42,9 @@ class OStatusInitAction extends Action
             return false;
         }
 
-        // Local user the remote wants to subscribe to
+        // Local user or group the remote wants to subscribe to
         $this->nickname = $this->trimmed('nickname');
+        $this->group = $this->trimmed('group');
         
         // Webfinger or profile URL of the remote user
         $this->profile = $this->trimmed('profile');
@@ -89,25 +91,33 @@ class OStatusInitAction extends Action
 
     function showContent()
     {
+        if ($this->group) {
+            $header = sprintf(_m('Join group %s'), $this->group);
+            $submit = _m('Join');
+        } else {
+            $header = sprintf(_m('Subscribe to %s'), $this->nickname);
+            $submit = _m('Subscribe');
+        }
         $this->elementStart('form', array('id' => 'form_ostatus_connect',
                                           'method' => 'post',
                                           'class' => 'form_settings',
                                           'action' => common_local_url('ostatusinit')));
         $this->elementStart('fieldset');
-        $this->element('legend', null,  sprintf(_m('Subscribe to %s'), $this->nickname));
+        $this->element('legend', null,  $header);
         $this->hidden('token', common_session_token());
 
         $this->elementStart('ul', 'form_data');
         $this->elementStart('li', array('id' => 'ostatus_nickname'));
         $this->input('nickname', _m('User nickname'), $this->nickname,
                      _m('Nickname of the user you want to follow'));
+        $this->hidden('group', $this->group); // pass-through for magic links
         $this->elementEnd('li');
         $this->elementStart('li', array('id' => 'ostatus_profile'));
         $this->input('profile', _m('Profile Account'), $this->profile,
                      _m('Your account id (i.e. user@identi.ca)'));
         $this->elementEnd('li');
         $this->elementEnd('ul');
-        $this->submit('submit', _m('Subscribe'));
+        $this->submit('submit', $submit);
         $this->elementEnd('fieldset');
         $this->elementEnd('form');
     }
@@ -131,19 +141,17 @@ class OStatusInitAction extends Action
 
     function connectWebfinger($acct)
     {
-        $disco = new Discovery;
+        $target_profile = $this->targetProfile();
 
+        $disco = new Discovery;
         $result = $disco->lookup($acct);
         if (!$result) {
             $this->clientError(_m("Couldn't look up OStatus account profile."));
         }
+
         foreach ($result->links as $link) {
             if ($link['rel'] == 'http://ostatus.org/schema/1.0/subscribe') {
                 // We found a URL - let's redirect!
-
-                $user = User::staticGet('nickname', $this->nickname);
-                $target_profile = common_local_url('userbyid', array('id' => $user->id));
-
                 $url = Discovery::applyTemplate($link['template'], $target_profile);
                 common_log(LOG_INFO, "Sending remote subscriber $acct to $url");
                 common_redirect($url, 303);
@@ -155,8 +163,7 @@ class OStatusInitAction extends Action
 
     function connectProfile($subscriber_profile)
     {
-        $user = User::staticGet('nickname', $this->nickname);
-        $target_profile = common_local_url('userbyid', array('id' => $user->id));
+        $target_profile = $this->targetProfile();
 
         // @fixme hack hack! We should look up the remote sub URL from XRDS
         $suburl = preg_replace('!^(.*)/(.*?)$!', '$1/main/ostatussub', $subscriber_profile);
@@ -166,6 +173,30 @@ class OStatusInitAction extends Action
         common_redirect($suburl, 303);
     }
 
+    /**
+     * Build the canonical profile URI+URL of the requested user or group
+     */
+    function targetProfile()
+    {
+        if ($this->nickname) {
+            $user = User::staticGet('nickname', $this->nickname);
+            if ($user) {
+                return common_local_url('userbyid', array('id' => $user->id));
+            } else {
+                $this->clientError("No such user.");
+            }
+        } else if ($this->group) {
+            $group = Local_group::staticGet('id', $this->group);
+            if ($group) {
+                return common_local_url('groupbyid', array('id' => $group->group_id));
+            } else {
+                $this->clientError("No such group.");
+            }
+        } else {
+            $this->clientError("No local user or group nickname provided.");
+        }
+    }
+
     function title()
     {
       return _m('OStatus Connect');  
index e318701a24f7e84b71cdde5bae2ce3b626a046f4..542f7e20ca8a08e5b8786aba12700eed40e44f08 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2009, StatusNet, Inc.
+ * Copyright (C) 2009-2010, StatusNet, Inc.
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as published by
@@ -31,11 +31,9 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
  *                    We end up back here on errors
  *
  *  showPreviewForm() - surrounding form for preview-and-confirm
- *    previewUser() - display profile for a remote user
- *    previewGroup() - display profile for a remote group
+ *    preview() - display profile for a remote user
  *
- *  successUser() - redirects to subscriptions page on subscribe
- *  successGroup() - redirects to groups page on join
+ *  success() - redirects to subscriptions page on subscribe
  */
 class OStatusSubAction extends Action
 {
@@ -55,8 +53,7 @@ class OStatusSubAction extends Action
         $this->elementStart('form', array('method' => 'post',
                                           'id' => 'form_ostatus_sub',
                                           'class' => 'form_settings',
-                                          'action' =>
-                                          common_local_url('ostatussub')));
+                                          'action' => $this->selfLink()));
 
         $this->hidden('token', common_session_token());
 
@@ -87,11 +84,7 @@ class OStatusSubAction extends Action
      */
     function showPreviewForm()
     {
-        if ($this->oprofile->isGroup()) {
-            $ok = $this->previewGroup();
-        } else {
-            $ok = $this->previewUser();
-        }
+        $ok = $this->preview();
         if (!$ok) {
             // @fixme maybe provide a cancel button or link back?
             return;
@@ -104,7 +97,7 @@ class OStatusSubAction extends Action
                                           'id' => 'form_ostatus_sub',
                                           'class' => 'form_remote_authorize',
                                           'action' =>
-                                          common_local_url('ostatussub')));
+                                          $this->selfLink()));
         $this->elementStart('fieldset');
         $this->hidden('token', common_session_token());
         $this->hidden('profile', $this->profile_uri);
@@ -126,7 +119,7 @@ class OStatusSubAction extends Action
      * Show a preview for a remote user's profile
      * @return boolean true if we're ok to try subscribing
      */
-    function previewUser()
+    function preview()
     {
         $oprofile = $this->oprofile;
         $profile = $oprofile->localProfile();
@@ -150,32 +143,6 @@ class OStatusSubAction extends Action
         return $ok;
     }
 
-    /**
-     * Show a preview for a remote group's profile
-     * @return boolean true if we're ok to try joining
-     */
-    function previewGroup()
-    {
-        $oprofile = $this->oprofile;
-        $group = $oprofile->localGroup();
-
-        $cur = common_current_user();
-        if ($cur->isMember($group)) {
-            $this->element('div', array('class' => 'error'),
-                           _m("You are already a member of this group."));
-            $ok = false;
-        } else {
-            $ok = true;
-        }
-
-        $this->showEntity($group,
-                          $group->getProfileUrl(),
-                          $group->homepage_logo,
-                          $group->description);
-        return $ok;
-    }
-
-
     function showEntity($entity, $profile, $avatar, $note)
     {
         $nickname = $entity->nickname;
@@ -254,23 +221,13 @@ class OStatusSubAction extends Action
     /**
      * Redirect on successful remote user subscription
      */
-    function successUser()
+    function success()
     {
         $cur = common_current_user();
         $url = common_local_url('subscriptions', array('nickname' => $cur->nickname));
         common_redirect($url, 303);
     }
 
-    /**
-     * Redirect on successful remote group join
-     */
-    function successGroup()
-    {
-        $cur = common_current_user();
-        $url = common_local_url('usergroups', array('nickname' => $cur->nickname));
-        common_redirect($url, 303);
-    }
-
     /**
      * Pull data for a remote profile and check if it's valid.
      * Fills out error UI string in $this->error
@@ -278,16 +235,9 @@ class OStatusSubAction extends Action
      *
      * @return boolean
      */
-    function validateFeed()
+    function pullRemoteProfile()
     {
-        $profile_uri = trim($this->arg('profile'));
-
-        if ($profile_uri == '') {
-            $this->showForm(_m('Empty remote profile URL!'));
-            return;
-        }
-        $this->profile_uri = $profile_uri;
-
+        $this->profile_uri = $this->trimmed('profile');
         try {
             if (Validate::email($this->profile_uri)) {
                 $this->oprofile = Ostatus_profile::ensureWebfinger($this->profile_uri);
@@ -318,48 +268,34 @@ class OStatusSubAction extends Action
         return false;
     }
 
+    function validateRemoteProfile()
+    {
+        if ($this->oprofile->isGroup()) {
+            // Send us to the group subscription form for conf
+            $target = common_local_url('ostatusgroup', array(), array('profile' => $this->profile_uri));
+            common_redirect($target, 303);
+        }
+    }
+
     /**
      * Attempt to finalize subscription.
      * validateFeed must have been run first.
      *
-     * Calls showForm on failure or successUser/successGroup on success.
+     * Calls showForm on failure or success on success.
      */
     function saveFeed()
     {
         // And subscribe the current user to the local profile
         $user = common_current_user();
-
-        if ($this->oprofile->isGroup()) {
-            $group = $this->oprofile->localGroup();
-            if ($user->isMember($group)) {
-                // TRANS: OStatus remote group subscription dialog error.
-                $this->showForm(_m('Already a member!'));
-                return;
-            }
-            if (Event::handle('StartJoinGroup', array($group, $user))) {
-                $ok = Group_member::join($this->oprofile->group_id, $user->id);
-                if ($ok) {
-                    Event::handle('EndJoinGroup', array($group, $user));
-                    $this->successGroup();
-                } else {
-                    // TRANS: OStatus remote group subscription dialog error.
-                    $this->showForm(_m('Remote group join failed!'));
-                }
-            } else {
-                // TRANS: OStatus remote group subscription dialog error.
-                $this->showForm(_m('Remote group join aborted!'));
-            }
+        $local = $this->oprofile->localProfile();
+        if ($user->isSubscribed($local)) {
+            // TRANS: OStatus remote subscription dialog error.
+            $this->showForm(_m('Already subscribed!'));
+        } elseif ($this->oprofile->subscribeLocalToRemote($user)) {
+            $this->success();
         } else {
-            $local = $this->oprofile->localProfile();
-            if ($user->isSubscribed($local)) {
-                // TRANS: OStatus remote subscription dialog error.
-                $this->showForm(_m('Already subscribed!'));
-            } elseif ($this->oprofile->subscribeLocalToRemote($user)) {
-                $this->successUser();
-            } else {
-                // TRANS: OStatus remote subscription dialog error.
-                $this->showForm(_m('Remote subscription failed!'));
-            }
+            // TRANS: OStatus remote subscription dialog error.
+            $this->showForm(_m('Remote subscription failed!'));
         }
     }
 
@@ -376,7 +312,9 @@ class OStatusSubAction extends Action
             return false;
         }
 
-        $this->profile_uri = $this->arg('profile');
+        if ($this->pullRemoteProfile()) {
+            $this->validateRemoteProfile();
+        }
 
         return true;
     }
@@ -390,9 +328,6 @@ class OStatusSubAction extends Action
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             $this->handlePost();
         } else {
-            if ($this->arg('profile')) {
-                $this->validateFeed();
-            }
             $this->showForm();
         }
     }
@@ -414,7 +349,7 @@ class OStatusSubAction extends Action
             return;
         }
 
-        if ($this->validateFeed()) {
+        if ($this->oprofile) {
             if ($this->arg('submit')) {
                 $this->saveFeed();
                 return;
@@ -500,4 +435,9 @@ class OStatusSubAction extends Action
         parent::showScripts();
         $this->autofocus('feedurl');
     }
+
+    function selfLink()
+    {
+        return common_local_url('ostatussub');
+    }
 }
index d1c60cc0d54a496ce03f9aca937a85141502384a..ac668623d8b3aa838c0050651a0484956f6444ae 100644 (file)
@@ -41,9 +41,6 @@ min-width:96px;
 #entity_remote_subscribe {
 padding:0;
 float:right;
-}
-
-.section #entity_remote_subscribe {
 position:relative;
 }
 
@@ -51,15 +48,26 @@ position:relative;
 margin-bottom:0;
 }
 
-.section #entity_remote_subscribe .entity_remote_subscribe {
-border-color:#AAAAAA;
-}
-
-.section #entity_remote_subscribe .dialogbox {
+#entity_remote_subscribe .dialogbox {
 width:405px;
 }
 
-
 .aside #entity_subscriptions .more {
 float:left;
 }
+
+.section #entity_remote_subscribe {
+border:0;
+}
+
+.section .entity_remote_subscribe {
+color:#002FA7;
+box-shadow:none;
+-moz-box-shadow:none;
+-webkit-box-shadow:none;
+background-color:transparent;
+background-position:0 -1183px;
+padding:0 0 0 23px;
+border:0;
+
+}
index 0ed53bc05bfb0b28aa89445c0c07d6c6038002c7..a78a92c66732ad6ed790e11d96a0a970c5374c83 100644 (file)
@@ -225,46 +225,12 @@ class TwitterAdminPanelForm extends AdminForm
         );
         $this->unli();
 
-                $globalConsumerKey = common_config('twitter', 'global_consumer_key');
+        $globalConsumerKey = common_config('twitter', 'global_consumer_key');
         $globalConsumerSec = common_config('twitter', 'global_consumer_secret');
 
-        if (!empty($globalConsumerKey)) {
+        if (!empty($globalConsumerKey) && !empty($globalConsumerSec)) {
             $this->li();
-            $this->out->element(
-                'label',
-                array('for' => 'global_consumer_key'),
-                ''
-            );
-            $this->out->element(
-                'input',
-                array(
-                    'name'     => 'global_consumer_key',
-                    'type'     => 'text',
-                    'id'       => 'global_consumer_key',
-                    'value'    => $globalConsumerKey,
-                    'disabled' => 'true'
-                )
-            );
-            $this->out->element('p', 'form_guide', _('Global consumer key'));
-            $this->unli();
-
-            $this->li();
-            $this->out->element(
-                'label',
-                array('for' => 'global_consumer_secret'),
-                ''
-            );
-            $this->out->element(
-                'input',
-                array(
-                    'name'     => 'global_consumer_secret',
-                    'type'     => 'text',
-                    'id'       => 'global_consumer_secret',
-                    'value'    => $globalConsumerSec,
-                    'disabled' => 'true'
-                   )
-            );
-            $this->out->element('p', 'form_guide', _('Global consumer secret'));
+            $this->out->element('p', 'form_guide', _('Note: a global consumer key and secret are set.'));
             $this->unli();
         }
 
index f32c57ea451758aa48fa0017817deb74e00cf784..b8dd561ccc7ae0907a54ddaf135e2ef9a4409f6a 100644 (file)
@@ -452,6 +452,13 @@ width:100%;
 float:left;
 }
 
+#content.admin {
+width:95.5%;
+}
+#content.admin #content_inner {
+width:66.3%;
+}
+
 #aside_primary {
 width:27.917%;
 min-height:259px;