aboutsummaryrefslogtreecommitdiff
path: root/lib/cronjobs/send_mail_queue.php
blob: f9cdd941c5186c55da77cb23d65285d4f7bb184a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/**
* send_mail_queue.php
*
* @author Rasmus Fuhse <fuhse@data-quest.de>, Suchi & Berg GmbH <info@data-quest.de>
* @access public
* @since  3.0
*/

/**
 * Cronjob class to send the mailqueue each interval.
 */
class SendMailQueueJob extends CronJob
{

    /**
     * Returns the name of the cronjob.
     * @return string : name of the cronjob
     */
    public static function getName()
    {
        return _('Mailqueue senden');
    }

    /**
     * Returns the description of the cronjob.
     * @return string : description of the cronjob.
     */
    public static function getDescription()
    {
        return _('Sendet alle Einträge in der Mailqueue bis zu 24 Stunden, nachdem sie hinzugefügt wurden.');
    }

    /**
     * Sends all mails in the queue.
     * @param integer $last_result : not evaluated for execution, so any integer
     * will do. Usually it would be a unix-timestamp of last execution. But in
     * this case we don't care at all.
     * @param array $parameters : not needed here
     */
    public function execute($last_result, $parameters = [])
    {
        $status_messages = MailQueueEntry::sendAll(
            Config::get()->MAILQUEUE_SEND_LIMIT,
            (bool)$parameters['verbose']
        );

        //We output one status message per line:
        echo implode("\n", $status_messages);
    }

    /**
     * Returns a list of available parameters for this cronjob.
     * See the description in the CronJob class for a specification
     * for the returned array.
     *
     * @return array A list of available parameters for this cronjob.
     */
    public static function getParameters()
    {
        return [
            'verbose' => [
                'type'        => 'boolean',
                'default'     => false,
                'status'      => 'optional',
                'description' => _('Sollen Ausgaben erzeugt werden? Diese sind später im Log des Cronjobs sichtbar.'),
            ],
        ];
    }
}