2009-07-07 02:26:36 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
|
|
|
// Moodle 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 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle 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.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
2007-09-26 09:42:28 +00:00
|
|
|
|
2009-08-27 09:39:50 +00:00
|
|
|
/**
|
|
|
|
* Grade import key management page.
|
|
|
|
*
|
|
|
|
* @package moodlecore
|
|
|
|
* @copyright 2008 Petr Skoda
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
*/
|
2007-09-26 09:42:28 +00:00
|
|
|
|
2009-08-27 09:39:50 +00:00
|
|
|
require_once(dirname(__FILE__).'/../../config.php');
|
|
|
|
require_once($CFG->dirroot.'/grade/lib.php');
|
|
|
|
|
|
|
|
$id = required_param('id', PARAM_INT); // course id
|
|
|
|
|
|
|
|
$PAGE->set_url('grade/import/keymanager.php', array('id' => $id));
|
2007-09-26 09:42:28 +00:00
|
|
|
|
2008-06-01 17:59:13 +00:00
|
|
|
if (!$course = $DB->get_record('course', array('id'=>$id))) {
|
2007-09-26 09:42:28 +00:00
|
|
|
print_error('nocourseid');
|
|
|
|
}
|
|
|
|
|
|
|
|
require_login($course);
|
|
|
|
$context = get_context_instance(CONTEXT_COURSE, $id);
|
|
|
|
|
|
|
|
require_capability('moodle/grade:import', $context);
|
|
|
|
|
2009-02-27 14:19:25 +00:00
|
|
|
print_grade_page_head($course->id, 'import', 'keymanager', get_string('keymanager', 'grades'));
|
2007-09-26 09:42:28 +00:00
|
|
|
|
2009-08-27 09:39:50 +00:00
|
|
|
$stredit = get_string('edit');
|
|
|
|
$strdelete = get_string('delete');
|
2007-09-26 09:42:28 +00:00
|
|
|
|
|
|
|
$data = array();
|
2008-06-03 16:10:57 +00:00
|
|
|
$params = array($course->id, $USER->id);
|
2008-06-03 21:58:44 +00:00
|
|
|
if ($keys = $DB->get_records_select('user_private_key', "script='grade/import' AND instance=? AND userid=?", $params)) {
|
2007-09-26 09:42:28 +00:00
|
|
|
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);
|
2009-11-01 12:11:29 +00:00
|
|
|
|
2009-08-27 09:39:50 +00:00
|
|
|
$icon = new moodle_action_icon();
|
|
|
|
$icon->link->url = new moodle_url('key.php', array('id' => $key->id));
|
|
|
|
$icon->image->add_class('iconsmall');
|
|
|
|
|
|
|
|
$editicon = clone($icon);
|
2009-12-16 21:50:45 +00:00
|
|
|
$editicon->image->src = $OUTPUT->pix_url('t/edit');
|
2009-08-27 09:39:50 +00:00
|
|
|
$editicon->image->title = $stredit;
|
|
|
|
$editicon->image->alt = $stredit;
|
|
|
|
$buttons = $OUTPUT->action_icon($editicon);
|
2007-09-26 09:42:28 +00:00
|
|
|
|
2009-08-27 09:39:50 +00:00
|
|
|
$deleteicon = clone($icon);
|
2009-12-16 21:50:45 +00:00
|
|
|
$deleteicon->image->src = $OUTPUT->pix_url('t/delete');
|
2009-08-27 09:39:50 +00:00
|
|
|
$deleteicon->image->title = $strdelete;
|
|
|
|
$deleteicon->image->alt = $strdelete;
|
|
|
|
$deleteicon->link->url->param('delete', 1);
|
|
|
|
$deleteicon->link->url->param('sesskey', sesskey());
|
|
|
|
$buttons .= $OUTPUT->action_icon($deleteicon);
|
2007-09-26 09:42:28 +00:00
|
|
|
|
|
|
|
$line[3] = $buttons;
|
|
|
|
$data[] = $line;
|
|
|
|
}
|
|
|
|
}
|
2009-08-20 08:40:49 +00:00
|
|
|
$table = new html_table();
|
2007-09-26 09:42:28 +00:00
|
|
|
$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;
|
2009-08-20 08:40:49 +00:00
|
|
|
echo $OUTPUT->table($table);
|
2007-09-26 09:42:28 +00:00
|
|
|
|
2009-08-27 09:39:50 +00:00
|
|
|
echo $OUTPUT->container_start('buttons mdl-align');
|
2009-08-20 08:40:49 +00:00
|
|
|
echo $OUTPUT->button(html_form::make_button('key.php', array('courseid'=>$course->id), get_string('newuserkey', 'userkey')));
|
|
|
|
echo $OUTPUT->container_end();
|
2007-09-26 09:42:28 +00:00
|
|
|
|
2009-08-06 14:12:17 +00:00
|
|
|
echo $OUTPUT->footer();
|
2009-11-01 12:11:29 +00:00
|
|
|
|