Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/grade/export/keymanager.php
Go to the documentation of this file.
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 '../../config.php';
00027 require_once $CFG->dirroot.'/grade/export/lib.php';
00028 
00029 $id = required_param('id', PARAM_INT); // course id
00030 
00031 $PAGE->set_url('/grade/export/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:export', $context);
00041 
00042 print_grade_page_head($course->id, 'export', 'keymanager', get_string('keymanager', 'grades'));
00043 
00044 $stredit   = get_string('edit');
00045 $strdelete = get_string('delete');
00046 
00047 $data = array();
00048 $keys = $DB->get_records_select('user_private_key', "script='grade/export' AND instance=? AND userid=?", array($course->id, $USER->id));
00049 if ($keys) {
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');
00057         if (!empty($key->id)) {
00058             $url->param('id', $key->id);
00059         }
00060 
00061         $buttons = $OUTPUT->action_icon($url, new pix_icon('t/edit', $stredit));
00062 
00063         $url->param('delete', 1);
00064         $url->param('sesskey', sesskey());
00065         $buttons .= $OUTPUT->action_icon($url, new pix_icon('t/delete', $strdelete));
00066 
00067         $line[3] = $buttons;
00068         $data[] = $line;
00069     }
00070 }
00071 $table = new html_table();
00072 $table->head  = array(get_string('keyvalue', 'userkey'), get_string('keyiprestriction', 'userkey'), get_string('keyvaliduntil', 'userkey'), $stredit);
00073 $table->size  = array('50%', '30%', '10%', '10%');
00074 $table->align = array('left', 'left', 'left', 'center');
00075 $table->width = '90%';
00076 $table->data  = $data;
00077 echo html_writer::table($table);
00078 
00079 echo $OUTPUT->container_start('buttons mdl-align');
00080 echo $OUTPUT->single_button(new moodle_url('key.php', array('courseid'=>$course->id)), get_string('newuserkey', 'userkey'));
00081 echo $OUTPUT->container_end();
00082 
00083 echo $OUTPUT->footer();
00084 
 All Data Structures Namespaces Files Functions Variables Enumerations