1
<?php //$Id: keymanager.php,v 1.1 2007/09/26 09:42:31 skodak Exp $
3
///////////////////////////////////////////////////////////////////////////
5
// NOTICE OF COPYRIGHT //
7
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
8
// http://moodle.com //
10
// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
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. //
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: //
22
// http://www.gnu.org/copyleft/gpl.html //
24
///////////////////////////////////////////////////////////////////////////
26
require_once '../../config.php';
27
require_once $CFG->dirroot.'/grade/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:import', $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');
50
if ($keys = get_records_select('user_private_key', "script='grade/import' AND instance={$course->id} AND userid={$USER->id}")) {
51
foreach($keys as $key) {
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&delete=1\"><img".
60
" src=\"$CFG->pixpath/t/delete.gif\" class=\"iconsmall\" alt=\"$strdelete\" /></a> ";
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%';
73
echo '<div class="buttons">';
74
print_single_button('key.php', array('courseid'=>$course->id), get_string('newuserkey', 'userkey'));