summaryrefslogtreecommitdiff
path: root/actions/newnotice.php
diff options
context:
space:
mode:
authorZach Copley <zach@controlyourself.ca>2009-06-26 18:32:18 -0700
committerZach Copley <zach@controlyourself.ca>2009-06-26 18:32:18 -0700
commita68722c9c75cd9dc8ed84e186f3b4ecc5556b1a3 (patch)
tree564b804360160c908fe6c4469824f1ee9c194b25 /actions/newnotice.php
parent60b47d879781e28c0f08978bba43d5b9ad22b32a (diff)
parent96ba25c34bc03c5b72c13241a00e467a0585cd2a (diff)
Merge branch 'attachment-fixup' into 0.8.x
* attachment-fixup: Added readonly flag to FileAction just in case Make shorturls in notice content point to AttachmentAction urls Add attachment action back into router
Diffstat (limited to 'actions/newnotice.php')
-rw-r--r--actions/newnotice.php26
1 files changed, 20 insertions, 6 deletions
diff --git a/actions/newnotice.php b/actions/newnotice.php
index 15caff6ea..5f44a32a9 100644
--- a/actions/newnotice.php
+++ b/actions/newnotice.php
@@ -229,14 +229,25 @@ class NewnoticeAction extends Action
if (empty($filename)) {
$this->clientError(_('Couldn\'t save file.'));
}
- $fileurl = File::url($filename);
+
+ $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);
$content_shortened .= ' ' . $short_fileurl;
+
if (mb_strlen($content_shortened) > 140) {
$this->deleteFile($filename);
$this->clientError(_('Max notice size is 140 chars, including attachment URL.'));
}
- $fileRecord = $this->rememberFile($filename, $mimetype, $short_fileurl);
+
+ // Also, not sure this is necessary -- Zach
+ $this->maybeAddRedir($fileRecord->id, $short_fileurl);
}
$notice = Notice::saveNew($user->id, $content_shortened, 'web', 1,
@@ -305,8 +316,8 @@ class NewnoticeAction extends Action
@unlink($filepath);
}
- function rememberFile($filename, $mimetype, $short)
- {
+ function storeFile($filename, $mimetype) {
+
$file = new File;
$file->filename = $filename;
@@ -325,11 +336,14 @@ class NewnoticeAction extends Action
$this->clientError(_('There was a database error while saving your file. Please try again.'));
}
- $this->maybeAddRedir($file_id, $short);
-
return $file;
}
+ function rememberFile($file, $short)
+ {
+ $this->maybeAddRedir($file->id, $short);
+ }
+
function maybeAddRedir($file_id, $url)
{
$file_redir = File_redirection::staticGet('url', $url);