summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2009-08-27 20:09:07 -0700
committerEvan Prodromou <evan@status.net>2009-08-27 20:09:07 -0700
commit34ce75c71d37754fa941233c805c042a47910184 (patch)
tree7f83c9aec038916b2ce13ae3458293f33b6a02bb
parent0056b635c661c4aaf6bce08795af925388e35f5c (diff)
remove duplicate save of Notice and streamline attachment detection
-rw-r--r--classes/Notice.php13
-rw-r--r--lib/util.php41
2 files changed, 13 insertions, 41 deletions
diff --git a/classes/Notice.php b/classes/Notice.php
index e59712864..28d5b8ddf 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -58,7 +58,7 @@ class Notice extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
- /* Notice types */
+ /* Notice types */
const LOCAL_PUBLIC = 1;
const REMOTE_OMB = 0;
const LOCAL_NONPUBLIC = -1;
@@ -248,17 +248,6 @@ class Notice extends Memcached_DataObject
$notice->saveUrls();
- // FIXME: why do we have to re-render the content?
- // Remove this if it's not necessary.
-
- $orig2 = clone($notice);
-
- $notice->rendered = common_render_content($final, $notice);
- if (!$notice->update($orig2)) {
- common_log_db_error($notice, 'UPDATE', __FILE__);
- return _('Problem saving notice.');
- }
-
$notice->query('COMMIT');
Event::handle('EndNoticeSave', array($notice));
diff --git a/lib/util.php b/lib/util.php
index 79a219fd6..070b4232c 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -542,8 +542,7 @@ function common_linkify($url) {
$attachment_id = null;
$has_thumb = false;
- // Check to see whether there's a filename associated with this URL.
- // If there is, it's an upload and qualifies as an attachment
+ // Check to see whether this is a known "attachment" URL.
$localfile = File::staticGet('url', $longurl);
@@ -551,33 +550,17 @@ function common_linkify($url) {
if (isset($localfile->filename)) {
$is_attachment = true;
$attachment_id = $localfile->id;
- }
- }
-
- // if this URL is an attachment, then we set class='attachment' and id='attahcment-ID'
- // where ID is the id of the attachment for the given URL.
- //
- // we need a better test telling what can be shown as an attachment
- // we're currently picking up oembeds only.
- // I think the best option is another file_view table in the db
- // and associated dbobject.
-
- $query = "select file_oembed.file_id as file_id from file join file_oembed on file.id = file_oembed.file_id where file.url='$longurl'";
- $file = new File;
- $file->query($query);
- $file->fetch();
-
- if (!empty($file->file_id)) {
- $is_attachment = true;
- $attachment_id = $file->file_id;
-
- $query = "select file_thumbnail.file_id as file_id from file join file_thumbnail on file.id = file_thumbnail.file_id where file.url='$longurl'";
- $file2 = new File;
- $file2->query($query);
- $file2->fetch();
-
- if (!empty($file2)) {
- $has_thumb = true;
+ } else { // if it has OEmbed info, it's an attachment, too
+ $foe = File_oembed::staticGet('file_id', $localfile->id);
+ if (!empty($foe)) {
+ $is_attachment = true;
+ $attachment_id = $localfile->id;
+
+ $thumb = File_thumbnail::staticGet('file_id', $localfile->id);
+ if (!empty($thumb)) {
+ $has_thumb = true;
+ }
+ }
}
}