summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--EVENTS.txt6
-rw-r--r--actions/apitimelinegroup.php2
-rw-r--r--actions/oauthconnectionssettings.php4
-rw-r--r--actions/showgroup.php5
-rw-r--r--actions/siteadminpanel.php4
-rw-r--r--actions/sitenoticeadminpanel.php201
-rw-r--r--actions/subscribers.php9
-rw-r--r--actions/usergroups.php30
-rw-r--r--classes/User_group.php5
-rw-r--r--index.php2
-rw-r--r--lib/adminpanelaction.php41
-rw-r--r--lib/default.php10
-rw-r--r--lib/router.php1
-rw-r--r--lib/util.php12
-rw-r--r--plugins/OStatus/OStatusPlugin.php26
-rw-r--r--plugins/OStatus/actions/ostatusgroup.php181
-rw-r--r--plugins/OStatus/actions/ostatusinit.php51
-rw-r--r--plugins/OStatus/actions/ostatussub.php134
-rw-r--r--plugins/OStatus/theme/base/css/ostatus.css26
-rw-r--r--plugins/TwitterBridge/twitteradminpanel.php40
-rw-r--r--theme/base/css/display.css7
21 files changed, 596 insertions, 201 deletions
diff --git a/EVENTS.txt b/EVENTS.txt
index 47c67512a..2da6f3da6 100644
--- a/EVENTS.txt
+++ b/EVENTS.txt
@@ -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
diff --git a/actions/apitimelinegroup.php b/actions/apitimelinegroup.php
index d0af49844..e30a08fb5 100644
--- a/actions/apitimelinegroup.php
+++ b/actions/apitimelinegroup.php
@@ -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);
diff --git a/actions/oauthconnectionssettings.php b/actions/oauthconnectionssettings.php
index b1467f0d0..f125f4c63 100644
--- a/actions/oauthconnectionssettings.php
+++ b/actions/oauthconnectionssettings.php
@@ -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));
}
/**
diff --git a/actions/showgroup.php b/actions/showgroup.php
index a1dc3865b..5704b13d1 100644
--- a/actions/showgroup.php
+++ b/actions/showgroup.php
@@ -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');
}
diff --git a/actions/siteadminpanel.php b/actions/siteadminpanel.php
index 8c8f8b374..4b29819b7 100644
--- a/actions/siteadminpanel.php
+++ b/actions/siteadminpanel.php
@@ -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
index 000000000..613a2e96b
--- /dev/null
+++ b/actions/sitenoticeadminpanel.php
@@ -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')
+ );
+ }
+}
diff --git a/actions/subscribers.php b/actions/subscribers.php
index cd3e2ee5b..4bced6284 100644
--- a/actions/subscribers.php
+++ b/actions/subscribers.php
@@ -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();
}
diff --git a/actions/usergroups.php b/actions/usergroups.php
index 97faabae6..29bda0a76 100644
--- a/actions/usergroups.php
+++ b/actions/usergroups.php
@@ -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()
diff --git a/classes/User_group.php b/classes/User_group.php
index 1a5ddf253..0460c9870 100644
--- a/classes/User_group.php
+++ b/classes/User_group.php
@@ -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;
diff --git a/index.php b/index.php
index 06ff9900f..36ba3a0d2 100644
--- 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;
diff --git a/lib/adminpanelaction.php b/lib/adminpanelaction.php
index 536d97cdf..eb622871e 100644
--- a/lib/adminpanelaction.php
+++ b/lib/adminpanelaction.php
@@ -172,6 +172,34 @@ class AdminPanelAction extends Action
}
/**
+ * 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));
diff --git a/lib/default.php b/lib/default.php
index 7b50242ae..8e99a0e1c 100644
--- a/lib/default.php
+++ b/lib/default.php
@@ -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),
diff --git a/lib/router.php b/lib/router.php
index abbce041d..7e8e22a7d 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -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'),
diff --git a/lib/util.php b/lib/util.php
index 46be920fa..da2799d4f 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -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...
diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php
index da7ca2fe2..cc7e75976 100644
--- a/plugins/OStatus/OStatusPlugin.php
+++ b/plugins/OStatus/OStatusPlugin.php
@@ -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
index 000000000..4fcd0eb39
--- /dev/null
+++ b/plugins/OStatus/actions/ostatusgroup.php
@@ -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');
+ }
+}
diff --git a/plugins/OStatus/actions/ostatusinit.php b/plugins/OStatus/actions/ostatusinit.php
index 8ba8dcdcc..1e45025b0 100644
--- a/plugins/OStatus/actions/ostatusinit.php
+++ b/plugins/OStatus/actions/ostatusinit.php
@@ -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');
diff --git a/plugins/OStatus/actions/ostatussub.php b/plugins/OStatus/actions/ostatussub.php
index e318701a2..542f7e20c 100644
--- a/plugins/OStatus/actions/ostatussub.php
+++ b/plugins/OStatus/actions/ostatussub.php
@@ -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,7 +221,7 @@ 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));
@@ -262,32 +229,15 @@ class OStatusSubAction extends Action
}
/**
- * 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
* Fills out $this->oprofile on success.
*
* @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');
+ }
}
diff --git a/plugins/OStatus/theme/base/css/ostatus.css b/plugins/OStatus/theme/base/css/ostatus.css
index d1c60cc0d..ac668623d 100644
--- a/plugins/OStatus/theme/base/css/ostatus.css
+++ b/plugins/OStatus/theme/base/css/ostatus.css
@@ -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;
+
+}
diff --git a/plugins/TwitterBridge/twitteradminpanel.php b/plugins/TwitterBridge/twitteradminpanel.php
index 0ed53bc05..a78a92c66 100644
--- a/plugins/TwitterBridge/twitteradminpanel.php
+++ b/plugins/TwitterBridge/twitteradminpanel.php
@@ -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();
}
diff --git a/theme/base/css/display.css b/theme/base/css/display.css
index f32c57ea4..b8dd561cc 100644
--- a/theme/base/css/display.css
+++ b/theme/base/css/display.css
@@ -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;