Merge branch 'MDL-26502_symbian' of git://github.com/stronk7/moodle into MOODLE_19_STABLE
[moodle.git] / course / report / stats / index.php
blob7fb0f3e1213f525755cc843f4b939007d6d1583c
1 <?php // $Id$
3 require_once('../../../config.php');
4 require_once($CFG->dirroot.'/lib/statslib.php');
5 require_once($CFG->dirroot.'/course/report/stats/lib.php');
6 require_once($CFG->libdir.'/adminlib.php');
8 $courseid = optional_param('course', SITEID, PARAM_INT);
9 $report = optional_param('report', 0, PARAM_INT);
10 $time = optional_param('time', 0, PARAM_INT);
11 $mode = optional_param('mode', STATS_MODE_GENERAL, PARAM_INT);
12 $userid = optional_param('userid', 0, PARAM_INT);
13 $roleid = 0;
15 if ($report > 50) {
16 $roleid = substr($report,1);
17 $report = 5;
20 if ($report == STATS_REPORT_USER_LOGINS) {
21 $courseid = SITEID; //override
24 if ($mode == STATS_MODE_RANKED) {
25 redirect($CFG->wwwroot.'/course/report/stats/index.php?time='.$time);
28 if (!$course = get_record("course","id",$courseid)) {
29 error("That's an invalid course id");
32 if (!empty($userid)) {
33 if (!$user = get_record('user','id',$userid)) {
34 error("That's an invalid user id");
38 require_login($course);
39 $context = get_context_instance(CONTEXT_COURSE, $course->id);
41 require_capability('coursereport/stats:view', $context);
43 add_to_log($course->id, "course", "report stats", "report/stats/index.php?course=$course->id", $course->id);
44 stats_check_uptodate($course->id);
46 if ($course->id == SITEID) {
47 admin_externalpage_setup('reportstats');
48 admin_externalpage_print_header();
50 } else {
51 $strreports = get_string("reports");
52 $strstats = get_string('stats');
54 $menu = report_stats_mode_menu($course, $mode, $time, "$CFG->wwwroot/course/report/stats/index.php");
56 $navlinks = array();
57 $navlinks[] = array('name' => $strreports, 'link' => "$CFG->wwwroot/course/report.php?id=$course->id", 'type' => 'misc');
58 $navlinks[] = array('name' => $strstats, 'link' => null, 'type' => 'misc');
59 $navigation = build_navigation($navlinks);
61 print_header("$course->shortname: $strstats", $course->fullname, $navigation, '', '', true, '&nbsp;', $menu);
64 if (empty($CFG->enablestats)) {
65 if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
66 redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3);
67 } else {
68 error("Stats is not enabled.");
72 require($CFG->dirroot.'/course/report/stats/report.php');
74 print_footer();