xref: /dokuwiki/inc/Subscriptions/MediaSubscriptionSender.php (revision 83734cddc910b198a1a199d89dad99d7831c1590)
1704a815fSMichael Große<?php
2704a815fSMichael Große
3704a815fSMichael Große
4704a815fSMichael Großenamespace dokuwiki\Subscriptions;
5704a815fSMichael Große
6704a815fSMichael Große
7704a815fSMichael Großeclass MediaSubscriptionSender extends SubscriptionSender
8704a815fSMichael Große{
9704a815fSMichael Große
10704a815fSMichael Große    /**
11704a815fSMichael Große     * Send the diff for some media change
12704a815fSMichael Große     *
13704a815fSMichael Große     * @fixme this should embed thumbnails of images in HTML version
14704a815fSMichael Große     *
15704a815fSMichael Große     * @param string   $subscriber_mail The target mail address
16704a815fSMichael Große     * @param string   $template        Mail template ('uploadmail', ...)
17704a815fSMichael Große     * @param string   $id              Media file for which the notification is
18704a815fSMichael Große     * @param int|bool $rev             Old revision if any
19*83734cddSPhy     * @param int|bool $current_rev     New revision if any
20704a815fSMichael Große     */
21*83734cddSPhy    public function sendMediaDiff($subscriber_mail, $template, $id, $rev = false, $current_rev = false)
22704a815fSMichael Große    {
23704a815fSMichael Große        global $conf;
24704a815fSMichael Große
25704a815fSMichael Große        $file = mediaFN($id);
26704a815fSMichael Große        list($mime, /* $ext */) = mimetype($id);
27704a815fSMichael Große
28704a815fSMichael Große        $trep = [
29704a815fSMichael Große            'MIME' => $mime,
30*83734cddSPhy            'MEDIA' => ml($id, $current_rev?('rev='.$current_rev):'', true, '&', true),
31704a815fSMichael Große            'SIZE' => filesize_h(filesize($file)),
32704a815fSMichael Große        ];
33704a815fSMichael Große
34704a815fSMichael Große        if ($rev && $conf['mediarevisions']) {
35704a815fSMichael Große            $trep['OLD'] = ml($id, "rev=$rev", true, '&', true);
36704a815fSMichael Große        } else {
37704a815fSMichael Große            $trep['OLD'] = '---';
38704a815fSMichael Große        }
39704a815fSMichael Große
40704a815fSMichael Große        $headers = ['Message-Id' => $this->getMessageID($id, @filemtime($file))];
41704a815fSMichael Große        if ($rev) {
42704a815fSMichael Große            $headers['In-Reply-To'] = $this->getMessageID($id, $rev);
43704a815fSMichael Große        }
44704a815fSMichael Große
45704a815fSMichael Große        $this->send($subscriber_mail, 'upload', $id, $template, $trep, null, $headers);
46704a815fSMichael Große    }
47704a815fSMichael Große}
48