3 // This file is part of Moodle - http://moodle.org/
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
19 require_once '../../config.php';
20 require_once $CFG->dirroot
.'/grade/export/lib.php';
22 $id = required_param('id', PARAM_INT
); // course id
24 if (!$course = get_record('course', 'id', $id)) {
25 print_error('nocourseid');
28 require_login($course);
29 $context = get_context_instance(CONTEXT_COURSE
, $id);
31 require_capability('moodle/grade:export', $context);
33 print_grade_page_head($course->id
, 'export', 'keymanager', get_string('keymanager', 'grades'));
35 $stredit = get_string('edit');
36 $strdelete = get_string('delete');
39 if ($keys = get_records_select('user_private_key', "script='grade/export' AND instance={$course->id} AND userid={$USER->id}")) {
40 foreach($keys as $key) {
42 $line[0] = format_string($key->value
);
43 $line[1] = $key->iprestriction
;
44 $line[2] = empty($key->validuntil
) ?
get_string('always') : userdate($key->validuntil
);
46 $buttons = "<a title=\"$stredit\" href=\"key.php?id=$key->id\"><img".
47 " src=\"$CFG->pixpath/t/edit.gif\" class=\"iconsmall\" alt=\"$stredit\" /></a> ";
48 $buttons .= "<a title=\"$strdelete\" href=\"key.php?id=$key->id&delete=1\"><img".
49 " src=\"$CFG->pixpath/t/delete.gif\" class=\"iconsmall\" alt=\"$strdelete\" /></a> ";
55 $table->head
= array(get_string('keyvalue', 'userkey'), get_string('keyiprestriction', 'userkey'), get_string('keyvaliduntil', 'userkey'), $stredit);
56 $table->size
= array('50%', '30%', '10%', '10%');
57 $table->align
= array('left', 'left', 'left', 'center');
58 $table->width
= '90%';
62 echo '<div class="buttons">';
63 print_single_button('key.php', array('courseid'=>$course->id
), get_string('newuserkey', 'userkey'));