/** * This function extends the course navigation with the report items * * @param navigation_node $navigation The navigation node to extend * @param stdClass $user * @param stdClass $course The course to object for the report */ function report_log_extend_navigation_user($navigation, $user, $course) { list($all, $today) = report_log_can_access_user_report($user, $course); if ($today) { $url = new moodle_url('/report/log/user.php', array('id' => $user->id, 'course' => $course->id, 'mode' => 'today')); $navigation->add(get_string('todaylogs'), $url); } if ($all) { $url = new moodle_url('/report/log/user.php', array('id' => $user->id, 'course' => $course->id, 'mode' => 'all')); $navigation->add(get_string('alllogs'), $url); } }
$PAGE->set_url($url); if ($type !== "usercourse.png" and $type !== "userday.png") { $type = 'userday.png'; } $course = $DB->get_record("course", array("id" => $id), '*', MUST_EXIST); $user = $DB->get_record("user", array("id" => $user, 'deleted' => 0), '*', MUST_EXIST); $coursecontext = context_course::instance($course->id); $personalcontext = context_user::instance($user->id); if ($USER->id != $user->id and has_capability('moodle/user:viewuseractivitiesreport', $personalcontext) and !is_enrolled($coursecontext, $USER) and is_enrolled($coursecontext, $user)) { //TODO: do not require parents to be enrolled in courses - this is a hack! require_login(); $PAGE->set_course($course); } else { require_login($course); } list($all, $today) = report_log_can_access_user_report($user, $course); if ($type === "userday.png") { if (!$today) { require_capability('report/log:viewtoday', $coursecontext); } } else { if (!$all) { require_capability('report/log:view', $coursecontext); } } $logs = array(); $timenow = time(); if ($type === "usercourse.png") { $site = get_site(); if ($course->id == $site->id) { $courseselect = 0;
/** * Add nodes to myprofile page. * * @param \core_user\output\myprofile\tree $tree Tree object * @param stdClass $user user object * @param bool $iscurrentuser * @param stdClass $course Course object * * @return bool */ function report_log_myprofile_navigation(core_user\output\myprofile\tree $tree, $user, $iscurrentuser, $course) { if (empty($course)) { // We want to display these reports under the site context. $course = get_fast_modinfo(SITEID)->get_course(); } list($all, $today) = report_log_can_access_user_report($user, $course); if ($today) { // Today's log. $url = new moodle_url('/report/log/user.php', array('id' => $user->id, 'course' => $course->id, 'mode' => 'today')); $node = new core_user\output\myprofile\node('reports', 'todayslogs', get_string('todaylogs'), null, $url); $tree->add_node($node); } if ($all) { // All logs. $url = new moodle_url('/report/log/user.php', array('id' => $user->id, 'course' => $course->id, 'mode' => 'all')); $node = new core_user\output\myprofile\node('reports', 'alllogs', get_string('alllogs'), null, $url); $tree->add_node($node); } return true; }