1 |
efrain |
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 |
/**
|
|
|
18 |
* Standard functions for block_messageteacher
|
|
|
19 |
*
|
|
|
20 |
* @package block_messageteacher
|
|
|
21 |
* @author Mark Johnson <mark@barrenfrozenwasteland.com>
|
|
|
22 |
* @copyright 2019 Mark Johnson
|
|
|
23 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
24 |
*/
|
|
|
25 |
|
|
|
26 |
defined('MOODLE_INTERNAL') || die();
|
|
|
27 |
|
|
|
28 |
/**
|
|
|
29 |
* Output fragment for modal message form.
|
|
|
30 |
*
|
|
|
31 |
* @param array $args
|
|
|
32 |
* @return string
|
|
|
33 |
* @throws coding_exception
|
|
|
34 |
* @throws dml_exception
|
|
|
35 |
* @throws moodle_exception
|
|
|
36 |
* @throws require_login_exception
|
|
|
37 |
* @throws required_capability_exception
|
|
|
38 |
*/
|
|
|
39 |
function block_messageteacher_output_fragment_message_form($args) : string {
|
|
|
40 |
global $DB;
|
|
|
41 |
$coursecontext = context_course::instance($args['courseid']);
|
|
|
42 |
|
|
|
43 |
require_login();
|
|
|
44 |
require_capability('moodle/site:sendmessage', $coursecontext);
|
|
|
45 |
|
|
|
46 |
$recipient = $DB->get_record('user', array('id' => $args['recipientid']));
|
|
|
47 |
|
|
|
48 |
$customdata = array(
|
|
|
49 |
'recipient' => $recipient,
|
|
|
50 |
'referurl' => $args['referurl'],
|
|
|
51 |
'courseid' => $args['courseid'],
|
|
|
52 |
'modal' => true,
|
|
|
53 |
);
|
|
|
54 |
$mform = new block_messageteacher\message_form(null, $customdata);
|
|
|
55 |
ob_start();
|
|
|
56 |
$mform->display();
|
|
|
57 |
$output = ob_get_contents();
|
|
|
58 |
ob_end_clean();
|
|
|
59 |
|
|
|
60 |
return $output;
|
|
|
61 |
}
|