forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
keymanager.php
78 lines (64 loc) · 3.62 KB
/
keymanager.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php //$Id$
///////////////////////////////////////////////////////////////////////////
// //
// NOTICE OF COPYRIGHT //
// //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
// //
// This program 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 2 of the License, or //
// (at your option) any later version. //
// //
// This program 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: //
// //
// http://www.gnu.org/copyleft/gpl.html //
// //
///////////////////////////////////////////////////////////////////////////
require_once '../../config.php';
require_once $CFG->dirroot.'/grade/lib.php';
$id = required_param('id', PARAM_INT); // course id
if (!$course = get_record('course', 'id', $id)) {
print_error('nocourseid');
}
require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $id);
require_capability('moodle/grade:import', $context);
$strgrades = get_string('grades', 'grades');
$navigation = grade_build_nav(__FILE__, null, array('courseid' => $course->id));
print_header($course->shortname.': '.get_string('grades'), $course->fullname, $navigation);
print_grade_plugin_selector($id, '', '');
$stredit = get_string('edit');
$strdelete = get_string('delete');
$data = array();
if ($keys = get_records_select('user_private_key', "script='grade/import' AND instance={$course->id} AND userid={$USER->id}")) {
foreach($keys as $key) {
$line = array();
$line[0] = format_string($key->value);
$line[1] = $key->iprestriction;
$line[2] = empty($key->validuntil) ? get_string('always') : userdate($key->validuntil);
$buttons = "<a title=\"$stredit\" href=\"key.php?id=$key->id\"><img".
" src=\"$CFG->pixpath/t/edit.gif\" class=\"iconsmall\" alt=\"$stredit\" /></a> ";
$buttons .= "<a title=\"$strdelete\" href=\"key.php?id=$key->id&delete=1\"><img".
" src=\"$CFG->pixpath/t/delete.gif\" class=\"iconsmall\" alt=\"$strdelete\" /></a> ";
$line[3] = $buttons;
$data[] = $line;
}
}
$table->head = array(get_string('keyvalue', 'userkey'), get_string('keyiprestriction', 'userkey'), get_string('keyvaliduntil', 'userkey'), $stredit);
$table->size = array('50%', '30%', '10%', '10%');
$table->align = array('left', 'left', 'left', 'center');
$table->width = '90%';
$table->data = $data;
print_table($table);
echo '<div class="buttons">';
print_single_button('key.php', array('courseid'=>$course->id), get_string('newuserkey', 'userkey'));
echo '</div>';
print_footer();
?>