summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorMichael Hamann <michael@content-space.de>2013-01-26 15:10:52 +0100
committerMichael Hamann <michael@content-space.de>2013-01-26 16:18:26 +0100
commitb5460ee2c820d95f75fd47d2f8bcbe5dddc21e7e (patch)
treeac9b804add1d9097f0323f3a54632203adfb828e /inc
parent10eac6731852014bcef1a0d16c59a4f6f77d8e31 (diff)
downloadrpg-b5460ee2c820d95f75fd47d2f8bcbe5dddc21e7e.tar.gz
rpg-b5460ee2c820d95f75fd47d2f8bcbe5dddc21e7e.tar.bz2
Implement media subscriptions in the new subscription class
Diffstat (limited to 'inc')
-rw-r--r--inc/media.php23
-rw-r--r--inc/subscription.php37
2 files changed, 39 insertions, 21 deletions
diff --git a/inc/media.php b/inc/media.php
index 6335bf210..572b1177c 100644
--- a/inc/media.php
+++ b/inc/media.php
@@ -535,32 +535,13 @@ function media_contentcheck($file,$mime){
* Send a notify mail on uploads
*
* @author Andreas Gohr <andi@splitbrain.org>
- * @fixme this should embed thumbnails of images in HTML version
*/
function media_notify($id,$file,$mime,$old_rev=false){
- global $lang;
global $conf;
- global $INFO;
if(empty($conf['notify'])) return; //notify enabled?
- $text = rawLocale('uploadmail');
- $trep = array(
- 'MIME' => $mime,
- 'MEDIA' => ml($id,'',true,'&',true),
- 'SIZE' => filesize_h(filesize($file)),
- );
-
- if ($old_rev && $conf['mediarevisions']) {
- $trep['OLD'] = ml($id, "rev=$old_rev", true, '&', true);
- } else {
- $trep['OLD'] = '---';
- }
-
- $mail = new Mailer();
- $mail->to($conf['notify']);
- $mail->subject($lang['mail_upload'].' '.$id);
- $mail->setBody($text,$trep);
- return $mail->send();
+ $subscription = new Subscription();
+ return $subscription->send_media_diff($conf['notify'], 'uploadmail', $id, $old_rev, '');
}
/**
diff --git a/inc/subscription.php b/inc/subscription.php
index 31e3e08e1..2989de032 100644
--- a/inc/subscription.php
+++ b/inc/subscription.php
@@ -436,6 +436,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
*
* @author Andreas Gohr <andi@splitbrain.org>