From 24713499a9686b6c2f1e765bb29d7e93e7256cd0 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sat, 7 Mar 2009 12:38:47 +0100 Subject: Fixes #827: Laconica expects full OAuth message for user auth request. When a user subscribes to a remote profile, he is redirected to his own service to confirm the request. This authorization request is specified in http://oauth.net/core/1.0#auth_step2. According to the standard, it does not have to pass consumer_key, nonce, timestamp or signature. The only specified parameters are oauth_token and oauth_callback, both optional. --- actions/userauthorization.php | 107 ++++-------------------------------------- 1 file changed, 8 insertions(+), 99 deletions(-) (limited to 'actions') diff --git a/actions/userauthorization.php b/actions/userauthorization.php index 6a76e3a4c..d0041ca5a 100644 --- a/actions/userauthorization.php +++ b/actions/userauthorization.php @@ -216,10 +216,8 @@ class UserauthorizationAction extends Action function authorizeToken(&$req) { - $consumer_key = $req->get_parameter('oauth_consumer_key'); $token_field = $req->get_parameter('oauth_token'); $rt = new Token(); - $rt->consumer_key = $consumer_key; $rt->tok = $token_field; $rt->type = 0; $rt->state = 0; @@ -390,15 +388,14 @@ class UserauthorizationAction extends Action function validateRequest(&$req) { - # 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); + /* Find token. */ + $t = new Token(); + $t->tok = $req->get_parameter('oauth_token'); + $t->type = 0; + if (!$t->find(true)) { + throw new OAuthException("Invalid request token: " . $req->get_parameter('oauth_token')); + } + $this->validateOmb($req); return true; } @@ -515,92 +512,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(); - } } -- cgit v1.2.3-54-g00ecf From df7565ddcca1e75476f4ad9318e83751d79884ba Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sat, 7 Mar 2009 13:04:36 +0100 Subject: Remove second OAuth request validation. --- actions/userauthorization.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'actions') diff --git a/actions/userauthorization.php b/actions/userauthorization.php index d0041ca5a..28243decc 100644 --- a/actions/userauthorization.php +++ b/actions/userauthorization.php @@ -56,7 +56,6 @@ class UserauthorizationAction extends Action 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); @@ -307,14 +306,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 = $req->get_parameter('oauth_token'); # NOTE: request token, not valid for use! $sub->created = DB_DataObject_Cast::dateTime(); # current time if (!$sub->insert()) { @@ -388,7 +384,9 @@ class UserauthorizationAction extends Action function validateRequest(&$req) { - /* Find token. */ + /* 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 = $req->get_parameter('oauth_token'); $t->type = 0; -- cgit v1.2.3-54-g00ecf From 6367def2d80d725c560079b48153964959f740a9 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sun, 8 Mar 2009 09:28:34 +0100 Subject: Remove OAuthRequest as storage from userauthorization. Since we are not really handling a fullblown OAuth request (No signature, nonce, consumer) we should not use this class, rather store the plain param array in the session. --- actions/userauthorization.php | 159 ++++++++++++++++++++---------------------- 1 file changed, 74 insertions(+), 85 deletions(-) (limited to 'actions') diff --git a/actions/userauthorization.php b/actions/userauthorization.php index 28243decc..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,17 +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!')); - } - $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; } @@ -68,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(); } @@ -90,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) { @@ -146,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); @@ -213,9 +209,9 @@ class UserauthorizationAction extends Action } } - function authorizeToken(&$req) + function authorizeToken(&$params) { - $token_field = $req->get_parameter('oauth_token'); + $token_field = $params['oauth_token']; $rt = new Token(); $rt->tok = $token_field; $rt->type = 0; @@ -232,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) { @@ -310,7 +306,7 @@ class UserauthorizationAction extends Action $sub = new Subscription(); $sub->subscriber = $user->id; $sub->subscribed = $remote->id; - $sub->token = $req->get_parameter('oauth_token'); # 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()) { @@ -354,66 +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() { /* 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 = $req->get_parameter('oauth_token'); + $t->tok = $_GET['oauth_token']; $t->type = 0; if (!$t->find(true)) { - throw new OAuthException("Invalid request token: " . $req->get_parameter('oauth_token')); + throw new OAuthException("Invalid request token: " . $_GET['oauth_token']); } - $this->validateOmb($req); + $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"); @@ -422,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"); @@ -445,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'."); } @@ -460,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'."); } @@ -469,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'"); @@ -502,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'"); } -- cgit v1.2.3-54-g00ecf From 1ee24a2aaf6d07f0f6ffd4697da88c43b140bd13 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Sun, 5 Apr 2009 23:11:40 +0000 Subject: added filler text to people search, suggesting other search options. --- actions/peoplesearch.php | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'actions') diff --git a/actions/peoplesearch.php b/actions/peoplesearch.php index 9e515ade1..6fbb19b88 100644 --- a/actions/peoplesearch.php +++ b/actions/peoplesearch.php @@ -60,14 +60,8 @@ 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. $search_engine->limit((($page-1)*PROFILES_PER_PAGE), PROFILES_PER_PAGE + 1); @@ -81,14 +75,34 @@ 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.')); - $profile->free(); + $qe = urlencode($q); + $message = _(<<pagination($page > 1, $cnt > PROFILES_PER_PAGE, - $page, 'peoplesearch', array('q' => $q)); +You can also try your search on other engines: + +* [Twingly](http://www.twingly.com/search?q=$qe&content=microblog&site=identi.ca) +* [Tweet scan](http://www.tweetscan.com/indexi.php?s=$qe) +* [Google](http://www.google.com/search?q=site%3Aidenti.ca+$qe) +* [Yahoo](http://search.yahoo.com/search?p=site%3Aidenti.ca+$qe) + +E_O_T +); + $this->elementStart('div', 'blankfiller'); + $this->raw(common_markup_to_html($message)); + $this->elementEnd('div'); + $profile->free(); + } } } -- cgit v1.2.3-54-g00ecf From 84d2aa7df49dc85603dd6c2d60c1f605800a458c Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Mon, 6 Apr 2009 01:14:59 +0000 Subject: refactored search suggestions and added forgotten sprintf. --- actions/peoplesearch.php | 21 ++------------------- lib/searchaction.php | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 19 deletions(-) (limited to 'actions') diff --git a/actions/peoplesearch.php b/actions/peoplesearch.php index 6fbb19b88..3ce719dd5 100644 --- a/actions/peoplesearch.php +++ b/actions/peoplesearch.php @@ -82,25 +82,8 @@ class PeoplesearchAction extends SearchAction } else { $this->element('p', 'error', _('No results.')); - $qe = urlencode($q); - $message = _(<<elementStart('div', 'blankfiller'); - $this->raw(common_markup_to_html($message)); - $this->elementEnd('div'); +//TODO + $this->searchSuggestions($q); $profile->free(); } } diff --git a/lib/searchaction.php b/lib/searchaction.php index c762db16f..697262ccd 100644 --- a/lib/searchaction.php +++ b/lib/searchaction.php @@ -133,5 +133,28 @@ class SearchAction extends Action $this->showResults($q, $page); } } + + function searchSuggestions($q) { + $qe = urlencode($q); + $message = sprintf(_(<<elementStart('div', 'blankfiller'); + $this->raw(common_markup_to_html($message)); + $this->elementEnd('div'); + } } -- cgit v1.2.3-54-g00ecf From 9ad8307b7ee60b3263733b8b8c3d7ac6f350a452 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Mon, 6 Apr 2009 05:04:11 +0000 Subject: external search now depends on site.server. --- actions/peoplesearch.php | 2 -- lib/searchaction.php | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'actions') diff --git a/actions/peoplesearch.php b/actions/peoplesearch.php index 3ce719dd5..65d970dd1 100644 --- a/actions/peoplesearch.php +++ b/actions/peoplesearch.php @@ -81,8 +81,6 @@ class PeoplesearchAction extends SearchAction } else { $this->element('p', 'error', _('No results.')); - -//TODO $this->searchSuggestions($q); $profile->free(); } diff --git a/lib/searchaction.php b/lib/searchaction.php index 697262ccd..918f8dd9a 100644 --- a/lib/searchaction.php +++ b/lib/searchaction.php @@ -146,8 +146,8 @@ You can also try your search on other engines: * [Twingly](http://www.twingly.com/search?q=%s&content=microblog&site=identi.ca) * [Tweet scan](http://www.tweetscan.com/indexi.php?s=%s) -* [Google](http://www.google.com/search?q=site%%3Aidenti.ca+%s) -* [Yahoo](http://search.yahoo.com/search?p=site%%3Aidenti.ca+%s) +* [Google](http://www.google.com/search?q=site%%3A%%%%site.server%%%%+%s) +* [Yahoo](http://search.yahoo.com/search?p=site%%3A%%%%site.server%%%%+%s) E_O_T -- cgit v1.2.3-54-g00ecf From 17fb51f747c023392cd6127abe9b019e693f0544 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Tue, 7 Apr 2009 03:26:33 +0000 Subject: added filler text to notice and group search, suggesting other search options. --- actions/groupsearch.php | 24 +++++++++++++++--------- actions/noticesearch.php | 21 +++++++++++++-------- 2 files changed, 28 insertions(+), 17 deletions(-) (limited to 'actions') diff --git a/actions/groupsearch.php b/actions/groupsearch.php index 109a53ce1..31c4ffd94 100644 --- a/actions/groupsearch.php +++ b/actions/groupsearch.php @@ -72,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', 'blankfiller'); + $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)); } } @@ -98,10 +109,5 @@ class GroupSearchResults extends GroupList { return preg_replace($this->pattern, '\\1', htmlspecialchars($text)); } - - function isReadOnly() - { - return true; - } } diff --git a/actions/noticesearch.php b/actions/noticesearch.php index 9058cf53c..a4308450b 100644 --- a/actions/noticesearch.php +++ b/actions/noticesearch.php @@ -114,22 +114,27 @@ 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', 'blankfiller'); + $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($page > 1, $cnt > NOTICES_PER_PAGE, $page, 'noticesearch', array('q' => $q)); } - - function isReadOnly() - { - return true; - } } class SearchNoticeList extends NoticeList { -- cgit v1.2.3-54-g00ecf From 640ae109354336a684c9b01e5d842b8aff4e0ea1 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Tue, 7 Apr 2009 16:11:03 +0000 Subject: added filler text to personal timeline. --- actions/all.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'actions') diff --git a/actions/all.php b/actions/all.php index 8e67ec0f3..5189f31f5 100644 --- a/actions/all.php +++ b/actions/all.php @@ -93,6 +93,32 @@ class AllAction extends Action $nav->show(); } + function showPageNotice() + { + $notice = $this->user->noticesWithFriends(0, 1); + if ($notice->count()) { + return; + } + + $message = sprintf(_('This is the timeline for %s and friends but noone 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](./) from his profile or [post something to his or her attention](%%%%action.newnotice%%%%?status_textarea=%s).'), $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', 'blankfiller'); + $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); -- cgit v1.2.3-54-g00ecf From a6e950b7a1ca7654613dd7f5cefcdae6a3a0f579 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 7 Apr 2009 21:09:27 +0000 Subject: Renamed 'blankfiller' to 'guide'. --- actions/all.php | 2 +- actions/favorited.php | 2 +- actions/groupsearch.php | 2 +- actions/noticesearch.php | 2 +- actions/public.php | 2 +- actions/publictagcloud.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) (limited to 'actions') diff --git a/actions/all.php b/actions/all.php index 5189f31f5..9c6182ccc 100644 --- a/actions/all.php +++ b/actions/all.php @@ -114,7 +114,7 @@ class AllAction extends Action $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', 'blankfiller'); + $this->elementStart('div', 'guide'); $this->raw(common_markup_to_html($message)); $this->elementEnd('div'); } diff --git a/actions/favorited.php b/actions/favorited.php index 20a354674..6935eda23 100644 --- a/actions/favorited.php +++ b/actions/favorited.php @@ -159,7 +159,7 @@ class FavoritedAction extends Action $message .= _('Why not [register an account](%%action.register%%) and be the first to add a notice to your favorites!'); } - $this->elementStart('div', 'blankfiller'); + $this->elementStart('div', 'guide'); $this->raw(common_markup_to_html($message)); $this->elementEnd('div'); } diff --git a/actions/groupsearch.php b/actions/groupsearch.php index 31c4ffd94..06b4a7755 100644 --- a/actions/groupsearch.php +++ b/actions/groupsearch.php @@ -84,7 +84,7 @@ class GroupsearchAction extends SearchAction else { $message = _('Why not [register an account](%%action.register%%) and [create the group](%%action.newgroup%%) yourself!'); } - $this->elementStart('div', 'blankfiller'); + $this->elementStart('div', 'guide'); $this->raw(common_markup_to_html($message)); $this->elementEnd('div'); $user_group->free(); diff --git a/actions/noticesearch.php b/actions/noticesearch.php index a4308450b..095d0a454 100644 --- a/actions/noticesearch.php +++ b/actions/noticesearch.php @@ -124,7 +124,7 @@ class NoticesearchAction extends SearchAction $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', 'blankfiller'); + $this->elementStart('div', 'guide'); $this->raw(common_markup_to_html($message)); $this->elementEnd('div'); return; diff --git a/actions/public.php b/actions/public.php index 5a2720a9a..d64b651fd 100644 --- a/actions/public.php +++ b/actions/public.php @@ -188,7 +188,7 @@ class PublicAction extends Action $message .= _('Why not [register an account](%%action.register%%) and be the first to post!'); } - $this->elementStart('div', 'blankfiller'); + $this->elementStart('div', 'guide'); $this->raw(common_markup_to_html($message)); $this->elementEnd('div'); } diff --git a/actions/publictagcloud.php b/actions/publictagcloud.php index 5bc7e0cbf..4ff41d2a6 100644 --- a/actions/publictagcloud.php +++ b/actions/publictagcloud.php @@ -77,7 +77,7 @@ class PublictagcloudAction extends Action $message .= _('Why not [register an account](%%action.register%%) and be the first to post one!'); } - $this->elementStart('div', 'blankfiller'); + $this->elementStart('div', 'guide'); $this->raw(common_markup_to_html($message)); $this->elementEnd('div'); } -- cgit v1.2.3-54-g00ecf From 05b04b7970d1b0f1e35a64a5537ad61e2fb8db1c Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 7 Apr 2009 21:12:11 +0000 Subject: Changed text "noone" to "no one". --- actions/all.php | 2 +- actions/favorited.php | 2 +- actions/public.php | 2 +- actions/publictagcloud.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'actions') diff --git a/actions/all.php b/actions/all.php index 9c6182ccc..9a1632670 100644 --- a/actions/all.php +++ b/actions/all.php @@ -100,7 +100,7 @@ class AllAction extends Action return; } - $message = sprintf(_('This is the timeline for %s and friends but noone has posted anything yet.'), $this->user->nickname) . ' '; + $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(); diff --git a/actions/favorited.php b/actions/favorited.php index 6935eda23..27da25435 100644 --- a/actions/favorited.php +++ b/actions/favorited.php @@ -150,7 +150,7 @@ class FavoritedAction extends Action return; } - $message = _('Favorite notices appear on this page but noone has favorited one yet.') . ' '; + $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.'); diff --git a/actions/public.php b/actions/public.php index d64b651fd..b7b7fc6b7 100644 --- a/actions/public.php +++ b/actions/public.php @@ -179,7 +179,7 @@ class PublicAction extends Action return; } - $message = _('This is the public timeline for %%site.name%% but noone has posted anything yet.') . ' '; + $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!'); diff --git a/actions/publictagcloud.php b/actions/publictagcloud.php index 4ff41d2a6..0cd8940d4 100644 --- a/actions/publictagcloud.php +++ b/actions/publictagcloud.php @@ -68,7 +68,7 @@ class PublictagcloudAction extends Action return; } - $message = _('Noone has posted a notice with a [hashtag](%%doc.tags%%) yet.') . ' '; + $message = _('No one has posted a notice with a [hashtag](%%doc.tags%%) yet.') . ' '; if (common_logged_in()) { $message .= _('Be the first to post one!'); -- cgit v1.2.3-54-g00ecf From 50b32227d1c4bb6fa5c6f81077ddd4a21981e639 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 7 Apr 2009 17:47:08 -0400 Subject: Add subscribers, subscriptions, groups to personal page We show stats, subscriptions info on the personal page in the sidebar. Pushed code from showstream.php into a common parent class for personal and profile. --- actions/all.php | 20 +--- actions/showstream.php | 201 ++-------------------------------------- lib/profileaction.php | 242 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 250 insertions(+), 213 deletions(-) create mode 100644 lib/profileaction.php (limited to 'actions') diff --git a/actions/all.php b/actions/all.php index 9a1632670..d457378dd 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); diff --git a/actions/showstream.php b/actions/showstream.php index f5886f3d3..3c6c06070 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; @@ -82,45 +78,6 @@ class ShowstreamAction extends Action } } - 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) { @@ -383,156 +340,6 @@ class ShowstreamAction extends Action '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() - { - $profile = $this->user->getSubscriptions(0, PROFILES_PER_MINILIST + 1); - - $this->elementStart('div', array('id' => 'entity_subscriptions', - 'class' => 'section')); - - $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 ($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'); - } - - $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() - { - $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)')); - } - } - - 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'); - } - - $this->elementEnd('div'); - } - function showAnonymousMessage() { if (!(common_config('site','closed') || common_config('site','inviteonly'))) { @@ -550,6 +357,12 @@ class ShowstreamAction extends Action $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/lib/profileaction.php b/lib/profileaction.php new file mode 100644 index 000000000..c81924e31 --- /dev/null +++ b/lib/profileaction.php @@ -0,0 +1,242 @@ +. + * + * @category Personal + * @package Laconica + * @author Evan Prodromou + * @author Sarven Capadisli + * @copyright 2008-2009 Control Yourself, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +if (!defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/profileminilist.php'; +require_once INSTALLDIR.'/lib/groupminilist.php'; + +/** + * Profile action common superclass + * + * Abstracts out common code from profile and personal tabs + * + * @category Personal + * @package Laconica + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +class ProfileAction extends Action +{ + var $user = null; + var $page = null; + var $profile = null; + + 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($this->trimmed('action'), $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 showSections() + { + $this->showSubscriptions(); + $this->showSubscribers(); + $this->showGroups(); + $this->showStatistics(); + } + + function showSubscriptions() + { + $profile = $this->user->getSubscriptions(0, PROFILES_PER_MINILIST + 1); + + $this->elementStart('div', array('id' => 'entity_subscriptions', + 'class' => 'section')); + + $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 ($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'); + } + + $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() + { + $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)')); + } + } + + 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'); + } + + $this->elementEnd('div'); + } +} \ No newline at end of file -- cgit v1.2.3-54-g00ecf From c79bad0601512191f9b7523cea6a222444cb92d0 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Tue, 7 Apr 2009 22:16:09 +0000 Subject: fixed filler/guide text on personal timeline to take memcached into account. --- actions/all.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'actions') diff --git a/actions/all.php b/actions/all.php index d457378dd..dc5da3e00 100644 --- a/actions/all.php +++ b/actions/all.php @@ -75,13 +75,8 @@ class AllAction extends ProfileAction $nav->show(); } - function showPageNotice() + function showEmptyListMessage() { - $notice = $this->user->noticesWithFriends(0, 1); - if ($notice->count()) { - return; - } - $message = sprintf(_('This is the timeline for %s and friends but no one has posted anything yet.'), $this->user->nickname) . ' '; if (common_logged_in()) { @@ -109,6 +104,10 @@ class AllAction extends ProfileAction $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)); } -- cgit v1.2.3-54-g00ecf From d704b3fa8ed8731251ff27919d447c8bd382383d Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Tue, 7 Apr 2009 23:14:02 +0000 Subject: added filler/guide text to user timeline. --- actions/showstream.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'actions') diff --git a/actions/showstream.php b/actions/showstream.php index 3c6c06070..cb40d1302 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -329,12 +329,37 @@ class ShowstreamAction extends ProfileAction _('Subscribe')); } + function showEmptyListMessage() + { + $message = sprintf(_('This is the timeline for %s but %s hasn\'t posted anything yet.'), $this->user->nickname, $this->user->nickname) . ' '; + + 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); + } + } + 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->element('br', array('clear' => 'both')); + $this->elementStart('div', 'guide'); + $this->raw(common_markup_to_html($message)); + $this->elementEnd('div'); + } + function showNotices() { $notice = $this->user->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); $pnl = new ProfileNoticeList($notice, $this); $cnt = $pnl->show(); + if (0 == $cnt) { + $this->showemptyListMessage(); + } $this->pagination($this->page>1, $cnt>NOTICES_PER_PAGE, $this->page, 'showstream', array('nickname' => $this->user->nickname)); -- cgit v1.2.3-54-g00ecf From 79b1e3a488372065590700491320b9d3b0c74de4 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Tue, 7 Apr 2009 23:25:12 +0000 Subject: added filler/guide text to user replies timeline. --- actions/all.php | 2 +- actions/replies.php | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'actions') diff --git a/actions/all.php b/actions/all.php index dc5da3e00..f5bbfe2e3 100644 --- a/actions/all.php +++ b/actions/all.php @@ -84,7 +84,7 @@ class AllAction extends ProfileAction 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](./) from his profile or [post something to his or her attention](%%%%action.newnotice%%%%?status_textarea=%s).'), $this->user->nickname, '@' . $this->user->nickname); + $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 { 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; -- cgit v1.2.3-54-g00ecf From a839daad2ecbf8430f518e8690cc509885973e82 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 7 Apr 2009 23:45:22 +0000 Subject: HTML br is not needed. Using 'clear' in CSS instead. --- actions/showstream.php | 1 - theme/base/css/display.css | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'actions') diff --git a/actions/showstream.php b/actions/showstream.php index cb40d1302..4181a2bab 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -345,7 +345,6 @@ class ShowstreamAction extends ProfileAction $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->element('br', array('clear' => 'both')); $this->elementStart('div', 'guide'); $this->raw(common_markup_to_html($message)); $this->elementEnd('div'); diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 6c3c7e912..dfac7712a 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -1156,3 +1156,6 @@ margin-bottom:18px; .help dt { display:none; } +.guide { +clear:both; +} -- cgit v1.2.3-54-g00ecf From cc50031658f1665d60efdf8e3e5963e01584baf9 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Wed, 8 Apr 2009 00:15:05 +0000 Subject: added filler/guide text to user favorites. --- actions/showfavorites.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'actions') diff --git a/actions/showfavorites.php b/actions/showfavorites.php index d1c9283f0..035b899d2 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 any notices to his favorites yet. Post something interesting they would add to their favorites :)'), $this->user->nickname); + } + } + else { + $message = sprintf(_('%s hasn\'t 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.')); + } } + -- cgit v1.2.3-54-g00ecf From b20815e8e2d6d170fecc7143656b22bc68de3780 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Wed, 8 Apr 2009 00:16:53 +0000 Subject: added missing word to user favorites guide. --- actions/showfavorites.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actions') diff --git a/actions/showfavorites.php b/actions/showfavorites.php index 035b899d2..c4c91058f 100644 --- a/actions/showfavorites.php +++ b/actions/showfavorites.php @@ -169,11 +169,11 @@ class ShowfavoritesAction extends Action 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 any notices to his favorites yet. Post something interesting they would add to their favorites :)'), $this->user->nickname); + $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 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); + $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'); -- cgit v1.2.3-54-g00ecf From 68ed6be71f24f5b434dfe8a5d3f28543d6bd2644 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Wed, 8 Apr 2009 01:05:17 +0000 Subject: added filler/guide text to subscription list. --- actions/subscriptions.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'actions') diff --git a/actions/subscriptions.php b/actions/subscriptions.php index 3fbea2039..878fd0cd2 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->profile->nickname); + } + } + else { + $message = sprintf(_('%s is not listening to anyone.'), $this->profile->fullname); + } + + $this->elementStart('div', 'guide'); + $this->raw(common_markup_to_html($message)); + $this->elementEnd('div'); + } } class SubscriptionsList extends ProfileList -- cgit v1.2.3-54-g00ecf From 3fb6c8218a1c8dc2078bf244bcc937e36f1e0e0e Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Wed, 8 Apr 2009 01:12:43 +0000 Subject: added filler/guide text to subscribers list. --- actions/subscribers.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'actions') 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 -- cgit v1.2.3-54-g00ecf From ddb59f72db7f3c6393c0fb245631117e29f093a8 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Wed, 8 Apr 2009 01:13:37 +0000 Subject: text bugfix to guide text in subscription list. --- actions/subscriptions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actions') diff --git a/actions/subscriptions.php b/actions/subscriptions.php index 878fd0cd2..b0c0a9b8d 100644 --- a/actions/subscriptions.php +++ b/actions/subscriptions.php @@ -114,11 +114,11 @@ class SubscriptionsAction extends GalleryAction 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->profile->nickname); + $message = sprintf(_('%s is not listening to anyone.'), $this->user->nickname); } } else { - $message = sprintf(_('%s is not listening to anyone.'), $this->profile->fullname); + $message = sprintf(_('%s is not listening to anyone.'), $this->user->nickname); } $this->elementStart('div', 'guide'); -- cgit v1.2.3-54-g00ecf From 5c876167785768c41c78a9819868aca17a91e41d Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Wed, 8 Apr 2009 01:19:23 +0000 Subject: added filler/guide text to user groups list. --- actions/usergroups.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'actions') 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'); + } } -- cgit v1.2.3-54-g00ecf From afebef50e46dc6285e3b3fcdf7907d26598a4e95 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Wed, 8 Apr 2009 01:20:50 +0000 Subject: showemptListMessage -> showEmptyListMessage method name cleanup. --- actions/showfavorites.php | 2 +- actions/showstream.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'actions') diff --git a/actions/showfavorites.php b/actions/showfavorites.php index c4c91058f..4d4349505 100644 --- a/actions/showfavorites.php +++ b/actions/showfavorites.php @@ -203,7 +203,7 @@ class ShowfavoritesAction extends Action $cnt = $nl->show(); if (0 == $cnt) { - $this->showemptyListMessage(); + $this->showEmptyListMessage(); } $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE, diff --git a/actions/showstream.php b/actions/showstream.php index 4181a2bab..ce237dae2 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -357,7 +357,7 @@ class ShowstreamAction extends ProfileAction $pnl = new ProfileNoticeList($notice, $this); $cnt = $pnl->show(); if (0 == $cnt) { - $this->showemptyListMessage(); + $this->showEmptyListMessage(); } $this->pagination($this->page>1, $cnt>NOTICES_PER_PAGE, $this->page, -- cgit v1.2.3-54-g00ecf From 579332aa247140d4da720b6c756c97bffdbf955d Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 7 Apr 2009 23:57:45 -0400 Subject: don't use count() to check for empty page --- actions/favorited.php | 17 +++++++++-------- actions/public.php | 17 +++++------------ actions/publictagcloud.php | 10 +++++----- 3 files changed, 19 insertions(+), 25 deletions(-) (limited to 'actions') diff --git a/actions/favorited.php b/actions/favorited.php index 27da25435..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; } @@ -143,13 +143,10 @@ class FavoritedAction extends Action $this->elementStart('div', 'instructions'); $this->raw($output); $this->elementEnd('div'); + } - $favorite = new Fave; - - if ($favorite->count()) { - return; - } - + function showEmptyList() + { $message = _('Favorite notices appear on this page but no one has favorited one yet.') . ' '; if (common_logged_in()) { @@ -217,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/public.php b/actions/public.php index b7b7fc6b7..5a380de9a 100644 --- a/actions/public.php +++ b/actions/public.php @@ -166,19 +166,8 @@ class PublicAction extends Action $nav->show(); } - function showPageNotice() + function showEmptyList() { - $notice = new Notice; - - if (!$notice) { - $this->serverError(_('Could not retrieve public stream.')); - return; - } - - if ($notice->count()) { - return; - } - $message = _('This is the public timeline for %%site.name%% but no one has posted anything yet.') . ' '; if (common_logged_in()) { @@ -216,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'); } diff --git a/actions/publictagcloud.php b/actions/publictagcloud.php index 0cd8940d4..855cfed9b 100644 --- a/actions/publictagcloud.php +++ b/actions/publictagcloud.php @@ -62,12 +62,10 @@ class PublictagcloudAction extends Action $this->element('p', 'instructions', sprintf(_('These are most popular recent tags on %s '), common_config('site', 'name'))); + } - $tags = new Notice_tag; - if ($tags->count()) { - return; - } - + function showEmptyList() + { $message = _('No one has posted a notice with a [hashtag](%%doc.tags%%) yet.') . ' '; if (common_logged_in()) { @@ -144,6 +142,8 @@ class PublictagcloudAction extends Action $this->elementEnd('dd'); $this->elementEnd('dl'); $this->elementEnd('div'); + } else { + $this->showEmptyList(); } } -- cgit v1.2.3-54-g00ecf