From b5460ee2c820d95f75fd47d2f8bcbe5dddc21e7e Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sat, 26 Jan 2013 15:10:52 +0100 Subject: Implement media subscriptions in the new subscription class --- inc/subscription.php | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'inc/subscription.php') diff --git a/inc/subscription.php b/inc/subscription.php index 31e3e08e1..2989de032 100644 --- a/inc/subscription.php +++ b/inc/subscription.php @@ -435,6 +435,43 @@ class Subscription { ); } + /** + * Send the diff for some media change + * + * @fixme this should embed thumbnails of images in HTML version + * @param string $subscriber_mail The target mail address + * @param string $template Mail template ('uploadmail', ...) + * @param string $id Media file for which the notification is + * @param int|bool $rev Old revision if any + * @return bool true if successfully sent + */ + public function send_media_diff($subscriber_mail, $template, $id, $rev = false) { + global $conf; + + $file = mediaFN($id); + list($mime, $ext) = mimetype($id); + + $trep = array( + 'MIME' => $mime, + 'MEDIA' => ml($id,'',true,'&',true), + 'SIZE' => filesize_h(filesize($file)), + ); + + if ($rev && $conf['mediarevisions']) { + $trep['OLD'] = ml($id, "rev=$rev", true, '&', true); + } else { + $trep['OLD'] = '---'; + } + + $headers = array('Message-Id' => $this->getMessageID($id, @filemtime($file))); + if ($rev) { + $headers['In-Reply-To'] = $this->getMessageID($id, $rev); + } + + $this->send($subscriber_mail, 'upload', $id, $template, $trep, null, $headers); + + } + /** * Send a notify mail on new registration * -- cgit v1.2.3