summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorRobin Millette <millette@controlyourself.ca>2009-05-15 15:04:58 -0400
committerRobin Millette <millette@controlyourself.ca>2009-05-15 15:04:58 -0400
commitfecb8c706dadb790c3a8c219275b4ba88e00b8ea (patch)
tree674650bcdc21627aedb97250426a554c85eca096 /classes
parent2e394ef47ce2f069e331c24586cda13bc34413aa (diff)
Attachments and their list now provide "ajax" view. Also added a few sidebars relating tags and attachments.
Diffstat (limited to 'classes')
-rw-r--r--classes/File.php11
-rw-r--r--classes/File_oembed.php11
-rw-r--r--classes/File_thumbnail.php10
-rw-r--r--classes/Notice.php12
4 files changed, 32 insertions, 12 deletions
diff --git a/classes/File.php b/classes/File.php
index 2ddc5deb8..e5913115b 100644
--- a/classes/File.php
+++ b/classes/File.php
@@ -54,6 +54,17 @@ class File extends Memcached_DataObject
return 'http://www.facebook.com/login.php' === $url;
}
+ function getAttachments($post_id) {
+ $query = "select file.* from file join file_to_post on (file_id = file.id) join notice on (post_id = notice.id) where post_id = " . $this->escape($post_id);
+ $this->query($query);
+ $att = array();
+ while ($this->fetch()) {
+ $att[] = clone($this);
+ }
+ $this->free();
+ return $att;
+ }
+
function saveNew($redir_data, $given_url) {
$x = new File;
$x->url = $given_url;
diff --git a/classes/File_oembed.php b/classes/File_oembed.php
index 2846f49db..f1b2cb13c 100644
--- a/classes/File_oembed.php
+++ b/classes/File_oembed.php
@@ -78,18 +78,9 @@ class File_oembed extends Memcached_DataObject
if (!empty($data['author_url'])) $file_oembed->author_url = $data['author_url'];
if (!empty($data['url'])) $file_oembed->url = $data['url'];
$file_oembed->insert();
-
if (!empty($data['thumbnail_url'])) {
- $tn = new File_thumbnail;
- $tn->file_id = $file_id;
- $tn->url = $data['thumbnail_url'];
- $tn->width = intval($data['thumbnail_width']);
- $tn->height = intval($data['thumbnail_height']);
- $tn->insert();
+ File_thumbnail::saveNew($data, $file_id);
}
-
-
-
}
}
diff --git a/classes/File_thumbnail.php b/classes/File_thumbnail.php
index 7b906a07c..1a65b92c9 100644
--- a/classes/File_thumbnail.php
+++ b/classes/File_thumbnail.php
@@ -42,4 +42,14 @@ class File_thumbnail extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
+
+ function saveNew($data, $file_id) {
+ $tn = new File_thumbnail;
+ $tn->file_id = $file_id;
+ $tn->url = $data['thumbnail_url'];
+ $tn->width = intval($data['thumbnail_width']);
+ $tn->height = intval($data['thumbnail_height']);
+ $tn->insert();
+ }
}
+
diff --git a/classes/Notice.php b/classes/Notice.php
index c2fa2d19e..30508070e 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -124,8 +124,6 @@ class Notice extends Memcached_DataObject
$profile = Profile::staticGet($profile_id);
-// $final = common_shorten_links($content);
-
if (!$profile) {
common_log(LOG_ERR, 'Problem saving notice. Unknown user.');
return _('Problem saving notice. Unknown user.');
@@ -279,6 +277,16 @@ class Notice extends Memcached_DataObject
return true;
}
+ function hasAttachments() {
+ $post = clone($this);
+ $query = "select count(file_id) as n_attachments from file join file_to_post on (file_id = file.id) join notice on (post_id = notice.id) where post_id = " . $post->escape($this->id);
+ $post->query($query);
+ $post->fetch();
+ $n_attachments = intval($post->n_attachments);
+ $post->free();
+ return $n_attachments;
+ }
+
function blowCaches($blowLast=false)
{
$this->blowSubsCache($blowLast);