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