From 0d2aa4a617df20143b5800a939de6de89d5c5a6a Mon Sep 17 00:00:00 2001 From: skodak Date: Sat, 29 Nov 2008 16:16:21 +0000 Subject: [PATCH] MDL-17465 - separate live log capability adn admin tree link; backported from HEAD --- course/report/log/db/access.php | 14 ++++++++++ course/report/log/index.php | 8 ------ course/report/log/indexlive.php | 43 +++++++++++++++++++++++++++++++ course/report/log/live.php | 2 +- course/report/log/mod.php | 2 ++ course/report/log/version.php | 2 +- lang/en_utf8/coursereport_log.php | 3 +++ theme/standard/styles_layout.css | 3 ++- version.php | 2 +- 9 files changed, 67 insertions(+), 12 deletions(-) create mode 100644 course/report/log/indexlive.php diff --git a/course/report/log/db/access.php b/course/report/log/db/access.php index b8873df06fc..85377d37742 100644 --- a/course/report/log/db/access.php +++ b/course/report/log/db/access.php @@ -35,8 +35,22 @@ $coursereport_log_capabilities = array( 'admin' => CAP_ALLOW ), + 'clonepermissionsfrom' => 'moodle/site:viewreports', + ), + + 'coursereport/log:viewlive' => array( + 'riskbitmask' => RISK_PERSONAL, + 'captype' => 'read', + 'contextlevel' => CONTEXT_COURSE, + 'legacy' => array( + 'teacher' => CAP_ALLOW, + 'editingteacher' => CAP_ALLOW, + 'admin' => CAP_ALLOW + ), + 'clonepermissionsfrom' => 'moodle/site:viewreports', ) + ); ?> diff --git a/course/report/log/index.php b/course/report/log/index.php index e6ddbaee99b..0b2cc586460 100644 --- a/course/report/log/index.php +++ b/course/report/log/index.php @@ -136,14 +136,6 @@ print_heading(get_string('chooselogs') .':'); print_log_selector_form($course, $user, $date, $modname, $modid, $modaction, $group, $showcourses, $showusers, $logformat); - - echo '
'; - print_heading(get_string('chooselivelogs') .':'); - - echo '

'; - link_to_popup_window('/course/report/log/live.php?id='. $course->id,'livelog', get_string('livelogs'), 500, 800); - echo '

'; - } print_footer($course); diff --git a/course/report/log/indexlive.php b/course/report/log/indexlive.php new file mode 100644 index 00000000000..1332c729cb1 --- /dev/null +++ b/course/report/log/indexlive.php @@ -0,0 +1,43 @@ +libdir.'/adminlib.php'); + + $id = optional_param('id', 0, PARAM_INT);// Course ID + + if (!$course = get_record('course', 'id', $id) ) { + error('That\'s an invalid course id'.$id); + } + + require_login($course); + $context = get_context_instance(CONTEXT_COURSE, $course->id); + + require_capability('coursereport/log:viewlive', $context); + + $strlogs = get_string('logs'); + $strreports = get_string('reports'); + + if ($course->id == SITEID) { + admin_externalpage_setup('reportloglive'); + admin_externalpage_print_header(); + + } else { + $navlinks = array(); + $navlinks[] = array('name' => $strreports, 'link' => "$CFG->wwwroot/course/report.php?id=$course->id", 'type' => 'misc'); + $navlinks[] = array('name' => $strlogs, 'link' => null, 'type' => 'misc'); + $navigation = build_navigation($navlinks); + print_header($course->shortname .': '. $strlogs, $course->fullname, $navigation, ''); + } + + print_heading(get_string('loglive', 'coursereport_log')); + + echo '
'; + link_to_popup_window('/course/report/log/live.php?id='. $course->id,'livelog', get_string('livelogs'), 500, 800); + echo '
'; + + print_footer($course); + +?> diff --git a/course/report/log/live.php b/course/report/log/live.php index dc739661a1b..f4a8fbaf629 100644 --- a/course/report/log/live.php +++ b/course/report/log/live.php @@ -14,7 +14,7 @@ require_login($course); $context = get_context_instance(CONTEXT_COURSE, $course->id); - require_capability('coursereport/log:view', $context); + require_capability('coursereport/log:viewlive', $context); add_to_log($course->id, "course", "report live", "report/log/live.php?id=$course->id", $course->id); diff --git a/course/report/log/mod.php b/course/report/log/mod.php index a3eff2b7801..970253b84c1 100644 --- a/course/report/log/mod.php +++ b/course/report/log/mod.php @@ -11,7 +11,9 @@ print_heading(get_string('chooselogs') .':'); print_log_selector_form($course); + } + if (has_capability('coursereport/log:viewlive', $context)) { print_heading(get_string('chooselivelogs') .':'); echo '

'; link_to_popup_window('/course/report/log/live.php?id='. $course->id,'livelog', get_string('livelogs'), 500, 800); diff --git a/course/report/log/version.php b/course/report/log/version.php index c62920f9d7c..702efd5e035 100644 --- a/course/report/log/version.php +++ b/course/report/log/version.php @@ -23,7 +23,7 @@ // // /////////////////////////////////////////////////////////////////////////// -$plugin->version = 2007101500; +$plugin->version = 2007101502; $plugin->requires = 2007101532; ?> diff --git a/lang/en_utf8/coursereport_log.php b/lang/en_utf8/coursereport_log.php index 6b1de337123..721454522e0 100644 --- a/lang/en_utf8/coursereport_log.php +++ b/lang/en_utf8/coursereport_log.php @@ -1,5 +1,8 @@ diff --git a/theme/standard/styles_layout.css b/theme/standard/styles_layout.css index c34fe79c6c1..c3af369af33 100644 --- a/theme/standard/styles_layout.css +++ b/theme/standard/styles_layout.css @@ -2101,7 +2101,8 @@ body#course-info .generalbox.info { margin-right:5px; } -#course-report-log-index .info { +#course-report-log-index .info, +#course-report-log-indexlive .info { margin-left:auto; margin-right:auto; text-align:center; diff --git a/version.php b/version.php index 231140772eb..de7b636267e 100644 --- a/version.php +++ b/version.php @@ -6,7 +6,7 @@ // This is compared against the values stored in the database to determine // whether upgrades should be performed (see lib/db/*.php) - $version = 2007101532.02; // YYYYMMDD = date of the 1.9 branch (don't change) + $version = 2007101532.03; // YYYYMMDD = date of the 1.9 branch (don't change) // X = release number 1.9.[0,1,2,3...] // Y.YY = micro-increments between releases