Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/report/log/user.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.'/report/log/locallib.php');
00028 
00029 $userid   = required_param('id', PARAM_INT);
00030 $courseid = required_param('course', PARAM_INT);
00031 $mode     = optional_param('mode', 'today', PARAM_ALPHA);
00032 $page     = optional_param('page', 0, PARAM_INT);
00033 $perpage  = optional_param('perpage', 100, PARAM_INT);
00034 
00035 if ($mode !== 'today' and $mode !== 'all') {
00036     $mode = 'today';
00037 }
00038 
00039 $user = $DB->get_record('user', array('id'=>$userid, 'deleted'=>0), '*', MUST_EXIST);
00040 $course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST);
00041 
00042 $coursecontext   = context_course::instance($course->id);
00043 $personalcontext = context_user::instance($user->id);
00044 
00045 if ($USER->id != $user->id and has_capability('moodle/user:viewuseractivitiesreport', $personalcontext)
00046         and !is_enrolled($coursecontext, $USER) and is_enrolled($coursecontext, $user)) {
00047     //TODO: do not require parents to be enrolled in courses - this is a hack!
00048     require_login();
00049     $PAGE->set_course($course);
00050 } else {
00051     require_login($course);
00052 }
00053 
00054 list($all, $today) = report_log_can_access_user_report($user, $course);
00055 
00056 if ($mode === 'today') {
00057     if (!$today) {
00058         require_capability('report/log:viewtoday', $coursecontext);
00059     }
00060 } else {
00061     if (!$all) {
00062         require_capability('report/log:view', $coursecontext);
00063     }
00064 }
00065 
00066 add_to_log($course->id, 'course', 'report log', "report/log/user.php?id=$user->id&course=$course->id&mode=$mode", $course->id);
00067 
00068 $stractivityreport = get_string('activityreport');
00069 
00070 $PAGE->set_pagelayout('admin');
00071 $PAGE->set_url('/report/log/user.php', array('id'=>$user->id, 'course'=>$course->id, 'mode'=>$mode));
00072 $PAGE->navigation->extend_for_user($user);
00073 $PAGE->navigation->set_userid_for_parent_checks($user->id); // see MDL-25805 for reasons and for full commit reference for reversal when fixed.
00074 $PAGE->set_title("$course->shortname: $stractivityreport");
00075 $PAGE->set_heading($course->fullname);
00076 echo $OUTPUT->header();
00077 
00078 if ($mode === 'today') {
00079     echo '<div class="graph">';
00080     report_log_print_graph($course, $user->id, "userday.png");
00081     echo '</div>';
00082     print_log($course, $user->id, usergetmidnight(time()), "l.time DESC", $page, $perpage,
00083               "user.php?course=$course->id&amp;id=$user->id&amp;mode=$mode");
00084 } else {
00085     echo '<div class="graph">';
00086     report_log_print_graph($course, $user->id, "usercourse.png");
00087     echo '</div>';
00088     print_log($course, $user->id, 0, "l.time DESC", $page, $perpage,
00089               "user.php?course=$course->id&amp;id=$user->id&amp;mode=$mode");
00090 }
00091 
00092 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations