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