2017-02-02 09:17:41 +00:00
|
|
|
<?php
|
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Email certificate renderable.
|
|
|
|
*
|
2021-11-24 07:29:43 +00:00
|
|
|
* @package mod_htmlcert
|
|
|
|
* @copyright 2017 Mark Nelson <markn@moodle.com>, 2021 Klaus-Uwe Mitterer <kumitterer@kumi.systems>
|
2017-02-02 09:17:41 +00:00
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
*/
|
|
|
|
|
2021-11-24 07:29:43 +00:00
|
|
|
namespace mod_htmlcert\output;
|
2017-02-02 09:17:41 +00:00
|
|
|
|
|
|
|
defined('MOODLE_INTERNAL') || die();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Email certificate renderable.
|
|
|
|
*
|
|
|
|
* @copyright 2017 Mark Nelson <markn@moodle.com>
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
*/
|
|
|
|
class email_certificate implements \renderable, \templatable {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var bool Are we emailing the student?
|
|
|
|
*/
|
|
|
|
public $isstudent;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string The name of the user who owns the certificate.
|
|
|
|
*/
|
|
|
|
public $userfullname;
|
|
|
|
|
2017-11-11 07:11:55 +00:00
|
|
|
/**
|
|
|
|
* @var string The course short name.
|
|
|
|
*/
|
|
|
|
public $courseshortname;
|
|
|
|
|
2017-02-02 09:17:41 +00:00
|
|
|
/**
|
|
|
|
* @var string The course full name.
|
|
|
|
*/
|
|
|
|
public $coursefullname;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var int The certificate name.
|
|
|
|
*/
|
|
|
|
public $certificatename;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var int The course module id.
|
|
|
|
*/
|
|
|
|
public $cmid;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
*
|
|
|
|
* @param bool $isstudent Are we emailing the student?
|
|
|
|
* @param string $userfullname The name of the user who owns the certificate.
|
2017-11-11 07:11:55 +00:00
|
|
|
* @param string $courseshortname The short name of the course.
|
|
|
|
* @param string $coursefullname The full name of the course.
|
2017-02-02 09:17:41 +00:00
|
|
|
* @param string $certificatename The name of the certificate.
|
|
|
|
* @param string $cmid The course module id.
|
|
|
|
*/
|
2017-11-11 07:11:55 +00:00
|
|
|
public function __construct($isstudent, $userfullname, $courseshortname, $coursefullname, $certificatename, $cmid) {
|
2017-02-02 09:17:41 +00:00
|
|
|
$this->isstudent = $isstudent;
|
|
|
|
$this->userfullname = $userfullname;
|
2017-11-11 07:11:55 +00:00
|
|
|
$this->courseshortname = $courseshortname;
|
2017-02-02 09:17:41 +00:00
|
|
|
$this->coursefullname = $coursefullname;
|
|
|
|
$this->certificatename = $certificatename;
|
|
|
|
$this->cmid = $cmid;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Export this data so it can be used as the context for a mustache template.
|
|
|
|
*
|
|
|
|
* @param \renderer_base $renderer The render to be used for formatting the email
|
|
|
|
* @return \stdClass The data ready for use in a mustache template
|
|
|
|
*/
|
|
|
|
public function export_for_template(\renderer_base $renderer) {
|
|
|
|
$data = new \stdClass();
|
|
|
|
|
|
|
|
// Used for the body text.
|
|
|
|
$info = new \stdClass();
|
|
|
|
$info->userfullname = $this->userfullname;
|
|
|
|
$info->certificatename = $this->certificatename;
|
2017-11-11 07:11:55 +00:00
|
|
|
$info->courseshortname = $this->courseshortname;
|
2017-02-02 09:17:41 +00:00
|
|
|
$info->coursefullname = $this->coursefullname;
|
|
|
|
|
|
|
|
if ($this->isstudent) {
|
2021-11-24 07:29:43 +00:00
|
|
|
$data->emailgreeting = get_string('emailstudentgreeting', 'htmlcert', $this->userfullname);
|
|
|
|
$data->emailbody = get_string('emailstudentbody', 'htmlcert', $info);
|
|
|
|
$data->emailbodyplaintext = get_string('emailstudentbodyplaintext', 'htmlcert', $info);
|
|
|
|
$data->emailcertificatelink = new \moodle_url('/mod/htmlcert/view.php', array('id' => $this->cmid));
|
|
|
|
$data->emailcertificatetext = get_string('emailstudentcertificatelinktext', 'htmlcert');
|
2017-02-02 09:17:41 +00:00
|
|
|
} else {
|
2021-11-24 07:29:43 +00:00
|
|
|
$data->emailgreeting = get_string('emailnonstudentgreeting', 'htmlcert');
|
|
|
|
$data->emailbody = get_string('emailnonstudentbody', 'htmlcert', $info);
|
|
|
|
$data->emailbodyplaintext = get_string('emailnonstudentbodyplaintext', 'htmlcert', $info);
|
|
|
|
$data->emailcertificatelink = new \moodle_url('/mod/htmlcert/view.php', array('id' => $this->cmid));
|
|
|
|
$data->emailcertificatetext = get_string('emailnonstudentcertificatelinktext', 'htmlcert');
|
2017-02-02 09:17:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
}
|