summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
Diffstat (limited to 'actions')
-rw-r--r--actions/all.php14
-rw-r--r--actions/apistatusesupdate.php70
-rw-r--r--actions/bookmarklet.php75
-rw-r--r--actions/emailsettings.php2
-rw-r--r--actions/getfile.php145
-rw-r--r--actions/invite.php2
-rw-r--r--actions/newmessage.php20
-rw-r--r--actions/newnotice.php207
-rw-r--r--actions/othersettings.php2
-rw-r--r--actions/profilesettings.php10
-rw-r--r--actions/public.php17
-rw-r--r--actions/publicxrds.php81
-rw-r--r--actions/register.php2
-rw-r--r--actions/replies.php24
-rw-r--r--actions/showfavorites.php26
-rw-r--r--actions/showgroup.php14
-rw-r--r--actions/shownotice.php4
-rw-r--r--actions/showstream.php26
-rw-r--r--actions/tag.php16
-rw-r--r--actions/xrds.php106
20 files changed, 562 insertions, 301 deletions
diff --git a/actions/all.php b/actions/all.php
index f1786462e..61cedce74 100644
--- a/actions/all.php
+++ b/actions/all.php
@@ -99,19 +99,17 @@ class AllAction extends ProfileAction
sprintf(_('Feed for friends of %s (RSS 1.0)'), $this->user->nickname)),
new Feed(Feed::RSS2,
common_local_url(
- 'api', array(
- 'apiaction' => 'statuses',
- 'method' => 'friends_timeline',
- 'argument' => $this->user->nickname.'.rss'
+ 'ApiTimelineFriends', array(
+ 'format' => 'rss',
+ 'id' => $this->user->nickname
)
),
sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->user->nickname)),
new Feed(Feed::ATOM,
common_local_url(
- 'api', array(
- 'apiaction' => 'statuses',
- 'method' => 'friends_timeline',
- 'argument' => $this->user->nickname.'.atom'
+ 'ApiTimelineFriends', array(
+ 'format' => 'atom',
+ 'id' => $this->user->nickname
)
),
sprintf(_('Feed for friends of %s (Atom)'), $this->user->nickname))
diff --git a/actions/apistatusesupdate.php b/actions/apistatusesupdate.php
index 0d71e1512..898a4bd72 100644
--- a/actions/apistatusesupdate.php
+++ b/actions/apistatusesupdate.php
@@ -38,6 +38,7 @@ if (!defined('STATUSNET')) {
}
require_once INSTALLDIR . '/lib/apiauth.php';
+require_once INSTALLDIR . '/lib/mediafile.php';
/**
* Updates the authenticating user's status (posts a notice).
@@ -60,7 +61,6 @@ class ApiStatusesUpdateAction extends ApiAuthAction
var $source = null;
var $status = null;
var $in_reply_to_status_id = null;
-
static $reserved_sources = array('web', 'omb', 'mail', 'xmpp', 'api');
/**
@@ -76,25 +76,8 @@ class ApiStatusesUpdateAction extends ApiAuthAction
{
parent::prepare($args);
- $this->user = $this->auth_user;
-
- if (empty($this->user)) {
- $this->clientError(_('No such user!'), 404, $this->format);
- return false;
- }
-
+ $this->user = $this->auth_user;
$this->status = $this->trimmed('status');
-
- if (empty($this->status)) {
- $this->clientError(
- 'Client must provide a \'status\' parameter with a value.',
- 400,
- $this->format
- );
-
- return false;
- }
-
$this->source = $this->trimmed('source');
if (empty($this->source) || in_array($source, $this->reserved_sources)) {
@@ -129,6 +112,27 @@ class ApiStatusesUpdateAction extends ApiAuthAction
return;
}
+ if (empty($this->status)) {
+ $this->clientError(
+ 'Client must provide a \'status\' parameter with a value.',
+ 400,
+ $this->format
+ );
+ return;
+ }
+
+ if (empty($this->user)) {
+ $this->clientError(_('No such user!'), 404, $this->format);
+ return;
+ }
+
+ // Workaround for PHP returning empty $_FILES when POST length > PHP settings
+
+ if (empty($_POST) && ($_SERVER['CONTENT_LENGTH'] > 0)) {
+ $this->clientError(_('Unable to handle that much POST data!'));
+ return;
+ }
+
$status_shortened = common_shorten_links($this->status);
if (Notice::contentTooLong($status_shortened)) {
@@ -187,14 +191,40 @@ class ApiStatusesUpdateAction extends ApiAuthAction
}
}
+ $upload = null;
+
+ try {
+ $upload = MediaFile::fromUpload('media', $this->user);
+ } catch (ClientException $ce) {
+ $this->clientError($ce->getMessage());
+ return;
+ }
+
+ if (isset($upload)) {
+ $status_shortened .= ' ' . $upload->shortUrl();
+
+ if (Notice::contentTooLong($status_shortened)) {
+ $upload->delete();
+ $msg = _(
+ 'Max notice size is %d chars, ' .
+ 'including attachment URL.'
+ );
+ $this->clientError(sprintf($msg, Notice::maxContent()));
+ }
+ }
+
$this->notice = Notice::saveNew(
$this->user->id,
- html_entity_decode($this->status, ENT_NOQUOTES, 'UTF-8'),
+ html_entity_decode($status_shortened, ENT_NOQUOTES, 'UTF-8'),
$this->source,
1,
$reply_to
);
+ if (isset($upload)) {
+ $upload->attachToNotice($this->notice);
+ }
+
common_broadcast_notice($this->notice);
}
diff --git a/actions/bookmarklet.php b/actions/bookmarklet.php
new file mode 100644
index 000000000..0603a7456
--- /dev/null
+++ b/actions/bookmarklet.php
@@ -0,0 +1,75 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Handler for posting new notices
+ *
+ * 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 Bookmarklet
+ * @package StatusNet
+ * @author Sarven Capadisli <csarven@status.net>
+ * @copyright 2008-2009 StatusNet, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+if (!defined('STATUSNET') && !defined('LACONICA')) {
+ exit(1);
+}
+
+require_once INSTALLDIR . '/actions/newnotice.php';
+
+/**
+ * Action for posting a notice
+ *
+ * @category Bookmarklet
+ * @package StatusNet
+ * @author Sarven Capadisli <csarven@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+class BookmarkletAction extends NewnoticeAction
+{
+ function showTitle()
+ {
+ $this->element('title', null, _('Post to ').common_config('site', 'name'));
+ }
+
+ function showHeader()
+ {
+ $this->elementStart('div', array('id' => 'header'));
+ $this->elementStart('address');
+ $this->element('a', array('class' => 'url',
+ 'href' => common_local_url('public')),
+ '');
+ $this->elementEnd('address');
+ if (common_logged_in()) {
+ $this->showNoticeForm();
+ }
+ $this->elementEnd('div');
+ }
+
+ function showCore()
+ {
+ }
+
+ function showFooter()
+ {
+ }
+}
+
diff --git a/actions/emailsettings.php b/actions/emailsettings.php
index 6eff06c0d..67b991cdc 100644
--- a/actions/emailsettings.php
+++ b/actions/emailsettings.php
@@ -326,7 +326,7 @@ class EmailsettingsAction extends AccountSettingsAction
$this->showForm(_('Cannot normalize that email address'));
return;
}
- if (!Validate::email($email, true)) {
+ if (!Validate::email($email, common_config('email', 'check_domain'))) {
$this->showForm(_('Not a valid email address'));
return;
} else if ($user->email == $email) {
diff --git a/actions/getfile.php b/actions/getfile.php
new file mode 100644
index 000000000..ecda34c0f
--- /dev/null
+++ b/actions/getfile.php
@@ -0,0 +1,145 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Returns a given file attachment, allowing private sites to only allow
+ * access to file attachments after login.
+ *
+ * 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 Personal
+ * @package StatusNet
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @copyright 2008-2009 StatusNet, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+if (!defined('STATUSNET') && !defined('LACONICA')) {
+ exit(1);
+}
+
+require_once 'MIME/Type.php';
+
+/**
+ * Action for getting a file attachment
+ *
+ * @category Personal
+ * @package StatusNet
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+class GetfileAction extends Action
+{
+ /**
+ * Path of file to return
+ */
+
+ var $path = null;
+
+ /**
+ * Get file name
+ *
+ * @param array $args $_REQUEST array
+ *
+ * @return success flag
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $filename = $this->trimmed('filename');
+ $path = null;
+
+ if ($filename) {
+ $path = common_config('attachments', 'dir') . $filename;
+ }
+
+ if (empty($path) or !file_exists($path)) {
+ $this->clientError(_('No such file.'), 404);
+ return false;
+ }
+ if (!is_readable($path)) {
+ $this->clientError(_('Cannot read file.'), 403);
+ return false;
+ }
+
+ $this->path = $path;
+ return true;
+ }
+
+ /**
+ * Is this page read-only?
+ *
+ * @return boolean true
+ */
+
+ function isReadOnly($args)
+ {
+ return true;
+ }
+
+ /**
+ * Last-modified date for file
+ *
+ * @return int last-modified date as unix timestamp
+ */
+
+ function lastModified()
+ {
+ return filemtime($this->path);
+ }
+
+ /**
+ * etag for file
+ *
+ * This returns the same data (inode, size, mtime) as Apache would,
+ * but in decimal instead of hex.
+ *
+ * @return string etag http header
+ */
+ function etag()
+ {
+ $stat = stat($this->path);
+ return '"' . $stat['ino'] . '-' . $stat['size'] . '-' . $stat['mtime'] . '"';
+ }
+
+ /**
+ * Handle input, produce output
+ *
+ * @param array $args $_REQUEST contents
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ // undo headers set by PHP sessions
+ $sec = session_cache_expire() * 60;
+ header('Expires: ' . date(DATE_RFC1123, time() + $sec));
+ header('Cache-Control: public, max-age=' . $sec);
+ header('Pragma: public');
+
+ parent::handle($args);
+
+ $path = $this->path;
+ header('Content-Type: ' . MIME_Type::autoDetect($path));
+ readfile($path);
+ }
+}
diff --git a/actions/invite.php b/actions/invite.php
index 788130c58..3015202e9 100644
--- a/actions/invite.php
+++ b/actions/invite.php
@@ -68,7 +68,7 @@ class InviteAction extends CurrentUserDesignAction
foreach ($addresses as $email) {
$email = trim($email);
- if (!Validate::email($email, true)) {
+ if (!Validate::email($email, common_config('email', 'check_domain'))) {
$this->showForm(sprintf(_('Invalid email address: %s'), $email));
return;
}
diff --git a/actions/newmessage.php b/actions/newmessage.php
index a0b17fc18..095a7d1d3 100644
--- a/actions/newmessage.php
+++ b/actions/newmessage.php
@@ -99,7 +99,9 @@ class NewmessageAction extends Action
$user = common_current_user();
if (!$user) {
- $this->clientError(_('Only logged-in users can send direct messages.'), 403);
+ /* Go log in, and then come back. */
+ common_set_returnto($_SERVER['REQUEST_URI']);
+ common_redirect(common_local_url('login'));
return false;
}
@@ -221,7 +223,21 @@ class NewmessageAction extends Action
}
$this->msg = $msg;
- $this->showPage();
+ if ($this->trimmed('ajax')) {
+ header('Content-Type: text/xml;charset=utf-8');
+ $this->xw->startDocument('1.0', 'UTF-8');
+ $this->elementStart('html');
+ $this->elementStart('head');
+ $this->element('title', null, _('New message'));
+ $this->elementEnd('head');
+ $this->elementStart('body');
+ $this->showNoticeForm();
+ $this->elementEnd('body');
+ $this->endHTML();
+ }
+ else {
+ $this->showPage();
+ }
}
function showPageNotice()
diff --git a/actions/newnotice.php b/actions/newnotice.php
index 9ee031f93..fbd7ab6bc 100644
--- a/actions/newnotice.php
+++ b/actions/newnotice.php
@@ -33,7 +33,8 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
-require_once INSTALLDIR.'/lib/noticelist.php';
+require_once INSTALLDIR . '/lib/noticelist.php';
+require_once INSTALLDIR . '/lib/mediafile.php';
/**
* Action for posting new notices
@@ -113,33 +114,6 @@ class NewnoticeAction extends Action
}
}
- function getUploadedFileType() {
- require_once 'MIME/Type.php';
-
- $cmd = &PEAR::getStaticProperty('MIME_Type', 'fileCmd');
- $cmd = common_config('attachments', 'filecommand');
-
- $filetype = MIME_Type::autoDetect($_FILES['attach']['tmp_name']);
- if (in_array($filetype, common_config('attachments', 'supported'))) {
- return $filetype;
- }
- $media = MIME_Type::getMedia($filetype);
- if ('application' !== $media) {
- $hint = sprintf(_(' Try using another %s format.'), $media);
- } else {
- $hint = '';
- }
- $this->clientError(sprintf(
- _('%s is not a supported filetype on this server.'), $filetype) . $hint);
- }
-
- function isRespectsQuota($user) {
- $file = new File;
- $ret = $file->isRespectsQuota($user,$_FILES['attach']['size']);
- if (true === $ret) return true;
- $this->clientError($ret);
- }
-
/**
* Save a new notice, based on arguments
*
@@ -160,18 +134,12 @@ class NewnoticeAction extends Action
if (!$content) {
$this->clientError(_('No content!'));
- } else {
- $content_shortened = common_shorten_links($content);
- if (Notice::contentTooLong($content_shortened)) {
- $this->clientError(sprintf(_('That\'s too long. '.
- 'Max notice size is %d chars.'),
- Notice::maxContent()));
- }
+ return;
}
$inter = new CommandInterpreter();
- $cmd = $inter->handle_command($user, $content_shortened);
+ $cmd = $inter->handle_command($user, $content);
if ($cmd) {
if ($this->boolean('ajax')) {
@@ -182,6 +150,13 @@ class NewnoticeAction extends Action
return;
}
+ $content_shortened = common_shorten_links($content);
+ if (Notice::contentTooLong($content_shortened)) {
+ $this->clientError(sprintf(_('That\'s too long. '.
+ 'Max notice size is %d chars.'),
+ Notice::maxContent()));
+ }
+
$replyto = $this->trimmed('inreplyto');
#If an ID of 0 is wrongly passed here, it will cause a database error,
#so override it...
@@ -189,84 +164,37 @@ class NewnoticeAction extends Action
$replyto = 'false';
}
- if (isset($_FILES['attach']['error'])) {
- switch ($_FILES['attach']['error']) {
- 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_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.'));
+ $upload = null;
+ $upload = MediaFile::fromUpload('attach');
- case UPLOAD_ERR_PARTIAL:
- $this->clientError(_('The uploaded file was only partially uploaded.'));
+ if (isset($upload)) {
- 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_EXTENSION:
- $this->clientError(_('File upload stopped by extension.'));
-
- default:
- die('Should never reach here.');
- }
- }
-
- if (isset($mimetype)) {
- $filename = $this->saveFile($mimetype);
- if (empty($filename)) {
- $this->clientError(_('Couldn\'t save file.'));
- }
-
- $fileRecord = $this->storeFile($filename, $mimetype);
-
- $fileurl = common_local_url('attachment',
- array('attachment' => $fileRecord->id));
-
- // not sure this is necessary -- Zach
- $this->maybeAddRedir($fileRecord->id, $fileurl);
-
- $short_fileurl = common_shorten_url($fileurl);
- if (!$short_fileurl) {
- // todo -- Consider forcing default shortener if none selected?
- $short_fileurl = $fileurl;
- }
- $content_shortened .= ' ' . $short_fileurl;
+ $content_shortened .= ' ' . $upload->shortUrl();
if (Notice::contentTooLong($content_shortened)) {
- $this->deleteFile($filename);
- $this->clientError(sprintf(_('Max notice size is %d chars, including attachment URL.'),
- Notice::maxContent()));
+ $upload->delete();
+ $this->clientError(
+ sprintf(
+ _('Max notice size is %d chars, including attachment URL.'),
+ Notice::maxContent()
+ )
+ );
}
-
- // Also, not sure this is necessary -- Zach
- $this->maybeAddRedir($fileRecord->id, $short_fileurl);
}
$notice = Notice::saveNew($user->id, $content_shortened, 'web', 1,
($replyto == 'false') ? null : $replyto);
- if (isset($mimetype)) {
- $this->attachFile($notice, $fileRecord);
+ if (isset($upload)) {
+ $upload->attachToNotice($notice);
}
common_broadcast_notice($notice);
if ($this->boolean('ajax')) {
- $this->startHTML('text/xml;charset=utf-8');
+ header('Content-Type: text/xml;charset=utf-8');
+ $this->xw->startDocument('1.0', 'UTF-8');
+ $this->elementStart('html');
$this->elementStart('head');
$this->element('title', null, _('Notice posted'));
$this->elementEnd('head');
@@ -288,87 +216,6 @@ class NewnoticeAction extends Action
}
}
- function saveFile($mimetype) {
-
- $cur = common_current_user();
-
- if (empty($cur)) {
- $this->serverError(_('Somehow lost the login in saveFile'));
- }
-
- $basename = basename($_FILES['attach']['name']);
-
- $filename = File::filename($cur->getProfile(), $basename, $mimetype);
-
- $filepath = File::path($filename);
-
- if (move_uploaded_file($_FILES['attach']['tmp_name'], $filepath)) {
- return $filename;
- } else {
- $this->clientError(_('File could not be moved to destination directory.'));
- }
- }
-
- function deleteFile($filename)
- {
- $filepath = File::path($filename);
- @unlink($filepath);
- }
-
- function storeFile($filename, $mimetype) {
-
- $file = new File;
- $file->filename = $filename;
-
- $file->url = File::url($filename);
-
- $filepath = File::path($filename);
-
- $file->size = filesize($filepath);
- $file->date = time();
- $file->mimetype = $mimetype;
-
- $file_id = $file->insert();
-
- if (!$file_id) {
- common_log_db_error($file, "INSERT", __FILE__);
- $this->clientError(_('There was a database error while saving your file. Please try again.'));
- }
-
- return $file;
- }
-
- function rememberFile($file, $short)
- {
- $this->maybeAddRedir($file->id, $short);
- }
-
- function maybeAddRedir($file_id, $url)
- {
- $file_redir = File_redirection::staticGet('url', $url);
-
- if (empty($file_redir)) {
- $file_redir = new File_redirection;
- $file_redir->url = $url;
- $file_redir->file_id = $file_id;
-
- $result = $file_redir->insert();
-
- if (!$result) {
- common_log_db_error($file_redir, "INSERT", __FILE__);
- $this->clientError(_('There was a database error while saving your file. Please try again.'));
- }
- }
- }
-
- function attachFile($notice, $filerec)
- {
- File_to_post::processNew($filerec->id, $notice->id);
-
- $this->maybeAddRedir($filerec->id,
- common_local_url('file', array('notice' => $notice->id)));
- }
-
/**
* Show an Ajax-y error message
*
diff --git a/actions/othersettings.php b/actions/othersettings.php
index 011b4fc83..d32a2d651 100644
--- a/actions/othersettings.php
+++ b/actions/othersettings.php
@@ -103,7 +103,7 @@ class OthersettingsAction extends AccountSettingsAction
foreach($_shorteners as $name=>$value)
{
$services[$name]=$name;
- if($value['info']['freeService']){
+ if(!empty($value['info']['freeService'])){
// I18N
$services[$name].=' (free service)';
}
diff --git a/actions/profilesettings.php b/actions/profilesettings.php
index 5445d9bb2..0a0cc5997 100644
--- a/actions/profilesettings.php
+++ b/actions/profilesettings.php
@@ -306,6 +306,16 @@ class ProfilesettingsAction extends AccountSettingsAction
$profile->homepage = $homepage;
$profile->bio = $bio;
$profile->location = $location;
+
+ $loc = Location::fromName($location);
+
+ if (!empty($loc)) {
+ $profile->lat = $loc->lat;
+ $profile->lon = $loc->lon;
+ $profile->location_id = $loc->location_id;
+ $profile->location_ns = $loc->location_ns;
+ }
+
$profile->profileurl = common_profile_url($nickname);
common_debug('Old profile: ' . common_log_objstring($orig_profile), __FILE__);
diff --git a/actions/public.php b/actions/public.php
index 73fad182a..982dfde15 100644
--- a/actions/public.php
+++ b/actions/public.php
@@ -131,6 +131,13 @@ class PublicAction extends Action
return _('Public timeline');
}
}
+
+ function extraHead()
+ {
+ parent::extraHead();
+ $this->element('meta', array('http-equiv' => 'X-XRDS-Location',
+ 'content' => common_local_url('publicxrds')));
+ }
/**
* Output <head> elements for RSS and Atom feeds
@@ -143,14 +150,12 @@ class PublicAction extends Action
return array(new Feed(Feed::RSS1, common_local_url('publicrss'),
_('Public Stream Feed (RSS 1.0)')),
new Feed(Feed::RSS2,
- common_local_url('api',
- array('apiaction' => 'statuses',
- 'method' => 'public_timeline.rss')),
+ common_local_url('ApiTimelinePublic',
+ array('format' => 'rss')),
_('Public Stream Feed (RSS 2.0)')),
new Feed(Feed::ATOM,
- common_local_url('api',
- array('apiaction' => 'statuses',
- 'method' => 'public_timeline.atom')),
+ common_local_url('ApiTimelinePublic',
+ array('format' => 'atom')),
_('Public Stream Feed (Atom)')));
}
diff --git a/actions/publicxrds.php b/actions/publicxrds.php
new file mode 100644
index 000000000..5fd4eead7
--- /dev/null
+++ b/actions/publicxrds.php
@@ -0,0 +1,81 @@
+<?php
+
+/**
+ * Public XRDS for OpenID
+ *
+ * PHP version 5
+ *
+ * @category Action
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Robin Millette <millette@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
+ * @link http://status.net/
+ *
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+if (!defined('STATUSNET') && !defined('LACONICA')) {
+ exit(1);
+}
+
+require_once INSTALLDIR.'/plugins/OpenID/openid.php';
+require_once INSTALLDIR.'/lib/xrdsoutputter.php';
+
+/**
+ * Public XRDS
+ *
+ * @category Action
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Robin Millette <millette@status.net>
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
+ * @link http://status.net/
+ *
+ * @todo factor out similarities with XrdsAction
+ */
+class PublicxrdsAction extends Action
+{
+ /**
+ * Is read only?
+ *
+ * @return boolean true
+ */
+ function isReadOnly($args)
+ {
+ return true;
+ }
+
+ /**
+ * Class handler.
+ *
+ * @param array $args array of arguments
+ *
+ * @return nothing
+ */
+ function handle($args)
+ {
+ parent::handle($args);
+ $xrdsOutputter = new XRDSOutputter();
+ $xrdsOutputter->startXRDS();
+ Event::handle('StartPublicXRDS', array($this,&$xrdsOutputter));
+ Event::handle('EndPublicXRDS', array($this,&$xrdsOutputter));
+ $xrdsOutputter->endXRDS();
+ }
+}
+
diff --git a/actions/register.php b/actions/register.php
index 100ab7424..a6c1a903a 100644
--- a/actions/register.php
+++ b/actions/register.php
@@ -191,7 +191,7 @@ class RegisterAction extends Action
if (!$this->boolean('license')) {
$this->showForm(_('You can\'t register if you don\'t '.
'agree to the license.'));
- } else if ($email && !Validate::email($email, true)) {
+ } else if ($email && !Validate::email($email, common_config('email', 'check_domain'))) {
$this->showForm(_('Not a valid email address.'));
} else if (!Validate::string($nickname, array('min_length' => 1,
'max_length' => 64,
diff --git a/actions/replies.php b/actions/replies.php
index 6003ad30b..a13b5a227 100644
--- a/actions/replies.php
+++ b/actions/replies.php
@@ -138,11 +138,25 @@ class RepliesAction extends OwnerDesignAction
function getFeeds()
{
- $rssurl = common_local_url('repliesrss',
- array('nickname' => $this->user->nickname));
- $rsstitle = sprintf(_('Feed for replies to %s'), $this->user->nickname);
-
- return array(new Feed(Feed::RSS1, $rssurl, $rsstitle));
+ return array(new Feed(Feed::RSS1,
+ common_local_url('repliesrss',
+ array('nickname' => $this->user->nickname)),
+ sprintf(_('Replies feed for %s (RSS 1.0)'),
+ $this->user->nickname)),
+ new Feed(Feed::RSS2,
+ common_local_url('ApiTimelineMentions',
+ array(
+ 'id' => $this->user->nickname,
+ 'format' => 'rss')),
+ sprintf(_('Replies feed for %s (RSS 2.0)'),
+ $this->user->nickname)),
+ new Feed(Feed::ATOM,
+ common_local_url('ApiTimelineMentions',
+ array(
+ 'id' => $this->user->nickname,
+ 'format' => 'atom')),
+ sprintf(_('Replies feed for %s (Atom)'),
+ $this->user->nickname)));
}
/**
diff --git a/actions/showfavorites.php b/actions/showfavorites.php
index b96d2af37..b12fcdd9a 100644
--- a/actions/showfavorites.php
+++ b/actions/showfavorites.php
@@ -164,13 +164,25 @@ class ShowfavoritesAction extends OwnerDesignAction
function getFeeds()
{
- $feedurl = common_local_url('favoritesrss',
- array('nickname' =>
- $this->user->nickname));
- $feedtitle = sprintf(_('Feed for favorites of %s'),
- $this->user->nickname);
-
- return array(new Feed(Feed::RSS1, $feedurl, $feedtitle));
+ return array(new Feed(Feed::RSS1,
+ common_local_url('favoritesrss',
+ array('nickname' => $this->user->nickname)),
+ sprintf(_('Feed for favorites of %s (RSS 1.0)'),
+ $this->user->nickname)),
+ new Feed(Feed::RSS2,
+ common_local_url('ApiTimelineFavorites',
+ array(
+ 'id' => $this->user->nickname,
+ 'format' => 'rss')),
+ sprintf(_('Feed for favorites of %s (RSS 2.0)'),
+ $this->user->nickname)),
+ new Feed(Feed::ATOM,
+ common_local_url('ApiTimelineFavorites',
+ array(
+ 'id' => $this->user->nickname,
+ 'format' => 'atom')),
+ sprintf(_('Feed for favorites of %s (Atom)'),
+ $this->user->nickname)));
}
/**
diff --git a/actions/showgroup.php b/actions/showgroup.php
index bfe45ddad..a4af29391 100644
--- a/actions/showgroup.php
+++ b/actions/showgroup.php
@@ -328,17 +328,15 @@ class ShowgroupAction extends GroupDesignAction
sprintf(_('Notice feed for %s group (RSS 1.0)'),
$this->group->nickname)),
new Feed(Feed::RSS2,
- common_local_url('api',
- array('apiaction' => 'groups',
- 'method' => 'timeline',
- 'argument' => $this->group->nickname.'.rss')),
+ common_local_url('ApiTimelineGroup',
+ array('format' => 'rss',
+ 'id' => $this->group->nickname)),
sprintf(_('Notice feed for %s group (RSS 2.0)'),
$this->group->nickname)),
new Feed(Feed::ATOM,
- common_local_url('api',
- array('apiaction' => 'groups',
- 'method' => 'timeline',
- 'argument' => $this->group->nickname.'.atom')),
+ common_local_url('ApiTimelineGroup',
+ array('format' => 'atom',
+ 'id' => $this->group->nickname)),
sprintf(_('Notice feed for %s group (Atom)'),
$this->group->nickname)),
new Feed(Feed::FOAF,
diff --git a/actions/shownotice.php b/actions/shownotice.php
index 41408c23c..5d16fdad9 100644
--- a/actions/shownotice.php
+++ b/actions/shownotice.php
@@ -172,9 +172,9 @@ class ShownoticeAction extends OwnerDesignAction
function title()
{
if (!empty($this->profile->fullname)) {
- $base = $this->profile->fullname . ' (' . $this->user->nickname . ') ';
+ $base = $this->profile->fullname . ' (' . $this->profile->nickname . ') ';
} else {
- $base = $this->user->nickname;
+ $base = $this->profile->nickname;
}
return sprintf(_('%1$s\'s status on %2$s'),
diff --git a/actions/showstream.php b/actions/showstream.php
index b3a9b1f05..4f4806037 100644
--- a/actions/showstream.php
+++ b/actions/showstream.php
@@ -128,17 +128,17 @@ class ShowstreamAction extends ProfileAction
sprintf(_('Notice feed for %s (RSS 1.0)'),
$this->user->nickname)),
new Feed(Feed::RSS2,
- common_local_url('api',
- array('apiaction' => 'statuses',
- 'method' => 'user_timeline',
- 'argument' => $this->user->nickname.'.rss')),
+ common_local_url('ApiTimelineUser',
+ array(
+ 'id' => $this->user->nickname,
+ 'format' => 'rss')),
sprintf(_('Notice feed for %s (RSS 2.0)'),
$this->user->nickname)),
new Feed(Feed::ATOM,
- common_local_url('api',
- array('apiaction' => 'statuses',
- 'method' => 'user_timeline',
- 'argument' => $this->user->nickname.'.atom')),
+ common_local_url('ApiTimelineUser',
+ array(
+ 'id' => $this->user->nickname,
+ 'format' => 'atom')),
sprintf(_('Notice feed for %s (Atom)'),
$this->user->nickname)),
new Feed(Feed::FOAF,
@@ -348,6 +348,8 @@ class ShowstreamAction extends ProfileAction
{
if (Event::handle('StartProfilePageActionsSection', array(&$this, $this->profile))) {
+ $cur = common_current_user();
+
$this->elementStart('div', 'entity_actions');
$this->element('h2', null, _('User actions'));
$this->elementStart('ul');
@@ -379,21 +381,21 @@ class ShowstreamAction extends ProfileAction
}
$this->elementEnd('li');
- if ($cur->mutuallySubscribed($user)) {
+ if ($cur->mutuallySubscribed($this->user)) {
// message
$this->elementStart('li', 'entity_send-a-message');
- $this->element('a', array('href' => common_local_url('newmessage', array('to' => $user->id)),
+ $this->element('a', array('href' => common_local_url('newmessage', array('to' => $this->user->id)),
'title' => _('Send a direct message to this user')),
_('Message'));
$this->elementEnd('li');
// nudge
- if ($user->email && $user->emailnotifynudge) {
+ if ($this->user->email && $this->user->emailnotifynudge) {
$this->elementStart('li', 'entity_nudge');
- $nf = new NudgeForm($this, $user);
+ $nf = new NudgeForm($this, $this->user);
$nf->show();
$this->elementEnd('li');
}
diff --git a/actions/tag.php b/actions/tag.php
index f0ab30308..3a88c1229 100644
--- a/actions/tag.php
+++ b/actions/tag.php
@@ -86,17 +86,15 @@ class TagAction extends Action
sprintf(_('Notice feed for tag %s (RSS 1.0)'),
$this->tag)),
new Feed(Feed::RSS2,
- common_local_url('api',
- array('apiaction' => 'tags',
- 'method' => 'timeline',
- 'argument' => $this->tag.'.rss')),
- sprintf(_('Notice feed for %s group (RSS 2.0)'),
+ common_local_url('ApiTimelineTag',
+ array('format' => 'rss',
+ 'tag' => $this->tag)),
+ sprintf(_('Notice feed for tag %s (RSS 2.0)'),
$this->tag)),
new Feed(Feed::ATOM,
- common_local_url('api',
- array('apiaction' => 'tags',
- 'method' => 'timeline',
- 'argument' => $this->tag.'.atom')),
+ common_local_url('ApiTimelineTag',
+ array('format' => 'atom',
+ 'tag' => $this->tag)),
sprintf(_('Notice feed for tag %s (Atom)'),
$this->tag)));
}
diff --git a/actions/xrds.php b/actions/xrds.php
index 8ba89fec0..8f09557d1 100644
--- a/actions/xrds.php
+++ b/actions/xrds.php
@@ -36,6 +36,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
require_once INSTALLDIR.'/lib/omb.php';
require_once INSTALLDIR.'/extlib/libomb/service_provider.php';
require_once INSTALLDIR.'/extlib/libomb/xrds_mapper.php';
+require_once INSTALLDIR.'/lib/xrdsoutputter.php';
/**
* XRDS for OpenMicroBlogging
@@ -49,6 +50,8 @@ require_once INSTALLDIR.'/extlib/libomb/xrds_mapper.php';
*/
class XrdsAction extends Action
{
+ var $user;
+
/**
* Is read only?
*
@@ -58,60 +61,87 @@ class XrdsAction extends Action
{
return true;
}
-
- /**
- * Class handler.
- *
- * @param array $args query arguments
- *
- * @return void
- */
- function handle($args)
+
+ function prepare($args)
{
- parent::handle($args);
+ parent::prepare($args);
$nickname = $this->trimmed('nickname');
- $user = User::staticGet('nickname', $nickname);
- if (!$user) {
+ $this->user = User::staticGet('nickname', $nickname);
+ if (!$this->user) {
$this->clientError(_('No such user.'));
return;
}
- $this->showXrds($user);
+ return true;
}
/**
- * Show XRDS for a user.
+ * Class handler.
*
- * @param class $user XRDS for this user.
+ * @param array $args query arguments
*
* @return void
*/
- function showXrds($user)
+ function handle($args)
{
- $srv = new OMB_Service_Provider(profile_to_omb_profile($user->uri,
- $user->getProfile()));
- /* Use libomb’s default XRDS Writer. */
- $xrds_writer = null;
- $srv->writeXRDS(new Laconica_XRDS_Mapper(), $xrds_writer);
- }
-}
+ parent::handle($args);
+ $xrdsOutputter = new XRDSOutputter();
+ $xrdsOutputter->startXRDS();
-class Laconica_XRDS_Mapper implements OMB_XRDS_Mapper
-{
- protected $urls;
+ Event::handle('StartUserXRDS', array($this,&$xrdsOutputter));
- public function __construct()
- {
- $this->urls = array(
- OAUTH_ENDPOINT_REQUEST => 'requesttoken',
- OAUTH_ENDPOINT_AUTHORIZE => 'userauthorization',
- OAUTH_ENDPOINT_ACCESS => 'accesstoken',
- OMB_ENDPOINT_POSTNOTICE => 'postnotice',
- OMB_ENDPOINT_UPDATEPROFILE => 'updateprofile');
- }
+ //oauth
+ $xrdsOutputter->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
+ 'xml:id' => 'oauth',
+ 'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
+ 'version' => '2.0'));
+ $xrdsOutputter->element('Type', null, 'xri://$xrds*simple');
+ $xrdsOutputter->showXrdsService(OAUTH_ENDPOINT_REQUEST,
+ common_local_url('requesttoken'),
+ array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY, OAUTH_HMAC_SHA1));
+ $xrdsOutputter->showXrdsService( OAUTH_ENDPOINT_AUTHORIZE,
+ common_local_url('userauthorization'),
+ array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY, OAUTH_HMAC_SHA1),
+ null,
+ $this->user->getIdentifierURI());
+ $xrdsOutputter->showXrdsService(OAUTH_ENDPOINT_ACCESS,
+ common_local_url('accesstoken'),
+ array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY, OAUTH_HMAC_SHA1),
+ null,
+ $this->user->getIdentifierURI());
+ $xrdsOutputter->showXrdsService(OAUTH_ENDPOINT_RESOURCE,
+ null,
+ array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY, OAUTH_HMAC_SHA1),
+ null,
+ $this->user->getIdentifierURI());
+ $xrdsOutputter->elementEnd('XRD');
+
+ //omb
+ $xrdsOutputter->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
+ 'xml:id' => 'oauth',
+ 'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
+ 'version' => '2.0'));
+ $xrdsOutputter->element('Type', null, 'xri://$xrds*simple');
+ $xrdsOutputter->showXrdsService(OMB_ENDPOINT_POSTNOTICE,
+ common_local_url('postnotice'));
+ $xrdsOutputter->showXrdsService(OMB_ENDPOINT_UPDATEPROFILE,
+ common_local_url('updateprofile'));
+ $xrdsOutputter->elementEnd('XRD');
+
+ //misc
+ $xrdsOutputter->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
+ 'xml:id' => 'oauth',
+ 'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
+ 'version' => '2.0'));
+ $xrdsOutputter->showXrdsService(OAUTH_DISCOVERY,
+ '#oauth');
+ $xrdsOutputter->showXrdsService(OMB_VERSION,
+ '#omb');
+ $xrdsOutputter->elementEnd('XRD');
- public function getURL($action)
- {
- return common_local_url($this->urls[$action]);
+ Event::handle('EndUserXRDS', array($this,&$xrdsOutputter));
+
+ $xrdsOutputter->endXRDS();
+
}
}
?>