summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
Diffstat (limited to 'actions')
-rw-r--r--actions/all.php45
-rw-r--r--actions/block.php11
-rw-r--r--actions/deletenotice.php2
-rw-r--r--actions/disfavor.php5
-rw-r--r--actions/editgroup.php3
-rw-r--r--actions/favor.php7
-rw-r--r--actions/favorited.php24
-rw-r--r--actions/finishaddopenid.php2
-rw-r--r--actions/finishopenidlogin.php5
-rw-r--r--actions/finishremotesubscribe.php3
-rw-r--r--actions/foaf.php63
-rw-r--r--actions/groupsearch.php35
-rw-r--r--actions/joingroup.php3
-rw-r--r--actions/leavegroup.php3
-rw-r--r--actions/login.php2
-rw-r--r--actions/logout.php8
-rw-r--r--actions/newgroup.php2
-rw-r--r--actions/noticesearch.php26
-rw-r--r--actions/noticesearchrss.php3
-rw-r--r--actions/nudge.php7
-rw-r--r--actions/peoplesearch.php21
-rw-r--r--actions/public.php31
-rw-r--r--actions/publictagcloud.php18
-rw-r--r--actions/recoverpassword.php22
-rw-r--r--actions/remotesubscribe.php6
-rw-r--r--actions/replies.php24
-rw-r--r--actions/showfavorites.php27
-rw-r--r--actions/showgroup.php25
-rw-r--r--actions/shownotice.php16
-rw-r--r--actions/showstream.php251
-rw-r--r--actions/smssettings.php3
-rw-r--r--actions/subedit.php3
-rw-r--r--actions/subscribe.php3
-rw-r--r--actions/subscribers.php22
-rw-r--r--actions/subscriptions.php22
-rw-r--r--actions/sup.php2
-rw-r--r--actions/tag.php4
-rw-r--r--actions/tagother.php3
-rw-r--r--actions/unblock.php5
-rw-r--r--actions/unsubscribe.php3
-rw-r--r--actions/userauthorization.php268
-rw-r--r--actions/usergroups.php18
42 files changed, 531 insertions, 525 deletions
diff --git a/actions/all.php b/actions/all.php
index 8e67ec0f3..f5bbfe2e3 100644
--- a/actions/all.php
+++ b/actions/all.php
@@ -23,31 +23,13 @@ require_once INSTALLDIR.'/lib/personalgroupnav.php';
require_once INSTALLDIR.'/lib/noticelist.php';
require_once INSTALLDIR.'/lib/feedlist.php';
-class AllAction extends Action
+class AllAction extends ProfileAction
{
- var $user = null;
- var $page = null;
-
function isReadOnly()
{
return true;
}
- function prepare($args)
- {
- parent::prepare($args);
- $nickname = common_canonical_nickname($this->arg('nickname'));
- $this->user = User::staticGet('nickname', $nickname);
- $this->page = $this->trimmed('page');
- if (!$this->page) {
- $this->page = 1;
- }
-
- common_set_returnto($this->selfUrl());
-
- return true;
- }
-
function handle($args)
{
parent::handle($args);
@@ -93,6 +75,27 @@ class AllAction extends Action
$nav->show();
}
+ function showEmptyListMessage()
+ {
+ $message = sprintf(_('This is the timeline for %s and friends but no one has posted anything yet.'), $this->user->nickname) . ' ';
+
+ if (common_logged_in()) {
+ $current_user = common_current_user();
+ if ($this->user->id === $current_user->id) {
+ $message .= _('Try subscribing to more people, [join a group](%%action.groups) or post something yourself.');
+ } else {
+ $message .= sprintf(_('You can try to [nudge %s](../%s) from his profile or [post something to his or her attention](%%%%action.newnotice%%%%?status_textarea=%s).'), $this->user->nickname, $this->user->nickname, '@' . $this->user->nickname);
+ }
+ }
+ else {
+ $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to his or her attention.'), $this->user->nickname);
+ }
+
+ $this->elementStart('div', 'guide');
+ $this->raw(common_markup_to_html($message));
+ $this->elementEnd('div');
+ }
+
function showContent()
{
$notice = $this->user->noticesWithFriends(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
@@ -101,6 +104,10 @@ class AllAction extends Action
$cnt = $nl->show();
+ if (0 == $cnt) {
+ $this->showEmptyListMessage();
+ }
+
$this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
$this->page, 'all', array('nickname' => $this->user->nickname));
}
diff --git a/actions/block.php b/actions/block.php
index e77b634c8..34f991dc6 100644
--- a/actions/block.php
+++ b/actions/block.php
@@ -93,7 +93,8 @@ class BlockAction extends Action
if ($this->arg('no')) {
$cur = common_current_user();
$other = Profile::staticGet('id', $this->arg('blockto'));
- common_redirect(common_local_url('showstream', array('nickname' => $other->nickname)));
+ common_redirect(common_local_url('showstream', array('nickname' => $other->nickname)),
+ 303);
} elseif ($this->arg('yes')) {
$this->blockProfile();
} elseif ($this->arg('blockto')) {
@@ -102,7 +103,6 @@ class BlockAction extends Action
}
}
-
function showContent() {
$this->areYouSureForm();
}
@@ -110,7 +110,7 @@ class BlockAction extends Action
function title() {
return _('Block user');
}
-
+
function showNoticeForm() {
// nop
}
@@ -178,10 +178,11 @@ class BlockAction extends Action
}
if ($action) {
- common_redirect(common_local_url($action, $args));
+ common_redirect(common_local_url($action, $args), 303);
} else {
common_redirect(common_local_url('subscriptions',
- array('nickname' => $cur->nickname)));
+ array('nickname' => $cur->nickname)),
+ 303);
}
}
}
diff --git a/actions/deletenotice.php b/actions/deletenotice.php
index 16e2df889..6c350b33a 100644
--- a/actions/deletenotice.php
+++ b/actions/deletenotice.php
@@ -141,6 +141,6 @@ class DeletenoticeAction extends DeleteAction
$url = common_local_url('public');
}
- common_redirect($url);
+ common_redirect($url, 303);
}
}
diff --git a/actions/disfavor.php b/actions/disfavor.php
index 90bab3cca..bc13b09da 100644
--- a/actions/disfavor.php
+++ b/actions/disfavor.php
@@ -49,7 +49,7 @@ class DisfavorAction extends Action
{
/**
* Class handler.
- *
+ *
* @param array $args query arguments
*
* @return void
@@ -100,7 +100,8 @@ class DisfavorAction extends Action
$this->elementEnd('html');
} else {
common_redirect(common_local_url('showfavorites',
- array('nickname' => $user->nickname)));
+ array('nickname' => $user->nickname)),
+ 303);
}
}
}
diff --git a/actions/editgroup.php b/actions/editgroup.php
index e7e79040a..39dad0465 100644
--- a/actions/editgroup.php
+++ b/actions/editgroup.php
@@ -166,7 +166,6 @@ class EditgroupAction extends Action
return;
}
-
$nickname = common_canonical_nickname($this->trimmed('nickname'));
$fullname = $this->trimmed('fullname');
$homepage = $this->trimmed('homepage');
@@ -221,7 +220,7 @@ class EditgroupAction extends Action
if ($this->group->nickname != $orig->nickname) {
common_redirect(common_local_url('editgroup',
array('nickname' => $nickname)),
- 307);
+ 303);
} else {
$this->showForm(_('Options saved.'));
}
diff --git a/actions/favor.php b/actions/favor.php
index 3940df688..3b7d979eb 100644
--- a/actions/favor.php
+++ b/actions/favor.php
@@ -52,7 +52,7 @@ class FavorAction extends Action
{
/**
* Class handler.
- *
+ *
* @param array $args query arguments
*
* @return void
@@ -100,13 +100,14 @@ class FavorAction extends Action
$this->elementEnd('html');
} else {
common_redirect(common_local_url('showfavorites',
- array('nickname' => $user->nickname)));
+ array('nickname' => $user->nickname)),
+ 303);
}
}
/**
* Notifies a user when his notice is favorited.
- *
+ *
* @param class $notice favorited notice
* @param class $user user declaring a favorite
*
diff --git a/actions/favorited.php b/actions/favorited.php
index 231b97897..09ab1216a 100644
--- a/actions/favorited.php
+++ b/actions/favorited.php
@@ -104,9 +104,9 @@ class FavoritedAction extends Action
{
parent::prepare($args);
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
-
+
common_set_returnto($this->selfUrl());
-
+
return true;
}
@@ -145,6 +145,22 @@ class FavoritedAction extends Action
$this->elementEnd('div');
}
+ function showEmptyList()
+ {
+ $message = _('Favorite notices appear on this page but no one has favorited one yet.') . ' ';
+
+ if (common_logged_in()) {
+ $message .= _('Be the first to add a notice to your favorites by clicking the fave button next to any notice you like.');
+ }
+ else {
+ $message .= _('Why not [register an account](%%action.register%%) and be the first to add a notice to your favorites!');
+ }
+
+ $this->elementStart('div', 'guide');
+ $this->raw(common_markup_to_html($message));
+ $this->elementEnd('div');
+ }
+
/**
* Local navigation
*
@@ -198,6 +214,10 @@ class FavoritedAction extends Action
$cnt = $nl->show();
+ if ($cnt == 0) {
+ $this->showEmptyList();
+ }
+
$this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
$this->page, 'favorited');
}
diff --git a/actions/finishaddopenid.php b/actions/finishaddopenid.php
index 8f10505cf..32bceecfd 100644
--- a/actions/finishaddopenid.php
+++ b/actions/finishaddopenid.php
@@ -139,7 +139,7 @@ class FinishaddopenidAction extends Action
oid_set_last($display);
- common_redirect(common_local_url('openidsettings'));
+ common_redirect(common_local_url('openidsettings'), 303);
}
}
diff --git a/actions/finishopenidlogin.php b/actions/finishopenidlogin.php
index 52d9be29c..952185742 100644
--- a/actions/finishopenidlogin.php
+++ b/actions/finishopenidlogin.php
@@ -271,7 +271,8 @@ class FinishopenidloginAction extends Action
common_rememberme($user);
}
unset($_SESSION['openid_rememberme']);
- common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)));
+ common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)),
+ 303);
}
function connectUser()
@@ -324,7 +325,7 @@ class FinishopenidloginAction extends Action
array('nickname' =>
$nickname));
}
- common_redirect($url);
+ common_redirect($url, 303);
}
function bestNewNickname($display, $sreg)
diff --git a/actions/finishremotesubscribe.php b/actions/finishremotesubscribe.php
index eaf57c2d8..d54c29a60 100644
--- a/actions/finishremotesubscribe.php
+++ b/actions/finishremotesubscribe.php
@@ -230,7 +230,8 @@ class FinishremotesubscribeAction extends Action
# show up close to the top of the page
common_redirect(common_local_url('subscribers', array('nickname' =>
- $user->nickname)));
+ $user->nickname)),
+ 303);
}
function add_avatar($profile, $url)
diff --git a/actions/foaf.php b/actions/foaf.php
index 3a99835b4..416935b1b 100644
--- a/actions/foaf.php
+++ b/actions/foaf.php
@@ -33,7 +33,24 @@ class FoafAction extends Action
function prepare($args)
{
parent::prepare($args);
- $this->nickname = $this->trimmed('nickname');
+
+ $nickname_arg = $this->arg('nickname');
+
+ if (empty($nickname_arg)) {
+ $this->clientError(_('No such user.'), 404);
+ return false;
+ }
+
+ $this->nickname = common_canonical_nickname($nickname_arg);
+
+ // Permanent redirect on non-canonical nickname
+
+ if ($nickname_arg != $this->nickname) {
+ common_redirect(common_local_url('foaf',
+ array('nickname' => $this->nickname)),
+ 301);
+ return false;
+ }
$this->user = User::staticGet('nickname', $this->nickname);
@@ -122,20 +139,30 @@ class FoafAction extends Action
if ($sub->find()) {
while ($sub->fetch()) {
- if ($sub->token) {
+ if (!empty($sub->token)) {
$other = Remote_profile::staticGet('id', $sub->subscribed);
} else {
$other = User::staticGet('id', $sub->subscribed);
}
- if (!$other) {
+ if (empty($other)) {
common_debug('Got a bad subscription: '.print_r($sub,true));
continue;
}
$this->element('knows', array('rdf:resource' => $other->uri));
- $person[$other->uri] = array(LISTENEE, $other);
+ $person[$other->uri] = array(LISTENEE,
+ $other->id,
+ $other->nickname,
+ (empty($sub->token)) ? 'User' : 'Remote_profile');
+ $other->free();
+ $other = null;
+ unset($other);
}
}
+ $sub->free();
+ $sub = null;
+ unset($sub);
+
// Get people who subscribe to user
$sub = new Subscription();
@@ -156,25 +183,36 @@ class FoafAction extends Action
if (array_key_exists($other->uri, $person)) {
$person[$other->uri][0] = BOTH;
} else {
- $person[$other->uri] = array(LISTENER, $other);
+ $person[$other->uri] = array(LISTENER,
+ $other->id,
+ $other->nickname,
+ (empty($sub->token)) ? 'User' : 'Remote_profile');
}
+ $other->free();
+ $other = null;
+ unset($other);
}
}
+ $sub->free();
+ $sub = null;
+ unset($sub);
+
$this->elementEnd('Person');
foreach ($person as $uri => $p) {
$foaf_url = null;
- if ($p[1] instanceof User) {
- $foaf_url = common_local_url('foaf', array('nickname' => $p[1]->nickname));
+ list($type, $id, $nickname, $cls) = $p;
+ if ($cls == 'User') {
+ $foaf_url = common_local_url('foaf', array('nickname' => $nickname));
}
- $this->profile = Profile::staticGet($p[1]->id);
+ $profile = Profile::staticGet($id);
$this->elementStart('Person', array('rdf:about' => $uri));
- if ($p[0] == LISTENER || $p[0] == BOTH) {
+ if ($type == LISTENER || $type == BOTH) {
$this->element('knows', array('rdf:resource' => $this->user->uri));
}
- $this->showMicrobloggingAccount($this->profile, ($p[1] instanceof User) ?
- common_root_url() : null);
+ $this->showMicrobloggingAccount($profile, ($cls == 'User') ?
+ common_root_url() : null);
if ($foaf_url) {
$this->element('rdfs:seeAlso', array('rdf:resource' => $foaf_url));
}
@@ -182,6 +220,9 @@ class FoafAction extends Action
if ($foaf_url) {
$this->showPpd($foaf_url, $uri);
}
+ $profile->free();
+ $profile = null;
+ unset($profile);
}
$this->elementEnd('rdf:RDF');
diff --git a/actions/groupsearch.php b/actions/groupsearch.php
index 9b0026db9..06b4a7755 100644
--- a/actions/groupsearch.php
+++ b/actions/groupsearch.php
@@ -1,9 +1,4 @@
<?php
-
-
-// define('GROUPS_PER_PAGE', 20);
-
-
/**
* Group search action class.
*
@@ -77,12 +72,23 @@ class GroupsearchAction extends SearchAction
$terms = preg_split('/[\s,]+/', $q);
$results = new GroupSearchResults($user_group, $terms, $this);
$results->show();
+ $user_group->free();
+ $this->pagination($page > 1, $cnt > GROUPS_PER_PAGE,
+ $page, 'groupsearch', array('q' => $q));
} else {
- $this->element('p', 'error', _('No results'));
+ $this->element('p', 'error', _('No results.'));
+ $this->searchSuggestions($q);
+ if (common_logged_in()) {
+ $message = _('If you can\'t find the group you\'re looking for, you can [create it](%%action.newgroup%%) yourself.');
+ }
+ else {
+ $message = _('Why not [register an account](%%action.register%%) and [create the group](%%action.newgroup%%) yourself!');
+ }
+ $this->elementStart('div', 'guide');
+ $this->raw(common_markup_to_html($message));
+ $this->elementEnd('div');
+ $user_group->free();
}
- $user_group->free();
- $this->pagination($page > 1, $cnt > GROUPS_PER_PAGE,
- $page, 'groupsearch', array('q' => $q));
}
}
@@ -90,23 +96,18 @@ class GroupSearchResults extends GroupList
{
var $terms = null;
var $pattern = null;
-
+
function __construct($user_group, $terms, $action)
{
parent::__construct($user_group, $terms, $action);
- $this->terms = array_map('preg_quote',
+ $this->terms = array_map('preg_quote',
array_map('htmlspecialchars', $terms));
$this->pattern = '/('.implode('|',$terms).')/i';
}
-
+
function highlight($text)
{
return preg_replace($this->pattern, '<strong>\\1</strong>', htmlspecialchars($text));
}
-
- function isReadOnly()
- {
- return true;
- }
}
diff --git a/actions/joingroup.php b/actions/joingroup.php
index eeea4a37b..a5d82ddc7 100644
--- a/actions/joingroup.php
+++ b/actions/joingroup.php
@@ -143,7 +143,8 @@ class JoingroupAction extends Action
$this->elementEnd('html');
} else {
common_redirect(common_local_url('groupmembers', array('nickname' =>
- $this->group->nickname)));
+ $this->group->nickname)),
+ 303);
}
}
} \ No newline at end of file
diff --git a/actions/leavegroup.php b/actions/leavegroup.php
index eb30d0e50..215ccd901 100644
--- a/actions/leavegroup.php
+++ b/actions/leavegroup.php
@@ -147,7 +147,8 @@ class LeavegroupAction extends Action
$this->elementEnd('html');
} else {
common_redirect(common_local_url('groupmembers', array('nickname' =>
- $this->group->nickname)));
+ $this->group->nickname)),
+ 303);
}
}
}
diff --git a/actions/login.php b/actions/login.php
index b049791fb..59c6b4874 100644
--- a/actions/login.php
+++ b/actions/login.php
@@ -138,7 +138,7 @@ class LoginAction extends Action
$nickname));
}
- common_redirect($url);
+ common_redirect($url, 303);
}
/**
diff --git a/actions/logout.php b/actions/logout.php
index 3977f90a0..b7681be38 100644
--- a/actions/logout.php
+++ b/actions/logout.php
@@ -46,10 +46,10 @@ require_once INSTALLDIR.'/lib/openid.php';
*/
class LogoutAction extends Action
{
-
+
/**
* This is read only.
- *
+ *
* @return boolean true
*/
function isReadOnly()
@@ -59,7 +59,7 @@ class LogoutAction extends Action
/**
* Class handler.
- *
+ *
* @param array $args array of arguments
*
* @return nothing
@@ -73,7 +73,7 @@ class LogoutAction extends Action
common_set_user(null);
common_real_login(false); // not logged in
common_forgetme(); // don't log back in!
- common_redirect(common_local_url('public'));
+ common_redirect(common_local_url('public'), 303);
}
}
}
diff --git a/actions/newgroup.php b/actions/newgroup.php
index cbd8dfeec..67cd6b2f1 100644
--- a/actions/newgroup.php
+++ b/actions/newgroup.php
@@ -193,7 +193,7 @@ class NewgroupAction extends Action
$group->query('COMMIT');
- common_redirect($group->homeUrl(), 307);
+ common_redirect($group->homeUrl(), 303);
}
function nicknameExists($nickname)
diff --git a/actions/noticesearch.php b/actions/noticesearch.php
index 83e59dd9a..095d0a454 100644
--- a/actions/noticesearch.php
+++ b/actions/noticesearch.php
@@ -103,7 +103,7 @@ class NoticesearchAction extends SearchAction
function showResults($q, $page)
{
$notice = new Notice();
- $q = strtolower($q);
+
$search_engine = $notice->getSearchEngine('identica_notices');
$search_engine->set_sort_mode('chron');
// Ask for an extra to see if there's more.
@@ -114,20 +114,26 @@ class NoticesearchAction extends SearchAction
$cnt = $notice->find();
}
if ($cnt === 0) {
- $this->element('p', 'error', _('No results'));
+ $this->element('p', 'error', _('No results.'));
+
+ $this->searchSuggestions($q);
+ if (common_logged_in()) {
+ $message = sprintf(_('Be the first to [post on this topic](%%%%action.newnotice%%%%?status_textarea=%s)!'), urlencode($q));
+ }
+ else {
+ $message = sprintf(_('Why not [register an account](%%%%action.register%%%%) and be the first to [post on this topic](%%%%action.newnotice%%%%?status_textarea=%s)!'), urlencode($q));
+ }
+
+ $this->elementStart('div', 'guide');
+ $this->raw(common_markup_to_html($message));
+ $this->elementEnd('div');
return;
}
$terms = preg_split('/[\s,]+/', $q);
$nl = new SearchNoticeList($notice, $this, $terms);
-
$cnt = $nl->show();
-
- $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
- $this->page, 'noticesearch', array('q' => $q));
- }
- function isReadOnly()
- {
- return true;
+ $this->pagination($page > 1, $cnt > NOTICES_PER_PAGE,
+ $page, 'noticesearch', array('q' => $q));
}
}
diff --git a/actions/noticesearchrss.php b/actions/noticesearchrss.php
index 0f98ed04b..ba5276d06 100644
--- a/actions/noticesearchrss.php
+++ b/actions/noticesearchrss.php
@@ -62,9 +62,6 @@ class NoticesearchrssAction extends Rss10Action
$notice = new Notice();
- # lcase it for comparison
- $q = strtolower($q);
-
$search_engine = $notice->getSearchEngine('identica_notices');
$search_engine->set_sort_mode('chron');
diff --git a/actions/nudge.php b/actions/nudge.php
index bc3d48478..b4e5e01dd 100644
--- a/actions/nudge.php
+++ b/actions/nudge.php
@@ -50,7 +50,7 @@ class NudgeAction extends Action
{
/**
* Class handler.
- *
+ *
* @param array $args array of arguments
*
* @return nothing
@@ -75,7 +75,7 @@ class NudgeAction extends Action
// CSRF protection
$token = $this->trimmed('token');
-
+
if (!$token || $token != common_session_token()) {
$this->clientError(_('There was a problem with your session token. Try again, please.'));
return;
@@ -100,7 +100,8 @@ class NudgeAction extends Action
} else {
// display a confirmation to the user
common_redirect(common_local_url('showstream',
- array('nickname' => $other->nickname)));
+ array('nickname' => $other->nickname)),
+ 303);
}
}
diff --git a/actions/peoplesearch.php b/actions/peoplesearch.php
index 14177fcf0..65d970dd1 100644
--- a/actions/peoplesearch.php
+++ b/actions/peoplesearch.php
@@ -60,16 +60,10 @@ class PeoplesearchAction extends SearchAction
function showResults($q, $page)
{
-
$profile = new Profile();
-
- # lcase it for comparison
- $q = strtolower($q);
-
$search_engine = $profile->getSearchEngine('identica_people');
-
$search_engine->set_sort_mode('chron');
- # Ask for an extra to see if there's more.
+ // Ask for an extra to see if there's more.
$search_engine->limit((($page-1)*PROFILES_PER_PAGE), PROFILES_PER_PAGE + 1);
if (false === $search_engine->query($q)) {
$cnt = 0;
@@ -81,14 +75,15 @@ class PeoplesearchAction extends SearchAction
$terms = preg_split('/[\s,]+/', $q);
$results = new PeopleSearchResults($profile, $terms, $this);
$results->show();
+ $profile->free();
+ $this->pagination($page > 1, $cnt > PROFILES_PER_PAGE,
+ $page, 'peoplesearch', array('q' => $q));
+
} else {
- $this->element('p', 'error', _('No results'));
+ $this->element('p', 'error', _('No results.'));
+ $this->searchSuggestions($q);
+ $profile->free();
}
-
- $profile->free();
-
- $this->pagination($page > 1, $cnt > PROFILES_PER_PAGE,
- $page, 'peoplesearch', array('q' => $q));
}
}
diff --git a/actions/public.php b/actions/public.php
index a20ae4032..5a380de9a 100644
--- a/actions/public.php
+++ b/actions/public.php
@@ -166,6 +166,22 @@ class PublicAction extends Action
$nav->show();
}
+ function showEmptyList()
+ {
+ $message = _('This is the public timeline for %%site.name%% but no one has posted anything yet.') . ' ';
+
+ if (common_logged_in()) {
+ $message .= _('Be the first to post!');
+ }
+ else {
+ $message .= _('Why not [register an account](%%action.register%%) and be the first to post!');
+ }
+
+ $this->elementStart('div', 'guide');
+ $this->raw(common_markup_to_html($message));
+ $this->elementEnd('div');
+ }
+
/**
* Fill the content area
*
@@ -189,6 +205,10 @@ class PublicAction extends Action
$cnt = $nl->show();
+ if ($cnt == 0) {
+ $this->showEmptyList();
+ }
+
$this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
$this->page, 'public');
}
@@ -207,9 +227,14 @@ class PublicAction extends Action
function showAnonymousMessage()
{
- $m = _('This is %%site.name%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
- 'based on the Free Software [Laconica](http://laconi.ca/) tool. ' .
- '[Join now](%%action.register%%) to share notices about yourself with friends, family, and colleagues! ([Read more](%%doc.help%%))');
+ if (! (common_config('site','closed') || common_config('site','inviteonly'))) {
+ $m = _('This is %%site.name%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
+ 'based on the Free Software [Laconica](http://laconi.ca/) tool. ' .
+ '[Join now](%%action.register%%) to share notices about yourself with friends, family, and colleagues! ([Read more](%%doc.help%%))');
+ } else {
+ $m = _('This is %%site.name%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
+ 'based on the Free Software [Laconica](http://laconi.ca/) tool.');
+ }
$this->elementStart('div', array('id' => 'anon_notice'));
$this->raw(common_markup_to_html($m));
$this->elementEnd('div');
diff --git a/actions/publictagcloud.php b/actions/publictagcloud.php
index 6f5fc7541..855cfed9b 100644
--- a/actions/publictagcloud.php
+++ b/actions/publictagcloud.php
@@ -64,6 +64,22 @@ class PublictagcloudAction extends Action
common_config('site', 'name')));
}
+ function showEmptyList()
+ {
+ $message = _('No one has posted a notice with a [hashtag](%%doc.tags%%) yet.') . ' ';
+
+ if (common_logged_in()) {
+ $message .= _('Be the first to post one!');
+ }
+ else {
+ $message .= _('Why not [register an account](%%action.register%%) and be the first to post one!');
+ }
+
+ $this->elementStart('div', 'guide');
+ $this->raw(common_markup_to_html($message));
+ $this->elementEnd('div');
+ }
+
function showLocalNav()
{
$nav = new PublicGroupNav($this);
@@ -126,6 +142,8 @@ class PublictagcloudAction extends Action
$this->elementEnd('dd');
$this->elementEnd('dl');
$this->elementEnd('div');
+ } else {
+ $this->showEmptyList();
}
}
diff --git a/actions/recoverpassword.php b/actions/recoverpassword.php
index eeb6b2516..620fe7eb8 100644
--- a/actions/recoverpassword.php
+++ b/actions/recoverpassword.php
@@ -181,13 +181,21 @@ class RecoverpasswordAction extends Action
function showRecoverForm()
{
$this->elementStart('form', array('method' => 'post',
- 'id' => 'recoverpassword',
+ 'id' => 'form_password_recover',
+ 'class' => 'form_settings',
'action' => common_local_url('recoverpassword')));
+ $this->elementStart('fieldset');
+ $this->element('legend', null, _('Password recover'));
+ $this->elementStart('ul', 'form_data');
+ $this->elementStart('li');
$this->input('nicknameoremail', _('Nickname or email'),
$this->trimmed('nicknameoremail'),
_('Your nickname on this server, ' .
'or your registered email address.'));
+ $this->elementEnd('li');
+ $this->elementEnd('ul');
$this->submit('recover', _('Recover'));
+ $this->elementEnd('fieldset');
$this->elementEnd('form');
}
@@ -213,14 +221,24 @@ class RecoverpasswordAction extends Action
function showResetForm()
{
$this->elementStart('form', array('method' => 'post',
- 'id' => 'recoverpassword',
+ 'id' => 'form_password_change',
+ 'class' => 'form_settings',
'action' => common_local_url('recoverpassword')));
+ $this->elementStart('fieldset');
+ $this->element('legend', null, _('Password change'));
$this->hidden('token', common_session_token());
+ $this->elementStart('ul', 'form_data');
+ $this->elementStart('li');
$this->password('newpassword', _('New password'),
_('6 or more characters, and don\'t forget it!'));
+ $this->elementEnd('li');
+ $this->elementStart('li');
$this->password('confirm', _('Confirm'),
_('Same as password above'));
+ $this->elementEnd('li');
+ $this->elementEnd('ul');
$this->submit('reset', _('Reset'));
+ $this->elementEnd('fieldset');
$this->elementEnd('form');
}
diff --git a/actions/remotesubscribe.php b/actions/remotesubscribe.php
index af130f425..0b1174896 100644
--- a/actions/remotesubscribe.php
+++ b/actions/remotesubscribe.php
@@ -97,9 +97,9 @@ class RemotesubscribeAction extends Action
'class' => 'form_settings',
'action' => common_local_url('remotesubscribe')));
$this->elementStart('fieldset');
- $this->element('legend', 'Subscribe to a remote user');
+ $this->element('legend', _('Subscribe to a remote user'));
$this->hidden('token', common_session_token());
-
+
$this->elementStart('ul', 'form_data');
$this->elementStart('li');
$this->input('nickname', _('User nickname'), $this->nickname,
@@ -407,7 +407,7 @@ class RemotesubscribeAction extends Action
# Redirect to authorization service
- common_redirect($req->to_url());
+ common_redirect($req->to_url(), 303);
return;
}
}
diff --git a/actions/replies.php b/actions/replies.php
index 4ab9b14ed..2769cb422 100644
--- a/actions/replies.php
+++ b/actions/replies.php
@@ -166,12 +166,36 @@ class RepliesAction extends Action
$nl = new NoticeList($notice, $this);
$cnt = $nl->show();
+ if (0 === $cnt) {
+ $this->showEmptyListMessage();
+ }
$this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
$this->page, 'replies',
array('nickname' => $this->user->nickname));
}
+ function showEmptyListMessage()
+ {
+ $message = sprintf(_('This is the timeline showing replies to %s but %s hasn\'t received a notice to his attention yet.'), $this->user->nickname, $this->user->nickname) . ' ';
+
+ if (common_logged_in()) {
+ $current_user = common_current_user();
+ if ($this->user->id === $current_user->id) {
+ $message .= _('You can engage other users in a conversation, subscribe to more people or [join groups](%%action.groups%%).');
+ } else {
+ $message .= sprintf(_('You can try to [nudge %s](../%s) or [post something to his or her attention](%%%%action.newnotice%%%%?status_textarea=%s).'), $this->user->nickname, $this->user->nickname, '@' . $this->user->nickname);
+ }
+ }
+ else {
+ $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to his or her attention.'), $this->user->nickname);
+ }
+
+ $this->elementStart('div', 'guide');
+ $this->raw(common_markup_to_html($message));
+ $this->elementEnd('div');
+ }
+
function isReadOnly()
{
return true;
diff --git a/actions/showfavorites.php b/actions/showfavorites.php
index d1c9283f0..4d4349505 100644
--- a/actions/showfavorites.php
+++ b/actions/showfavorites.php
@@ -162,6 +162,25 @@ class ShowfavoritesAction extends Action
$nav->show();
}
+ function showEmptyListMessage()
+ {
+ if (common_logged_in()) {
+ $current_user = common_current_user();
+ if ($this->user->id === $current_user->id) {
+ $message = _('You haven\'t chosen any favorite notices yet. Click the fave button on notices you like to bookmark them for later or shed a spotlight on them.');
+ } else {
+ $message = sprintf(_('%s hasn\'t added any notices to his favorites yet. Post something interesting they would add to their favorites :)'), $this->user->nickname);
+ }
+ }
+ else {
+ $message = sprintf(_('%s hasn\'t added any notices to his favorites yet. Why not [register an account](%%%%action.register%%%%) and then post something interesting they would add to thier favorites :)'), $this->user->nickname);
+ }
+
+ $this->elementStart('div', 'guide');
+ $this->raw(common_markup_to_html($message));
+ $this->elementEnd('div');
+ }
+
/**
* Show the content
*
@@ -183,9 +202,17 @@ class ShowfavoritesAction extends Action
$nl = new NoticeList($notice, $this);
$cnt = $nl->show();
+ if (0 == $cnt) {
+ $this->showEmptyListMessage();
+ }
$this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
$this->page, 'showfavorites',
array('nickname' => $this->user->nickname));
}
+
+ function showPageNotice() {
+ $this->element('p', 'instructions', _('This is a way to share what you like.'));
+ }
}
+
diff --git a/actions/showgroup.php b/actions/showgroup.php
index b6022840b..79445851f 100644
--- a/actions/showgroup.php
+++ b/actions/showgroup.php
@@ -73,11 +73,17 @@ class ShowgroupAction extends Action
function title()
{
+ if (!empty($this->group->fullname)) {
+ $base = $this->group->fullname . ' (' . $this->group->nickname . ')';
+ } else {
+ $base = $this->group->nickname;
+ }
+
if ($this->page == 1) {
- return sprintf(_("%s group"), $this->group->nickname);
+ return sprintf(_("%s group"), $base);
} else {
return sprintf(_("%s group, page %d"),
- $this->group->nickname,
+ $base,
$this->page);
}
}
@@ -390,11 +396,18 @@ class ShowgroupAction extends Action
function showAnonymousMessage()
{
- $m = sprintf(_('**%s** is a user group on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
- 'based on the Free Software [Laconica](http://laconi.ca/) tool. Its members share ' .
- 'short messages about their life and interests. '.
- '[Join now](%%%%action.register%%%%) to become part of this group and many more! ([Read more](%%%%doc.help%%%%))'),
+ if (!(common_config('site','closed') || common_config('site','inviteonly'))) {
+ $m = sprintf(_('**%s** is a user group on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
+ 'based on the Free Software [Laconica](http://laconi.ca/) tool. Its members share ' .
+ 'short messages about their life and interests. '.
+ '[Join now](%%%%action.register%%%%) to become part of this group and many more! ([Read more](%%%%doc.help%%%%))'),
$this->group->nickname);
+ } else {
+ $m = sprintf(_('**%s** is a user group on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
+ 'based on the Free Software [Laconica](http://laconi.ca/) tool. Its members share ' .
+ 'short messages about their life and interests. '),
+ $this->group->nickname);
+ }
$this->elementStart('div', array('id' => 'anon_notice'));
$this->raw(common_markup_to_html($m));
$this->elementEnd('div');
diff --git a/actions/shownotice.php b/actions/shownotice.php
index d5f35cd84..ccae49bb3 100644
--- a/actions/shownotice.php
+++ b/actions/shownotice.php
@@ -177,10 +177,17 @@ class ShownoticeAction extends Action
{
parent::handle($args);
- $this->showPage();
+ if ($this->notice->is_local == 0) {
+ if (!empty($this->notice->url)) {
+ common_redirect($this->notice->url, 301);
+ } else if (!empty($this->notice->uri) && preg_match('/^https?:/', $this->notice->uri)) {
+ common_redirect($this->notice->uri, 301);
+ }
+ } else {
+ $this->showPage();
+ }
}
-
/**
* Don't show local navigation
*
@@ -191,7 +198,6 @@ class ShownoticeAction extends Action
{
}
-
/**
* Fill the content area of the page
*
@@ -208,8 +214,6 @@ class ShownoticeAction extends Action
$this->elementEnd('ul');
}
-
-
/**
* Don't show page notice
*
@@ -220,7 +224,6 @@ class ShownoticeAction extends Action
{
}
-
/**
* Don't show aside
*
@@ -230,7 +233,6 @@ class ShownoticeAction extends Action
function showAside() {
}
-
/**
* Extra <head> content
*
diff --git a/actions/showstream.php b/actions/showstream.php
index 65482167e..ce237dae2 100644
--- a/actions/showstream.php
+++ b/actions/showstream.php
@@ -54,12 +54,8 @@ require_once INSTALLDIR.'/lib/feedlist.php';
* @link http://laconi.ca/
*/
-class ShowstreamAction extends Action
+class ShowstreamAction extends ProfileAction
{
- var $user = null;
- var $page = null;
- var $profile = null;
-
function isReadOnly()
{
return true;
@@ -67,54 +63,21 @@ class ShowstreamAction extends Action
function title()
{
+ if (!empty($this->profile->fullname)) {
+ $base = $this->profile->fullname . ' (' . $this->user->nickname . ') ';
+ } else {
+ $base = $this->user->nickname;
+ }
+
if ($this->page == 1) {
- return $this->user->nickname;
+ return $base;
} else {
return sprintf(_("%s, page %d"),
- $this->user->nickname,
+ $base,
$this->page);
}
}
- function prepare($args)
- {
- parent::prepare($args);
-
- $nickname_arg = $this->arg('nickname');
- $nickname = common_canonical_nickname($nickname_arg);
-
- // Permanent redirect on non-canonical nickname
-
- if ($nickname_arg != $nickname) {
- $args = array('nickname' => $nickname);
- if ($this->arg('page') && $this->arg('page') != 1) {
- $args['page'] = $this->arg['page'];
- }
- common_redirect(common_local_url('showstream', $args), 301);
- return false;
- }
-
- $this->user = User::staticGet('nickname', $nickname);
-
- if (!$this->user) {
- $this->clientError(_('No such user.'), 404);
- return false;
- }
-
- $this->profile = $this->user->getProfile();
-
- if (!$this->profile) {
- $this->serverError(_('User has no profile.'));
- return false;
- }
-
- $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
-
- common_set_returnto($this->selfUrl());
-
- return true;
- }
-
function handle($args)
{
@@ -140,16 +103,6 @@ class ShowstreamAction extends Action
$nav->show();
}
- function showPageTitle()
- {
- $user =& common_current_user();
- if ($user && ($user->id == $this->profile->id)) {
- $this->element('h1', NULL, _("Your profile"));
- } else {
- $this->element('h1', NULL, sprintf(_('%s\'s profile'), $this->profile->nickname));
- }
- }
-
function showPageNoticeBlock()
{
return;
@@ -376,178 +329,64 @@ class ShowstreamAction extends Action
_('Subscribe'));
}
- function showNotices()
- {
- $notice = $this->user->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
-
- $pnl = new ProfileNoticeList($notice, $this);
- $cnt = $pnl->show();
-
- $this->pagination($this->page>1, $cnt>NOTICES_PER_PAGE, $this->page,
- 'showstream', array('nickname' => $this->user->nickname));
- }
-
- function showSections()
- {
- $this->showSubscriptions();
- $this->showSubscribers();
- $this->showGroups();
- $this->showStatistics();
- $cloud = new PersonalTagCloudSection($this, $this->user);
- $cloud->show();
- }
-
- function showSubscriptions()
+ function showEmptyListMessage()
{
- $profile = $this->user->getSubscriptions(0, PROFILES_PER_MINILIST + 1);
-
- $this->elementStart('div', array('id' => 'entity_subscriptions',
- 'class' => 'section'));
+ $message = sprintf(_('This is the timeline for %s but %s hasn\'t posted anything yet.'), $this->user->nickname, $this->user->nickname) . ' ';
- $this->element('h2', null, _('Subscriptions'));
-
- if ($profile) {
- $pml = new ProfileMiniList($profile, $this->user, $this);
- $cnt = $pml->show();
- if ($cnt == 0) {
- $this->element('p', null, _('(None)'));
- }
- }
-
- if ($cnt > PROFILES_PER_MINILIST) {
- $this->elementStart('p');
- $this->element('a', array('href' => common_local_url('subscriptions',
- array('nickname' => $this->profile->nickname)),
- 'class' => 'more'),
- _('All subscriptions'));
- $this->elementEnd('p');
- }
-
- $this->elementEnd('div');
- }
-
- function showSubscribers()
- {
- $profile = $this->user->getSubscribers(0, PROFILES_PER_MINILIST + 1);
-
- $this->elementStart('div', array('id' => 'entity_subscribers',
- 'class' => 'section'));
-
- $this->element('h2', null, _('Subscribers'));
-
- if ($profile) {
- $pml = new ProfileMiniList($profile, $this->user, $this);
- $cnt = $pml->show();
- if ($cnt == 0) {
- $this->element('p', null, _('(None)'));
+ if (common_logged_in()) {
+ $current_user = common_current_user();
+ if ($this->user->id === $current_user->id) {
+ $message .= _('Seen anything interesting recently? You haven\'t posted any notices yet, now would be a good time to start :)');
+ } else {
+ $message .= sprintf(_('You can try to nudge %s or [post something to his or her attention](%%%%action.newnotice%%%%?status_textarea=%s).'), $this->user->nickname, '@' . $this->user->nickname);
}
}
-
- if ($cnt > PROFILES_PER_MINILIST) {
- $this->elementStart('p');
- $this->element('a', array('href' => common_local_url('subscribers',
- array('nickname' => $this->profile->nickname)),
- 'class' => 'more'),
- _('All subscribers'));
- $this->elementEnd('p');
+ else {
+ $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to his or her attention.'), $this->user->nickname);
}
+ $this->elementStart('div', 'guide');
+ $this->raw(common_markup_to_html($message));
$this->elementEnd('div');
}
- function showStatistics()
- {
- // XXX: WORM cache this
- $subs = new Subscription();
- $subs->subscriber = $this->profile->id;
- $subs_count = (int) $subs->count() - 1;
-
- $subbed = new Subscription();
- $subbed->subscribed = $this->profile->id;
- $subbed_count = (int) $subbed->count() - 1;
-
- $notices = new Notice();
- $notices->profile_id = $this->profile->id;
- $notice_count = (int) $notices->count();
-
- $this->elementStart('div', array('id' => 'entity_statistics',
- 'class' => 'section'));
-
- $this->element('h2', null, _('Statistics'));
-
- // Other stats...?
- $this->elementStart('dl', 'entity_member-since');
- $this->element('dt', null, _('Member since'));
- $this->element('dd', null, date('j M Y',
- strtotime($this->profile->created)));
- $this->elementEnd('dl');
-
- $this->elementStart('dl', 'entity_subscriptions');
- $this->elementStart('dt');
- $this->element('a', array('href' => common_local_url('subscriptions',
- array('nickname' => $this->profile->nickname))),
- _('Subscriptions'));
- $this->elementEnd('dt');
- $this->element('dd', null, (is_int($subs_count)) ? $subs_count : '0');
- $this->elementEnd('dl');
-
- $this->elementStart('dl', 'entity_subscribers');
- $this->elementStart('dt');
- $this->element('a', array('href' => common_local_url('subscribers',
- array('nickname' => $this->profile->nickname))),
- _('Subscribers'));
- $this->elementEnd('dt');
- $this->element('dd', 'subscribers', (is_int($subbed_count)) ? $subbed_count : '0');
- $this->elementEnd('dl');
-
- $this->elementStart('dl', 'entity_notices');
- $this->element('dt', null, _('Notices'));
- $this->element('dd', null, (is_int($notice_count)) ? $notice_count : '0');
- $this->elementEnd('dl');
-
- $this->elementEnd('div');
- }
-
- function showGroups()
+ function showNotices()
{
- $groups = $this->user->getGroups(0, GROUPS_PER_MINILIST + 1);
-
- $this->elementStart('div', array('id' => 'entity_groups',
- 'class' => 'section'));
-
- $this->element('h2', null, _('Groups'));
-
- if ($groups) {
- $gml = new GroupMiniList($groups, $this->user, $this);
- $cnt = $gml->show();
- if ($cnt == 0) {
- $this->element('p', null, _('(None)'));
- }
- }
+ $notice = $this->user->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
- if ($cnt > GROUPS_PER_MINILIST) {
- $this->elementStart('p');
- $this->element('a', array('href' => common_local_url('usergroups',
- array('nickname' => $this->profile->nickname)),
- 'class' => 'more'),
- _('All groups'));
- $this->elementEnd('p');
+ $pnl = new ProfileNoticeList($notice, $this);
+ $cnt = $pnl->show();
+ if (0 == $cnt) {
+ $this->showEmptyListMessage();
}
- $this->elementEnd('div');
+ $this->pagination($this->page>1, $cnt>NOTICES_PER_PAGE, $this->page,
+ 'showstream', array('nickname' => $this->user->nickname));
}
function showAnonymousMessage()
{
- $m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
- 'based on the Free Software [Laconica](http://laconi.ca/) tool. ' .
- '[Join now](%%%%action.register%%%%) to follow **%s**\'s notices and many more! ([Read more](%%%%doc.help%%%%))'),
- $this->user->nickname, $this->user->nickname);
+ if (!(common_config('site','closed') || common_config('site','inviteonly'))) {
+ $m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
+ 'based on the Free Software [Laconica](http://laconi.ca/) tool. ' .
+ '[Join now](%%%%action.register%%%%) to follow **%s**\'s notices and many more! ([Read more](%%%%doc.help%%%%))'),
+ $this->user->nickname, $this->user->nickname);
+ } else {
+ $m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
+ 'based on the Free Software [Laconica](http://laconi.ca/) tool. '),
+ $this->user->nickname, $this->user->nickname);
+ }
$this->elementStart('div', array('id' => 'anon_notice'));
$this->raw(common_markup_to_html($m));
$this->elementEnd('div');
}
+ function showSections()
+ {
+ parent::showSections();
+ $cloud = new PersonalTagCloudSection($this, $this->user);
+ $cloud->show();
+ }
}
// We don't show the author for a profile, since we already know who it is!
diff --git a/actions/smssettings.php b/actions/smssettings.php
index a5f75d266..922bab9a4 100644
--- a/actions/smssettings.php
+++ b/actions/smssettings.php
@@ -488,7 +488,8 @@ class SmssettingsAction extends ConnectSettingsAction
}
common_redirect(common_local_url('confirmaddress',
- array('code' => $code)));
+ array('code' => $code)),
+ 303);
}
/**
diff --git a/actions/subedit.php b/actions/subedit.php
index 89081ffc7..8ca2d7914 100644
--- a/actions/subedit.php
+++ b/actions/subedit.php
@@ -85,7 +85,8 @@ class SubeditAction extends Action
}
common_redirect(common_local_url('subscriptions',
- array('nickname' => $cur->nickname)));
+ array('nickname' => $cur->nickname)),
+ 303);
}
}
}
diff --git a/actions/subscribe.php b/actions/subscribe.php
index f761992de..0bc522867 100644
--- a/actions/subscribe.php
+++ b/actions/subscribe.php
@@ -75,7 +75,8 @@ class SubscribeAction extends Action
$this->elementEnd('html');
} else {
common_redirect(common_local_url('subscriptions', array('nickname' =>
- $user->nickname)));
+ $user->nickname)),
+ 303);
}
}
}
diff --git a/actions/subscribers.php b/actions/subscribers.php
index 22faafaef..7ebb54d33 100644
--- a/actions/subscribers.php
+++ b/actions/subscribers.php
@@ -88,6 +88,9 @@ class SubscribersAction extends GalleryAction
if ($subscribers) {
$subscribers_list = new SubscribersList($subscribers, $this->user, $this);
$cnt = $subscribers_list->show();
+ if (0 == $cnt) {
+ $this->showEmptyListMessage();
+ }
}
$subscribers->free();
@@ -96,6 +99,25 @@ class SubscribersAction extends GalleryAction
$this->page, 'subscribers',
array('nickname' => $this->user->nickname));
}
+
+ function showEmptyListMessage()
+ {
+ if (common_logged_in()) {
+ $current_user = common_current_user();
+ if ($this->user->id === $current_user->id) {
+ $message = _('You have no subscribers. Try subscribing to people you know and they might return the favor');
+ } else {
+ $message = sprintf(_('%s has no subscribers. Want to be the first?'), $this->user->nickname);
+ }
+ }
+ else {
+ $message = sprintf(_('%s has no subscribers. Why not [register an account](%%%%action.register%%%%) and be the first?'), $this->user->nickname);
+ }
+
+ $this->elementStart('div', 'guide');
+ $this->raw(common_markup_to_html($message));
+ $this->elementEnd('div');
+ }
}
class SubscribersList extends ProfileList
diff --git a/actions/subscriptions.php b/actions/subscriptions.php
index 3fbea2039..b0c0a9b8d 100644
--- a/actions/subscriptions.php
+++ b/actions/subscriptions.php
@@ -95,6 +95,9 @@ class SubscriptionsAction extends GalleryAction
if ($subscriptions) {
$subscriptions_list = new SubscriptionsList($subscriptions, $this->user, $this);
$cnt = $subscriptions_list->show();
+ if (0 == $cnt) {
+ $this->showEmptyListMessage();
+ }
}
$subscriptions->free();
@@ -103,6 +106,25 @@ class SubscriptionsAction extends GalleryAction
$this->page, 'subscriptions',
array('nickname' => $this->user->nickname));
}
+
+ function showEmptyListMessage()
+ {
+ if (common_logged_in()) {
+ $current_user = common_current_user();
+ if ($this->user->id === $current_user->id) {
+ $message = _('You\'re not listening to anyone\'s notices right now, try subscribing to people you know. Try [people search](%%action.peoplesearch%%), look for members in groups you\'re interested in and in our [featured users](%%action.featured%%). If you\'re a [Twitter user](%%action.twittersettings%%), you can automatically subscribe to people you already follow there.');
+ } else {
+ $message = sprintf(_('%s is not listening to anyone.'), $this->user->nickname);
+ }
+ }
+ else {
+ $message = sprintf(_('%s is not listening to anyone.'), $this->user->nickname);
+ }
+
+ $this->elementStart('div', 'guide');
+ $this->raw(common_markup_to_html($message));
+ $this->elementEnd('div');
+ }
}
class SubscriptionsList extends ProfileList
diff --git a/actions/sup.php b/actions/sup.php
index 8ef9207fa..246b3299d 100644
--- a/actions/sup.php
+++ b/actions/sup.php
@@ -45,7 +45,7 @@ class SupAction extends Action
function availablePeriods()
{
static $periods = array(86400, 43200, 21600, 7200,
- 3600, 1800, 600, 300, 120,
+ 3600, 1800, 600, 300, 120,
60, 30, 15);
$available = array();
foreach ($periods as $period) {
diff --git a/actions/tag.php b/actions/tag.php
index 231f2c299..d15f64498 100644
--- a/actions/tag.php
+++ b/actions/tag.php
@@ -33,7 +33,9 @@ class TagAction extends Action
}
if ($this->tag != $taginput) {
- common_redirect(common_local_url('tag', array('tag' => $this->tag)));
+ common_redirect(common_local_url('tag', array('tag' => $this->tag)),
+ 301);
+ return false;
}
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
diff --git a/actions/tagother.php b/actions/tagother.php
index 0d18945a0..0c5bb7cf3 100644
--- a/actions/tagother.php
+++ b/actions/tagother.php
@@ -221,7 +221,8 @@ class TagotherAction extends Action
$this->elementEnd('html');
} else {
common_redirect(common_local_url($action, array('nickname' =>
- $user->nickname)));
+ $user->nickname)),
+ 303);
}
}
diff --git a/actions/unblock.php b/actions/unblock.php
index bad496353..8573b2a87 100644
--- a/actions/unblock.php
+++ b/actions/unblock.php
@@ -116,10 +116,11 @@ class UnblockAction extends Action
}
}
if ($action) {
- common_redirect(common_local_url($action, $args));
+ common_redirect(common_local_url($action, $args), 303);
} else {
common_redirect(common_local_url('subscriptions',
- array('nickname' => $cur->nickname)));
+ array('nickname' => $cur->nickname)),
+ 303);
}
}
}
diff --git a/actions/unsubscribe.php b/actions/unsubscribe.php
index b1e2b6425..7dcab04c0 100644
--- a/actions/unsubscribe.php
+++ b/actions/unsubscribe.php
@@ -77,7 +77,8 @@ class UnsubscribeAction extends Action
$this->elementEnd('html');
} else {
common_redirect(common_local_url('subscriptions', array('nickname' =>
- $user->nickname)));
+ $user->nickname)),
+ 303);
}
}
}
diff --git a/actions/userauthorization.php b/actions/userauthorization.php
index 6a76e3a4c..8723848c7 100644
--- a/actions/userauthorization.php
+++ b/actions/userauthorization.php
@@ -25,7 +25,7 @@ define('TIMESTAMP_THRESHOLD', 300);
class UserauthorizationAction extends Action
{
var $error;
- var $req;
+ var $params;
function handle($args)
{
@@ -35,8 +35,8 @@ class UserauthorizationAction extends Action
# CSRF protection
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
- $req = $this->getStoredRequest();
- $this->showForm($req, _('There was a problem with your session token. '.
+ $params = $this->getStoredParams();
+ $this->showForm($params, _('There was a problem with your session token. '.
'Try again, please.'));
return;
}
@@ -50,18 +50,13 @@ class UserauthorizationAction extends Action
common_redirect(common_local_url('login'));
return;
}
+
try {
- # this must be a new request
- $req = $this->getNewRequest();
- if (!$req) {
- $this->clientError(_('No request found!'));
- }
- # XXX: only validate new requests, since nonce is one-time use
- $this->validateRequest($req);
- $this->storeRequest($req);
- $this->showForm($req);
+ $this->validateRequest();
+ $this->storeParams($_GET);
+ $this->showForm($_GET);
} catch (OAuthException $e) {
- $this->clearRequest();
+ $this->clearParams();
$this->clientError($e->getMessage());
return;
}
@@ -69,9 +64,9 @@ class UserauthorizationAction extends Action
}
}
- function showForm($req, $error=null)
+ function showForm($params, $error=null)
{
- $this->req = $req;
+ $this->params = $params;
$this->error = $error;
$this->showPage();
}
@@ -91,16 +86,16 @@ class UserauthorizationAction extends Action
function showContent()
{
- $req = $this->req;
+ $params = $this->params;
- $nickname = $req->get_parameter('omb_listenee_nickname');
- $profile = $req->get_parameter('omb_listenee_profile');
- $license = $req->get_parameter('omb_listenee_license');
- $fullname = $req->get_parameter('omb_listenee_fullname');
- $homepage = $req->get_parameter('omb_listenee_homepage');
- $bio = $req->get_parameter('omb_listenee_bio');
- $location = $req->get_parameter('omb_listenee_location');
- $avatar = $req->get_parameter('omb_listenee_avatar');
+ $nickname = $params['omb_listenee_nickname'];
+ $profile = $params['omb_listenee_profile'];
+ $license = $params['omb_listenee_license'];
+ $fullname = $params['omb_listenee_fullname'];
+ $homepage = $params['omb_listenee_homepage'];
+ $bio = $params['omb_listenee_bio'];
+ $location = $params['omb_listenee_location'];
+ $avatar = $params['omb_listenee_avatar'];
$this->elementStart('div', 'profile');
if ($avatar) {
@@ -147,56 +142,56 @@ class UserauthorizationAction extends Action
function sendAuthorization()
{
- $req = $this->getStoredRequest();
+ $params = $this->getStoredParams();
- if (!$req) {
+ if (!$params) {
$this->clientError(_('No authorization request!'));
return;
}
- $callback = $req->get_parameter('oauth_callback');
+ $callback = $params['oauth_callback'];
if ($this->arg('accept')) {
- if (!$this->authorizeToken($req)) {
+ if (!$this->authorizeToken($params)) {
$this->clientError(_('Error authorizing token'));
}
- if (!$this->saveRemoteProfile($req)) {
+ if (!$this->saveRemoteProfile($params)) {
$this->clientError(_('Error saving remote profile'));
}
if (!$callback) {
- $this->showAcceptMessage($req->get_parameter('oauth_token'));
+ $this->showAcceptMessage($params['oauth_token']);
} else {
- $params = array();
- $params['oauth_token'] = $req->get_parameter('oauth_token');
- $params['omb_version'] = OMB_VERSION_01;
- $user = User::staticGet('uri', $req->get_parameter('omb_listener'));
+ $newparams = array();
+ $newparams['oauth_token'] = $params['oauth_token'];
+ $newparams['omb_version'] = OMB_VERSION_01;
+ $user = User::staticGet('uri', $params['omb_listener']);
$profile = $user->getProfile();
if (!$profile) {
common_log_db_error($user, 'SELECT', __FILE__);
$this->serverError(_('User without matching profile'));
return;
}
- $params['omb_listener_nickname'] = $user->nickname;
- $params['omb_listener_profile'] = common_local_url('showstream',
+ $newparams['omb_listener_nickname'] = $user->nickname;
+ $newparams['omb_listener_profile'] = common_local_url('showstream',
array('nickname' => $user->nickname));
if (!is_null($profile->fullname)) {
- $params['omb_listener_fullname'] = $profile->fullname;
+ $newparams['omb_listener_fullname'] = $profile->fullname;
}
if (!is_null($profile->homepage)) {
- $params['omb_listener_homepage'] = $profile->homepage;
+ $newparams['omb_listener_homepage'] = $profile->homepage;
}
if (!is_null($profile->bio)) {
- $params['omb_listener_bio'] = $profile->bio;
+ $newparams['omb_listener_bio'] = $profile->bio;
}
if (!is_null($profile->location)) {
- $params['omb_listener_location'] = $profile->location;
+ $newparams['omb_listener_location'] = $profile->location;
}
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
if ($avatar) {
- $params['omb_listener_avatar'] = $avatar->url;
+ $newparams['omb_listener_avatar'] = $avatar->url;
}
$parts = array();
- foreach ($params as $k => $v) {
+ foreach ($newparams as $k => $v) {
$parts[] = $k . '=' . OAuthUtil::urlencode_rfc3986($v);
}
$query_string = implode('&', $parts);
@@ -214,12 +209,10 @@ class UserauthorizationAction extends Action
}
}
- function authorizeToken(&$req)
+ function authorizeToken(&$params)
{
- $consumer_key = $req->get_parameter('oauth_consumer_key');
- $token_field = $req->get_parameter('oauth_token');
+ $token_field = $params['oauth_token'];
$rt = new Token();
- $rt->consumer_key = $consumer_key;
$rt->tok = $token_field;
$rt->type = 0;
$rt->state = 0;
@@ -235,21 +228,21 @@ class UserauthorizationAction extends Action
# XXX: refactor with similar code in finishremotesubscribe.php
- function saveRemoteProfile(&$req)
+ function saveRemoteProfile(&$params)
{
# FIXME: we should really do this when the consumer comes
# back for an access token. If they never do, we've got stuff in a
# weird state.
- $nickname = $req->get_parameter('omb_listenee_nickname');
- $fullname = $req->get_parameter('omb_listenee_fullname');
- $profile_url = $req->get_parameter('omb_listenee_profile');
- $homepage = $req->get_parameter('omb_listenee_homepage');
- $bio = $req->get_parameter('omb_listenee_bio');
- $location = $req->get_parameter('omb_listenee_location');
- $avatar_url = $req->get_parameter('omb_listenee_avatar');
+ $nickname = $params['omb_listenee_nickname'];
+ $fullname = $params['omb_listenee_fullname'];
+ $profile_url = $params['omb_listenee_profile'];
+ $homepage = $params['omb_listenee_homepage'];
+ $bio = $params['omb_listenee_bio'];
+ $location = $params['omb_listenee_location'];
+ $avatar_url = $params['omb_listenee_avatar'];
- $listenee = $req->get_parameter('omb_listenee');
+ $listenee = $params['omb_listenee'];
$remote = Remote_profile::staticGet('uri', $listenee);
if ($remote) {
@@ -309,14 +302,11 @@ class UserauthorizationAction extends Action
}
$user = common_current_user();
- $datastore = omb_oauth_datastore();
- $consumer = $this->getConsumer($datastore, $req);
- $token = $this->getToken($datastore, $req, $consumer);
$sub = new Subscription();
$sub->subscriber = $user->id;
$sub->subscribed = $remote->id;
- $sub->token = $token->key; # NOTE: request token, not valid for use!
+ $sub->token = $params['oauth_token']; # NOTE: request token, not valid for use!
$sub->created = DB_DataObject_Cast::dateTime(); # current time
if (!$sub->insert()) {
@@ -360,65 +350,59 @@ class UserauthorizationAction extends Action
common_show_footer();
}
- function storeRequest($req)
+ function storeParams($params)
{
common_ensure_session();
- $_SESSION['userauthorizationrequest'] = $req;
+ $_SESSION['userauthorizationparams'] = $params;
}
- function clearRequest()
+ function clearParams()
{
common_ensure_session();
- unset($_SESSION['userauthorizationrequest']);
+ unset($_SESSION['userauthorizationparams']);
}
- function getStoredRequest()
+ function getStoredParams()
{
common_ensure_session();
- $req = $_SESSION['userauthorizationrequest'];
- return $req;
- }
-
- function getNewRequest()
- {
- common_remove_magic_from_request();
- $req = OAuthRequest::from_request();
- return $req;
+ $params = $_SESSION['userauthorizationparams'];
+ return $params;
}
# Throws an OAuthException if anything goes wrong
- function validateRequest(&$req)
+ function validateRequest()
{
- # OAuth stuff -- have to copy from OAuth.php since they're
- # all private methods, and there's no user-authentication method
- $this->checkVersion($req);
- $datastore = omb_oauth_datastore();
- $consumer = $this->getConsumer($datastore, $req);
- $token = $this->getToken($datastore, $req, $consumer);
- $this->checkTimestamp($req);
- $this->checkNonce($datastore, $req, $consumer, $token);
- $this->checkSignature($req, $consumer, $token);
- $this->validateOmb($req);
+ /* Find token.
+ TODO: If no token is passed the user should get a prompt to enter it
+ according to OAuth Core 1.0 */
+ $t = new Token();
+ $t->tok = $_GET['oauth_token'];
+ $t->type = 0;
+ if (!$t->find(true)) {
+ throw new OAuthException("Invalid request token: " . $_GET['oauth_token']);
+ }
+
+ $this->validateOmb();
return true;
}
- function validateOmb(&$req)
+ function validateOmb()
{
foreach (array('omb_version', 'omb_listener', 'omb_listenee',
'omb_listenee_profile', 'omb_listenee_nickname',
'omb_listenee_license') as $param)
{
- if (is_null($req->get_parameter($param))) {
+ if (!isset($_GET[$param]) || is_null($_GET[$param])) {
throw new OAuthException("Required parameter '$param' not found");
}
}
# Now, OMB stuff
- $version = $req->get_parameter('omb_version');
+ $version = $_GET['omb_version'];
if ($version != OMB_VERSION_01) {
throw new OAuthException("OpenMicroBlogging version '$version' not supported");
}
- $listener = $req->get_parameter('omb_listener');
+ $listener = $_GET['omb_listener'];
$user = User::staticGet('uri', $listener);
if (!$user) {
throw new OAuthException("Listener URI '$listener' not found here");
@@ -427,7 +411,7 @@ class UserauthorizationAction extends Action
if ($cur->id != $user->id) {
throw new OAuthException("Can't add for another user!");
}
- $listenee = $req->get_parameter('omb_listenee');
+ $listenee = $_GET['omb_listenee'];
if (!Validate::uri($listenee) &&
!common_valid_tag($listenee)) {
throw new OAuthException("Listenee URI '$listenee' not a recognizable URI");
@@ -450,13 +434,13 @@ class UserauthorizationAction extends Action
throw new OAuthException("Already subscribed to user!");
}
}
- $nickname = $req->get_parameter('omb_listenee_nickname');
+ $nickname = $_GET['omb_listenee_nickname'];
if (!Validate::string($nickname, array('min_length' => 1,
'max_length' => 64,
'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
throw new OAuthException('Nickname must have only letters and numbers and no spaces.');
}
- $profile = $req->get_parameter('omb_listenee_profile');
+ $profile = $_GET['omb_listenee_profile'];
if (!common_valid_http_url($profile)) {
throw new OAuthException("Invalid profile URL '$profile'.");
}
@@ -465,7 +449,7 @@ class UserauthorizationAction extends Action
throw new OAuthException("Profile URL '$profile' is for a local user.");
}
- $license = $req->get_parameter('omb_listenee_license');
+ $license = $_GET['omb_listenee_license'];
if (!common_valid_http_url($license)) {
throw new OAuthException("Invalid license URL '$license'.");
}
@@ -474,23 +458,23 @@ class UserauthorizationAction extends Action
throw new OAuthException("Listenee stream license '$license' not compatible with site license '$site_license'.");
}
# optional stuff
- $fullname = $req->get_parameter('omb_listenee_fullname');
+ $fullname = $_GET['omb_listenee_fullname'];
if ($fullname && mb_strlen($fullname) > 255) {
throw new OAuthException("Full name '$fullname' too long.");
}
- $homepage = $req->get_parameter('omb_listenee_homepage');
+ $homepage = $_GET['omb_listenee_homepage'];
if ($homepage && (!common_valid_http_url($homepage) || mb_strlen($homepage) > 255)) {
throw new OAuthException("Invalid homepage '$homepage'");
}
- $bio = $req->get_parameter('omb_listenee_bio');
+ $bio = $_GET['omb_listenee_bio'];
if ($bio && mb_strlen($bio) > 140) {
throw new OAuthException("Bio too long '$bio'");
}
- $location = $req->get_parameter('omb_listenee_location');
+ $location = $_GET['omb_listenee_location'];
if ($location && mb_strlen($location) > 255) {
throw new OAuthException("Location too long '$location'");
}
- $avatar = $req->get_parameter('omb_listenee_avatar');
+ $avatar = $_GET['omb_listenee_avatar'];
if ($avatar) {
if (!common_valid_http_url($avatar) || strlen($avatar) > 255) {
throw new OAuthException("Invalid avatar URL '$avatar'");
@@ -507,7 +491,7 @@ class UserauthorizationAction extends Action
throw new OAuthException("Wrong image type for '$avatar'");
}
}
- $callback = $req->get_parameter('oauth_callback');
+ $callback = $_GET['oauth_callback'];
if ($callback && !common_valid_http_url($callback)) {
throw new OAuthException("Invalid callback URL '$callback'");
}
@@ -515,92 +499,4 @@ class UserauthorizationAction extends Action
throw new OAuthException("Callback URL '$callback' is for local site.");
}
}
-
- # Snagged from OAuthServer
-
- function checkVersion(&$req)
- {
- $version = $req->get_parameter("oauth_version");
- if (!$version) {
- $version = 1.0;
- }
- if ($version != 1.0) {
- throw new OAuthException("OAuth version '$version' not supported");
- }
- return $version;
- }
-
- # Snagged from OAuthServer
-
- function getConsumer($datastore, $req)
- {
- $consumer_key = @$req->get_parameter("oauth_consumer_key");
- if (!$consumer_key) {
- throw new OAuthException("Invalid consumer key");
- }
-
- $consumer = $datastore->lookup_consumer($consumer_key);
- if (!$consumer) {
- throw new OAuthException("Invalid consumer");
- }
- return $consumer;
- }
-
- # Mostly cadged from OAuthServer
-
- function getToken($datastore, &$req, $consumer)
- {/*{{{*/
- $token_field = @$req->get_parameter('oauth_token');
- $token = $datastore->lookup_token($consumer, 'request', $token_field);
- if (!$token) {
- throw new OAuthException("Invalid $token_type token: $token_field");
- }
- return $token;
- }
-
- function checkTimestamp(&$req)
- {
- $timestamp = @$req->get_parameter('oauth_timestamp');
- $now = time();
- if ($now - $timestamp > TIMESTAMP_THRESHOLD) {
- throw new OAuthException("Expired timestamp, yours $timestamp, ours $now");
- }
- }
-
- # NOTE: don't call twice on the same request; will fail!
- function checkNonce(&$datastore, &$req, $consumer, $token)
- {
- $timestamp = @$req->get_parameter('oauth_timestamp');
- $nonce = @$req->get_parameter('oauth_nonce');
- $found = $datastore->lookup_nonce($consumer, $token, $nonce, $timestamp);
- if ($found) {
- throw new OAuthException("Nonce already used");
- }
- return true;
- }
-
- function checkSignature(&$req, $consumer, $token)
- {
- $signature_method = $this->getSignatureMethod($req);
- $signature = $req->get_parameter('oauth_signature');
- $valid_sig = $signature_method->check_signature($req,
- $consumer,
- $token,
- $signature);
- if (!$valid_sig) {
- throw new OAuthException("Invalid signature");
- }
- }
-
- function getSignatureMethod(&$req)
- {
- $signature_method = @$req->get_parameter("oauth_signature_method");
- if (!$signature_method) {
- $signature_method = "PLAINTEXT";
- }
- if ($signature_method != 'HMAC-SHA1') {
- throw new OAuthException("Signature method '$signature_method' not supported.");
- }
- return omb_hmac_sha1();
- }
}
diff --git a/actions/usergroups.php b/actions/usergroups.php
index ded4ba76b..06b2334bf 100644
--- a/actions/usergroups.php
+++ b/actions/usergroups.php
@@ -139,10 +139,28 @@ class UsergroupsAction extends Action
if ($groups) {
$gl = new GroupList($groups, $this->user, $this);
$cnt = $gl->show();
+ if (0 == $cnt) {
+ $this->showEmptyListMessage();
+ }
}
$this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE,
$this->page, 'usergroups',
array('nickname' => $this->user->nickname));
}
+
+ function showEmptyListMessage()
+ {
+ $message = sprintf(_('%s is not a member of any group.'), $this->user->nickname) . ' ';
+
+ if (common_logged_in()) {
+ $current_user = common_current_user();
+ if ($this->user->id === $current_user->id) {
+ $message .= _('Try [searching for groups](%%action.groupsearch%%) and joining them.');
+ }
+ }
+ $this->elementStart('div', 'guide');
+ $this->raw(common_markup_to_html($message));
+ $this->elementEnd('div');
+ }
}