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 |
* Email certificate renderable.
|
|
|
19 |
*
|
|
|
20 |
* @package mod_customcert
|
|
|
21 |
* @copyright 2017 Mark Nelson <markn@moodle.com>
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
namespace mod_customcert\output;
|
|
|
26 |
|
|
|
27 |
/**
|
|
|
28 |
* Email certificate renderable.
|
|
|
29 |
*
|
|
|
30 |
* @copyright 2017 Mark Nelson <markn@moodle.com>
|
|
|
31 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
32 |
*/
|
|
|
33 |
class email_certificate implements \renderable, \templatable {
|
|
|
34 |
|
|
|
35 |
/**
|
|
|
36 |
* @var bool Are we emailing the student?
|
|
|
37 |
*/
|
|
|
38 |
public $isstudent;
|
|
|
39 |
|
|
|
40 |
/**
|
|
|
41 |
* @var string The name of the user who owns the certificate.
|
|
|
42 |
*/
|
|
|
43 |
public $userfullname;
|
|
|
44 |
|
|
|
45 |
/**
|
|
|
46 |
* @var string The course short name.
|
|
|
47 |
*/
|
|
|
48 |
public $courseshortname;
|
|
|
49 |
|
|
|
50 |
/**
|
|
|
51 |
* @var string The course full name.
|
|
|
52 |
*/
|
|
|
53 |
public $coursefullname;
|
|
|
54 |
|
|
|
55 |
/**
|
|
|
56 |
* @var int The certificate name.
|
|
|
57 |
*/
|
|
|
58 |
public $certificatename;
|
|
|
59 |
|
|
|
60 |
/**
|
|
|
61 |
* @var int The course module id.
|
|
|
62 |
*/
|
|
|
63 |
public $cmid;
|
|
|
64 |
|
|
|
65 |
/**
|
|
|
66 |
* Constructor.
|
|
|
67 |
*
|
|
|
68 |
* @param bool $isstudent Are we emailing the student?
|
|
|
69 |
* @param string $userfullname The name of the user who owns the certificate.
|
|
|
70 |
* @param string $courseshortname The short name of the course.
|
|
|
71 |
* @param string $coursefullname The full name of the course.
|
|
|
72 |
* @param string $certificatename The name of the certificate.
|
|
|
73 |
* @param string $cmid The course module id.
|
|
|
74 |
*/
|
|
|
75 |
public function __construct($isstudent, $userfullname, $courseshortname, $coursefullname, $certificatename, $cmid) {
|
|
|
76 |
$this->isstudent = $isstudent;
|
|
|
77 |
$this->userfullname = $userfullname;
|
|
|
78 |
$this->courseshortname = $courseshortname;
|
|
|
79 |
$this->coursefullname = $coursefullname;
|
|
|
80 |
$this->certificatename = $certificatename;
|
|
|
81 |
$this->cmid = $cmid;
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
/**
|
|
|
85 |
* Export this data so it can be used as the context for a mustache template.
|
|
|
86 |
*
|
|
|
87 |
* @param \renderer_base $renderer The render to be used for formatting the email
|
|
|
88 |
* @return \stdClass The data ready for use in a mustache template
|
|
|
89 |
*/
|
|
|
90 |
public function export_for_template(\renderer_base $renderer) {
|
|
|
91 |
$data = new \stdClass();
|
|
|
92 |
|
|
|
93 |
// Used for the body text.
|
|
|
94 |
$info = new \stdClass();
|
|
|
95 |
$info->userfullname = $this->userfullname;
|
|
|
96 |
$info->certificatename = $this->certificatename;
|
|
|
97 |
$info->courseshortname = $this->courseshortname;
|
|
|
98 |
$info->coursefullname = $this->coursefullname;
|
|
|
99 |
|
|
|
100 |
if ($this->isstudent) {
|
|
|
101 |
$data->emailgreeting = get_string('emailstudentgreeting', 'customcert', $this->userfullname);
|
|
|
102 |
$data->emailbody = get_string('emailstudentbody', 'customcert', $info);
|
|
|
103 |
$data->emailbodyplaintext = get_string('emailstudentbodyplaintext', 'customcert', $info);
|
|
|
104 |
$data->emailcertificatelink = new \moodle_url('/mod/customcert/view.php', ['id' => $this->cmid]);
|
|
|
105 |
$data->emailcertificatelinktext = get_string('emailstudentcertificatelinktext', 'customcert');
|
|
|
106 |
} else {
|
|
|
107 |
$data->emailgreeting = get_string('emailnonstudentgreeting', 'customcert');
|
|
|
108 |
$data->emailbody = get_string('emailnonstudentbody', 'customcert', $info);
|
|
|
109 |
$data->emailbodyplaintext = get_string('emailnonstudentbodyplaintext', 'customcert', $info);
|
|
|
110 |
$data->emailcertificatelink = new \moodle_url('/mod/customcert/view.php', ['id' => $this->cmid]);
|
|
|
111 |
$data->emailcertificatelinktext = get_string('emailnonstudentcertificatelinktext', 'customcert');
|
|
|
112 |
}
|
|
|
113 |
|
|
|
114 |
return $data;
|
|
|
115 |
}
|
|
|
116 |
}
|