From c82efb7fd8ba28b854020821246878fc0a8cec2b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 3 Mar 2010 15:09:07 -0500 Subject: subscribers list wasn't firing correct events --- actions/subscribers.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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(); } -- cgit v1.2.3-54-g00ecf From 2f167f2663b2731d9f5d21bb9893aebff4dcf6f0 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Wed, 3 Mar 2010 12:10:21 -0800 Subject: Fix syntax errors --- actions/oauthconnectionssettings.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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)); } /** -- cgit v1.2.3-54-g00ecf From 0881eba80eabfea65919be2f3d65235ccd0b5eb6 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 3 Mar 2010 12:08:07 -0800 Subject: Language setting fixes: - switch 'en_US' to 'en', fixes the "admin panel switches to Arabic" bug - tweak setting descriptions to clarify that most of the time we'll be using browser language - add a backend switch to disable language detection (should this be exposed to ui?) --- actions/siteadminpanel.php | 4 ++-- index.php | 1 + lib/default.php | 3 ++- lib/util.php | 12 +++++++----- 4 files changed, 12 insertions(+), 8 deletions(-) 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/index.php b/index.php index 06ff9900f..a46bc084d 100644 --- a/index.php +++ b/index.php @@ -253,6 +253,7 @@ function main() $user = common_current_user(); // initialize language env +common_log(LOG_DEBUG, "XXX: WAIII"); common_init_language(); diff --git a/lib/default.php b/lib/default.php index 7b50242ae..b7216045c 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, 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... -- cgit v1.2.3-54-g00ecf From c7d390e4949b28c28c95375bfe4523de05af7808 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Wed, 3 Mar 2010 12:18:20 -0800 Subject: Add class="admin" to the content div of admin panels for styling --- lib/adminpanelaction.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/adminpanelaction.php b/lib/adminpanelaction.php index 536d97cdf..9ea4fe206 100644 --- a/lib/adminpanelaction.php +++ b/lib/adminpanelaction.php @@ -171,6 +171,24 @@ 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'); + } + /** * show human-readable instructions for the page, or * a success/failure on save. -- cgit v1.2.3-54-g00ecf From 2ce9ae004d1f15ea4181f9fa686a73817ee45474 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 3 Mar 2010 15:29:51 -0500 Subject: Added event hooks for before and after user groups content --- EVENTS.txt | 6 ++++++ actions/usergroups.php | 30 +++++++++++++++++------------- 2 files changed, 23 insertions(+), 13 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/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() -- cgit v1.2.3-54-g00ecf From 3c55edde39086918eea8c1adba5d01a026e230a3 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 3 Mar 2010 15:30:43 -0500 Subject: Showing the remote subscribe button on the user groups page --- plugins/OStatus/OStatusPlugin.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php index da7ca2fe2..dc502e52c 100644 --- a/plugins/OStatus/OStatusPlugin.php +++ b/plugins/OStatus/OStatusPlugin.php @@ -729,6 +729,13 @@ class OStatusPlugin extends Plugin return true; } + function onStartShowUserGroupsContent($action) + { + $this->showEntityRemoteSubscribe($action); + + return true; + } + function onEndShowSubscriptionsMiniList($action) { $this->showEntityRemoteSubscribe($action); -- cgit v1.2.3-54-g00ecf From d3c1888256e32495cb0db9065ff7a03e105299a3 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 3 Mar 2010 15:31:16 -0500 Subject: Generalized style for remote subscription button --- plugins/OStatus/theme/base/css/ostatus.css | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/plugins/OStatus/theme/base/css/ostatus.css b/plugins/OStatus/theme/base/css/ostatus.css index d1c60cc0d..3b8928a3a 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; } @@ -55,11 +52,10 @@ margin-bottom:0; border-color:#AAAAAA; } -.section #entity_remote_subscribe .dialogbox { +#entity_remote_subscribe .dialogbox { width:405px; } - .aside #entity_subscriptions .more { float:left; } -- cgit v1.2.3-54-g00ecf From ef6bf8f331175374af6889df82927b3cf6757b8a Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 3 Mar 2010 15:42:34 -0500 Subject: Removed aside container from output for the admin panel sections --- lib/adminpanelaction.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/adminpanelaction.php b/lib/adminpanelaction.php index 9ea4fe206..1d9c42563 100644 --- a/lib/adminpanelaction.php +++ b/lib/adminpanelaction.php @@ -189,6 +189,16 @@ class AdminPanelAction extends Action $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. -- cgit v1.2.3-54-g00ecf From 5c70481d30a82c3f2fe91ef5b24be29b8464ae49 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 3 Mar 2010 15:43:02 -0500 Subject: Using the full width for the content area for the admin section. It also makes the local navigation's tabs stay in context with the content --- theme/base/css/display.css | 7 +++++++ 1 file changed, 7 insertions(+) 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; -- cgit v1.2.3-54-g00ecf From 7e5bf39f768e3c97ddb5b82ad20a690b674f1f47 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 3 Mar 2010 12:57:40 -0800 Subject: Avoid notice on local group creation when uri isn't passed in at create time (needs to be generated) --- classes/User_group.php | 5 +++++ 1 file changed, 5 insertions(+) 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; -- cgit v1.2.3-54-g00ecf From c04c8ae59a7953a21cc464a49b657dfdc926e009 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 3 Mar 2010 13:00:09 -0800 Subject: quick fix: skip notice from unused variable on group atom feed generation --- actions/apitimelinegroup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); -- cgit v1.2.3-54-g00ecf From 339b0b0a4d506638b7b3457db295ab7969e2a9df Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Wed, 3 Mar 2010 13:05:11 -0800 Subject: Don't expose global Twitter consumer key and secret, because that would be idiotic. --- plugins/TwitterBridge/twitteradminpanel.php | 40 +++-------------------------- 1 file changed, 3 insertions(+), 37 deletions(-) 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(); } -- cgit v1.2.3-54-g00ecf From 6ff994b14c93c51f1af1a52d568ffb3391d9c6db Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 3 Mar 2010 16:25:17 -0500 Subject: Fix to group join event position. --- actions/showgroup.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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'); } -- cgit v1.2.3-54-g00ecf From 219e15ac64b0ceefcd714af27b9bbb53123dbe71 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 3 Mar 2010 16:26:02 -0500 Subject: Returning true instead for group remote subscription. If not logged in, it gives the chance to use the logged in join/leave instead. --- plugins/OStatus/OStatusPlugin.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php index dc502e52c..d28260a4a 100644 --- a/plugins/OStatus/OStatusPlugin.php +++ b/plugins/OStatus/OStatusPlugin.php @@ -216,17 +216,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)); $output->element('a', array('href' => $url, 'class' => 'entity_remote_subscribe'), _m('Join')); - - $output->elementEnd('li'); } - return false; + return true; } /** -- cgit v1.2.3-54-g00ecf From a42d1116db06539f2da4eb5332bbdbef5beda3fe Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 3 Mar 2010 13:40:26 -0800 Subject: Separate the UI paths for ostatussub and ostatusgroup. They'll redirect to each other transparently if they find you've put a remote entity of the other type. --- plugins/OStatus/OStatusPlugin.php | 12 +- plugins/OStatus/actions/ostatusgroup.php | 181 +++++++++++++++++++++++++++++++ plugins/OStatus/actions/ostatussub.php | 134 +++++++---------------- 3 files changed, 224 insertions(+), 103 deletions(-) create mode 100644 plugins/OStatus/actions/ostatusgroup.php diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php index dc502e52c..b4b446a7f 100644 --- a/plugins/OStatus/OStatusPlugin.php +++ b/plugins/OStatus/OStatusPlugin.php @@ -51,8 +51,8 @@ class OStatusPlugin extends Plugin array('action' => 'ostatusinit'), array('nickname' => '[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')); @@ -731,7 +731,7 @@ class OStatusPlugin extends Plugin function onStartShowUserGroupsContent($action) { - $this->showEntityRemoteSubscribe($action); + $this->showEntityRemoteSubscribe($action, 'ostatusgroup'); return true; } @@ -745,19 +745,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 @@ +. + */ + +/** + * @package OStatusPlugin + * @maintainer Brion Vibber + */ + +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/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 @@ 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'); + } } -- cgit v1.2.3-54-g00ecf From 628338265c1607000eaffc42418c63092b019720 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 3 Mar 2010 14:06:05 -0800 Subject: OStatus: fix up remote join button on group profiles --- plugins/OStatus/OStatusPlugin.php | 4 ++- plugins/OStatus/actions/ostatusinit.php | 51 ++++++++++++++++++++++++++------- 2 files changed, 44 insertions(+), 11 deletions(-) diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php index ca6786a26..cc7e75976 100644 --- a/plugins/OStatus/OStatusPlugin.php +++ b/plugins/OStatus/OStatusPlugin.php @@ -49,6 +49,8 @@ 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/ostatusgroup', @@ -217,7 +219,7 @@ class OStatusPlugin extends Plugin if (empty($cur)) { // Add an OStatus 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')); 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'); -- cgit v1.2.3-54-g00ecf From 337b1aaaa16bde80b42a9902ebeb299f8f13a226 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Wed, 3 Mar 2010 14:32:14 -0800 Subject: Site-wide notice text admin panel --- actions/sitenoticeadminpanel.php | 201 +++++++++++++++++++++++++++++++++++++++ lib/adminpanelaction.php | 15 ++- lib/default.php | 7 +- lib/router.php | 1 + 4 files changed, 216 insertions(+), 8 deletions(-) create mode 100644 actions/sitenoticeadminpanel.php 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 @@ +. + * + * @category Settings + * @package StatusNet + * @author Zach Copley + * @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 + * @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/lib/adminpanelaction.php b/lib/adminpanelaction.php index 1d9c42563..eb622871e 100644 --- a/lib/adminpanelaction.php +++ b/lib/adminpanelaction.php @@ -173,7 +173,7 @@ class AdminPanelAction extends Action /** * Show content block. Overrided just to add a special class - * to the content div to allow styling. + * to the content div to allow styling. * * @return nothing */ @@ -358,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 b7216045c..8e99a0e1c 100644 --- a/lib/default.php +++ b/lib/default.php @@ -54,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', @@ -283,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'), -- cgit v1.2.3-54-g00ecf From b3969be85ae37b2b3e8abfce2c545866dd910af7 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 3 Mar 2010 17:48:00 -0500 Subject: Updated remote subscribe button style in aside --- plugins/OStatus/theme/base/css/ostatus.css | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/plugins/OStatus/theme/base/css/ostatus.css b/plugins/OStatus/theme/base/css/ostatus.css index 3b8928a3a..ac668623d 100644 --- a/plugins/OStatus/theme/base/css/ostatus.css +++ b/plugins/OStatus/theme/base/css/ostatus.css @@ -48,10 +48,6 @@ position:relative; margin-bottom:0; } -.section #entity_remote_subscribe .entity_remote_subscribe { -border-color:#AAAAAA; -} - #entity_remote_subscribe .dialogbox { width:405px; } @@ -59,3 +55,19 @@ 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; + +} -- cgit v1.2.3-54-g00ecf From 06db00d303bda500eec578b490c12d2bf389c853 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 3 Mar 2010 15:15:46 -0800 Subject: remove debug line --- index.php | 1 - 1 file changed, 1 deletion(-) diff --git a/index.php b/index.php index a46bc084d..06ff9900f 100644 --- a/index.php +++ b/index.php @@ -253,7 +253,6 @@ function main() $user = common_current_user(); // initialize language env -common_log(LOG_DEBUG, "XXX: WAIII"); common_init_language(); -- cgit v1.2.3-54-g00ecf From 4103e8584c7ccfb444af0814345104afedd2c6fc Mon Sep 17 00:00:00 2001 From: James Walker Date: Wed, 3 Mar 2010 18:16:56 -0500 Subject: Making one time passwords work on private sites --- index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- cgit v1.2.3-54-g00ecf