* dropped unnecessary join on notice table
* made the function actually static, since it makes no sense as an instance variable. The only caller (in AttachmentList) is updated.
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);
+ /**
+ * Get the attachments for a particlar notice.
+ *
+ * @param int $post_id
+ * @return array of File objects
+ */
+ static function getAttachments($post_id) {
+ $file = new File();
+ $query = "select file.* from file join file_to_post on (file_id = file.id) where post_id = " . $file->escape($post_id);
+ $file = Memcached_DataObject::cachedQuery('File', $query);
$att = array();
- while ($this->fetch()) {
- $att[] = clone($this);
+ while ($file->fetch()) {
+ $att[] = clone($file);
}
- $this->free();
return $att;
}
*/
function show()
{
- $atts = new File;
- $att = $atts->getAttachments($this->notice->id);
+ $att = File::getAttachments($this->notice->id);
if (empty($att)) return 0;
$this->showListStart();