2013-05-22 11:37:39 +00:00
|
|
|
<?php
|
|
|
|
// This file is part of the customcert module for 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/>.
|
|
|
|
|
|
|
|
/**
|
2013-06-05 07:37:52 +00:00
|
|
|
* Handles viewing a report that shows who has received a customcert.
|
2013-05-22 11:37:39 +00:00
|
|
|
*
|
|
|
|
* @package mod_customcert
|
2013-07-22 05:06:18 +00:00
|
|
|
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
2013-05-22 11:37:39 +00:00
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once('../../config.php');
|
|
|
|
|
2016-08-23 08:22:58 +00:00
|
|
|
$id = required_param('id', PARAM_INT);
|
2016-08-24 09:06:45 +00:00
|
|
|
$download = optional_param('download', null, PARAM_ALPHA);
|
2016-08-23 08:22:58 +00:00
|
|
|
$downloadcert = optional_param('downloadcert', '', PARAM_BOOL);
|
2017-09-02 06:01:21 +00:00
|
|
|
$deleteissue = optional_param('deleteissue', 0, PARAM_INT);
|
|
|
|
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
2016-08-23 08:22:58 +00:00
|
|
|
if ($downloadcert) {
|
|
|
|
$userid = required_param('userid', PARAM_INT);
|
|
|
|
}
|
2013-05-22 11:37:39 +00:00
|
|
|
|
|
|
|
$page = optional_param('page', 0, PARAM_INT);
|
2016-02-16 09:03:34 +00:00
|
|
|
$perpage = optional_param('perpage', \mod_customcert\certificate::CUSTOMCERT_PER_PAGE, PARAM_INT);
|
2013-09-10 07:52:20 +00:00
|
|
|
$pageurl = $url = new moodle_url('/mod/customcert/report.php', array('id' => $id, 'page' => $page, 'perpage' => $perpage));
|
2013-05-22 11:37:39 +00:00
|
|
|
|
|
|
|
$cm = get_coursemodule_from_id('customcert', $id, 0, false, MUST_EXIST);
|
|
|
|
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
|
|
|
|
$customcert = $DB->get_record('customcert', array('id' => $cm->instance), '*', MUST_EXIST);
|
|
|
|
|
|
|
|
// Requires a course login.
|
2015-03-11 22:57:45 +00:00
|
|
|
require_login($course, false, $cm);
|
2013-05-22 11:37:39 +00:00
|
|
|
|
|
|
|
// Check capabilities.
|
2013-05-28 09:00:07 +00:00
|
|
|
$context = context_module::instance($cm->id);
|
2017-06-02 04:42:04 +00:00
|
|
|
require_capability('mod/customcert:viewreport', $context);
|
2013-05-22 11:37:39 +00:00
|
|
|
|
2017-09-02 06:01:21 +00:00
|
|
|
if ($deleteissue && confirm_sesskey()) {
|
|
|
|
require_capability('mod/customcert:manage', $context);
|
|
|
|
|
|
|
|
if (!$confirm) {
|
|
|
|
$nourl = new moodle_url('/mod/customcert/report.php', ['id' => $id]);
|
|
|
|
$yesurl = new moodle_url('/mod/customcert/report.php',
|
|
|
|
[
|
|
|
|
'id' => $id,
|
|
|
|
'deleteissue' => $deleteissue,
|
|
|
|
'confirm' => 1,
|
|
|
|
'sesskey' => sesskey()
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Show a confirmation page.
|
|
|
|
$strheading = get_string('deleteconfirm', 'customcert');
|
|
|
|
$PAGE->navbar->add($strheading);
|
|
|
|
$PAGE->set_title($strheading);
|
|
|
|
$PAGE->set_url($url);
|
|
|
|
$message = get_string('deleteissueconfirm', 'customcert');
|
|
|
|
echo $OUTPUT->header();
|
|
|
|
echo $OUTPUT->heading($strheading);
|
|
|
|
echo $OUTPUT->confirm($message, $yesurl, $nourl);
|
|
|
|
echo $OUTPUT->footer();
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delete the issue.
|
|
|
|
$DB->delete_records('customcert_issues', array('id' => $deleteissue, 'customcertid' => $customcert->id));
|
|
|
|
|
|
|
|
// Redirect back to the manage templates page.
|
|
|
|
redirect(new moodle_url('/mod/customcert/report.php', array('id' => $id)));
|
|
|
|
}
|
|
|
|
|
2016-08-23 08:22:58 +00:00
|
|
|
// Check if we requested to download another user's certificate.
|
|
|
|
if ($downloadcert) {
|
|
|
|
$template = $DB->get_record('customcert_templates', array('id' => $customcert->templateid), '*', MUST_EXIST);
|
|
|
|
$template = new \mod_customcert\template($template);
|
|
|
|
$template->generate_pdf(false, $userid);
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if we are in group mode.
|
2015-03-11 21:58:52 +00:00
|
|
|
if ($groupmode = groups_get_activity_groupmode($cm)) {
|
|
|
|
groups_get_activity_group($cm, true);
|
|
|
|
}
|
2013-05-22 11:37:39 +00:00
|
|
|
|
2016-08-24 09:06:45 +00:00
|
|
|
$table = new \mod_customcert\report_table($customcert->id, $cm, $groupmode, $download);
|
2016-08-22 11:42:23 +00:00
|
|
|
$table->define_baseurl($pageurl);
|
2013-05-22 11:37:39 +00:00
|
|
|
|
2016-08-24 09:06:45 +00:00
|
|
|
if ($table->is_downloading()) {
|
2016-08-22 11:42:23 +00:00
|
|
|
$table->download();
|
|
|
|
exit();
|
2013-05-22 11:37:39 +00:00
|
|
|
}
|
|
|
|
|
2016-02-16 09:03:34 +00:00
|
|
|
// Set up the page.
|
|
|
|
\mod_customcert\page_helper::page_setup($pageurl, $context, get_string('customcertreport', 'customcert'));
|
|
|
|
|
|
|
|
// Additional page setup.
|
|
|
|
$PAGE->navbar->add(get_string('customcertreport', 'customcert'));
|
2013-05-22 11:37:39 +00:00
|
|
|
|
|
|
|
echo $OUTPUT->header();
|
2018-06-19 13:33:11 +00:00
|
|
|
echo $OUTPUT->heading(get_string('listofissues', 'customcert'));
|
2016-08-22 11:42:23 +00:00
|
|
|
|
2013-05-22 11:37:39 +00:00
|
|
|
groups_print_activity_menu($cm, $url);
|
2016-08-22 11:42:23 +00:00
|
|
|
|
|
|
|
$table->out($perpage, false);
|
|
|
|
|
2016-10-21 21:45:48 +00:00
|
|
|
echo $OUTPUT->footer();
|