summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2009-08-21 15:42:11 -0400
committerEvan Prodromou <evan@controlyourself.ca>2009-08-21 15:42:11 -0400
commitb2664e1ae2e2cf66585cdd8696d88efdd053eb3b (patch)
tree3e406bc5502c0937f2cf81e0b4a6a1b714a1b403 /actions
parentc78772b2748f70acc8158b665218fe53b277a031 (diff)
parent9f07921b45190b462e1a798622068e24ef31e124 (diff)
Merge branch '0.8.x' into 0.9.x
Conflicts: actions/updateprofile.php actions/userauthorization.php classes/User_group.php index.php install.php lib/accountsettingsaction.php lib/logingroupnav.php
Diffstat (limited to 'actions')
-rw-r--r--actions/all.php34
-rw-r--r--actions/allrss.php4
-rw-r--r--actions/api.php5
-rw-r--r--actions/attachment.php12
-rw-r--r--actions/avatarsettings.php17
-rw-r--r--actions/confirmaddress.php6
-rw-r--r--actions/emailsettings.php14
-rw-r--r--actions/favorited.php3
-rw-r--r--actions/favoritesrss.php4
-rw-r--r--actions/finishopenidlogin.php8
-rw-r--r--actions/grouplogo.php17
-rw-r--r--actions/grouprss.php5
-rw-r--r--actions/groupsearch.php3
-rw-r--r--actions/imsettings.php6
-rw-r--r--actions/invite.php2
-rw-r--r--actions/login.php12
-rw-r--r--actions/newnotice.php56
-rw-r--r--actions/noticesearch.php4
-rw-r--r--actions/noticesearchrss.php5
-rw-r--r--actions/oembed.php (renamed from actions/twitapioembed.php)61
-rw-r--r--actions/openidlogin.php4
-rw-r--r--actions/openidsettings.php6
-rw-r--r--actions/opensearch.php2
-rw-r--r--actions/profilesettings.php2
-rw-r--r--actions/public.php34
-rw-r--r--actions/publicrss.php4
-rw-r--r--actions/publictagcloud.php3
-rw-r--r--actions/register.php28
-rw-r--r--actions/remotesubscribe.php12
-rw-r--r--actions/replies.php17
-rw-r--r--actions/repliesrss.php3
-rw-r--r--actions/showfavorites.php48
-rw-r--r--actions/showgroup.php19
-rw-r--r--actions/shownotice.php18
-rw-r--r--actions/showstream.php10
-rw-r--r--actions/smssettings.php6
-rw-r--r--actions/subscribers.php4
-rw-r--r--actions/subscriptions.php16
-rw-r--r--actions/tag.php13
-rw-r--r--actions/tagrss.php3
-rw-r--r--actions/twitapigroups.php97
-rw-r--r--actions/twitapistatuses.php16
-rw-r--r--actions/twitterauthorization.php222
-rw-r--r--actions/twittersettings.php389
-rw-r--r--actions/updateprofile.php50
-rw-r--r--actions/userauthorization.php7
-rw-r--r--actions/userrss.php5
47 files changed, 786 insertions, 530 deletions
diff --git a/actions/all.php b/actions/all.php
index f06ead2a8..38aee65b6 100644
--- a/actions/all.php
+++ b/actions/all.php
@@ -25,11 +25,31 @@ require_once INSTALLDIR.'/lib/feedlist.php';
class AllAction extends ProfileAction
{
+ var $notice;
+
function isReadOnly($args)
{
return true;
}
+ function prepare($args)
+ {
+ parent::prepare($args);
+ $cur = common_current_user();
+
+ if (!empty($cur) && $cur->id == $this->user->id) {
+ $this->notice = $this->user->noticeInbox(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
+ } else {
+ $this->notice = $this->user->noticesWithFriends(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
+ }
+
+ if($this->page > 1 && $this->notice->N == 0){
+ $this->serverError(_('No such page'),$code=404);
+ }
+
+ return true;
+ }
+
function handle($args)
{
parent::handle($args);
@@ -88,7 +108,9 @@ class AllAction extends ProfileAction
}
}
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);
+ $message .= sprintf(_('Why not [register an account](%%%%action.%s%%%%) and then nudge %s or post a notice to his or her attention.'),
+ (!common_config('site','openidonly')) ? 'register' : 'openidlogin',
+ $this->user->nickname);
}
$this->elementStart('div', 'guide');
@@ -98,15 +120,7 @@ class AllAction extends ProfileAction
function showContent()
{
- $cur = common_current_user();
-
- if (!empty($cur) && $cur->id == $this->user->id) {
- $notice = $this->user->noticeInbox(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
- } else {
- $notice = $this->user->noticesWithFriends(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
- }
-
- $nl = new NoticeList($notice, $this);
+ $nl = new NoticeList($this->notice, $this);
$cnt = $nl->show();
diff --git a/actions/allrss.php b/actions/allrss.php
index 885a67f61..260667090 100644
--- a/actions/allrss.php
+++ b/actions/allrss.php
@@ -115,8 +115,8 @@ class AllrssAction extends Rss10Action
'link' => common_local_url('all',
array('nickname' =>
$user->nickname)),
- 'description' => sprintf(_('Feed for friends of %s'),
- $user->nickname));
+ 'description' => sprintf(_('Updates from %1$s and friends on %2$s!'),
+ $user->nickname, common_config('site', 'name')));
return $c;
}
diff --git a/actions/api.php b/actions/api.php
index 99ab262ad..6d226af7e 100644
--- a/actions/api.php
+++ b/actions/api.php
@@ -131,6 +131,8 @@ class ApiAction extends Action
'tags/timeline',
'oembed/oembed',
'groups/show',
+ 'groups/timeline',
+ 'groups/list_all',
'groups/timeline');
static $bareauth = array('statuses/user_timeline',
@@ -140,7 +142,8 @@ class ApiAction extends Action
'statuses/mentions',
'statuses/followers',
'favorites/favorites',
- 'friendships/show');
+ 'friendships/show',
+ 'groups/list_groups');
$fullname = "$this->api_action/$this->api_method";
diff --git a/actions/attachment.php b/actions/attachment.php
index c6a5d0d52..f42906fd8 100644
--- a/actions/attachment.php
+++ b/actions/attachment.php
@@ -103,18 +103,18 @@ class AttachmentAction extends Action
$this->element('link',array('rel'=>'alternate',
'type'=>'application/json+oembed',
'href'=>common_local_url(
- 'api',
- array('apiaction'=>'oembed','method'=>'oembed.json'),
- array('url'=>
+ 'oembed',
+ array(),
+ array('format'=>'json', 'url'=>
common_local_url('attachment',
array('attachment' => $this->attachment->id)))),
'title'=>'oEmbed'),null);
$this->element('link',array('rel'=>'alternate',
'type'=>'text/xml+oembed',
'href'=>common_local_url(
- 'api',
- array('apiaction'=>'oembed','method'=>'oembed.xml'),
- array('url'=>
+ 'oembed',
+ array(),
+ array('format'=>'xml','url'=>
common_local_url('attachment',
array('attachment' => $this->attachment->id)))),
'title'=>'oEmbed'),null);
diff --git a/actions/avatarsettings.php b/actions/avatarsettings.php
index c2bb35a39..c45514ff6 100644
--- a/actions/avatarsettings.php
+++ b/actions/avatarsettings.php
@@ -382,13 +382,7 @@ class AvatarsettingsAction extends AccountSettingsAction
function showStylesheets()
{
parent::showStylesheets();
- $jcropStyle =
- common_path('theme/base/css/jquery.Jcrop.css?version='.LACONICA_VERSION);
-
- $this->element('link', array('rel' => 'stylesheet',
- 'type' => 'text/css',
- 'href' => $jcropStyle,
- 'media' => 'screen, projection, tv'));
+ $this->cssLink('css/jquery.Jcrop.css','base','screen, projection, tv');
}
/**
@@ -402,13 +396,8 @@ class AvatarsettingsAction extends AccountSettingsAction
parent::showScripts();
if ($this->mode == 'crop') {
- $jcropPack = common_path('js/jcrop/jquery.Jcrop.pack.js');
- $jcropGo = common_path('js/jcrop/jquery.Jcrop.go.js');
-
- $this->element('script', array('type' => 'text/javascript',
- 'src' => $jcropPack));
- $this->element('script', array('type' => 'text/javascript',
- 'src' => $jcropGo));
+ $this->script('js/jcrop/jquery.Jcrop.min.js');
+ $this->script('js/jcrop/jquery.Jcrop.go.js');
}
}
}
diff --git a/actions/confirmaddress.php b/actions/confirmaddress.php
index 725c1f1e3..3c41a5c70 100644
--- a/actions/confirmaddress.php
+++ b/actions/confirmaddress.php
@@ -67,7 +67,11 @@ class ConfirmaddressAction extends Action
parent::handle($args);
if (!common_logged_in()) {
common_set_returnto($this->selfUrl());
- common_redirect(common_local_url('login'));
+ if (!common_config('site', 'openidonly')) {
+ common_redirect(common_local_url('login'));
+ } else {
+ common_redirect(common_local_url('openidlogin'));
+ }
return;
}
$code = $this->trimmed('code');
diff --git a/actions/emailsettings.php b/actions/emailsettings.php
index 634388fdd..cdd092829 100644
--- a/actions/emailsettings.php
+++ b/actions/emailsettings.php
@@ -122,7 +122,7 @@ class EmailsettingsAction extends AccountSettingsAction
}
$this->elementEnd('fieldset');
- if ($user->email) {
+ if (common_config('emailpost', 'enabled') && $user->email) {
$this->elementStart('fieldset', array('id' => 'settings_email_incoming'));
$this->element('legend',_('Incoming email'));
if ($user->incomingemail) {
@@ -173,11 +173,13 @@ class EmailsettingsAction extends AccountSettingsAction
_('Allow friends to nudge me and send me an email.'),
$user->emailnotifynudge);
$this->elementEnd('li');
- $this->elementStart('li');
- $this->checkbox('emailpost',
- _('I want to post notices by email.'),
- $user->emailpost);
- $this->elementEnd('li');
+ if (common_config('emailpost', 'enabled')) {
+ $this->elementStart('li');
+ $this->checkbox('emailpost',
+ _('I want to post notices by email.'),
+ $user->emailpost);
+ $this->elementEnd('li');
+ }
$this->elementStart('li');
$this->checkbox('emailmicroid',
_('Publish a MicroID for my email address.'),
diff --git a/actions/favorited.php b/actions/favorited.php
index 156c7a700..a3d1a5e20 100644
--- a/actions/favorited.php
+++ b/actions/favorited.php
@@ -153,7 +153,8 @@ class FavoritedAction extends Action
$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!');
+ $message .= sprintf(_('Why not [register an account](%%%%action.%s%%%%) and be the first to add a notice to your favorites!'),
+ (!common_config('site','openidonly')) ? 'register' : 'openidlogin');
}
$this->elementStart('div', 'guide');
diff --git a/actions/favoritesrss.php b/actions/favoritesrss.php
index c439a9a62..5dc09e5e8 100644
--- a/actions/favoritesrss.php
+++ b/actions/favoritesrss.php
@@ -111,8 +111,8 @@ class FavoritesrssAction extends Rss10Action
'link' => common_local_url('showfavorites',
array('nickname' =>
$user->nickname)),
- 'description' => sprintf(_('Feed of favorite notices of %s'),
- $user->nickname));
+ 'description' => sprintf(_('Updates favored by %1$s on %2$s!'),
+ $user->nickname, common_config('site', 'name')));
return $c;
}
diff --git a/actions/finishopenidlogin.php b/actions/finishopenidlogin.php
index ff0b35218..a29195826 100644
--- a/actions/finishopenidlogin.php
+++ b/actions/finishopenidlogin.php
@@ -30,7 +30,9 @@ class FinishopenidloginAction extends Action
function handle($args)
{
parent::handle($args);
- if (common_is_real_login()) {
+ if (!common_config('openid', 'enabled')) {
+ common_redirect(common_local_url('login'));
+ } else if (common_is_real_login()) {
$this->clientError(_('Already logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$token = $this->trimmed('token');
@@ -217,7 +219,7 @@ class FinishopenidloginAction extends Action
if (!Validate::string($nickname, array('min_length' => 1,
'max_length' => 64,
- 'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
+ 'format' => NICKNAME_FMT))) {
$this->showForm(_('Nickname must have only lowercase letters and numbers and no spaces.'));
return;
}
@@ -389,7 +391,7 @@ class FinishopenidloginAction extends Action
{
if (!Validate::string($str, array('min_length' => 1,
'max_length' => 64,
- 'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
+ 'format' => NICKNAME_FMT))) {
return false;
}
if (!User::allowed_nickname($str)) {
diff --git a/actions/grouplogo.php b/actions/grouplogo.php
index 8f6158dac..87c68e2a2 100644
--- a/actions/grouplogo.php
+++ b/actions/grouplogo.php
@@ -428,13 +428,7 @@ class GrouplogoAction extends GroupDesignAction
function showStylesheets()
{
parent::showStylesheets();
- $jcropStyle =
- common_path('theme/base/css/jquery.Jcrop.css?version='.LACONICA_VERSION);
-
- $this->element('link', array('rel' => 'stylesheet',
- 'type' => 'text/css',
- 'href' => $jcropStyle,
- 'media' => 'screen, projection, tv'));
+ $this->cssLink('css/jquery.Jcrop.css','base','screen, projection, tv');
}
/**
@@ -448,13 +442,8 @@ class GrouplogoAction extends GroupDesignAction
parent::showScripts();
if ($this->mode == 'crop') {
- $jcropPack = common_path('js/jcrop/jquery.Jcrop.pack.js');
- $jcropGo = common_path('js/jcrop/jquery.Jcrop.go.js');
-
- $this->element('script', array('type' => 'text/javascript',
- 'src' => $jcropPack));
- $this->element('script', array('type' => 'text/javascript',
- 'src' => $jcropGo));
+ $this->script('js/jcrop/jquery.Jcrop.min.js');
+ $this->script('js/jcrop/jquery.Jcrop.go.js');
}
}
diff --git a/actions/grouprss.php b/actions/grouprss.php
index 2bdcaafb2..e1e2d2018 100644
--- a/actions/grouprss.php
+++ b/actions/grouprss.php
@@ -132,9 +132,10 @@ class groupRssAction extends Rss10Action
$c = array('url' => common_local_url('grouprss',
array('nickname' =>
$group->nickname)),
- 'title' => $group->nickname,
+ 'title' => sprintf(_('%s timeline'), $group->nickname),
'link' => common_local_url('showgroup', array('nickname' => $group->nickname)),
- 'description' => sprintf(_('Microblog by %s group'), $group->nickname));
+ 'description' => sprintf(_('Updates from members of %1$s on %2$s!'),
+ $group->nickname, common_config('site', 'name')));
return $c;
}
diff --git a/actions/groupsearch.php b/actions/groupsearch.php
index c50466ce6..7437166e6 100644
--- a/actions/groupsearch.php
+++ b/actions/groupsearch.php
@@ -82,7 +82,8 @@ class GroupsearchAction extends SearchAction
$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!');
+ $message = sprintf(_('Why not [register an account](%%%%action.%s%%%%) and [create the group](%%%%action.newgroup%%%%) yourself!'),
+ (!common_config('site','openidonly')) ? 'register' : 'openidlogin');
}
$this->elementStart('div', 'guide');
$this->raw(common_markup_to_html($message));
diff --git a/actions/imsettings.php b/actions/imsettings.php
index e0f5ede3a..70a6f37d4 100644
--- a/actions/imsettings.php
+++ b/actions/imsettings.php
@@ -84,6 +84,12 @@ class ImsettingsAction extends ConnectSettingsAction
function showContent()
{
+ if (!common_config('xmpp', 'enabled')) {
+ $this->element('div', array('class' => 'error'),
+ _('IM is not available.'));
+ return;
+ }
+
$user = common_current_user();
$this->elementStart('form', array('method' => 'post',
'id' => 'form_settings_im',
diff --git a/actions/invite.php b/actions/invite.php
index 26c951ed2..bdc0d34cb 100644
--- a/actions/invite.php
+++ b/actions/invite.php
@@ -235,7 +235,7 @@ class InviteAction extends CurrentUserDesignAction
common_root_url(),
$personal,
common_local_url('showstream', array('nickname' => $user->nickname)),
- common_local_url('register', array('code' => $invite->code)));
+ common_local_url((!common_config('site', 'openidonly')) ? 'register' : 'openidlogin', array('code' => $invite->code)));
mail_send($recipients, $headers, $body);
}
diff --git a/actions/login.php b/actions/login.php
index 50de83f6f..6f1b4777e 100644
--- a/actions/login.php
+++ b/actions/login.php
@@ -65,6 +65,8 @@ class LoginAction extends Action
*
* Switches on request method; either shows the form or handles its input.
*
+ * Checks if only OpenID is allowed and redirects to openidlogin if so.
+ *
* @param array $args $_REQUEST data
*
* @return void
@@ -73,7 +75,9 @@ class LoginAction extends Action
function handle($args)
{
parent::handle($args);
- if (common_is_real_login()) {
+ if (common_config('site', 'openidonly')) {
+ common_redirect(common_local_url('openidlogin'));
+ } else if (common_is_real_login()) {
$this->clientError(_('Already logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$this->checkLogin();
@@ -247,11 +251,15 @@ class LoginAction extends Action
return _('For security reasons, please re-enter your ' .
'user name and password ' .
'before changing your settings.');
- } else {
+ } else if (common_config('openid', 'enabled')) {
return _('Login with your username and password. ' .
'Don\'t have a username yet? ' .
'[Register](%%action.register%%) a new account, or ' .
'try [OpenID](%%action.openidlogin%%). ');
+ } else {
+ return _('Login with your username and password. ' .
+ 'Don\'t have a username yet? ' .
+ '[Register](%%action.register%%) a new account.');
}
}
diff --git a/actions/newnotice.php b/actions/newnotice.php
index f773fc880..049d7c322 100644
--- a/actions/newnotice.php
+++ b/actions/newnotice.php
@@ -91,8 +91,8 @@ class NewnoticeAction extends Action
// is losts when size is exceeded
if (empty($_POST) && $_SERVER['CONTENT_LENGTH']) {
$this->clientError(sprintf(_('The server was unable to handle ' .
- 'that much POST data (%s bytes) due to its current configuration.'),
- $_SERVER['CONTENT_LENGTH']));
+ 'that much POST data (%s bytes) due to its current configuration.'),
+ $_SERVER['CONTENT_LENGTH']));
}
parent::handle($args);
@@ -130,7 +130,7 @@ class NewnoticeAction extends Action
$hint = '';
}
$this->clientError(sprintf(
- _('%s is not a supported filetype on this server.'), $filetype) . $hint);
+ _('%s is not a supported filetype on this server.'), $filetype) . $hint);
}
function isRespectsQuota($user) {
@@ -191,37 +191,37 @@ class NewnoticeAction extends Action
if (isset($_FILES['attach']['error'])) {
switch ($_FILES['attach']['error']) {
- case UPLOAD_ERR_NO_FILE:
- // no file uploaded, nothing to do
- break;
+ case UPLOAD_ERR_NO_FILE:
+ // no file uploaded, nothing to do
+ break;
- case UPLOAD_ERR_OK:
- $mimetype = $this->getUploadedFileType();
- if (!$this->isRespectsQuota($user)) {
- die('clientError() should trigger an exception before reaching here.');
- }
- break;
+ case UPLOAD_ERR_OK:
+ $mimetype = $this->getUploadedFileType();
+ if (!$this->isRespectsQuota($user)) {
+ die('clientError() should trigger an exception before reaching here.');
+ }
+ break;
- case UPLOAD_ERR_INI_SIZE:
- $this->clientError(_('The uploaded file exceeds the upload_max_filesize directive in php.ini.'));
+ case UPLOAD_ERR_INI_SIZE:
+ $this->clientError(_('The uploaded file exceeds the upload_max_filesize directive in php.ini.'));
- case UPLOAD_ERR_FORM_SIZE:
- $this->clientError(_('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.'));
+ case UPLOAD_ERR_FORM_SIZE:
+ $this->clientError(_('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.'));
- case UPLOAD_ERR_PARTIAL:
- $this->clientError(_('The uploaded file was only partially uploaded.'));
+ case UPLOAD_ERR_PARTIAL:
+ $this->clientError(_('The uploaded file was only partially uploaded.'));
- case UPLOAD_ERR_NO_TMP_DIR:
- $this->clientError(_('Missing a temporary folder.'));
+ case UPLOAD_ERR_NO_TMP_DIR:
+ $this->clientError(_('Missing a temporary folder.'));
- case UPLOAD_ERR_CANT_WRITE:
- $this->clientError(_('Failed to write file to disk.'));
+ case UPLOAD_ERR_CANT_WRITE:
+ $this->clientError(_('Failed to write file to disk.'));
- case UPLOAD_ERR_EXTENSION:
- $this->clientError(_('File upload stopped by extension.'));
+ case UPLOAD_ERR_EXTENSION:
+ $this->clientError(_('File upload stopped by extension.'));
- default:
- die('Should never reach here.');
+ default:
+ die('Should never reach here.');
}
}
@@ -234,7 +234,7 @@ class NewnoticeAction extends Action
$fileRecord = $this->storeFile($filename, $mimetype);
$fileurl = common_local_url('attachment',
- array('attachment' => $fileRecord->id));
+ array('attachment' => $fileRecord->id));
// not sure this is necessary -- Zach
$this->maybeAddRedir($fileRecord->id, $fileurl);
@@ -369,7 +369,7 @@ class NewnoticeAction extends Action
File_to_post::processNew($filerec->id, $notice->id);
$this->maybeAddRedir($filerec->id,
- common_local_url('file', array('notice' => $notice->id)));
+ common_local_url('file', array('notice' => $notice->id)));
}
/**
diff --git a/actions/noticesearch.php b/actions/noticesearch.php
index 49b473d9e..90b3309cf 100644
--- a/actions/noticesearch.php
+++ b/actions/noticesearch.php
@@ -121,7 +121,9 @@ class NoticesearchAction extends SearchAction
$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));
+ $message = sprintf(_('Why not [register an account](%%%%action.%s%%%%) and be the first to [post on this topic](%%%%action.newnotice%%%%?status_textarea=%s)!'),
+ (!common_config('site','openidonly')) ? 'register' : 'openidlogin',
+ urlencode($q));
}
$this->elementStart('div', 'guide');
diff --git a/actions/noticesearchrss.php b/actions/noticesearchrss.php
index 2a4b2060d..045531c5a 100644
--- a/actions/noticesearchrss.php
+++ b/actions/noticesearchrss.php
@@ -86,9 +86,10 @@ class NoticesearchrssAction extends Rss10Action
{
$q = $this->trimmed('q');
$c = array('url' => common_local_url('noticesearchrss', array('q' => $q)),
- 'title' => common_config('site', 'name') . sprintf(_(' Search Stream for "%s"'), $q),
+ 'title' => sprintf(_('Updates with "%s"'), $q),
'link' => common_local_url('noticesearch', array('q' => $q)),
- 'description' => sprintf(_('All updates matching search term "%s"'), $q));
+ 'description' => sprintf(_('Updates matching search term "%1$s" on %2$s!'),
+ $q, common_config('site', 'name')));
return $c;
}
diff --git a/actions/twitapioembed.php b/actions/oembed.php
index 3019e5878..3e46a7262 100644
--- a/actions/twitapioembed.php
+++ b/actions/oembed.php
@@ -31,8 +31,6 @@ if (!defined('LACONICA')) {
exit(1);
}
-require_once INSTALLDIR.'/lib/twitterapi.php';
-
/**
* Oembed provider implementation
*
@@ -46,17 +44,13 @@ require_once INSTALLDIR.'/lib/twitterapi.php';
* @link http://laconi.ca/
*/
-class TwitapioembedAction extends TwitterapiAction
+class OembedAction extends Action
{
- function oembed($args, $apidata)
+ function handle($args)
{
- parent::handle($args);
-
common_debug("in oembed api action");
- $this->auth_user = $apidata['user'];
-
$url = $args['url'];
if( substr(strtolower($url),0,strlen(common_root_url())) == strtolower(common_root_url()) ){
$path = substr($url,strlen(common_root_url()));
@@ -131,8 +125,7 @@ class TwitapioembedAction extends TwitterapiAction
default:
$this->serverError(_("$path not supported for oembed requests"), 501);
}
-
- switch($apidata['content-type']){
+ switch($args['format']){
case 'xml':
$this->init_document('xml');
$this->elementStart('oembed');
@@ -151,12 +144,11 @@ class TwitapioembedAction extends TwitterapiAction
if($oembed['thumbnail_url']) $this->element('thumbnail_url',null,$oembed['thumbnail_url']);
if($oembed['thumbnail_width']) $this->element('thumbnail_width',null,$oembed['thumbnail_width']);
if($oembed['thumbnail_height']) $this->element('thumbnail_height',null,$oembed['thumbnail_height']);
-
$this->elementEnd('oembed');
$this->end_document('xml');
break;
- case 'json':
+ case 'json': case '':
$this->init_document('json');
print(json_encode($oembed));
$this->end_document('json');
@@ -164,10 +156,51 @@ class TwitapioembedAction extends TwitterapiAction
default:
$this->serverError(_('content type ' . $apidata['content-type'] . ' not supported'), 501);
}
-
}else{
$this->serverError(_('Only ' . common_root_url() . ' urls over plain http please'), 404);
}
}
-}
+ function init_document($type)
+ {
+ switch ($type) {
+ case 'xml':
+ header('Content-Type: application/xml; charset=utf-8');
+ $this->startXML();
+ break;
+ case 'json':
+ header('Content-Type: application/json; charset=utf-8');
+
+ // Check for JSONP callback
+ $callback = $this->arg('callback');
+ if ($callback) {
+ print $callback . '(';
+ }
+ break;
+ default:
+ $this->serverError(_('Not a supported data format.'), 501);
+ break;
+ }
+ }
+
+ function end_document($type='xml')
+ {
+ switch ($type) {
+ case 'xml':
+ $this->endXML();
+ break;
+ case 'json':
+ // Check for JSONP callback
+ $callback = $this->arg('callback');
+ if ($callback) {
+ print ')';
+ }
+ break;
+ default:
+ $this->serverError(_('Not a supported data format.'), 501);
+ break;
+ }
+ return;
+ }
+
+}
diff --git a/actions/openidlogin.php b/actions/openidlogin.php
index a8d052096..744aae713 100644
--- a/actions/openidlogin.php
+++ b/actions/openidlogin.php
@@ -26,7 +26,9 @@ class OpenidloginAction extends Action
function handle($args)
{
parent::handle($args);
- if (common_is_real_login()) {
+ if (!common_config('openid', 'enabled')) {
+ common_redirect(common_local_url('login'));
+ } else if (common_is_real_login()) {
$this->clientError(_('Already logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$openid_url = $this->trimmed('openid_url');
diff --git a/actions/openidsettings.php b/actions/openidsettings.php
index 5f59ebc01..40a480dc4 100644
--- a/actions/openidsettings.php
+++ b/actions/openidsettings.php
@@ -82,6 +82,12 @@ class OpenidsettingsAction extends AccountSettingsAction
function showContent()
{
+ if (!common_config('openid', 'enabled')) {
+ $this->element('div', array('class' => 'error'),
+ _('OpenID is not available.'));
+ return;
+ }
+
$user = common_current_user();
$this->elementStart('form', array('method' => 'post',
diff --git a/actions/opensearch.php b/actions/opensearch.php
index 4fe95c93b..6044568f1 100644
--- a/actions/opensearch.php
+++ b/actions/opensearch.php
@@ -66,7 +66,7 @@ class OpensearchAction extends Action
$type = 'noticesearch';
$short_name = _('Notice Search');
}
- header('Content-Type: text/html');
+ header('Content-Type: application/opensearchdescription+xml');
$this->startXML();
$this->elementStart('OpenSearchDescription', array('xmlns' => 'http://a9.com/-/spec/opensearch/1.1/'));
$short_name = common_config('site', 'name').' '.$short_name;
diff --git a/actions/profilesettings.php b/actions/profilesettings.php
index 961e15ae7..f429a2e51 100644
--- a/actions/profilesettings.php
+++ b/actions/profilesettings.php
@@ -196,7 +196,7 @@ class ProfilesettingsAction extends AccountSettingsAction
// Some validation
if (!Validate::string($nickname, array('min_length' => 1,
'max_length' => 64,
- 'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
+ 'format' => NICKNAME_FMT))) {
$this->showForm(_('Nickname must have only lowercase letters and numbers and no spaces.'));
return;
} else if (!User::allowed_nickname($nickname)) {
diff --git a/actions/public.php b/actions/public.php
index d0317ac70..2cf2e96e6 100644
--- a/actions/public.php
+++ b/actions/public.php
@@ -59,6 +59,7 @@ class PublicAction extends Action
*/
var $page = null;
+ var $notice;
function isReadOnly($args)
{
@@ -84,6 +85,18 @@ class PublicAction extends Action
common_set_returnto($this->selfUrl());
+ $this->notice = Notice::publicStream(($this->page-1)*NOTICES_PER_PAGE,
+ NOTICES_PER_PAGE + 1);
+
+ if (!$this->notice) {
+ $this->serverError(_('Could not retrieve public stream.'));
+ return;
+ }
+
+ if($this->page > 1 && $this->notice->N == 0){
+ $this->serverError(_('No such page'),$code=404);
+ }
+
return true;
}
@@ -183,7 +196,8 @@ class PublicAction extends Action
}
else {
if (! (common_config('site','closed') || common_config('site','inviteonly'))) {
- $message .= _('Why not [register an account](%%action.register%%) and be the first to post!');
+ $message .= sprintf(_('Why not [register an account](%%%%action.%s%%%%) and be the first to post!'),
+ (!common_config('site','openidonly')) ? 'register' : 'openidlogin');
}
}
@@ -203,15 +217,7 @@ class PublicAction extends Action
function showContent()
{
- $notice = Notice::publicStream(($this->page-1)*NOTICES_PER_PAGE,
- NOTICES_PER_PAGE + 1);
-
- if (!$notice) {
- $this->serverError(_('Could not retrieve public stream.'));
- return;
- }
-
- $nl = new NoticeList($notice, $this);
+ $nl = new NoticeList($this->notice, $this);
$cnt = $nl->show();
@@ -238,9 +244,11 @@ class PublicAction extends Action
function showAnonymousMessage()
{
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%%))');
+ $m = sprintf(_('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.%s%%%%) to share notices about yourself with friends, family, and colleagues! ' .
+ '([Read more](%%%%doc.help%%%%))'),
+ (!common_config('site','openidonly')) ? 'register' : 'openidlogin');
} 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.');
diff --git a/actions/publicrss.php b/actions/publicrss.php
index 7e8df9625..5c08de641 100644
--- a/actions/publicrss.php
+++ b/actions/publicrss.php
@@ -86,9 +86,9 @@ class PublicrssAction extends Rss10Action
{
$c = array(
'url' => common_local_url('publicrss')
- , 'title' => sprintf(_('%s Public Stream'), common_config('site', 'name'))
+ , 'title' => sprintf(_('%s public timeline'), common_config('site', 'name'))
, 'link' => common_local_url('public')
- , 'description' => sprintf(_('All updates for %s'), common_config('site', 'name')));
+ , 'description' => sprintf(_('%s updates from everyone!'), common_config('site', 'name')));
return $c;
}
diff --git a/actions/publictagcloud.php b/actions/publictagcloud.php
index e9f33d58b..a2772869d 100644
--- a/actions/publictagcloud.php
+++ b/actions/publictagcloud.php
@@ -72,7 +72,8 @@ class PublictagcloudAction extends Action
$message .= _('Be the first to post one!');
}
else {
- $message .= _('Why not [register an account](%%action.register%%) and be the first to post one!');
+ $message .= sprintf(_('Why not [register an account](%%%%action.%s%%%%) and be the first to post one!'),
+ (!common_config('site','openidonly')) ? 'register' : 'openidlogin');
}
$this->elementStart('div', 'guide');
diff --git a/actions/register.php b/actions/register.php
index ab04f18d5..4654fad14 100644
--- a/actions/register.php
+++ b/actions/register.php
@@ -116,6 +116,8 @@ class RegisterAction extends Action
*
* Checks if registration is closed and shows an error if so.
*
+ * Checks if only OpenID is allowed and redirects to openidlogin if so.
+ *
* @param array $args $_REQUEST data
*
* @return void
@@ -127,6 +129,8 @@ class RegisterAction extends Action
if (common_config('site', 'closed')) {
$this->clientError(_('Registration not allowed.'));
+ } else if (common_config('site', 'openidonly')) {
+ common_redirect(common_local_url('openidlogin'));
} else if (common_logged_in()) {
$this->clientError(_('Already logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
@@ -326,14 +330,22 @@ class RegisterAction extends Action
} else if ($this->error) {
$this->element('p', 'error', $this->error);
} else {
- $instr =
- common_markup_to_html(_('With this form you can create '.
- ' a new account. ' .
- 'You can then post notices and '.
- 'link up to friends and colleagues. '.
- '(Have an [OpenID](http://openid.net/)? ' .
- 'Try our [OpenID registration]'.
- '(%%action.openidlogin%%)!)'));
+ if (common_config('openid', 'enabled')) {
+ $instr =
+ common_markup_to_html(_('With this form you can create '.
+ ' a new account. ' .
+ 'You can then post notices and '.
+ 'link up to friends and colleagues. '.
+ '(Have an [OpenID](http://openid.net/)? ' .
+ 'Try our [OpenID registration]'.
+ '(%%action.openidlogin%%)!)'));
+ } else {
+ $instr =
+ common_markup_to_html(_('With this form you can create '.
+ ' a new account. ' .
+ 'You can then post notices and '.
+ 'link up to friends and colleagues.'));
+ }
$this->elementStart('div', 'instructions');
$this->raw($instr);
diff --git a/actions/remotesubscribe.php b/actions/remotesubscribe.php
index 353717beb..90499bbe2 100644
--- a/actions/remotesubscribe.php
+++ b/actions/remotesubscribe.php
@@ -97,11 +97,13 @@ class RemotesubscribeAction extends Action
if ($this->err) {
$this->element('div', 'error', $this->err);
} else {
- $inst = _('To subscribe, you can [login](%%action.login%%),' .
- ' or [register](%%action.register%%) a new ' .
- ' account. If you already have an account ' .
- ' on a [compatible microblogging site](%%doc.openmublog%%), ' .
- ' enter your profile URL below.');
+ $inst = sprintf(_('To subscribe, you can [login](%%%%action.%s%%%%),' .
+ ' or [register](%%%%action.%s%%%%) a new ' .
+ ' account. If you already have an account ' .
+ ' on a [compatible microblogging site](%%doc.openmublog%%), ' .
+ ' enter your profile URL below.'),
+ (!common_config('site','openidonly')) ? 'login' : 'openidlogin',
+ (!common_config('site','openidonly')) ? 'register' : 'openidlogin');
$output = common_markup_to_html($inst);
$this->elementStart('div', 'instructions');
$this->raw($output);
diff --git a/actions/replies.php b/actions/replies.php
index d7ed440e9..fcfc3a272 100644
--- a/actions/replies.php
+++ b/actions/replies.php
@@ -48,6 +48,7 @@ require_once INSTALLDIR.'/lib/feedlist.php';
class RepliesAction extends OwnerDesignAction
{
var $page = null;
+ var $notice;
/**
* Prepare the object
@@ -84,6 +85,13 @@ class RepliesAction extends OwnerDesignAction
common_set_returnto($this->selfUrl());
+ $this->notice = $this->user->getReplies(($this->page-1) * NOTICES_PER_PAGE,
+ NOTICES_PER_PAGE + 1);
+
+ if($this->page > 1 && $this->notice->N == 0){
+ $this->serverError(_('No such page'),$code=404);
+ }
+
return true;
}
@@ -159,10 +167,7 @@ class RepliesAction extends OwnerDesignAction
function showContent()
{
- $notice = $this->user->getReplies(($this->page-1) * NOTICES_PER_PAGE,
- NOTICES_PER_PAGE + 1);
-
- $nl = new NoticeList($notice, $this);
+ $nl = new NoticeList($this->notice, $this);
$cnt = $nl->show();
if (0 === $cnt) {
@@ -187,7 +192,9 @@ class RepliesAction extends OwnerDesignAction
}
}
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);
+ $message .= sprintf(_('Why not [register an account](%%%%action.%s%%%%) and then nudge %s or post a notice to his or her attention.'),
+ (!common_config('site','openidonly')) ? 'register' : 'openidlogin',
+ $this->user->nickname);
}
$this->elementStart('div', 'guide');
diff --git a/actions/repliesrss.php b/actions/repliesrss.php
index a87e2870d..580bb91f7 100644
--- a/actions/repliesrss.php
+++ b/actions/repliesrss.php
@@ -68,7 +68,8 @@ class RepliesrssAction extends Rss10Action
'link' => common_local_url('replies',
array('nickname' =>
$user->nickname)),
- 'description' => sprintf(_('Feed for replies to %s'), $user->nickname));
+ 'description' => sprintf(_('Replies to %1$s on %2$s!'),
+ $user->nickname, common_config('site', 'name')));
return $c;
}
diff --git a/actions/showfavorites.php b/actions/showfavorites.php
index 8efe9d30a..91287cc96 100644
--- a/actions/showfavorites.php
+++ b/actions/showfavorites.php
@@ -114,6 +114,29 @@ class ShowfavoritesAction extends OwnerDesignAction
common_set_returnto($this->selfUrl());
+ $cur = common_current_user();
+
+ if (!empty($cur) && $cur->id == $this->user->id) {
+
+ // Show imported/gateway notices as well as local if
+ // the user is looking at his own favorites
+
+ $this->notice = $this->user->favoriteNotices(($this->page-1)*NOTICES_PER_PAGE,
+ NOTICES_PER_PAGE + 1, true);
+ } else {
+ $this->notice = $this->user->favoriteNotices(($this->page-1)*NOTICES_PER_PAGE,
+ NOTICES_PER_PAGE + 1, false);
+ }
+
+ if (empty($this->notice)) {
+ $this->serverError(_('Could not retrieve favorite notices.'));
+ return;
+ }
+
+ if($this->page > 1 && $this->notice->N == 0){
+ $this->serverError(_('No such page'),$code=404);
+ }
+
return true;
}
@@ -173,7 +196,9 @@ class ShowfavoritesAction extends OwnerDesignAction
}
}
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);
+ $message = sprintf(_('%s hasn\'t added any notices to his favorites yet. Why not [register an account](%%%%action.%s%%%%) and then post something interesting they would add to their favorites :)'),
+ $this->user->nickname,
+ (!common_config('site','openidonly')) ? 'register' : 'openidlogin');
}
$this->elementStart('div', 'guide');
@@ -191,26 +216,7 @@ class ShowfavoritesAction extends OwnerDesignAction
function showContent()
{
- $cur = common_current_user();
-
- if (!empty($cur) && $cur->id == $this->user->id) {
-
- // Show imported/gateway notices as well as local if
- // the user is looking at his own favorites
-
- $notice = $this->user->favoriteNotices(($this->page-1)*NOTICES_PER_PAGE,
- NOTICES_PER_PAGE + 1, true);
- } else {
- $notice = $this->user->favoriteNotices(($this->page-1)*NOTICES_PER_PAGE,
- NOTICES_PER_PAGE + 1, false);
- }
-
- if (empty($notice)) {
- $this->serverError(_('Could not retrieve favorite notices.'));
- return;
- }
-
- $nl = new NoticeList($notice, $this);
+ $nl = new NoticeList($this->notice, $this);
$cnt = $nl->show();
if (0 == $cnt) {
diff --git a/actions/showgroup.php b/actions/showgroup.php
index 32ec674a9..b0cc1dbc7 100644
--- a/actions/showgroup.php
+++ b/actions/showgroup.php
@@ -130,8 +130,18 @@ class ShowgroupAction extends GroupDesignAction
$this->group = User_group::staticGet('nickname', $nickname);
if (!$this->group) {
- $this->clientError(_('No such group'), 404);
- return false;
+ $alias = Group_alias::staticGet('alias', $nickname);
+ if ($alias) {
+ $args = array('id' => $alias->group_id);
+ if ($this->page != 1) {
+ $args['page'] = $this->page;
+ }
+ common_redirect(common_local_url('groupbyid', $args), 301);
+ return false;
+ } else {
+ $this->clientError(_('No such group'), 404);
+ return false;
+ }
}
common_set_returnto($this->selfUrl());
@@ -440,8 +450,9 @@ class ShowgroupAction extends GroupDesignAction
$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);
+ '[Join now](%%%%action.%s%%%%) to become part of this group and many more! ([Read more](%%%%doc.help%%%%))'),
+ $this->group->nickname,
+ (!common_config('site','openidonly')) ? 'register' : 'openidlogin');
} 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 ' .
diff --git a/actions/shownotice.php b/actions/shownotice.php
index 3d7319489..82031d90d 100644
--- a/actions/shownotice.php
+++ b/actions/shownotice.php
@@ -103,8 +103,8 @@ class ShownoticeAction extends OwnerDesignAction
$this->user = User::staticGet('id', $this->profile->id);
- if (empty($this->user)) {
- $this->serverError(_('Not a local notice'), 500);
+ if (! $this->notice->is_local) {
+ common_redirect($this->notice->uri);
return false;
}
@@ -196,7 +196,7 @@ class ShownoticeAction extends OwnerDesignAction
{
parent::handle($args);
- if ($this->notice->is_local == 0) {
+ if ($this->notice->is_local == Notice::REMOTE_OMB) {
if (!empty($this->notice->url)) {
common_redirect($this->notice->url, 301);
} else if (!empty($this->notice->uri) && preg_match('/^https?:/', $this->notice->uri)) {
@@ -284,16 +284,16 @@ class ShownoticeAction extends OwnerDesignAction
$this->element('link',array('rel'=>'alternate',
'type'=>'application/json+oembed',
'href'=>common_local_url(
- 'api',
- array('apiaction'=>'oembed','method'=>'oembed.json'),
- array('url'=>$this->notice->uri)),
+ 'oembed',
+ array(),
+ array('format'=>'json','url'=>$this->notice->uri)),
'title'=>'oEmbed'),null);
$this->element('link',array('rel'=>'alternate',
'type'=>'text/xml+oembed',
'href'=>common_local_url(
- 'api',
- array('apiaction'=>'oembed','method'=>'oembed.xml'),
- array('url'=>$this->notice->uri)),
+ 'oembed',
+ array(),
+ array('format'=>'xml','url'=>$this->notice->uri)),
'title'=>'oEmbed'),null);
}
}
diff --git a/actions/showstream.php b/actions/showstream.php
index cd5d4bb70..3f603d64f 100644
--- a/actions/showstream.php
+++ b/actions/showstream.php
@@ -358,7 +358,9 @@ class ShowstreamAction extends ProfileAction
}
}
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);
+ $message .= sprintf(_('Why not [register an account](%%%%action.%s%%%%) and then nudge %s or post a notice to his or her attention.'),
+ (!common_config('site','openidonly')) ? 'register' : 'openidlogin',
+ $this->user->nickname);
}
$this->elementStart('div', 'guide');
@@ -387,8 +389,10 @@ class ShowstreamAction extends ProfileAction
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);
+ '[Join now](%%%%action.%s%%%%) to follow **%s**\'s notices and many more! ([Read more](%%%%doc.help%%%%))'),
+ $this->user->nickname,
+ (!common_config('site','openidonly')) ? 'register' : 'openidlogin',
+ $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. '),
diff --git a/actions/smssettings.php b/actions/smssettings.php
index 922bab9a4..33b54abf6 100644
--- a/actions/smssettings.php
+++ b/actions/smssettings.php
@@ -80,6 +80,12 @@ class SmssettingsAction extends ConnectSettingsAction
function showContent()
{
+ if (!common_config('sms', 'enabled')) {
+ $this->element('div', array('class' => 'error'),
+ _('SMS is not available.'));
+ return;
+ }
+
$user = common_current_user();
$this->elementStart('form', array('method' => 'post',
diff --git a/actions/subscribers.php b/actions/subscribers.php
index 66ac00fb1..404738012 100644
--- a/actions/subscribers.php
+++ b/actions/subscribers.php
@@ -111,7 +111,9 @@ class SubscribersAction extends GalleryAction
}
}
else {
- $message = sprintf(_('%s has no subscribers. Why not [register an account](%%%%action.register%%%%) and be the first?'), $this->user->nickname);
+ $message = sprintf(_('%s has no subscribers. Why not [register an account](%%%%action.%s%%%%) and be the first?'),
+ $this->user->nickname,
+ (!common_config('site','openidonly')) ? 'register' : 'openidlogin');
}
$this->elementStart('div', 'guide');
diff --git a/actions/subscriptions.php b/actions/subscriptions.php
index 42bdae10f..0724471ff 100644
--- a/actions/subscriptions.php
+++ b/actions/subscriptions.php
@@ -174,14 +174,26 @@ class SubscriptionsListItem extends SubscriptionListItem
return;
}
+ if (!common_config('xmpp', 'enabled') && !common_config('sms', 'enabled')) {
+ return;
+ }
+
$this->out->elementStart('form', array('id' => 'subedit-' . $this->profile->id,
'method' => 'post',
'class' => 'form_subscription_edit',
'action' => common_local_url('subedit')));
$this->out->hidden('token', common_session_token());
$this->out->hidden('profile', $this->profile->id);
- $this->out->checkbox('jabber', _('Jabber'), $sub->jabber);
- $this->out->checkbox('sms', _('SMS'), $sub->sms);
+ if (common_config('xmpp', 'enabled')) {
+ $this->out->checkbox('jabber', _('Jabber'), $sub->jabber);
+ } else {
+ $this->out->hidden('jabber', $sub->jabber);
+ }
+ if (common_config('sms', 'enabled')) {
+ $this->out->checkbox('sms', _('SMS'), $sub->sms);
+ } else {
+ $this->out->hidden('sms', $sub->sms);
+ }
$this->out->submit('save', _('Save'));
$this->out->elementEnd('form');
return;
diff --git a/actions/tag.php b/actions/tag.php
index 020399d9e..771eb2861 100644
--- a/actions/tag.php
+++ b/actions/tag.php
@@ -21,6 +21,9 @@ if (!defined('LACONICA')) { exit(1); }
class TagAction extends Action
{
+
+ var $notice;
+
function prepare($args)
{
parent::prepare($args);
@@ -42,6 +45,12 @@ class TagAction extends Action
common_set_returnto($this->selfUrl());
+ $this->notice = Notice_tag::getStream($this->tag, (($this->page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
+
+ if($this->page > 1 && $this->notice->N == 0){
+ $this->serverError(_('No such page'),$code=404);
+ }
+
return true;
}
@@ -94,9 +103,7 @@ class TagAction extends Action
function showContent()
{
- $notice = Notice_tag::getStream($this->tag, (($this->page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
-
- $nl = new NoticeList($notice, $this);
+ $nl = new NoticeList($this->notice, $this);
$cnt = $nl->show();
diff --git a/actions/tagrss.php b/actions/tagrss.php
index f69374fca..c3c03b9cd 100644
--- a/actions/tagrss.php
+++ b/actions/tagrss.php
@@ -61,7 +61,8 @@ class TagrssAction extends Rss10Action
$c = array('url' => common_local_url('tagrss', array('tag' => $tagname)),
'title' => $tagname,
'link' => common_local_url('tagrss', array('tag' => $tagname)),
- 'description' => sprintf(_('Microblog tagged with %s'), $tagname));
+ 'description' => sprintf(_('Updates tagged with %1$s on %2$s!'),
+ $tagname, common_config('site', 'name')));
return $c;
}
diff --git a/actions/twitapigroups.php b/actions/twitapigroups.php
index 82604ebff..bebc07fa1 100644
--- a/actions/twitapigroups.php
+++ b/actions/twitapigroups.php
@@ -51,6 +51,103 @@ require_once INSTALLDIR.'/lib/twitterapi.php';
class TwitapigroupsAction extends TwitterapiAction
{
+ function list_groups($args, $apidata)
+ {
+ parent::handle($args);
+
+ common_debug("in groups api action");
+
+ $this->auth_user = $apidata['user'];
+ $user = $this->get_user($apidata['api_arg'], $apidata);
+
+ if (empty($user)) {
+ $this->clientError('Not Found', 404, $apidata['content-type']);
+ return;
+ }
+
+ $page = (int)$this->arg('page', 1);
+ $count = (int)$this->arg('count', 20);
+ $max_id = (int)$this->arg('max_id', 0);
+ $since_id = (int)$this->arg('since_id', 0);
+ $since = $this->arg('since');
+ $group = $user->getGroups(($page-1)*$count,
+ $count, $since_id, $max_id, $since);
+
+ $sitename = common_config('site', 'name');
+ $title = sprintf(_("%s's groups"), $user->nickname);
+ $taguribase = common_config('integration', 'taguri');
+ $id = "tag:$taguribase:Groups";
+ $link = common_root_url();
+ $subtitle = sprintf(_("groups %s is a member of on %s"), $user->nickname, $sitename);
+
+ switch($apidata['content-type']) {
+ case 'xml':
+ $this->show_xml_groups($group);
+ break;
+ case 'rss':
+ $this->show_rss_groups($group, $title, $link, $subtitle);
+ break;
+ case 'atom':
+ $selfuri = common_root_url() . 'api/laconica/groups/list/' . $user->id . '.atom';
+ $this->show_atom_groups($group, $title, $id, $link,
+ $subtitle, $selfuri);
+ break;
+ case 'json':
+ $this->show_json_groups($group);
+ break;
+ default:
+ $this->clientError(_('API method not found!'), $code = 404);
+ break;
+ }
+ }
+
+ function list_all($args, $apidata)
+ {
+ parent::handle($args);
+
+ common_debug("in groups api action");
+
+ $page = (int)$this->arg('page', 1);
+ $count = (int)$this->arg('count', 20);
+ $max_id = (int)$this->arg('max_id', 0);
+ $since_id = (int)$this->arg('since_id', 0);
+ $since = $this->arg('since');
+
+ /* TODO:
+ Use the $page, $count, $max_id, $since_id, and $since parameters
+ */
+ $group = new User_group();
+ $group->orderBy('created DESC');
+ $group->find();
+
+ $sitename = common_config('site', 'name');
+ $title = sprintf(_("%s groups"), $sitename);
+ $taguribase = common_config('integration', 'taguri');
+ $id = "tag:$taguribase:Groups";
+ $link = common_root_url();
+ $subtitle = sprintf(_("groups on %s"), $sitename);
+
+ switch($apidata['content-type']) {
+ case 'xml':
+ $this->show_xml_groups($group);
+ break;
+ case 'rss':
+ $this->show_rss_groups($group, $title, $link, $subtitle);
+ break;
+ case 'atom':
+ $selfuri = common_root_url() . 'api/laconica/groups/list_all.atom';
+ $this->show_atom_groups($group, $title, $id, $link,
+ $subtitle, $selfuri);
+ break;
+ case 'json':
+ $this->show_json_groups($group);
+ break;
+ default:
+ $this->clientError(_('API method not found!'), $code = 404);
+ break;
+ }
+ }
+
function show($args, $apidata)
{
parent::handle($args);
diff --git a/actions/twitapistatuses.php b/actions/twitapistatuses.php
index 038282414..1f3c53bef 100644
--- a/actions/twitapistatuses.php
+++ b/actions/twitapistatuses.php
@@ -456,7 +456,8 @@ class TwitapistatusesAction extends TwitterapiAction
function friends($args, $apidata)
{
parent::handle($args);
- return $this->subscriptions($apidata, 'subscribed', 'subscriber');
+ $includeStatuses=! (boolean) $args['lite'];
+ return $this->subscriptions($apidata, 'subscribed', 'subscriber', false, $includeStatuses);
}
function friendsIDs($args, $apidata)
@@ -468,7 +469,8 @@ class TwitapistatusesAction extends TwitterapiAction
function followers($args, $apidata)
{
parent::handle($args);
- return $this->subscriptions($apidata, 'subscriber', 'subscribed');
+ $includeStatuses=! (boolean) $args['lite'];
+ return $this->subscriptions($apidata, 'subscriber', 'subscribed', false, $includeStatuses);
}
function followersIDs($args, $apidata)
@@ -477,7 +479,7 @@ class TwitapistatusesAction extends TwitterapiAction
return $this->subscriptions($apidata, 'subscriber', 'subscribed', true);
}
- function subscriptions($apidata, $other_attr, $user_attr, $onlyIDs=false)
+ function subscriptions($apidata, $other_attr, $user_attr, $onlyIDs=false, $includeStatuses=true)
{
$this->auth_user = $apidata['user'];
$user = $this->get_user($apidata['api_arg'], $apidata);
@@ -533,26 +535,26 @@ class TwitapistatusesAction extends TwitterapiAction
if ($onlyIDs) {
$this->showIDs($others, $type);
} else {
- $this->show_profiles($others, $type);
+ $this->show_profiles($others, $type, $includeStatuses);
}
$this->end_document($type);
}
- function show_profiles($profiles, $type)
+ function show_profiles($profiles, $type, $includeStatuses)
{
switch ($type) {
case 'xml':
$this->elementStart('users', array('type' => 'array'));
foreach ($profiles as $profile) {
- $this->show_profile($profile);
+ $this->show_profile($profile,$type,null,$includeStatuses);
}
$this->elementEnd('users');
break;
case 'json':
$arrays = array();
foreach ($profiles as $profile) {
- $arrays[] = $this->twitter_user_array($profile, true);
+ $arrays[] = $this->twitter_user_array($profile, $includeStatuses);
}
print json_encode($arrays);
break;
diff --git a/actions/twitterauthorization.php b/actions/twitterauthorization.php
new file mode 100644
index 000000000..b04f35327
--- /dev/null
+++ b/actions/twitterauthorization.php
@@ -0,0 +1,222 @@
+<?php
+/**
+ * Laconica, the distributed open-source microblogging tool
+ *
+ * Class for doing OAuth authentication against Twitter
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Twitter
+ * @package Laconica
+ * @author Zach Copely <zach@controlyourself.ca>
+ * @copyright 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);
+}
+
+/**
+ * Class for doing OAuth authentication against Twitter
+ *
+ * Peforms the OAuth "dance" between Laconica and Twitter -- requests a token,
+ * authorizes it, and exchanges it for an access token. It also creates a link
+ * (Foreign_link) between the Laconica user and Twitter user and stores the
+ * access token and secret in the link.
+ *
+ * @category Twitter
+ * @package Laconica
+ * @author Zach Copley <zach@controlyourself.ca>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://laconi.ca/
+ *
+ */
+class TwitterauthorizationAction extends Action
+{
+ /**
+ * Initialize class members. Looks for 'oauth_token' parameter.
+ *
+ * @param array $args misc. arguments
+ *
+ * @return boolean true
+ */
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->oauth_token = $this->arg('oauth_token');
+
+ return true;
+ }
+
+ /**
+ * Handler method
+ *
+ * @param array $args is ignored since it's now passed in in prepare()
+ *
+ * @return nothing
+ */
+ function handle($args)
+ {
+ parent::handle($args);
+
+ if (!common_logged_in()) {
+ $this->clientError(_('Not logged in.'), 403);
+ }
+
+ $user = common_current_user();
+ $flink = Foreign_link::getByUserID($user->id, TWITTER_SERVICE);
+
+ // If there's already a foreign link record, it means we already
+ // have an access token, and this is unecessary. So go back.
+
+ if (isset($flink)) {
+ common_redirect(common_local_url('twittersettings'));
+ }
+
+ // $this->oauth_token is only populated once Twitter authorizes our
+ // request token. If it's empty we're at the beginning of the auth
+ // process
+
+ if (empty($this->oauth_token)) {
+ $this->authorizeRequestToken();
+ } else {
+ $this->saveAccessToken();
+ }
+ }
+
+ /**
+ * Asks Twitter for a request token, and then redirects to Twitter
+ * to authorize it.
+ *
+ * @return nothing
+ */
+ function authorizeRequestToken()
+ {
+ try {
+
+ // Get a new request token and authorize it
+
+ $client = new TwitterOAuthClient();
+ $req_tok =
+ $client->getRequestToken(TwitterOAuthClient::$requestTokenURL);
+
+ // Sock the request token away in the session temporarily
+
+ $_SESSION['twitter_request_token'] = $req_tok->key;
+ $_SESSION['twitter_request_token_secret'] = $req_tok->secret;
+
+ $auth_link = $client->getAuthorizeLink($req_tok);
+
+ } catch (TwitterOAuthClientException $e) {
+ $msg = sprintf('OAuth client cURL error - code: %1s, msg: %2s',
+ $e->getCode(), $e->getMessage());
+ $this->serverError(_('Couldn\'t link your Twitter account.'));
+ }
+
+ common_redirect($auth_link);
+ }
+
+ /**
+ * Called when Twitter returns an authorized request token. Exchanges
+ * it for an access token and stores it.
+ *
+ * @return nothing
+ */
+ function saveAccessToken()
+ {
+
+ // Check to make sure Twitter returned the same request
+ // token we sent them
+
+ if ($_SESSION['twitter_request_token'] != $this->oauth_token) {
+ $this->serverError(_('Couldn\'t link your Twitter account.'));
+ }
+
+ try {
+
+ $client = new TwitterOAuthClient($_SESSION['twitter_request_token'],
+ $_SESSION['twitter_request_token_secret']);
+
+ // Exchange the request token for an access token
+
+ $atok = $client->getAccessToken(TwitterOAuthClient::$accessTokenURL);
+
+ // Test the access token and get the user's Twitter info
+
+ $client = new TwitterOAuthClient($atok->key, $atok->secret);
+ $twitter_user = $client->verifyCredentials();
+
+ } catch (OAuthClientException $e) {
+ $msg = sprintf('OAuth client cURL error - code: %1$s, msg: %2$s',
+ $e->getCode(), $e->getMessage());
+ $this->serverError(_('Couldn\'t link your Twitter account.'));
+ }
+
+ // Save the access token and Twitter user info
+
+ $this->saveForeignLink($atok, $twitter_user);
+
+ // Clean up the the mess we made in the session
+
+ unset($_SESSION['twitter_request_token']);
+ unset($_SESSION['twitter_request_token_secret']);
+
+ common_redirect(common_local_url('twittersettings'));
+ }
+
+ /**
+ * Saves a Foreign_link between Twitter user and local user,
+ * which includes the access token and secret.
+ *
+ * @param OAuthToken $access_token the access token to save
+ * @param mixed $twitter_user twitter API user object
+ *
+ * @return nothing
+ */
+ function saveForeignLink($access_token, $twitter_user)
+ {
+ $user = common_current_user();
+
+ $flink = new Foreign_link();
+
+ $flink->user_id = $user->id;
+ $flink->foreign_id = $twitter_user->id;
+ $flink->service = TWITTER_SERVICE;
+
+ $creds = TwitterOAuthClient::packToken($access_token);
+
+ $flink->credentials = $creds;
+ $flink->created = common_sql_now();
+
+ // Defaults: noticesync on, everything else off
+
+ $flink->set_flags(true, false, false, false);
+
+ $flink_id = $flink->insert();
+
+ if (empty($flink_id)) {
+ common_log_db_error($flink, 'INSERT', __FILE__);
+ $this->serverError(_('Couldn\'t link your Twitter account.'));
+ }
+
+ save_twitter_user($twitter_user->id, $twitter_user->screen_name);
+ }
+
+}
+
diff --git a/actions/twittersettings.php b/actions/twittersettings.php
index 2b742788e..0859ab9d3 100644
--- a/actions/twittersettings.php
+++ b/actions/twittersettings.php
@@ -34,8 +34,6 @@ if (!defined('LACONICA')) {
require_once INSTALLDIR.'/lib/connectsettingsaction.php';
require_once INSTALLDIR.'/lib/twitter.php';
-define('SUBSCRIPTIONS', 80);
-
/**
* Settings for Twitter integration
*
@@ -69,9 +67,8 @@ class TwittersettingsAction extends ConnectSettingsAction
function getInstructions()
{
- return _('Add your Twitter account to automatically send '.
- ' your notices to Twitter, ' .
- 'and subscribe to Twitter friends already here.');
+ return _('Connect your Twitter account to share your updates ' .
+ 'with your Twitter friends and vice-versa.');
}
/**
@@ -85,6 +82,12 @@ class TwittersettingsAction extends ConnectSettingsAction
function showContent()
{
+ if (!common_config('twitter', 'enabled')) {
+ $this->element('div', array('class' => 'error'),
+ _('Twitter is not available.'));
+ return;
+ }
+
$user = common_current_user();
$profile = $user->getProfile();
@@ -93,7 +96,7 @@ class TwittersettingsAction extends ConnectSettingsAction
$flink = Foreign_link::getByUserID($user->id, TWITTER_SERVICE);
- if ($flink) {
+ if (!empty($flink)) {
$fuser = $flink->getForeignUser();
}
@@ -102,192 +105,86 @@ class TwittersettingsAction extends ConnectSettingsAction
'class' => 'form_settings',
'action' =>
common_local_url('twittersettings')));
- $this->elementStart('fieldset', array('id' => 'settings_twitter_account'));
- $this->element('legend', null, _('Twitter Account'));
+
$this->hidden('token', common_session_token());
- if ($fuser) {
+
+ $this->elementStart('fieldset', array('id' => 'settings_twitter_account'));
+
+ if (empty($fuser)) {
$this->elementStart('ul', 'form_data');
- $this->elementStart('li', array('id' => 'settings_twitter_remove'));
- $this->element('span', 'twitter_user', $fuser->nickname);
- $this->element('a', array('href' => $fuser->uri), $fuser->uri);
- $this->element('p', 'form_note',
- _('Current verified Twitter account.'));
- $this->hidden('flink_foreign_id', $flink->foreign_id);
+ $this->elementStart('li', array('id' => 'settings_twitter_login_button'));
+ $this->element('a', array('href' => common_local_url('twitterauthorization')),
+ 'Connect my Twitter account');
$this->elementEnd('li');
$this->elementEnd('ul');
- $this->submit('remove', _('Remove'));
+
+ $this->elementEnd('fieldset');
} else {
+ $this->element('legend', null, _('Twitter account'));
+ $this->elementStart('p', array('id' => 'form_confirmed'));
+ $this->element('a', array('href' => $fuser->uri), $fuser->nickname);
+ $this->elementEnd('p');
+ $this->element('p', 'form_note',
+ _('Connected Twitter account'));
+
+ $this->submit('remove', _('Remove'));
+
+ $this->elementEnd('fieldset');
+
+ $this->elementStart('fieldset', array('id' => 'settings_twitter_preferences'));
+
+ $this->element('legend', null, _('Preferences'));
$this->elementStart('ul', 'form_data');
- $this->elementStart('li', array('id' => 'settings_twitter_login'));
- $this->input('twitter_username', _('Twitter user name'),
- ($this->arg('twitter_username')) ?
- $this->arg('twitter_username') :
- $profile->nickname,
- _('No spaces, please.')); // hey, it's what Twitter says
+ $this->elementStart('li');
+ $this->checkbox('noticesend',
+ _('Automatically send my notices to Twitter.'),
+ ($flink) ?
+ ($flink->noticesync & FOREIGN_NOTICE_SEND) :
+ true);
$this->elementEnd('li');
$this->elementStart('li');
- $this->password('twitter_password', _('Twitter password'));
- $this->elementend('li');
- $this->elementEnd('ul');
- }
- $this->elementEnd('fieldset');
-
- $this->elementStart('fieldset',
- array('id' => 'settings_twitter_preferences'));
- $this->element('legend', null, _('Preferences'));
-
- $this->elementStart('ul', 'form_data');
- $this->elementStart('li');
- $this->checkbox('noticesend',
- _('Automatically send my notices to Twitter.'),
- ($flink) ?
- ($flink->noticesync & FOREIGN_NOTICE_SEND) :
- true);
- $this->elementEnd('li');
- $this->elementStart('li');
- $this->checkbox('replysync',
- _('Send local "@" replies to Twitter.'),
- ($flink) ?
- ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) :
- true);
- $this->elementEnd('li');
- $this->elementStart('li');
- $this->checkbox('friendsync',
- _('Subscribe to my Twitter friends here.'),
- ($flink) ?
- ($flink->friendsync & FOREIGN_FRIEND_RECV) :
- false);
- $this->elementEnd('li');
-
- if (common_config('twitterbridge','enabled')) {
+ $this->checkbox('replysync',
+ _('Send local "@" replies to Twitter.'),
+ ($flink) ?
+ ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) :
+ true);
+ $this->elementEnd('li');
$this->elementStart('li');
- $this->checkbox('noticerecv',
- _('Import my Friends Timeline.'),
+ $this->checkbox('friendsync',
+ _('Subscribe to my Twitter friends here.'),
($flink) ?
- ($flink->noticesync & FOREIGN_NOTICE_RECV) :
+ ($flink->friendsync & FOREIGN_FRIEND_RECV) :
false);
$this->elementEnd('li');
- } else {
- // preserve setting even if bidrection bridge toggled off
- if ($flink && ($flink->noticesync & FOREIGN_NOTICE_RECV)) {
- $this->hidden('noticerecv', true, 'noticerecv');
- }
- }
-
- $this->elementEnd('ul');
-
- if ($flink) {
- $this->submit('save', _('Save'));
- } else {
- $this->submit('add', _('Add'));
- }
- $this->elementEnd('fieldset');
-
- $this->showTwitterSubscriptions();
-
- $this->elementEnd('form');
- }
-
- /**
- * Gets some of the user's Twitter friends
- *
- * Gets the number of Twitter friends that are on this
- * instance of Laconica.
- *
- * @return array array of User objects
- */
-
- function subscribedTwitterUsers()
- {
-
- $current_user = common_current_user();
-
- $qry = 'SELECT "user".* ' .
- 'FROM subscription ' .
- 'JOIN "user" ON subscription.subscribed = "user".id ' .
- 'JOIN foreign_link ON foreign_link.user_id = "user".id ' .
- 'WHERE subscriber = %d ' .
- 'ORDER BY "user".nickname';
-
- $user = new User();
-
- $user->query(sprintf($qry, $current_user->id));
-
- $users = array();
-
- while ($user->fetch()) {
-
- // Don't include the user's own self-subscription
- if ($user->id != $current_user->id) {
- $users[] = clone($user);
- }
- }
-
- return $users;
- }
-
- /**
- * Show user's Twitter friends
- *
- * Gets the number of Twitter friends that are on this
- * instance of Laconica, and shows their mini-avatars.
- *
- * @return void
- */
-
- function showTwitterSubscriptions()
- {
-
- $friends = $this->subscribedTwitterUsers();
-
- $friends_count = count($friends);
- if ($friends_count > 0) {
- $this->elementStart('div', array('id' => 'entity_subscriptions',
- 'class' => 'section'));
- $this->element('h2', null, _('Twitter Friends'));
- $this->elementStart('ul', 'entities users xoxo');
-
- for ($i = 0; $i < min($friends_count, SUBSCRIPTIONS); $i++) {
+ if (common_config('twitterbridge','enabled')) {
+ $this->elementStart('li');
+ $this->checkbox('noticerecv',
+ _('Import my Friends Timeline.'),
+ ($flink) ?
+ ($flink->noticesync & FOREIGN_NOTICE_RECV) :
+ false);
+ $this->elementEnd('li');
- $other = Profile::staticGet($friends[$i]->id);
+ // preserve setting even if bidrection bridge toggled off
- if (!$other) {
- common_log_db_error($subs, 'SELECT', __FILE__);
- continue;
+ if ($flink && ($flink->noticesync & FOREIGN_NOTICE_RECV)) {
+ $this->hidden('noticerecv', true, 'noticerecv');
}
-
- $this->elementStart('li', 'vcard');
- $this->elementStart('a', array('title' => ($other->fullname) ?
- $other->fullname :
- $other->nickname,
- 'href' => $other->profileurl,
- 'class' => 'url'));
-
- $avatar = $other->getAvatar(AVATAR_MINI_SIZE);
-
- $avatar_url = ($avatar) ?
- $avatar->displayUrl() :
- Avatar::defaultImage(AVATAR_MINI_SIZE);
-
- $this->element('img', array('src' => $avatar_url,
- 'width' => AVATAR_MINI_SIZE,
- 'height' => AVATAR_MINI_SIZE,
- 'class' => 'avatar photo',
- 'alt' => ($other->fullname) ?
- $other->fullname :
- $other->nickname));
-
- $this->element('span', 'fn nickname', $other->nickname);
- $this->elementEnd('a');
- $this->elementEnd('li');
-
}
$this->elementEnd('ul');
- $this->elementEnd('div');
+ if ($flink) {
+ $this->submit('save', _('Save'));
+ } else {
+ $this->submit('add', _('Add'));
+ }
+
+ $this->elementEnd('fieldset');
}
+
+ $this->elementEnd('form');
}
/**
@@ -303,7 +200,6 @@ class TwittersettingsAction extends ConnectSettingsAction
function handlePost()
{
-
// CSRF protection
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
@@ -314,8 +210,6 @@ class TwittersettingsAction extends ConnectSettingsAction
if ($this->arg('save')) {
$this->savePreferences();
- } else if ($this->arg('add')) {
- $this->addTwitterAccount();
} else if ($this->arg('remove')) {
$this->removeTwitterAccount();
} else {
@@ -324,82 +218,6 @@ class TwittersettingsAction extends ConnectSettingsAction
}
/**
- * Associate a Twitter account with the user's account
- *
- * Validates post input; verifies it against Twitter; and if
- * successful stores in the database.
- *
- * @return void
- */
-
- function addTwitterAccount()
- {
- $screen_name = $this->trimmed('twitter_username');
- $password = $this->trimmed('twitter_password');
- $noticesend = $this->boolean('noticesend');
- $noticerecv = $this->boolean('noticerecv');
- $replysync = $this->boolean('replysync');
- $friendsync = $this->boolean('friendsync');
-
- if (!Validate::string($screen_name,
- array('min_length' => 1,
- 'max_length' => 15,
- 'format' => VALIDATE_NUM.VALIDATE_ALPHA.'_'))) {
- $this->showForm(_('Username must have only numbers, '.
- 'upper- and lowercase letters, '.
- 'and underscore (_). 15 chars max.'));
- return;
- }
-
- if (!$this->verifyCredentials($screen_name, $password)) {
- $this->showForm(_('Could not verify your Twitter credentials!'));
- return;
- }
-
- $twit_user = twitter_user_info($screen_name, $password);
-
- if (!$twit_user) {
- $this->showForm(sprintf(_('Unable to retrieve account information '.
- 'For "%s" from Twitter.'),
- $screen_name));
- return;
- }
-
- if (!save_twitter_user($twit_user->id, $screen_name)) {
- $this->showForm(_('Unable to save your Twitter settings!'));
- return;
- }
-
- $user = common_current_user();
-
- $flink = new Foreign_link();
-
- $flink->user_id = $user->id;
- $flink->foreign_id = $twit_user->id;
- $flink->service = TWITTER_SERVICE;
- $flink->credentials = $password;
- $flink->created = common_sql_now();
-
- $flink->set_flags($noticesend, $noticerecv, $replysync, $friendsync);
-
- $flink_id = $flink->insert();
-
- if (!$flink_id) {
- common_log_db_error($flink, 'INSERT', __FILE__);
- $this->showForm(_('Unable to save your Twitter settings!'));
- return;
- }
-
- if ($friendsync) {
- save_twitter_friends($user, $twit_user->id, $screen_name, $password);
- $flink->last_friendsync = common_sql_now();
- $flink->update();
- }
-
- $this->showForm(_('Twitter settings saved.'), true);
- }
-
- /**
* Disassociate an existing Twitter account from this account
*
* @return void
@@ -408,20 +226,11 @@ class TwittersettingsAction extends ConnectSettingsAction
function removeTwitterAccount()
{
$user = common_current_user();
-
- $flink = Foreign_link::getByUserID($user->id, 1);
-
- $flink_foreign_id = $this->arg('flink_foreign_id');
-
- // Maybe an old tab open...?
- if ($flink->foreign_id != $flink_foreign_id) {
- $this->showForm(_('That is not your Twitter account.'));
- return;
- }
+ $flink = Foreign_link::getByUserID($user->id, TWITTER_SERVICE);
$result = $flink->delete();
- if (!$result) {
+ if (empty($result)) {
common_log_db_error($flink, 'DELETE', __FILE__);
$this->serverError(_('Couldn\'t remove Twitter user.'));
return;
@@ -444,32 +253,16 @@ class TwittersettingsAction extends ConnectSettingsAction
$replysync = $this->boolean('replysync');
$user = common_current_user();
+ $flink = Foreign_link::getByUserID($user->id, TWITTER_SERVICE);
- $flink = Foreign_link::getByUserID($user->id, 1);
-
- if (!$flink) {
+ if (empty($flink)) {
common_log_db_error($flink, 'SELECT', __FILE__);
$this->showForm(_('Couldn\'t save Twitter preferences.'));
return;
}
- $twitter_id = $flink->foreign_id;
- $password = $flink->credentials;
-
- $fuser = $flink->getForeignUser();
-
- if (!$fuser) {
- common_log_db_error($fuser, 'SELECT', __FILE__);
- $this->showForm(_('Couldn\'t save Twitter preferences.'));
- return;
- }
-
- $screen_name = $fuser->nickname;
-
$original = clone($flink);
-
$flink->set_flags($noticesend, $noticerecv, $replysync, $friendsync);
-
$result = $flink->update($original);
if ($result === false) {
@@ -478,45 +271,7 @@ class TwittersettingsAction extends ConnectSettingsAction
return;
}
- if ($friendsync) {
- save_twitter_friends($user, $flink->foreign_id, $screen_name, $password);
- }
-
$this->showForm(_('Twitter preferences saved.'), true);
}
- /**
- * Verifies a username and password against Twitter's API
- *
- * @param string $screen_name Twitter user name
- * @param string $password Twitter password
- *
- * @return boolean success flag
- */
-
- function verifyCredentials($screen_name, $password)
- {
- $uri = 'http://twitter.com/account/verify_credentials.json';
-
- $data = get_twitter_data($uri, $screen_name, $password);
-
- if (!$data) {
- return false;
- }
-
- $user = json_decode($data);
-
- if (!$user) {
- return false;
- }
-
- $twitter_id = $user->id;
-
- if ($twitter_id) {
- return $twitter_id;
- }
-
- return false;
- }
-
}
diff --git a/actions/updateprofile.php b/actions/updateprofile.php
index b10554e8b..b020413b3 100644
--- a/actions/updateprofile.php
+++ b/actions/updateprofile.php
@@ -57,13 +57,46 @@ class UpdateprofileAction extends Action
*/
function prepare($argarray)
{
- parent::prepare($argarray);
- $license = $_POST['omb_listenee_license'];
- $site_license = common_config('license', 'url');
- if (!common_compatible_license($license, $site_license)) {
- $this->clientError(sprintf(_('Listenee stream license ā€˜%sā€™ is not '.
- 'compatible with site license ā€˜%sā€™.'),
- $license, $site_license);
+ $version = $req->get_parameter('omb_version');
+ if ($version != OMB_VERSION_01) {
+ $this->clientError(_('Unsupported OMB version'), 400);
+ return false;
+ }
+ # First, check to see if listenee exists
+ $listenee = $req->get_parameter('omb_listenee');
+ $remote = Remote_profile::staticGet('uri', $listenee);
+ if (!$remote) {
+ $this->clientError(_('Profile unknown'), 404);
+ return false;
+ }
+ # Second, check to see if they should be able to post updates!
+ # We see if there are any subscriptions to that remote user with
+ # the given token.
+
+ $sub = new Subscription();
+ $sub->subscribed = $remote->id;
+ $sub->token = $token->key;
+ if (!$sub->find(true)) {
+ $this->clientError(_('You did not send us that profile'), 403);
+ return false;
+ }
+
+ $profile = Profile::staticGet('id', $remote->id);
+ if (!$profile) {
+ # This one is our fault
+ $this->serverError(_('Remote profile with no matching profile'), 500);
+ return false;
+ }
+ $nickname = $req->get_parameter('omb_listenee_nickname');
+ if ($nickname && !Validate::string($nickname, array('min_length' => 1,
+ 'max_length' => 64,
+ 'format' => NICKNAME_FMT))) {
+ $this->clientError(_('Nickname must have only lowercase letters and numbers and no spaces.'));
+ return false;
+ }
+ $license = $req->get_parameter('omb_listenee_license');
+ if ($license && !common_valid_http_url($license)) {
+ $this->clientError(sprintf(_("Invalid license URL '%s'"), $license));
return false;
}
return true;
@@ -82,5 +115,4 @@ class UpdateprofileAction extends Action
return;
}
}
-}
-?>
+} \ No newline at end of file
diff --git a/actions/userauthorization.php b/actions/userauthorization.php
index 54e0ee920..3e7be9747 100644
--- a/actions/userauthorization.php
+++ b/actions/userauthorization.php
@@ -63,7 +63,11 @@ class UserauthorizationAction extends Action
/* Go log in, and then come back. */
common_set_returnto($_SERVER['REQUEST_URI']);
- common_redirect(common_local_url('login'));
+ if (!common_config('site', 'openidonly')) {
+ common_redirect(common_local_url('login'));
+ } else {
+ common_redirect(common_local_url('openidlogin'));
+ }
return;
}
@@ -353,4 +357,3 @@ class UserauthorizationAction extends Action
}
}
}
-?>
diff --git a/actions/userrss.php b/actions/userrss.php
index 8a940865f..a9f3fd5f8 100644
--- a/actions/userrss.php
+++ b/actions/userrss.php
@@ -88,9 +88,10 @@ class UserrssAction extends Rss10Action
$c = array('url' => common_local_url('userrss',
array('nickname' =>
$user->nickname)),
- 'title' => $user->nickname,
+ 'title' => sprintf(_('%s timeline'), $user->nickname),
'link' => $profile->profileurl,
- 'description' => sprintf(_('Microblog by %s'), $user->nickname));
+ 'description' => sprintf(_('Updates from %1$s on %2$s!'),
+ $user->nickname, common_config('site', 'name')));
return $c;
}