MDL-11517 reserved word MOD used in table alias in questions backup code
[moodle-pu.git] / grade / export / keymanager.php
blob7af872b304274e346baa604d0446897464c6526d
1 <?php //$Id$
3 ///////////////////////////////////////////////////////////////////////////
4 // //
5 // NOTICE OF COPYRIGHT //
6 // //
7 // Moodle - Modular Object-Oriented Dynamic Learning Environment //
8 // http://moodle.com //
9 // //
10 // Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
11 // //
12 // This program is free software; you can redistribute it and/or modify //
13 // it under the terms of the GNU General Public License as published by //
14 // the Free Software Foundation; either version 2 of the License, or //
15 // (at your option) any later version. //
16 // //
17 // This program is distributed in the hope that it will be useful, //
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
20 // GNU General Public License for more details: //
21 // //
22 // http://www.gnu.org/copyleft/gpl.html //
23 // //
24 ///////////////////////////////////////////////////////////////////////////
26 require_once '../../config.php';
27 require_once $CFG->dirroot.'/grade/export/lib.php';
29 $id = required_param('id', PARAM_INT); // course id
31 if (!$course = get_record('course', 'id', $id)) {
32 print_error('nocourseid');
35 require_login($course);
36 $context = get_context_instance(CONTEXT_COURSE, $id);
38 require_capability('moodle/grade:export', $context);
40 $strgrades = get_string('grades', 'grades');
41 $navigation = grade_build_nav(__FILE__, null, array('courseid' => $course->id));
43 print_header($course->shortname.': '.get_string('grades'), $course->fullname, $navigation);
44 print_grade_plugin_selector($id, '', '');
46 $stredit = get_string('edit');
47 $strdelete = get_string('delete');
49 $data = array();
50 if ($keys = get_records_select('user_private_key', "script='grade/export' AND instance={$course->id} AND userid={$USER->id}")) {
51 foreach($keys as $key) {
52 $line = array();
53 $line[0] = format_string($key->value);
54 $line[1] = $key->iprestriction;
55 $line[2] = empty($key->validuntil) ? get_string('always') : userdate($key->validuntil);
57 $buttons = "<a title=\"$stredit\" href=\"key.php?id=$key->id\"><img".
58 " src=\"$CFG->pixpath/t/edit.gif\" class=\"iconsmall\" alt=\"$stredit\" /></a> ";
59 $buttons .= "<a title=\"$strdelete\" href=\"key.php?id=$key->id&amp;delete=1\"><img".
60 " src=\"$CFG->pixpath/t/delete.gif\" class=\"iconsmall\" alt=\"$strdelete\" /></a> ";
62 $line[3] = $buttons;
63 $data[] = $line;
66 $table->head = array(get_string('keyvalue', 'userkey'), get_string('keyiprestriction', 'userkey'), get_string('keyvaliduntil', 'userkey'), $stredit);
67 $table->size = array('50%', '30%', '10%', '10%');
68 $table->align = array('left', 'left', 'left', 'center');
69 $table->width = '90%';
70 $table->data = $data;
71 print_table($table);
73 echo '<div class="buttons">';
74 print_single_button('key.php', array('courseid'=>$course->id), get_string('newuserkey', 'userkey'));
75 echo '</div>';
77 print_footer();