Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 15... Línea 15...
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
Línea 16... Línea 16...
16
 
16
 
Línea 17... Línea 17...
17
namespace core\task;
17
namespace core\task;
-
 
18
 
18
 
19
use core\hook\task\after_failed_task_max_delay;
19
use core\hook\task\after_failed_task_max_delay;
20
use core\url;
Línea 20... Línea 21...
20
use core_user;
21
use core_user;
21
use stdClass;
22
use stdClass;
Línea 37... Línea 38...
37
     */
38
     */
38
    public static function send_failed_task_max_delay_message(after_failed_task_max_delay $hook): void {
39
    public static function send_failed_task_max_delay_message(after_failed_task_max_delay $hook): void {
39
        $task = $hook->get_task();
40
        $task = $hook->get_task();
Línea 40... Línea 41...
40
 
41
 
41
        $admins = get_admins();
-
 
42
        if (empty($admins)) {
-
 
43
            return;
-
 
44
        }
42
        $admins = get_admins();
-
 
43
        foreach ($admins as $admin) {
-
 
44
            $tasklogslink = new url('/admin/tasklogs.php', ['filter' => get_class($task)]);
45
        foreach ($admins as $admin) {
45
 
46
            $a = new stdClass();
46
            $a = new stdClass();
47
            $a->firstname = $admin->firstname;
47
            $a->firstname = $admin->firstname;
48
            $a->taskname = $task->get_name();
48
            $a->taskname = $task->get_name();
49
            $a->link = new \moodle_url('/report/status/index.php', ['detail' => 'tool_task_maxfaildelay']);
49
            $a->link = $tasklogslink->out(false);
50
            $messagetxt = get_string('failedtaskbody', 'moodle', $a);
50
            $messagetxt = get_string('failedtaskbody', 'moodle', $a);
51
            // Create message.
51
            // Create message.
52
            $message = new \core\message\message();
52
            $message = new \core\message\message();
53
            $message->component = 'moodle';
53
            $message->component = 'moodle';
Línea 58... Línea 58...
58
            $message->fullmessage = html_to_text($messagetxt);
58
            $message->fullmessage = html_to_text($messagetxt);
59
            $message->fullmessageformat = FORMAT_MARKDOWN;
59
            $message->fullmessageformat = FORMAT_MARKDOWN;
60
            $message->fullmessagehtml = text_to_html($messagetxt);
60
            $message->fullmessagehtml = text_to_html($messagetxt);
61
            $message->smallmessage = get_string('failedtasksubject', 'moodle', $task->get_name());
61
            $message->smallmessage = get_string('failedtasksubject', 'moodle', $task->get_name());
62
            $message->notification = 1;
62
            $message->notification = 1;
63
            $message->contexturl = (
63
            $message->contexturl = $tasklogslink->out(false);
64
                new \moodle_url('/report/status/index.php', ['detail' => 'tool_task_maxfaildelay']))->out(false);
-
 
65
            $message->contexturlname = get_string('failedtaskcontexturlname', 'moodle');
64
            $message->contexturlname = get_string('tasklogs', 'admin');
66
            // Actually send the message.
65
            // Actually send the message.
67
            message_send($message);
66
            message_send($message);
68
        }
67
        }
69
    }
68
    }
70
}
69
}