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