Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]
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 * Badge awards information 19 * 20 * @package core 21 * @subpackage badges 22 * @copyright 2012 onwards Totara Learning Solutions Ltd {@link http://www.totaralms.com/} 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 * @author Yuliya Bozhko <yuliya.bozhko@totaralms.com> 25 */ 26 27 require_once(__DIR__ . '/../config.php'); 28 require_once($CFG->libdir . '/badgeslib.php'); 29 30 $badgeid = required_param('id', PARAM_INT); 31 $sortby = optional_param('sort', 'dateissued', PARAM_ALPHA); 32 $sorthow = optional_param('dir', 'DESC', PARAM_ALPHA); 33 $page = optional_param('page', 0, PARAM_INT); 34 35 require_login(); 36 37 if (empty($CFG->enablebadges)) { 38 print_error('badgesdisabled', 'badges'); 39 } 40 41 if (!in_array($sortby, array('firstname', 'lastname', 'dateissued'))) { 42 $sortby = 'dateissued'; 43 } 44 45 if ($sorthow != 'ASC' and $sorthow != 'DESC') { 46 $sorthow = 'DESC'; 47 } 48 49 if ($page < 0) { 50 $page = 0; 51 } 52 53 $badge = new badge($badgeid); 54 $context = $badge->get_context(); 55 $navurl = new moodle_url('/badges/index.php', array('type' => $badge->type)); 56 57 require_capability('moodle/badges:viewawarded', $context); 58 59 if ($badge->type == BADGE_TYPE_COURSE) { 60 if (empty($CFG->badges_allowcoursebadges)) { 61 print_error('coursebadgesdisabled', 'badges'); 62 } 63 require_login($badge->courseid); 64 $course = get_course($badge->courseid); 65 $heading = format_string($course->fullname, true, ['context' => $context]); 66 $navurl = new moodle_url('/badges/index.php', array('type' => $badge->type, 'id' => $badge->courseid)); 67 $PAGE->set_pagelayout('standard'); 68 navigation_node::override_active_url($navurl); 69 } else { 70 $PAGE->set_pagelayout('admin'); 71 $heading = get_string('administrationsite'); 72 navigation_node::override_active_url($navurl, true); 73 } 74 75 $PAGE->set_context($context); 76 $PAGE->set_url('/badges/recipients.php', array('id' => $badgeid, 'sort' => $sortby, 'dir' => $sorthow)); 77 $PAGE->set_heading($heading); 78 $PAGE->set_title($badge->name); 79 $PAGE->navbar->add($badge->name); 80 81 $output = $PAGE->get_renderer('core', 'badges'); 82 83 echo $output->header(); 84 85 $actionbar = new \core_badges\output\recipients_action_bar($badge, $PAGE); 86 echo $output->render_tertiary_navigation($actionbar); 87 88 echo $OUTPUT->heading(print_badge_image($badge, $context, 'small') . ' ' . $badge->name); 89 echo $output->print_badge_status_box($badge); 90 91 $userfieldsapi = \core_user\fields::for_name(); 92 $namefields = $userfieldsapi->get_sql('u', false, '', '', false)->selects; 93 $sql = "SELECT b.userid, b.dateissued, b.uniquehash, $namefields 94 FROM {badge_issued} b INNER JOIN {user} u 95 ON b.userid = u.id 96 WHERE b.badgeid = :badgeid AND u.deleted = 0 97 ORDER BY $sortby $sorthow"; 98 99 $totalcount = $DB->count_records('badge_issued', array('badgeid' => $badge->id)); 100 101 if ($badge->has_awards()) { 102 $users = $DB->get_records_sql($sql, array('badgeid' => $badge->id), $page * BADGE_PERPAGE, BADGE_PERPAGE); 103 $recipients = new core_badges\output\badge_recipients($users); 104 $recipients->sort = $sortby; 105 $recipients->dir = $sorthow; 106 $recipients->page = $page; 107 $recipients->perpage = BADGE_PERPAGE; 108 $recipients->totalcount = $totalcount; 109 110 echo $output->render($recipients); 111 } else { 112 echo $output->notification(get_string('noawards', 'badges')); 113 } 114 115 echo $output->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body