MediaSubscriptionSender.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace dokuwiki\Subscriptions;
  3. class MediaSubscriptionSender extends SubscriptionSender
  4. {
  5. /**
  6. * Send the diff for some media change
  7. *
  8. * @fixme this should embed thumbnails of images in HTML version
  9. *
  10. * @param string $subscriber_mail The target mail address
  11. * @param string $template Mail template ('uploadmail', ...)
  12. * @param string $id Media file for which the notification is
  13. * @param int|bool $rev Old revision if any
  14. * @param int|bool $current_rev New revision if any
  15. */
  16. public function sendMediaDiff($subscriber_mail, $template, $id, $rev = false, $current_rev = false)
  17. {
  18. global $conf;
  19. $file = mediaFN($id);
  20. list($mime, /* $ext */) = mimetype($id);
  21. $trep = [
  22. 'MIME' => $mime,
  23. 'MEDIA' => ml($id, $current_rev?('rev='.$current_rev):'', true, '&', true),
  24. 'SIZE' => filesize_h(filesize($file)),
  25. ];
  26. if ($rev && $conf['mediarevisions']) {
  27. $trep['OLD'] = ml($id, "rev=$rev", true, '&', true);
  28. } else {
  29. $trep['OLD'] = '---';
  30. }
  31. $headers = ['Message-Id' => $this->getMessageID($id, @filemtime($file))];
  32. if ($rev) {
  33. $headers['In-Reply-To'] = $this->getMessageID($id, $rev);
  34. }
  35. $this->send($subscriber_mail, 'upload', $id, $template, $trep, null, $headers);
  36. }
  37. }