|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00026 require_once(dirname(__FILE__).'/../../config.php'); 00027 require_once($CFG->dirroot.'/grade/lib.php'); 00028 00029 $id = required_param('id', PARAM_INT); // course id 00030 00031 $PAGE->set_url('/grade/import/keymanager.php', array('id' => $id)); 00032 00033 if (!$course = $DB->get_record('course', array('id'=>$id))) { 00034 print_error('nocourseid'); 00035 } 00036 00037 require_login($course); 00038 $context = get_context_instance(CONTEXT_COURSE, $id); 00039 00040 require_capability('moodle/grade:import', $context); 00041 00042 print_grade_page_head($course->id, 'import', 'keymanager', get_string('keymanager', 'grades')); 00043 00044 $stredit = get_string('edit'); 00045 $strdelete = get_string('delete'); 00046 00047 $data = array(); 00048 $params = array($course->id, $USER->id); 00049 if ($keys = $DB->get_records_select('user_private_key', "script='grade/import' AND instance=? AND userid=?", $params)) { 00050 foreach($keys as $key) { 00051 $line = array(); 00052 $line[0] = format_string($key->value); 00053 $line[1] = $key->iprestriction; 00054 $line[2] = empty($key->validuntil) ? get_string('always') : userdate($key->validuntil); 00055 00056 $url = new moodle_url('key.php', array('id' => $key->id)); 00057 00058 $buttons = $OUTPUT->action_icon($url, new pix_icon('t/edit', $stredit)); 00059 00060 $url->param('delete', 1); 00061 $url->param('sesskey', sesskey()); 00062 $buttons .= $OUTPUT->action_icon($url, new pix_icon('t/delete', $strdelete)); 00063 00064 $line[3] = $buttons; 00065 $data[] = $line; 00066 } 00067 } 00068 $table = new html_table(); 00069 $table->head = array(get_string('keyvalue', 'userkey'), get_string('keyiprestriction', 'userkey'), get_string('keyvaliduntil', 'userkey'), $stredit); 00070 $table->size = array('50%', '30%', '10%', '10%'); 00071 $table->align = array('left', 'left', 'left', 'center'); 00072 $table->width = '90%'; 00073 $table->data = $data; 00074 echo html_writer::table($table); 00075 00076 echo $OUTPUT->container_start('buttons mdl-align'); 00077 echo $OUTPUT->single_button(new moodle_url('key.php', array('courseid'=>$course->id)), get_string('newuserkey', 'userkey')); 00078 echo $OUTPUT->container_end(); 00079 00080 echo $OUTPUT->footer(); 00081