Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
namespace factor_sms\task;
18
 
19
use core\task\adhoc_task;
20
use moodle_url;
21
 
22
/**
23
 * Notification for admins to notify about the migration of SMS setup from MFA to SMS gateway plugins.
24
 *
25
 * @package    factor_sms
26
 * @copyright  2024 Safat Shahin <safat.shahin@moodle.com>
27
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28
 */
29
class sms_gateway_migration_notification extends adhoc_task {
30
 
31
    public function execute(): void {
32
 
33
        $siteadmins = get_admins();
34
        foreach ($siteadmins as $siteadmin) {
35
            $smsconfigureurl = new moodle_url('/sms/sms_gateways.php');
36
            $messagebody = get_string('notification:smsgatewaymigrationinfo', 'factor_sms', $smsconfigureurl);
37
            $messagesubject = get_string('notification:smsgatewaymigration', 'factor_sms');
38
 
39
            $message = new \core\message\message();
40
            $message->component = 'moodle';
41
            $message->name = 'notices';
42
            $message->userfrom = \core_user::get_noreply_user();
43
            $message->subject = $messagesubject;
44
            $message->fullmessageformat = FORMAT_HTML;
45
            $message->notification = 1;
46
            $message->userto = $siteadmin;
47
            $message->smallmessage = $messagesubject;
48
            $message->fullmessagehtml = $messagebody;
49
            $message->fullmessage = html_to_text($messagebody);
50
            $message->contexturl = $smsconfigureurl;
51
            $message->contexturlname = $messagesubject;
52
 
53
            // Send message.
54
            message_send($message);
55
        }
56
    }
57
}