]> git.mjollnir.org Git - moodle.git/commitdiff
Configuration option for block_course_list to determine what admin sees
authorgustav_delius <gustav_delius>
Sun, 30 May 2004 09:01:56 +0000 (09:01 +0000)
committergustav_delius <gustav_delius>
Sun, 30 May 2004 09:01:56 +0000 (09:01 +0000)
blocks/course_list/block_course_list.php
blocks/course_list/config.html [new file with mode: 0644]
lang/en/block_course_list.php [new file with mode: 0644]

index c48ea436f474cd29bc129828f98a783db3fba951..ffe4402cdc2565ec827278e4ff77c4860754de3c 100644 (file)
@@ -1,4 +1,4 @@
-<?PHP //$Id$
+Ad<?PHP //$Id$
 
 class CourseBlock_course_list extends MoodleBlock {
     function CourseBlock_course_list ($course) {
@@ -7,6 +7,25 @@ class CourseBlock_course_list extends MoodleBlock {
         $this->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  = "<img src=\"$CFG->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 (file)
index 0000000..a9aa62b
--- /dev/null
@@ -0,0 +1,31 @@
+<form method="post" action="block.php">
+
+<table cellpadding="9" cellspacing="0">
+<tr valign="top">
+    <td align="right"><p>block_course_list_adminview:</td>
+    <td>
+    <input name="block" type="hidden" value="<?php echo intval($_REQUEST['block']); ?>" />
+    <select name="block_course_list_adminview">
+     <option value="all" <?php if(isset($CFG->block_course_list_adminview)){ 
+     if($CFG->block_course_list_adminview == "all"){ p("selected");}
+     }else{
+        p("selected");
+     }?>     
+     ><?php p(get_string('allcourses', 'block_course_list')) ?></option>
+     <option value="own" <?php if(isset($CFG->block_course_list_adminview)){ 
+     if($CFG->block_course_list_adminview == "own"){ p("selected"); }
+     }?>
+     ><?php p(get_string('owncourses', 'block_course_list')) ?></option>
+    </select>
+    </td>
+    <td>
+    <?php print_string("configadminview", "block_course_list") ?>
+    </td>
+</tr>
+<tr>
+    <td colspan="3" align="center">
+    <input type="submit" value="<?php print_string("savechanges") ?>"></td>
+</tr>
+</table>
+
+</form>
diff --git a/lang/en/block_course_list.php b/lang/en/block_course_list.php
new file mode 100644 (file)
index 0000000..570f679
--- /dev/null
@@ -0,0 +1,8 @@
+<?PHP // $Id$ 
+
+$string['blockname'] = 'Course List';
+$string['allcourses'] = 'Admin user sees all courses';
+$string['configadminview'] = '';
+$string['owncourses'] = 'Admin user sees own courses';
+
+?>