Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/report/log/index.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00016 
00026 require('../../config.php');
00027 require_once($CFG->dirroot.'/course/lib.php');
00028 require_once($CFG->dirroot.'/report/log/locallib.php');
00029 require_once($CFG->libdir.'/adminlib.php');
00030 
00031 $id          = optional_param('id', 0, PARAM_INT);// Course ID
00032 $host_course = optional_param('host_course', '', PARAM_PATH);// Course ID
00033 
00034 if (empty($host_course)) {
00035     $hostid = $CFG->mnet_localhost_id;
00036     if (empty($id)) {
00037         $site = get_site();
00038         $id = $site->id;
00039     }
00040 } else {
00041     list($hostid, $id) = explode('/', $host_course);
00042 }
00043 
00044 $group       = optional_param('group', 0, PARAM_INT); // Group to display
00045 $user        = optional_param('user', 0, PARAM_INT); // User to display
00046 $date        = optional_param('date', 0, PARAM_FILE); // Date to display - number or some string
00047 $modname     = optional_param('modname', '', PARAM_PLUGIN); // course_module->id
00048 $modid       = optional_param('modid', 0, PARAM_FILE); // number or 'site_errors'
00049 $modaction   = optional_param('modaction', '', PARAM_PATH); // an action as recorded in the logs
00050 $page        = optional_param('page', '0', PARAM_INT);     // which page to show
00051 $perpage     = optional_param('perpage', '100', PARAM_INT); // how many per page
00052 $showcourses = optional_param('showcourses', 0, PARAM_INT); // whether to show courses if we're over our limit.
00053 $showusers   = optional_param('showusers', 0, PARAM_INT); // whether to show users if we're over our limit.
00054 $chooselog   = optional_param('chooselog', 0, PARAM_INT);
00055 $logformat   = optional_param('logformat', 'showashtml', PARAM_ALPHA);
00056 
00057 $params = array();
00058 if ($id !== 0) {
00059     $params['id'] = $id;
00060 }
00061 if ($host_course !== '') {
00062     $params['host_course'] = $host_course;
00063 }
00064 if ($group !== 0) {
00065     $params['group'] = $group;
00066 }
00067 if ($user !== 0) {
00068     $params['user'] = $user;
00069 }
00070 if ($date !== 0) {
00071     $params['date'] = $date;
00072 }
00073 if ($modname !== '') {
00074     $params['modname'] = $modname;
00075 }
00076 if ($modid !== 0) {
00077     $params['modid'] = $modid;
00078 }
00079 if ($modaction !== '') {
00080     $params['modaction'] = $modaction;
00081 }
00082 if ($page !== '0') {
00083     $params['page'] = $page;
00084 }
00085 if ($perpage !== '100') {
00086     $params['perpage'] = $perpage;
00087 }
00088 if ($showcourses !== 0) {
00089     $params['showcourses'] = $showcourses;
00090 }
00091 if ($showusers !== 0) {
00092     $params['showusers'] = $showusers;
00093 }
00094 if ($chooselog !== 0) {
00095     $params['chooselog'] = $chooselog;
00096 }
00097 if ($logformat !== 'showashtml') {
00098     $params['logformat'] = $logformat;
00099 }
00100 $PAGE->set_url('/report/log/index.php', $params);
00101 $PAGE->set_pagelayout('report');
00102 
00103 if ($hostid == $CFG->mnet_localhost_id) {
00104     $course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
00105 
00106 } else {
00107     $course_stub       = $DB->get_record('mnet_log', array('hostid'=>$hostid, 'course'=>$id), '*', true);
00108     $course->id        = $id;
00109     $course->shortname = $course_stub->coursename;
00110     $course->fullname  = $course_stub->coursename;
00111 }
00112 
00113 require_login($course);
00114 
00115 $context = get_context_instance(CONTEXT_COURSE, $course->id);
00116 
00117 require_capability('report/log:view', $context);
00118 
00119 add_to_log($course->id, "course", "report log", "report/log/index.php?id=$course->id", $course->id);
00120 
00121 $strlogs = get_string('logs');
00122 $stradministration = get_string('administration');
00123 $strreports = get_string('reports');
00124 
00125 session_get_instance()->write_close();
00126 
00127 if (!empty($chooselog)) {
00128     $userinfo = get_string('allparticipants');
00129     $dateinfo = get_string('alldays');
00130 
00131     if ($user) {
00132         $u = $DB->get_record('user', array('id'=>$user, 'deleted'=>0), '*', MUST_EXIST);
00133         $userinfo = fullname($u, has_capability('moodle/site:viewfullnames', $context));
00134     }
00135     if ($date) {
00136         $dateinfo = userdate($date, get_string('strftimedaydate'));
00137     }
00138 
00139     switch ($logformat) {
00140         case 'showashtml':
00141             if ($hostid != $CFG->mnet_localhost_id || $course->id == SITEID) {
00142                 admin_externalpage_setup('reportlog');
00143                 echo $OUTPUT->header();
00144 
00145             } else {
00146                 $PAGE->set_title($course->shortname .': '. $strlogs);
00147                 $PAGE->set_heading($course->fullname);
00148                 $PAGE->navbar->add("$userinfo, $dateinfo");
00149                 echo $OUTPUT->header();
00150             }
00151 
00152             echo $OUTPUT->heading(format_string($course->fullname) . ": $userinfo, $dateinfo (".usertimezone().")");
00153             report_log_print_mnet_selector_form($hostid, $course, $user, $date, $modname, $modid, $modaction, $group, $showcourses, $showusers, $logformat);
00154 
00155             if ($hostid == $CFG->mnet_localhost_id) {
00156                 print_log($course, $user, $date, 'l.time DESC', $page, $perpage,
00157                         "index.php?id=$course->id&amp;chooselog=1&amp;user=$user&amp;date=$date&amp;modid=$modid&amp;modaction=$modaction&amp;group=$group",
00158                         $modname, $modid, $modaction, $group);
00159             } else {
00160                 print_mnet_log($hostid, $id, $user, $date, 'l.time DESC', $page, $perpage, "", $modname, $modid, $modaction, $group);
00161             }
00162             break;
00163         case 'downloadascsv':
00164             if (!print_log_csv($course, $user, $date, 'l.time DESC', $modname,
00165                     $modid, $modaction, $group)) {
00166                 echo $OUTPUT->notification("No logs found!");
00167                 echo $OUTPUT->footer();
00168             }
00169             exit;
00170         case 'downloadasods':
00171             if (!print_log_ods($course, $user, $date, 'l.time DESC', $modname,
00172                     $modid, $modaction, $group)) {
00173                 echo $OUTPUT->notification("No logs found!");
00174                 echo $OUTPUT->footer();
00175             }
00176             exit;
00177         case 'downloadasexcel':
00178             if (!print_log_xls($course, $user, $date, 'l.time DESC', $modname,
00179                     $modid, $modaction, $group)) {
00180                 echo $OUTPUT->notification("No logs found!");
00181                 echo $OUTPUT->footer();
00182             }
00183             exit;
00184     }
00185 
00186 
00187 } else {
00188     if ($hostid != $CFG->mnet_localhost_id || $course->id == SITEID) {
00189         admin_externalpage_setup('reportlog', '', null, '', array('pagelayout'=>'report'));
00190         echo $OUTPUT->header();
00191     } else {
00192         $PAGE->set_title($course->shortname .': '. $strlogs);
00193         $PAGE->set_heading($course->fullname);
00194         echo $OUTPUT->header();
00195     }
00196 
00197     echo $OUTPUT->heading(get_string('chooselogs') .':');
00198 
00199     report_log_print_selector_form($course, $user, $date, $modname, $modid, $modaction, $group, $showcourses, $showusers, $logformat);
00200 }
00201 
00202 echo $OUTPUT->footer();
00203 
 All Data Structures Namespaces Files Functions Variables Enumerations