From 58bed599f391297fd7a1f2f7b0d42c2bc3adc3d1 Mon Sep 17 00:00:00 2001 From: gustav_delius Date: Sun, 30 May 2004 09:01:56 +0000 Subject: [PATCH] Configuration option for block_course_list to determine what admin sees --- blocks/course_list/block_course_list.php | 30 +++++++++++++++++++++-- blocks/course_list/config.html | 31 ++++++++++++++++++++++++ lang/en/block_course_list.php | 8 ++++++ 3 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 blocks/course_list/config.html create mode 100644 lang/en/block_course_list.php diff --git a/blocks/course_list/block_course_list.php b/blocks/course_list/block_course_list.php index c48ea436f4..ffe4402cdc 100644 --- a/blocks/course_list/block_course_list.php +++ b/blocks/course_list/block_course_list.php @@ -1,4 +1,4 @@ -course = $course; $this->version = 2005052600; } + + function has_config() { + return true; + } + + function print_config() { + global $CFG, $THEME; + print_simple_box_start('center', '', $THEME->cellheading); + include($CFG->dirroot.'/blocks/'.$this->name().'/config.html'); + print_simple_box_end(); + return true; + } + + function handle_config($config) { + foreach ($config as $name => $value) { + set_config($name, $value); + } + return true; + } function applicable_formats() { return COURSE_FORMAT_WEEKS | COURSE_FORMAT_TOPICS | COURSE_FORMAT_SOCIAL | COURSE_FORMAT_SITE; @@ -31,8 +50,15 @@ class CourseBlock_course_list extends MoodleBlock { $icon = "wwwroot/theme/$CFG->theme/pix/i/course.gif\"". " height=\"16\" width=\"16\" alt=\"".get_string("course")."\">"; } + + $adminseesall = true; + if (isset($CFG->block_course_list_adminview)) { + if ( $CFG->block_course_list_adminview == 'own'){ + $adminseesall = false; + } + } - if (isset($USER->id) and !isadmin()) { // Just print My Courses + if (isset($USER->id) and !(isadmin() and $adminseesall)) { // Just print My Courses if ($courses = get_my_courses($USER->id)) { foreach ($courses as $course) { if (!$course->category) { diff --git a/blocks/course_list/config.html b/blocks/course_list/config.html new file mode 100644 index 0000000000..a9aa62babe --- /dev/null +++ b/blocks/course_list/config.html @@ -0,0 +1,31 @@ +
+ + + + + + + + + + +

block_course_list_adminview:

+ + + + +
+ ">
+ +
diff --git a/lang/en/block_course_list.php b/lang/en/block_course_list.php new file mode 100644 index 0000000000..570f6794c2 --- /dev/null +++ b/lang/en/block_course_list.php @@ -0,0 +1,8 @@ + -- 2.39.5