summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
Diffstat (limited to 'actions')
-rw-r--r--actions/conversation.php12
-rw-r--r--actions/file.php44
-rw-r--r--actions/groupdesignsettings.php2
-rw-r--r--actions/newnotice.php46
-rw-r--r--actions/public.php8
-rw-r--r--actions/showfavorites.php17
-rw-r--r--actions/twitapifavorites.php6
-rw-r--r--actions/twitapistatuses.php11
-rw-r--r--actions/userdesignsettings.php2
9 files changed, 97 insertions, 51 deletions
diff --git a/actions/conversation.php b/actions/conversation.php
index d3fc5b6a9..654a670f5 100644
--- a/actions/conversation.php
+++ b/actions/conversation.php
@@ -63,6 +63,7 @@ class ConversationAction extends Action
if (empty($this->id)) {
return false;
}
+ $this->id = $this->id+0;
$this->page = $this->trimmed('page');
if (empty($this->page)) {
$this->page = 1;
@@ -106,18 +107,10 @@ class ConversationAction extends Action
function showContent()
{
- // FIXME this needs to be a tree, not a list
-
- $qry = 'SELECT * FROM notice WHERE conversation = %s ';
-
$offset = ($this->page-1) * NOTICES_PER_PAGE;
$limit = NOTICES_PER_PAGE + 1;
- $txt = sprintf($qry, $this->id);
-
- $notices = Notice::getStream($txt,
- 'notice:conversation:'.$this->id,
- $offset, $limit);
+ $notices = Notice::conversationStream($this->id, $offset, $limit);
$ct = new ConversationTree($notices, $this);
@@ -126,7 +119,6 @@ class ConversationAction extends Action
$this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
$this->page, 'conversation', array('id' => $this->id));
}
-
}
/**
diff --git a/actions/file.php b/actions/file.php
index bb245c4a7..271f57ab9 100644
--- a/actions/file.php
+++ b/actions/file.php
@@ -21,20 +21,40 @@ if (!defined('LACONICA')) { exit(1); }
require_once(INSTALLDIR.'/actions/shownotice.php');
-class FileAction extends ShowNoticeAction
+class FileAction extends Action
{
- function showPage() {
- $source_url = common_local_url('file', array('notice' => $this->notice->id));
- $query = "select file_redirection.url as url from file join file_redirection on file.id = file_redirection.file_id where file.url = '$source_url'";
- $file = new File_redirection;
- $file->query($query);
- $file->fetch();
- if (empty($file->url)) {
- die('nothing attached here');
- } else {
- header("Location: {$file->url}");
- die();
+ var $id = null;
+ var $filerec = null;
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+ $this->id = $this->trimmed('notice');
+ if (empty($this->id)) {
+ $this->clientError(_('No notice id'));
+ }
+ $notice = Notice::staticGet('id', $this->id);
+ if (empty($notice)) {
+ $this->clientError(_('No notice'));
+ }
+ $atts = $notice->attachments();
+ if (empty($atts)) {
+ $this->clientError(_('No attachments'));
+ }
+ foreach ($atts as $att) {
+ if (!empty($att->filename)) {
+ $this->filerec = $att;
+ break;
+ }
}
+ if (empty($this->filerec)) {
+ $this->clientError(_('No uploaded attachments'));
+ }
+ return true;
+ }
+
+ function handle() {
+ common_redirect($this->filerec->url);
}
}
diff --git a/actions/groupdesignsettings.php b/actions/groupdesignsettings.php
index 7270bc8f7..79c192ac4 100644
--- a/actions/groupdesignsettings.php
+++ b/actions/groupdesignsettings.php
@@ -238,7 +238,6 @@ class GroupDesignSettingsAction extends DesignSettingsAction
$design->sidebarcolor = $sbcolor->intValue();
$design->textcolor = $tcolor->intValue();
$design->linkcolor = $lcolor->intValue();
- $design->backgroundimage = $filepath;
$design->setDisposition($on, $off, $tile);
@@ -263,7 +262,6 @@ class GroupDesignSettingsAction extends DesignSettingsAction
$design->sidebarcolor = $sbcolor->intValue();
$design->textcolor = $tcolor->intValue();
$design->linkcolor = $lcolor->intValue();
- $design->backgroundimage = $filepath;
$design->setDisposition($on, $off, $tile);
diff --git a/actions/newnotice.php b/actions/newnotice.php
index 4a2c369f0..15caff6ea 100644
--- a/actions/newnotice.php
+++ b/actions/newnotice.php
@@ -236,6 +236,7 @@ class NewnoticeAction extends Action
$this->deleteFile($filename);
$this->clientError(_('Max notice size is 140 chars, including attachment URL.'));
}
+ $fileRecord = $this->rememberFile($filename, $mimetype, $short_fileurl);
}
$notice = Notice::saveNew($user->id, $content_shortened, 'web', 1,
@@ -249,7 +250,7 @@ class NewnoticeAction extends Action
}
if (isset($mimetype)) {
- $this->attachFile($notice, $filename, $mimetype, $short_fileurl);
+ $this->attachFile($notice, $fileRecord);
}
common_broadcast_notice($notice);
@@ -304,12 +305,12 @@ class NewnoticeAction extends Action
@unlink($filepath);
}
- function attachFile($notice, $filename, $mimetype, $short)
+ function rememberFile($filename, $mimetype, $short)
{
$file = new File;
$file->filename = $filename;
- $file->url = common_local_url('file', array('notice' => $notice->id));
+ $file->url = File::url($filename);
$filepath = File::path($filename);
@@ -324,28 +325,37 @@ class NewnoticeAction extends Action
$this->clientError(_('There was a database error while saving your file. Please try again.'));
}
- $file_redir = new File_redirection;
- $file_redir->url = File::url($filename);
- $file_redir->file_id = $file_id;
+ $this->maybeAddRedir($file_id, $short);
- $result = $file_redir->insert();
+ return $file;
+ }
- 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 maybeAddRedir($file_id, $url)
+ {
+ $file_redir = File_redirection::staticGet('url', $url);
- $f2p = new File_to_post;
- $f2p->file_id = $file_id;
- $f2p->post_id = $notice->id;
- $f2p->insert();
+ if (empty($file_redir)) {
+ $file_redir = new File_redirection;
+ $file_redir->url = $url;
+ $file_redir->file_id = $file_id;
- if (!$result) {
- common_log_db_error($f2p, "INSERT", __FILE__);
- $this->clientError(_('There was a database error while saving your file. Please try again.'));
+ $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/public.php b/actions/public.php
index 27153f131..9851285c4 100644
--- a/actions/public.php
+++ b/actions/public.php
@@ -35,6 +35,10 @@ require_once INSTALLDIR.'/lib/publicgroupnav.php';
require_once INSTALLDIR.'/lib/noticelist.php';
require_once INSTALLDIR.'/lib/feedlist.php';
+// Farther than any human will go
+
+define('MAX_PUBLIC_PAGE', 100);
+
/**
* Action for displaying the public stream
*
@@ -74,6 +78,10 @@ class PublicAction extends Action
parent::prepare($args);
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
+ if ($this->page > MAX_PUBLIC_PAGE) {
+ $this->clientError(sprintf(_("Beyond the page limit (%s)"), MAX_PUBLIC_PAGE));
+ }
+
common_set_returnto($this->selfUrl());
return true;
diff --git a/actions/showfavorites.php b/actions/showfavorites.php
index 01f38a892..b723924a5 100644
--- a/actions/showfavorites.php
+++ b/actions/showfavorites.php
@@ -191,10 +191,21 @@ class ShowfavoritesAction extends CurrentUserDesignAction
function showContent()
{
- $notice = $this->user->favoriteNotices(($this->page-1)*NOTICES_PER_PAGE,
- NOTICES_PER_PAGE + 1);
+ $cur = common_current_user();
- if (!$notice) {
+ 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;
}
diff --git a/actions/twitapifavorites.php b/actions/twitapifavorites.php
index e40fea91a..8256668f3 100644
--- a/actions/twitapifavorites.php
+++ b/actions/twitapifavorites.php
@@ -61,7 +61,11 @@ class TwitapifavoritesAction extends TwitterapiAction
$since_id = (int)$this->arg('since_id', 0);
$since = $this->arg('since');
- $notice = $user->favoriteNotices(($page-1)*$count, $count);
+ if (!empty($this->auth_user) && $this->auth_user->id == $user->id) {
+ $notice = $user->favoriteNotices(($page-1)*$count, $count, true);
+ } else {
+ $notice = $user->favoriteNotices(($page-1)*$count, $count, false);
+ }
switch($apidata['content-type']) {
case 'xml':
diff --git a/actions/twitapistatuses.php b/actions/twitapistatuses.php
index 2bc404063..555c746cb 100644
--- a/actions/twitapistatuses.php
+++ b/actions/twitapistatuses.php
@@ -75,8 +75,8 @@ class TwitapistatusesAction extends TwitterapiAction
{
parent::handle($args);
+ $this->auth_user = $apidata['user'];
$user = $this->get_user($apidata['api_arg'], $apidata);
- $this->auth_user = $user;
if (empty($user)) {
$this->clientError(_('No such user!'), 404,
@@ -100,8 +100,13 @@ class TwitapistatusesAction extends TwitterapiAction
$since_id = (int)$this->arg('since_id', 0);
$since = $this->arg('since');
- $notice = $user->noticesWithFriends(($page-1)*$count,
- $count, $since_id, $max_id,$since);
+ if (!empty($this->auth_user) && $this->auth_user->id == $user->id) {
+ $notice = $user->noticeInbox(($page-1)*$count,
+ $count, $since_id, $max_id, $since);
+ } else {
+ $notice = $user->noticesWithFriends(($page-1)*$count,
+ $count, $since_id, $max_id, $since);
+ }
switch($apidata['content-type']) {
case 'xml':
diff --git a/actions/userdesignsettings.php b/actions/userdesignsettings.php
index d6088aa9d..6e745e96f 100644
--- a/actions/userdesignsettings.php
+++ b/actions/userdesignsettings.php
@@ -149,7 +149,6 @@ class UserDesignSettingsAction extends DesignSettingsAction
$design->sidebarcolor = $sbcolor->intValue();
$design->textcolor = $tcolor->intValue();
$design->linkcolor = $lcolor->intValue();
- $design->backgroundimage = $filepath;
$design->setDisposition($on, $off, $tile);
@@ -174,7 +173,6 @@ class UserDesignSettingsAction extends DesignSettingsAction
$design->sidebarcolor = $sbcolor->intValue();
$design->textcolor = $tcolor->intValue();
$design->linkcolor = $lcolor->intValue();
- $design->backgroundimage = $filepath;
$design->setDisposition($on, $off, $tile);