Merge branch 'testing'
This commit is contained in:
commit
0f1c6e239a
@ -778,6 +778,12 @@ StartShowSubscriptionsContent: before showing the subscriptions content
|
|||||||
EndShowSubscriptionsContent: after showing the subscriptions content
|
EndShowSubscriptionsContent: after showing the subscriptions content
|
||||||
- $action: the current action
|
- $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
|
StartShowAllContent: before showing the all (you and friends) content
|
||||||
- $action: the current action
|
- $action: the current action
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
|
|||||||
|
|
||||||
// @todo set all this Atom junk up inside the feed class
|
// @todo set all this Atom junk up inside the feed class
|
||||||
|
|
||||||
$atom->setId($id);
|
#$atom->setId($id);
|
||||||
$atom->setTitle($title);
|
$atom->setTitle($title);
|
||||||
$atom->setSubtitle($subtitle);
|
$atom->setSubtitle($subtitle);
|
||||||
$atom->setLogo($logo);
|
$atom->setLogo($logo);
|
||||||
|
@ -99,7 +99,7 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction
|
|||||||
|
|
||||||
$application = $profile->getApplications($offset, $limit);
|
$application = $profile->getApplications($offset, $limit);
|
||||||
|
|
||||||
$cnt == 0;
|
$cnt = 0;
|
||||||
|
|
||||||
if (!empty($application)) {
|
if (!empty($application)) {
|
||||||
$al = new ApplicationList($application, $user, $this, true);
|
$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->pagination($this->page > 1, $cnt > APPS_PER_PAGE,
|
||||||
$this->page, 'connectionssettings',
|
$this->page, 'connectionssettings',
|
||||||
array('nickname' => $this->user->nickname));
|
array('nickname' => $user->nickname));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -300,8 +300,8 @@ class ShowgroupAction extends GroupDesignAction
|
|||||||
$this->elementStart('div', 'entity_actions');
|
$this->elementStart('div', 'entity_actions');
|
||||||
$this->element('h2', null, _('Group actions'));
|
$this->element('h2', null, _('Group actions'));
|
||||||
$this->elementStart('ul');
|
$this->elementStart('ul');
|
||||||
|
$this->elementStart('li', 'entity_subscribe');
|
||||||
if (Event::handle('StartGroupSubscribe', array($this, $this->group))) {
|
if (Event::handle('StartGroupSubscribe', array($this, $this->group))) {
|
||||||
$this->elementStart('li', 'entity_subscribe');
|
|
||||||
$cur = common_current_user();
|
$cur = common_current_user();
|
||||||
if ($cur) {
|
if ($cur) {
|
||||||
if ($cur->isMember($this->group)) {
|
if ($cur->isMember($this->group)) {
|
||||||
@ -312,10 +312,9 @@ class ShowgroupAction extends GroupDesignAction
|
|||||||
$jf->show();
|
$jf->show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->elementEnd('li');
|
|
||||||
Event::handle('EndGroupSubscribe', array($this, $this->group));
|
Event::handle('EndGroupSubscribe', array($this, $this->group));
|
||||||
}
|
}
|
||||||
|
$this->elementEnd('li');
|
||||||
$this->elementEnd('ul');
|
$this->elementEnd('ul');
|
||||||
$this->elementEnd('div');
|
$this->elementEnd('div');
|
||||||
}
|
}
|
||||||
|
@ -277,8 +277,8 @@ class SiteAdminPanelForm extends AdminForm
|
|||||||
$this->unli();
|
$this->unli();
|
||||||
|
|
||||||
$this->li();
|
$this->li();
|
||||||
$this->out->dropdown('language', _('Language'),
|
$this->out->dropdown('language', _('Default language'),
|
||||||
get_nice_language_list(), _('Default site language'),
|
get_nice_language_list(), _('Site language when autodetection from browser settings is not available'),
|
||||||
false, $this->value('language'));
|
false, $this->value('language'));
|
||||||
$this->unli();
|
$this->unli();
|
||||||
|
|
||||||
|
201
actions/sitenoticeadminpanel.php
Normal file
201
actions/sitenoticeadminpanel.php
Normal file
@ -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')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -143,9 +143,12 @@ class SubscribersListItem extends SubscriptionListItem
|
|||||||
function showActions()
|
function showActions()
|
||||||
{
|
{
|
||||||
$this->startActions();
|
$this->startActions();
|
||||||
$this->showSubscribeButton();
|
if (Event::handle('StartProfileListItemActionElements', array($this))) {
|
||||||
// Relevant code!
|
$this->showSubscribeButton();
|
||||||
$this->showBlockForm();
|
// Relevant code!
|
||||||
|
$this->showBlockForm();
|
||||||
|
Event::handle('EndProfileListItemActionElements', array($this));
|
||||||
|
}
|
||||||
$this->endActions();
|
$this->endActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,22 +130,26 @@ class UsergroupsAction extends OwnerDesignAction
|
|||||||
_('Search for more groups'));
|
_('Search for more groups'));
|
||||||
$this->elementEnd('p');
|
$this->elementEnd('p');
|
||||||
|
|
||||||
$offset = ($this->page-1) * GROUPS_PER_PAGE;
|
if (Event::handle('StartShowUserGroupsContent', array($this))) {
|
||||||
$limit = GROUPS_PER_PAGE + 1;
|
$offset = ($this->page-1) * GROUPS_PER_PAGE;
|
||||||
|
$limit = GROUPS_PER_PAGE + 1;
|
||||||
|
|
||||||
$groups = $this->user->getGroups($offset, $limit);
|
$groups = $this->user->getGroups($offset, $limit);
|
||||||
|
|
||||||
if ($groups) {
|
if ($groups) {
|
||||||
$gl = new GroupList($groups, $this->user, $this);
|
$gl = new GroupList($groups, $this->user, $this);
|
||||||
$cnt = $gl->show();
|
$cnt = $gl->show();
|
||||||
if (0 == $cnt) {
|
if (0 == $cnt) {
|
||||||
$this->showEmptyListMessage();
|
$this->showEmptyListMessage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE,
|
$this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE,
|
||||||
$this->page, 'usergroups',
|
$this->page, 'usergroups',
|
||||||
array('nickname' => $this->user->nickname));
|
array('nickname' => $this->user->nickname));
|
||||||
|
|
||||||
|
Event::handle('EndShowUserGroupsContent', array($this));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showEmptyListMessage()
|
function showEmptyListMessage()
|
||||||
|
@ -455,6 +455,11 @@ class User_group extends Memcached_DataObject
|
|||||||
$group = new User_group();
|
$group = new User_group();
|
||||||
|
|
||||||
$group->query('BEGIN');
|
$group->query('BEGIN');
|
||||||
|
|
||||||
|
if (empty($uri)) {
|
||||||
|
// fill in later...
|
||||||
|
$uri = null;
|
||||||
|
}
|
||||||
|
|
||||||
$group->nickname = $nickname;
|
$group->nickname = $nickname;
|
||||||
$group->fullname = $fullname;
|
$group->fullname = $fullname;
|
||||||
|
@ -185,7 +185,7 @@ function checkMirror($action_obj, $args)
|
|||||||
|
|
||||||
function isLoginAction($action)
|
function isLoginAction($action)
|
||||||
{
|
{
|
||||||
static $loginActions = array('login', 'recoverpassword', 'api', 'doc', 'register', 'publicxrds');
|
static $loginActions = array('login', 'recoverpassword', 'api', 'doc', 'register', 'publicxrds', 'otp');
|
||||||
|
|
||||||
$login = null;
|
$login = null;
|
||||||
|
|
||||||
|
@ -171,6 +171,34 @@ class AdminPanelAction extends Action
|
|||||||
$this->showForm();
|
$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
|
* show human-readable instructions for the page, or
|
||||||
* a success/failure on save.
|
* a success/failure on save.
|
||||||
@ -330,22 +358,27 @@ class AdminPanelNav extends Widget
|
|||||||
|
|
||||||
if (AdminPanelAction::canAdmin('user')) {
|
if (AdminPanelAction::canAdmin('user')) {
|
||||||
$this->out->menuItem(common_local_url('useradminpanel'), _('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')) {
|
if (AdminPanelAction::canAdmin('access')) {
|
||||||
$this->out->menuItem(common_local_url('accessadminpanel'), _('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')) {
|
if (AdminPanelAction::canAdmin('paths')) {
|
||||||
$this->out->menuItem(common_local_url('pathsadminpanel'), _('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')) {
|
if (AdminPanelAction::canAdmin('sessions')) {
|
||||||
$this->out->menuItem(common_local_url('sessionsadminpanel'), _('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));
|
Event::handle('EndAdminPanelNav', array($this));
|
||||||
|
@ -40,7 +40,8 @@ $default =
|
|||||||
'logdebug' => false,
|
'logdebug' => false,
|
||||||
'fancy' => false,
|
'fancy' => false,
|
||||||
'locale_path' => INSTALLDIR.'/locale',
|
'locale_path' => INSTALLDIR.'/locale',
|
||||||
'language' => 'en_US',
|
'language' => 'en',
|
||||||
|
'langdetect' => true,
|
||||||
'languages' => get_all_languages(),
|
'languages' => get_all_languages(),
|
||||||
'email' =>
|
'email' =>
|
||||||
array_key_exists('SERVER_ADMIN', $_SERVER) ? $_SERVER['SERVER_ADMIN'] : null,
|
array_key_exists('SERVER_ADMIN', $_SERVER) ? $_SERVER['SERVER_ADMIN'] : null,
|
||||||
@ -53,10 +54,11 @@ $default =
|
|||||||
'ssl' => 'never',
|
'ssl' => 'never',
|
||||||
'sslserver' => null,
|
'sslserver' => null,
|
||||||
'shorturllength' => 30,
|
'shorturllength' => 30,
|
||||||
'dupelimit' => 60, # default for same person saying the same thing
|
'dupelimit' => 60, // default for same person saying the same thing
|
||||||
'textlimit' => 140,
|
'textlimit' => 140,
|
||||||
'indent' => true,
|
'indent' => true,
|
||||||
'use_x_sendfile' => false
|
'use_x_sendfile' => false,
|
||||||
|
'notice' => null // site wide notice text
|
||||||
),
|
),
|
||||||
'db' =>
|
'db' =>
|
||||||
array('database' => 'YOU HAVE TO SET THIS IN config.php',
|
array('database' => 'YOU HAVE TO SET THIS IN config.php',
|
||||||
@ -282,7 +284,7 @@ $default =
|
|||||||
'OpenID' => null),
|
'OpenID' => null),
|
||||||
),
|
),
|
||||||
'admin' =>
|
'admin' =>
|
||||||
array('panels' => array('design', 'site', 'user', 'paths', 'access', 'sessions')),
|
array('panels' => array('design', 'site', 'user', 'paths', 'access', 'sessions', 'sitenotice')),
|
||||||
'singleuser' =>
|
'singleuser' =>
|
||||||
array('enabled' => false,
|
array('enabled' => false,
|
||||||
'nickname' => null),
|
'nickname' => null),
|
||||||
|
@ -649,6 +649,7 @@ class Router
|
|||||||
$m->connect('admin/access', array('action' => 'accessadminpanel'));
|
$m->connect('admin/access', array('action' => 'accessadminpanel'));
|
||||||
$m->connect('admin/paths', array('action' => 'pathsadminpanel'));
|
$m->connect('admin/paths', array('action' => 'pathsadminpanel'));
|
||||||
$m->connect('admin/sessions', array('action' => 'sessionsadminpanel'));
|
$m->connect('admin/sessions', array('action' => 'sessionsadminpanel'));
|
||||||
|
$m->connect('admin/sitenotice', array('action' => 'sitenoticeadminpanel'));
|
||||||
|
|
||||||
$m->connect('getfile/:filename',
|
$m->connect('getfile/:filename',
|
||||||
array('action' => 'getfile'),
|
array('action' => 'getfile'),
|
||||||
|
12
lib/util.php
12
lib/util.php
@ -105,11 +105,13 @@ function common_language()
|
|||||||
|
|
||||||
// Otherwise, find the best match for the languages requested by the
|
// Otherwise, find the best match for the languages requested by the
|
||||||
// user's browser...
|
// user's browser...
|
||||||
$httplang = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : null;
|
if (common_config('site', 'langdetect')) {
|
||||||
if (!empty($httplang)) {
|
$httplang = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : null;
|
||||||
$language = client_prefered_language($httplang);
|
if (!empty($httplang)) {
|
||||||
if ($language)
|
$language = client_prefered_language($httplang);
|
||||||
return $language;
|
if ($language)
|
||||||
|
return $language;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally, if none of the above worked, use the site's default...
|
// Finally, if none of the above worked, use the site's default...
|
||||||
|
@ -49,10 +49,12 @@ class OStatusPlugin extends Plugin
|
|||||||
array('action' => 'ostatusinit'));
|
array('action' => 'ostatusinit'));
|
||||||
$m->connect('main/ostatus?nickname=:nickname',
|
$m->connect('main/ostatus?nickname=:nickname',
|
||||||
array('action' => 'ostatusinit'), array('nickname' => '[A-Za-z0-9_-]+'));
|
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',
|
$m->connect('main/ostatussub',
|
||||||
array('action' => 'ostatussub'));
|
array('action' => 'ostatussub'));
|
||||||
$m->connect('main/ostatussub',
|
$m->connect('main/ostatusgroup',
|
||||||
array('action' => 'ostatussub'), array('feed' => '[A-Za-z0-9\.\/\:]+'));
|
array('action' => 'ostatusgroup'));
|
||||||
|
|
||||||
// PuSH actions
|
// PuSH actions
|
||||||
$m->connect('main/push/hub', array('action' => 'pushhub'));
|
$m->connect('main/push/hub', array('action' => 'pushhub'));
|
||||||
@ -216,17 +218,14 @@ class OStatusPlugin extends Plugin
|
|||||||
|
|
||||||
if (empty($cur)) {
|
if (empty($cur)) {
|
||||||
// Add an OStatus subscribe
|
// Add an OStatus subscribe
|
||||||
$output->elementStart('li', 'entity_subscribe');
|
|
||||||
$url = common_local_url('ostatusinit',
|
$url = common_local_url('ostatusinit',
|
||||||
array('nickname' => $group->nickname));
|
array('group' => $group->nickname));
|
||||||
$output->element('a', array('href' => $url,
|
$output->element('a', array('href' => $url,
|
||||||
'class' => 'entity_remote_subscribe'),
|
'class' => 'entity_remote_subscribe'),
|
||||||
_m('Join'));
|
_m('Join'));
|
||||||
|
|
||||||
$output->elementEnd('li');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -729,6 +728,13 @@ class OStatusPlugin extends Plugin
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onStartShowUserGroupsContent($action)
|
||||||
|
{
|
||||||
|
$this->showEntityRemoteSubscribe($action, 'ostatusgroup');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function onEndShowSubscriptionsMiniList($action)
|
function onEndShowSubscriptionsMiniList($action)
|
||||||
{
|
{
|
||||||
$this->showEntityRemoteSubscribe($action);
|
$this->showEntityRemoteSubscribe($action);
|
||||||
@ -738,19 +744,19 @@ class OStatusPlugin extends Plugin
|
|||||||
|
|
||||||
function onEndShowGroupsMiniList($action)
|
function onEndShowGroupsMiniList($action)
|
||||||
{
|
{
|
||||||
$this->showEntityRemoteSubscribe($action);
|
$this->showEntityRemoteSubscribe($action, 'ostatusgroup');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function showEntityRemoteSubscribe($action)
|
function showEntityRemoteSubscribe($action, $target='ostatussub')
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
if ($user && ($user->id == $action->profile->id)) {
|
if ($user && ($user->id == $action->profile->id)) {
|
||||||
$action->elementStart('div', 'entity_actions');
|
$action->elementStart('div', 'entity_actions');
|
||||||
$action->elementStart('p', array('id' => 'entity_remote_subscribe',
|
$action->elementStart('p', array('id' => 'entity_remote_subscribe',
|
||||||
'class' => 'entity_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')
|
'class' => 'entity_remote_subscribe')
|
||||||
, _m('Remote'));
|
, _m('Remote'));
|
||||||
$action->elementEnd('p');
|
$action->elementEnd('p');
|
||||||
|
181
plugins/OStatus/actions/ostatusgroup.php
Normal file
181
plugins/OStatus/actions/ostatusgroup.php
Normal file
@ -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');
|
||||||
|
}
|
||||||
|
}
|
@ -29,6 +29,7 @@ class OStatusInitAction extends Action
|
|||||||
{
|
{
|
||||||
|
|
||||||
var $nickname;
|
var $nickname;
|
||||||
|
var $group;
|
||||||
var $profile;
|
var $profile;
|
||||||
var $err;
|
var $err;
|
||||||
|
|
||||||
@ -41,8 +42,9 @@ class OStatusInitAction extends Action
|
|||||||
return false;
|
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->nickname = $this->trimmed('nickname');
|
||||||
|
$this->group = $this->trimmed('group');
|
||||||
|
|
||||||
// Webfinger or profile URL of the remote user
|
// Webfinger or profile URL of the remote user
|
||||||
$this->profile = $this->trimmed('profile');
|
$this->profile = $this->trimmed('profile');
|
||||||
@ -89,25 +91,33 @@ class OStatusInitAction extends Action
|
|||||||
|
|
||||||
function showContent()
|
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',
|
$this->elementStart('form', array('id' => 'form_ostatus_connect',
|
||||||
'method' => 'post',
|
'method' => 'post',
|
||||||
'class' => 'form_settings',
|
'class' => 'form_settings',
|
||||||
'action' => common_local_url('ostatusinit')));
|
'action' => common_local_url('ostatusinit')));
|
||||||
$this->elementStart('fieldset');
|
$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->hidden('token', common_session_token());
|
||||||
|
|
||||||
$this->elementStart('ul', 'form_data');
|
$this->elementStart('ul', 'form_data');
|
||||||
$this->elementStart('li', array('id' => 'ostatus_nickname'));
|
$this->elementStart('li', array('id' => 'ostatus_nickname'));
|
||||||
$this->input('nickname', _m('User nickname'), $this->nickname,
|
$this->input('nickname', _m('User nickname'), $this->nickname,
|
||||||
_m('Nickname of the user you want to follow'));
|
_m('Nickname of the user you want to follow'));
|
||||||
|
$this->hidden('group', $this->group); // pass-through for magic links
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
$this->elementStart('li', array('id' => 'ostatus_profile'));
|
$this->elementStart('li', array('id' => 'ostatus_profile'));
|
||||||
$this->input('profile', _m('Profile Account'), $this->profile,
|
$this->input('profile', _m('Profile Account'), $this->profile,
|
||||||
_m('Your account id (i.e. user@identi.ca)'));
|
_m('Your account id (i.e. user@identi.ca)'));
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
$this->elementEnd('ul');
|
$this->elementEnd('ul');
|
||||||
$this->submit('submit', _m('Subscribe'));
|
$this->submit('submit', $submit);
|
||||||
$this->elementEnd('fieldset');
|
$this->elementEnd('fieldset');
|
||||||
$this->elementEnd('form');
|
$this->elementEnd('form');
|
||||||
}
|
}
|
||||||
@ -131,19 +141,17 @@ class OStatusInitAction extends Action
|
|||||||
|
|
||||||
function connectWebfinger($acct)
|
function connectWebfinger($acct)
|
||||||
{
|
{
|
||||||
$disco = new Discovery;
|
$target_profile = $this->targetProfile();
|
||||||
|
|
||||||
|
$disco = new Discovery;
|
||||||
$result = $disco->lookup($acct);
|
$result = $disco->lookup($acct);
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
$this->clientError(_m("Couldn't look up OStatus account profile."));
|
$this->clientError(_m("Couldn't look up OStatus account profile."));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($result->links as $link) {
|
foreach ($result->links as $link) {
|
||||||
if ($link['rel'] == 'http://ostatus.org/schema/1.0/subscribe') {
|
if ($link['rel'] == 'http://ostatus.org/schema/1.0/subscribe') {
|
||||||
// We found a URL - let's redirect!
|
// 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);
|
$url = Discovery::applyTemplate($link['template'], $target_profile);
|
||||||
common_log(LOG_INFO, "Sending remote subscriber $acct to $url");
|
common_log(LOG_INFO, "Sending remote subscriber $acct to $url");
|
||||||
common_redirect($url, 303);
|
common_redirect($url, 303);
|
||||||
@ -155,8 +163,7 @@ class OStatusInitAction extends Action
|
|||||||
|
|
||||||
function connectProfile($subscriber_profile)
|
function connectProfile($subscriber_profile)
|
||||||
{
|
{
|
||||||
$user = User::staticGet('nickname', $this->nickname);
|
$target_profile = $this->targetProfile();
|
||||||
$target_profile = common_local_url('userbyid', array('id' => $user->id));
|
|
||||||
|
|
||||||
// @fixme hack hack! We should look up the remote sub URL from XRDS
|
// @fixme hack hack! We should look up the remote sub URL from XRDS
|
||||||
$suburl = preg_replace('!^(.*)/(.*?)$!', '$1/main/ostatussub', $subscriber_profile);
|
$suburl = preg_replace('!^(.*)/(.*?)$!', '$1/main/ostatussub', $subscriber_profile);
|
||||||
@ -166,6 +173,30 @@ class OStatusInitAction extends Action
|
|||||||
common_redirect($suburl, 303);
|
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()
|
function title()
|
||||||
{
|
{
|
||||||
return _m('OStatus Connect');
|
return _m('OStatus Connect');
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* StatusNet - the distributed open-source microblogging tool
|
* 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
|
* 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
|
* 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
|
* We end up back here on errors
|
||||||
*
|
*
|
||||||
* showPreviewForm() - surrounding form for preview-and-confirm
|
* showPreviewForm() - surrounding form for preview-and-confirm
|
||||||
* previewUser() - display profile for a remote user
|
* preview() - display profile for a remote user
|
||||||
* previewGroup() - display profile for a remote group
|
|
||||||
*
|
*
|
||||||
* successUser() - redirects to subscriptions page on subscribe
|
* success() - redirects to subscriptions page on subscribe
|
||||||
* successGroup() - redirects to groups page on join
|
|
||||||
*/
|
*/
|
||||||
class OStatusSubAction extends Action
|
class OStatusSubAction extends Action
|
||||||
{
|
{
|
||||||
@ -55,8 +53,7 @@ class OStatusSubAction extends Action
|
|||||||
$this->elementStart('form', array('method' => 'post',
|
$this->elementStart('form', array('method' => 'post',
|
||||||
'id' => 'form_ostatus_sub',
|
'id' => 'form_ostatus_sub',
|
||||||
'class' => 'form_settings',
|
'class' => 'form_settings',
|
||||||
'action' =>
|
'action' => $this->selfLink()));
|
||||||
common_local_url('ostatussub')));
|
|
||||||
|
|
||||||
$this->hidden('token', common_session_token());
|
$this->hidden('token', common_session_token());
|
||||||
|
|
||||||
@ -87,11 +84,7 @@ class OStatusSubAction extends Action
|
|||||||
*/
|
*/
|
||||||
function showPreviewForm()
|
function showPreviewForm()
|
||||||
{
|
{
|
||||||
if ($this->oprofile->isGroup()) {
|
$ok = $this->preview();
|
||||||
$ok = $this->previewGroup();
|
|
||||||
} else {
|
|
||||||
$ok = $this->previewUser();
|
|
||||||
}
|
|
||||||
if (!$ok) {
|
if (!$ok) {
|
||||||
// @fixme maybe provide a cancel button or link back?
|
// @fixme maybe provide a cancel button or link back?
|
||||||
return;
|
return;
|
||||||
@ -104,7 +97,7 @@ class OStatusSubAction extends Action
|
|||||||
'id' => 'form_ostatus_sub',
|
'id' => 'form_ostatus_sub',
|
||||||
'class' => 'form_remote_authorize',
|
'class' => 'form_remote_authorize',
|
||||||
'action' =>
|
'action' =>
|
||||||
common_local_url('ostatussub')));
|
$this->selfLink()));
|
||||||
$this->elementStart('fieldset');
|
$this->elementStart('fieldset');
|
||||||
$this->hidden('token', common_session_token());
|
$this->hidden('token', common_session_token());
|
||||||
$this->hidden('profile', $this->profile_uri);
|
$this->hidden('profile', $this->profile_uri);
|
||||||
@ -126,7 +119,7 @@ class OStatusSubAction extends Action
|
|||||||
* Show a preview for a remote user's profile
|
* Show a preview for a remote user's profile
|
||||||
* @return boolean true if we're ok to try subscribing
|
* @return boolean true if we're ok to try subscribing
|
||||||
*/
|
*/
|
||||||
function previewUser()
|
function preview()
|
||||||
{
|
{
|
||||||
$oprofile = $this->oprofile;
|
$oprofile = $this->oprofile;
|
||||||
$profile = $oprofile->localProfile();
|
$profile = $oprofile->localProfile();
|
||||||
@ -150,32 +143,6 @@ class OStatusSubAction extends Action
|
|||||||
return $ok;
|
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)
|
function showEntity($entity, $profile, $avatar, $note)
|
||||||
{
|
{
|
||||||
$nickname = $entity->nickname;
|
$nickname = $entity->nickname;
|
||||||
@ -254,23 +221,13 @@ class OStatusSubAction extends Action
|
|||||||
/**
|
/**
|
||||||
* Redirect on successful remote user subscription
|
* Redirect on successful remote user subscription
|
||||||
*/
|
*/
|
||||||
function successUser()
|
function success()
|
||||||
{
|
{
|
||||||
$cur = common_current_user();
|
$cur = common_current_user();
|
||||||
$url = common_local_url('subscriptions', array('nickname' => $cur->nickname));
|
$url = common_local_url('subscriptions', array('nickname' => $cur->nickname));
|
||||||
common_redirect($url, 303);
|
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.
|
* Pull data for a remote profile and check if it's valid.
|
||||||
* Fills out error UI string in $this->error
|
* Fills out error UI string in $this->error
|
||||||
@ -278,16 +235,9 @@ class OStatusSubAction extends Action
|
|||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function validateFeed()
|
function pullRemoteProfile()
|
||||||
{
|
{
|
||||||
$profile_uri = trim($this->arg('profile'));
|
$this->profile_uri = $this->trimmed('profile');
|
||||||
|
|
||||||
if ($profile_uri == '') {
|
|
||||||
$this->showForm(_m('Empty remote profile URL!'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$this->profile_uri = $profile_uri;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (Validate::email($this->profile_uri)) {
|
if (Validate::email($this->profile_uri)) {
|
||||||
$this->oprofile = Ostatus_profile::ensureWebfinger($this->profile_uri);
|
$this->oprofile = Ostatus_profile::ensureWebfinger($this->profile_uri);
|
||||||
@ -318,48 +268,34 @@ class OStatusSubAction extends Action
|
|||||||
return false;
|
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.
|
* Attempt to finalize subscription.
|
||||||
* validateFeed must have been run first.
|
* 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()
|
function saveFeed()
|
||||||
{
|
{
|
||||||
// And subscribe the current user to the local profile
|
// And subscribe the current user to the local profile
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
$local = $this->oprofile->localProfile();
|
||||||
if ($this->oprofile->isGroup()) {
|
if ($user->isSubscribed($local)) {
|
||||||
$group = $this->oprofile->localGroup();
|
// TRANS: OStatus remote subscription dialog error.
|
||||||
if ($user->isMember($group)) {
|
$this->showForm(_m('Already subscribed!'));
|
||||||
// TRANS: OStatus remote group subscription dialog error.
|
} elseif ($this->oprofile->subscribeLocalToRemote($user)) {
|
||||||
$this->showForm(_m('Already a member!'));
|
$this->success();
|
||||||
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!'));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$local = $this->oprofile->localProfile();
|
// TRANS: OStatus remote subscription dialog error.
|
||||||
if ($user->isSubscribed($local)) {
|
$this->showForm(_m('Remote subscription failed!'));
|
||||||
// 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!'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,7 +312,9 @@ class OStatusSubAction extends Action
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->profile_uri = $this->arg('profile');
|
if ($this->pullRemoteProfile()) {
|
||||||
|
$this->validateRemoteProfile();
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -390,9 +328,6 @@ class OStatusSubAction extends Action
|
|||||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
$this->handlePost();
|
$this->handlePost();
|
||||||
} else {
|
} else {
|
||||||
if ($this->arg('profile')) {
|
|
||||||
$this->validateFeed();
|
|
||||||
}
|
|
||||||
$this->showForm();
|
$this->showForm();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -414,7 +349,7 @@ class OStatusSubAction extends Action
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->validateFeed()) {
|
if ($this->oprofile) {
|
||||||
if ($this->arg('submit')) {
|
if ($this->arg('submit')) {
|
||||||
$this->saveFeed();
|
$this->saveFeed();
|
||||||
return;
|
return;
|
||||||
@ -500,4 +435,9 @@ class OStatusSubAction extends Action
|
|||||||
parent::showScripts();
|
parent::showScripts();
|
||||||
$this->autofocus('feedurl');
|
$this->autofocus('feedurl');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function selfLink()
|
||||||
|
{
|
||||||
|
return common_local_url('ostatussub');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,9 +41,6 @@ min-width:96px;
|
|||||||
#entity_remote_subscribe {
|
#entity_remote_subscribe {
|
||||||
padding:0;
|
padding:0;
|
||||||
float:right;
|
float:right;
|
||||||
}
|
|
||||||
|
|
||||||
.section #entity_remote_subscribe {
|
|
||||||
position:relative;
|
position:relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,15 +48,26 @@ position:relative;
|
|||||||
margin-bottom:0;
|
margin-bottom:0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.section #entity_remote_subscribe .entity_remote_subscribe {
|
#entity_remote_subscribe .dialogbox {
|
||||||
border-color:#AAAAAA;
|
|
||||||
}
|
|
||||||
|
|
||||||
.section #entity_remote_subscribe .dialogbox {
|
|
||||||
width:405px;
|
width:405px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.aside #entity_subscriptions .more {
|
.aside #entity_subscriptions .more {
|
||||||
float:left;
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -225,46 +225,12 @@ class TwitterAdminPanelForm extends AdminForm
|
|||||||
);
|
);
|
||||||
$this->unli();
|
$this->unli();
|
||||||
|
|
||||||
$globalConsumerKey = common_config('twitter', 'global_consumer_key');
|
$globalConsumerKey = common_config('twitter', 'global_consumer_key');
|
||||||
$globalConsumerSec = common_config('twitter', 'global_consumer_secret');
|
$globalConsumerSec = common_config('twitter', 'global_consumer_secret');
|
||||||
|
|
||||||
if (!empty($globalConsumerKey)) {
|
if (!empty($globalConsumerKey) && !empty($globalConsumerSec)) {
|
||||||
$this->li();
|
$this->li();
|
||||||
$this->out->element(
|
$this->out->element('p', 'form_guide', _('Note: a global consumer key and secret are set.'));
|
||||||
'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->unli();
|
$this->unli();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,6 +452,13 @@ width:100%;
|
|||||||
float:left;
|
float:left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#content.admin {
|
||||||
|
width:95.5%;
|
||||||
|
}
|
||||||
|
#content.admin #content_inner {
|
||||||
|
width:66.3%;
|
||||||
|
}
|
||||||
|
|
||||||
#aside_primary {
|
#aside_primary {
|
||||||
width:27.917%;
|
width:27.917%;
|
||||||
min-height:259px;
|
min-height:259px;
|
||||||
|
Loading…
Reference in New Issue
Block a user