]> git.mjollnir.org Git - moodle.git/commitdiff
Some tidying up of admin blocks
authormoodler <moodler>
Wed, 6 Sep 2006 05:24:35 +0000 (05:24 +0000)
committermoodler <moodler>
Wed, 6 Sep 2006 05:24:35 +0000 (05:24 +0000)
blocks/admin/block_admin.php
blocks/admin_bookmarks/block_admin_bookmarks.php
blocks/admin_tree/block_admin_tree.php
lang/en_utf8/moodle.php

index 26d944ac77c230fbf07ace517882f9e225d6cfe8..c2379b49a898cbd2d00cd7b965c286db014fa212 100644 (file)
@@ -8,7 +8,9 @@ class block_admin extends block_list {
 
     function get_content() {
 
-        if($this->content !== NULL) {
+        global $CFG, $USER;
+
+        if ($this->content !== NULL) {
             return $this->content;
         }
 
@@ -18,180 +20,115 @@ class block_admin extends block_list {
         $this->content->footer = '';
 
         if (empty($this->instance)) {
-            $this->content = '';
+            return $this->content = '';
         } else if ($this->instance->pageid == SITEID) {
-            $this->load_content_for_site();
-        } else {
-            $this->load_content_for_course();
-        }
-
-        return $this->content;
-    }
-
-
-    function load_content_for_site() {
-        global $CFG, $USER;
-        
-        $context = get_context_instance(CONTEXT_SYSTEM, SITEID);
-/*        if (has_capability('moodle/site:config', $context)) {
-
-            $this->content->items[] = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/configure.php">'.get_string('configuration').'</a>';
-            $this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/admin.gif" alt="" />';
-        }
-        
-        if (has_capability('moodle/site:config', $context)) {
-            $this->content->items[] = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/users.php">'.get_string('users').'</a>';
-            $this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/users.gif" alt="" />';
-        }*/
-        
-        if (has_capability('moodle/site:backup', $context)) {
-            $this->content->items[]='<a href="'.$CFG->wwwroot.'/backup/backup.php?id='.SITEID.'">'.get_string('backup').'</a>';
-            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/backup.gif" alt="" />';
-        }
-        
-        if (has_capability('moodle/site:restore', $context)) {
-            $this->content->items[]='<a href="'.$CFG->wwwroot.'/files/index.php?id='.SITEID.'&amp;wdir=/backupdata">'.get_string('restore').'</a>';
-            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/restore.gif" alt="" />';
-        }
-
-        if (has_capability('moodle/course:create', $context)) {
-            $this->content->items[] = '<a href="'.$CFG->wwwroot.'/course/index.php?edit=on&amp;sesskey='.sesskey().'">'.get_string('courses').'</a>';
-            $this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/course.gif" alt="" />';
+            return $this->content = '';
         }
 
-        if (has_capability('moodle/site:config', $context)) {
-            $this->content->items[] = '<a href="'.$CFG->wwwroot.'/course/report/log/index.php?id='.SITEID.'">'.get_string('logs').'</a>';
-            $this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/log.gif" alt="" />';
-
-
-            $this->content->items[] = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/report.php">'.get_string('reports').'</a>';
-            $this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/stats.gif" alt="" />';
-
-            $this->content->items[] = '<a href="'.$CFG->wwwroot.'/files/index.php?id='.SITEID.'">'.get_string('sitefiles').'</a>';
-            $this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/files.gif" alt="" />';
 
-            if (file_exists($CFG->dirroot.'/admin/'.$CFG->dbtype)) {
-                $this->content->items[] = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/'.$CFG->dbtype.'/frame.php">'.get_string('managedatabase').'</a>';
-                $this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/db.gif" alt="" />';
-            }
-
-            if ($CFG->enrol == 'authorize') {
-                require_once($CFG->dirroot.'/enrol/authorize/const.php');
-                $paymenturl = '<a href="'.$CFG->wwwroot.'/enrol/authorize/index.php">'.get_string('payments').'</a> ';
-                if ($cnt = count_records('enrol_authorize', 'status', AN_STATUS_AUTH)) {
-                    $paymenturl .= '<a href="'.$CFG->wwwroot.'/enrol/authorize/index.php?status='.AN_STATUS_AUTH.'">'.get_string('paymentpending', 'moodle', $cnt).'</a>';
-                }
-                $this->content->items[] = $paymenturl;
-                $this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/payment.gif" alt="" />';
-            }
-
-            $this->content->footer = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/">'.get_string('admin').'...</a>';
-        }
-    }
+        $course = get_record('course', 'id', $this->instance->pageid);
 
-    function load_content_for_course() {
-        global $CFG, $USER;
         $context = get_context_instance(CONTEXT_COURSE, $this->instance->pageid);
 
-        require_once($CFG->dirroot.'/mod/forum/lib.php');
-
-        if (isguest()) {
+        if (!has_capability('moodle/course:view', $context)) {  // Just return 
             return $this->content;
         }
 
-        if(empty($CFG->loginhttps)) {
+        if (empty($CFG->loginhttps)) {
             $securewwwroot = $CFG->wwwroot;
         } else {
             $securewwwroot = str_replace('http:','https:',$CFG->wwwroot);
         }
 
-        $course = get_record('course', 'id', $this->instance->pageid);
+    /// Course editing on/off
 
-        if (isteacher($this->instance->pageid)) {
-
-            if (has_capability('moodle/course:update', $context)) {
-                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/edit.gif" alt="" />';
-                if (isediting($this->instance->pageid)) {
-                    $this->content->items[]='<a href="view.php?id='.$this->instance->pageid.'&amp;edit=off&amp;sesskey='.sesskey().'">'.get_string('turneditingoff').'</a>';
-                } else {
-                    $this->content->items[]='<a href="view.php?id='.$this->instance->pageid.'&amp;edit=on&amp;sesskey='.sesskey().'">'.get_string('turneditingon').'</a>';
-                }
-                
-                $this->content->items[]='<a href="edit.php?id='.$this->instance->pageid.'">'.get_string('settings').'</a>';
-                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/settings.gif" alt="" />';
-            }
-            
-            $fullname = fullname($USER, has_capability('moodle/site:viewfullnames', $context));
-            $editmyprofile = '<a title="'.$fullname.'" href="'.$CFG->wwwroot.'/user/edit.php?id='.$USER->id.'&amp;course='.$this->instance->pageid.'">'.get_string('editmyprofile').'</a>';
-            if (empty($USER->description)) {
-                    //Accessibility: replace non-standard <blink> with CSS (<a> makes title visible in IE).
-                $text = get_string('profile').' '.get_string('missingdescription');
-                $this->content->items[]= $editmyprofile.' <a title="'.$text.'" class="useredit blink">*<span class="accesshide">'.$text.'</span></a>';
+        if (has_capability('moodle/course:update', $context)) {
+            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/edit.gif" alt="" />';
+            if (isediting($this->instance->pageid)) {
+                $this->content->items[]='<a href="view.php?id='.$this->instance->pageid.'&amp;edit=off&amp;sesskey='.sesskey().'">'.get_string('turneditingoff').'</a>';
             } else {
-                $this->content->items[]= $editmyprofile;
+                $this->content->items[]='<a href="view.php?id='.$this->instance->pageid.'&amp;edit=on&amp;sesskey='.sesskey().'">'.get_string('turneditingon').'</a>';
             }
-            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" alt="" />';
+            
+            $this->content->items[]='<a href="edit.php?id='.$this->instance->pageid.'">'.get_string('settings').'</a>';
+            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/settings.gif" alt="" />';
+        }
+            
 
-            /// always need a role assignment link
-            if (has_capability('moodle/role:assign', $context)) { 
-                $this->content->items[]='<a href="'.$CFG->wwwroot.'/admin/roles/assign.php?contextid='.$context->id.'">'.get_string('assignroles', 'role').'</a>';
-                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/roles.gif" alt="" />';         
-            }
+    /// Assign roles to the course
+
+        if (has_capability('moodle/role:assign', $context)) { 
+            $this->content->items[]='<a href="'.$CFG->wwwroot.'/admin/roles/assign.php?contextid='.$context->id.'">'.get_string('assignroles', 'role').'</a>';
+            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/roles.gif" alt="" />';         
             
             if ($course->metacourse) {
                 $strchildcourses = get_string('childcourses');
                 $this->content->items[]='<a href="importstudents.php?id='.$this->instance->pageid.'">'.$strchildcourses.'</a>';
                 $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/course.gif" alt="" />';
             }
-            if (($course->groupmode || !$course->groupmodeforce) && has_capability('moodle/course:managegroups', $context)) {
-                $strgroups = get_string('groups');
-                $this->content->items[]='<a title="'.$strgroups.'" href="'.$CFG->wwwroot.'/course/groups.php?id='.$this->instance->pageid.'">'.$strgroups.'</a>';
-                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/group.gif" alt="" />';
-            }
+        }
 
-            if (has_capability('moodle/site:backup', $context)) { 
-                $this->content->items[]='<a href="'.$CFG->wwwroot.'/backup/backup.php?id='.$this->instance->pageid.'">'.get_string('backup').'</a>';
-                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/backup.gif" alt="" />';
-            }
-            
-            if (has_capability('moodle/site:restore', $context)) {
-                $this->content->items[]='<a href="'.$CFG->wwwroot.'/files/index.php?id='.$this->instance->pageid.'&amp;wdir=/backupdata">'.get_string('restore').'</a>';
-                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/restore.gif" alt="" />';
-            }
-            
-            if (has_capability('moodle/site:import', $context)) {
-                $this->content->items[]='<a href="'.$CFG->wwwroot.'/course/import.php?id='.$this->instance->pageid.'">'.get_string('import').'</a>';
-                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/restore.gif" alt="" />';
-            }
-            
-            if (has_capability('moodle/course:reset', $context)) {
-                $this->content->items[]='<a href="'.$CFG->wwwroot.'/course/reset.php?id='.$this->instance->pageid.'">'.get_string('reset').'</a>';
-                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/return.gif" alt="" />';
-            }
-            
-            if (has_capability('moodle/site:viewreports', $context)) {
-                $this->content->items[]='<a href="'.$CFG->wwwroot.'/course/report.php?id='.$this->instance->pageid.'">'.get_string('reports').'</a>';
-                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/stats.gif" alt="" />';
-            }
-            
-            if (has_capability('moodle/course:managequestions', $context)) {
-                $this->content->items[]='<a href="'.$CFG->wwwroot.'/question/edit.php?courseid='.$this->instance->pageid.'&amp;clean=true">'.get_string('questions', 'quiz').'</a>';
-                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/questions.gif" alt="" />';
-            }
 
-            if (has_capability('moodle/course:managescales', $context)) {
-                $this->content->items[]='<a href="scales.php?id='.$this->instance->pageid.'">'.get_string('scales').'</a>';
-                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/scales.gif" alt="" />';      
-            }
+    /// Manage groups in this course
+
+        if (($course->groupmode || !$course->groupmodeforce) && has_capability('moodle/course:managegroups', $context)) {
+            $strgroups = get_string('groups');
+            $this->content->items[]='<a title="'.$strgroups.'" href="'.$CFG->wwwroot.'/course/groups.php?id='.$this->instance->pageid.'">'.$strgroups.'</a>';
+            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/group.gif" alt="" />';
+        }
+
+    /// Backup this course
+
+        if (has_capability('moodle/site:backup', $context)) { 
+            $this->content->items[]='<a href="'.$CFG->wwwroot.'/backup/backup.php?id='.$this->instance->pageid.'">'.get_string('backup').'</a>';
+            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/backup.gif" alt="" />';
+        }
             
-            $this->content->items[]='<a href="'.$CFG->wwwroot.'/grade/index.php?id='.$this->instance->pageid.'">'.get_string('grades').'</a>';
-            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/grades.gif" alt="" />';
+    /// Restore to this course
+        if (has_capability('moodle/site:restore', $context)) {
+            $this->content->items[]='<a href="'.$CFG->wwwroot.'/files/index.php?id='.$this->instance->pageid.'&amp;wdir=/backupdata">'.get_string('restore').'</a>';
+            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/restore.gif" alt="" />';
+        }
+        
+    /// Import data from other courses
+        if (has_capability('moodle/site:import', $context)) {
+            $this->content->items[]='<a href="'.$CFG->wwwroot.'/course/import.php?id='.$this->instance->pageid.'">'.get_string('import').'</a>';
+            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/restore.gif" alt="" />';
+        }
+        
+    /// Reset this course
+        if (has_capability('moodle/course:reset', $context)) {
+            $this->content->items[]='<a href="'.$CFG->wwwroot.'/course/reset.php?id='.$this->instance->pageid.'">'.get_string('reset').'</a>';
+            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/return.gif" alt="" />';
+        }
+        
+    /// View course reports
+        if (has_capability('moodle/site:viewreports', $context)) {
+            $this->content->items[]='<a href="'.$CFG->wwwroot.'/course/report.php?id='.$this->instance->pageid.'">'.get_string('reports').'</a>';
+            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/stats.gif" alt="" />';
+        }
+        
+    /// Manage questions
+        if (has_capability('moodle/course:managequestions', $context)) {
+            $this->content->items[]='<a href="'.$CFG->wwwroot.'/question/edit.php?courseid='.$this->instance->pageid.'&amp;clean=true">'.get_string('questions', 'quiz').'</a>';
+            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/questions.gif" alt="" />';
+        }
 
-            if (has_capability('moodle/course:managefiles', $context)) {
-                $this->content->items[]='<a href="'.$CFG->wwwroot.'/files/index.php?id='.$this->instance->pageid.'">'.get_string('files').'</a>';
-                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/files.gif" alt="" />';
-            }
+    /// Manage scales
+        if (has_capability('moodle/course:managescales', $context)) {
+            $this->content->items[]='<a href="scales.php?id='.$this->instance->pageid.'">'.get_string('scales').'</a>';
+            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/scales.gif" alt="" />';      
+        }
+        
 
+    /// Manage files
+        if (has_capability('moodle/course:managefiles', $context)) {
+            $this->content->items[]='<a href="'.$CFG->wwwroot.'/files/index.php?id='.$this->instance->pageid.'">'.get_string('files').'</a>';
+            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/files.gif" alt="" />';
+        }
+
+    /// Authorize hooks
+        if (has_capability('enrol/authorize:managepayments', $context)) {
             if ($course->enrol == 'authorize' || (empty($course->enrol) && $CFG->enrol == 'authorize')) {
                 require_once($CFG->dirroot.'/enrol/authorize/const.php');
                 $paymenturl = '<a href="'.$CFG->wwwroot.'/enrol/authorize/index.php?course='.$course->id.'">'.get_string('payments').'</a> ';
@@ -201,49 +138,53 @@ class block_admin extends block_list {
                 $this->content->items[] = $paymenturl;
                 $this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/payment.gif" alt="" />';
             }
+        }
 
-            $lang = str_replace('_utf8', '', current_language());
+    /// View course grades (or just your own grades, same link)
+        if (has_capability('moodle/course:viewcoursegrades', $context) or 
+            (has_capability('moodle/course:viewusergrades', $context) && $course->showgrades)) {
+            $this->content->items[]='<a href="'.$CFG->wwwroot.'/grade/index.php?id='.$this->instance->pageid.'">'.get_string('grades').'</a>';
+            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/grades.gif" alt="" />';
+        }
 
-            $this->content->items[]='<a href="http://docs.moodle.org/'.$lang.'/Teacher_documentation">'.get_string('help').'</a>';
-            $this->content->icons[]='<img src="'.$CFG->modpixpath.'/resource/icon.gif" alt="" />';
+    /// Person can unenrol themselves from this course
+        if (has_capability('moodle/role:unassignself', $context, NULL, false) and empty($course->metacourse)) {
+            $this->content->items[]='<a href="unenrol.php?id='.$this->instance->pageid.'">'.get_string('unenrolme', '', $course->shortname).'</a>';
+            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" alt="" />';
+        }
 
-        } else if (has_capability('moodle/course:view', $context)) {  // Students menu
 
-            if ($course->showgrades) {
-                $this->content->items[]='<a href="'.$CFG->wwwroot.'/grade/index.php?id='.$this->instance->pageid.'">'.get_string('grades').'</a>';
-                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/grades.gif" alt="" />';
-            }
-            if ($course->showreports) {
-                $this->content->items[]='<a href="user.php?id='.$this->instance->pageid.'&amp;user='.$USER->id.'">'.get_string('activityreport').'</a>';
-                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/report.gif" alt="" />';
-            }
 
-            $fullname = fullname($USER, true);
-            $editmyprofile = '<a title="'.$fullname.'" href="'.$securewwwroot.'/user/edit.php?id='.
-                             $USER->id.'&amp;course='.$this->instance->pageid.'">'.get_string('editmyprofile').'</a>';
-            if (empty($USER->description)) {
-                //Accessibility: replace non-standard <blink> with CSS (<a> makes title visible in IE).
-                $text = get_string('profile').' '.get_string('missingdescription');
-                $this->content->items[]= $editmyprofile.' <a title="'.$text.'" class="useredit blink">*<span class="accesshide">'.$text.'</span></a>';
-            } else {
-                $this->content->items[]= $editmyprofile;
-            }
-            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" alt="" />';
+    /// Should the following two be in this block?
 
-            if (is_internal_auth()) {
-                $this->content->items[]='<a href="'.$securewwwroot.'/login/change_password.php?id='.$this->instance->pageid.'">'.get_string('changepassword').'</a>';
-                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" alt="" />';
-            } 
-            
-            if ($CFG->allowunenroll && !$course->metacourse) {
-                $this->content->items[]='<a href="unenrol.php?id='.$this->instance->pageid.'">'.get_string('unenrolme', '', $course->shortname).'</a>';
-                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" alt="" />';
-            }
-        }
+
+    /// View own activity report
+//        if ($course->showreports) {
+//            $this->content->items[]='<a href="user.php?id='.$this->instance->pageid.'&amp;user='.$USER->id.'">'.get_string('activityreport').'</a>';
+//            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/report.gif" alt="" />';
+//        }
+
+
+    /// Edit your own profile
+
+//        $fullname = fullname($USER, has_capability('moodle/site:viewfullnames', $context));
+//        $editmyprofile = '<a title="'.$fullname.'" href="'.$CFG->wwwroot.'/user/edit.php?id='.$USER->id.'&amp;course='.$this->instance->pageid.'">'.get_string('editmyprofile').'</a>';
+//        if (empty($USER->description)) {
+//                //Accessibility: replace non-standard <blink> with CSS (<a> makes title visible in IE).
+//            $text = get_string('profile').' '.get_string('missingdescription');
+//            $this->content->items[]= $editmyprofile.' <a title="'.$text.'" class="useredit blink">*<span class="accesshide">'.$text.'</span></a>';
+//        } else {
+//            $this->content->items[]= $editmyprofile;
+//        }
+//        $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" alt="" />';
+
+
+
+        return $this->content;
     }
 
     function applicable_formats() {
-        return array('all' => true, 'mod' => false, 'my' => false, 'admin' => false);
+        return array('all' => false, 'course' => true);
     }
 }
 
index 126e44b97dec7f3ea612ccf8e85919134ab5b7cb..13a9d63da0b92d67a7417d8d33dc73a3d2d54902 100644 (file)
@@ -12,7 +12,7 @@ class block_admin_bookmarks extends block_base {
     }
 
     function applicable_formats() {
-        return array('site' => true, 'admin' => true);
+        return array('all' => true);
     }
 
     function preferred_width() {
@@ -65,4 +65,4 @@ class block_admin_bookmarks extends block_base {
     }
 }
 
-?>
\ No newline at end of file
+?>
index 9aa8f55b544c4cbb69a1cfbb68aa58d79d0c9376..663f384ff04ef49b0f9aff18c575504b0a31fdc7 100644 (file)
@@ -11,7 +11,7 @@ class block_admin_tree extends block_base {
 
     function init() {
         global $PAGE;
-        $this->title = get_string('admintree');
+        $this->title = get_string('administrationsite');
         $this->version = 2006090300;
         $this->currentdepth = 0;
         $this->spancounter = 1;
index 8a4dd8a2d2d792256134ea6e5cfd18e9f0d1ea17..908f1c3fe3abc2402340f636dc3ebf790a049457 100644 (file)
@@ -37,6 +37,7 @@ $string['addstudent'] = 'Add student';
 $string['addteacher'] = 'Add teacher';
 $string['addnousersrecip'] = 'Add users who haven\'t accessed this $a to recipient list';
 $string['admin'] = 'Admin';
+$string['adminbookmarks'] = 'Admin bookmarks';
 $string['adminprimarynoedit'] = 'You may not change the primary admin\'s password';
 $string['adminhelpaddnewuser'] = 'To manually create a new user account';
 $string['adminhelpassignadmins'] = 'Admins can do anything and go anywhere in the site';
@@ -72,6 +73,7 @@ $string['adminhelpuploadusers'] = 'Import new user accounts from a text file';
 $string['adminhelpxmldbeditor'] = 'Interface to edit the XMLDB files. Only for developers.';
 $string['adminhelpusers'] = 'Define your users and set up authentication';
 $string['administration'] = 'Administration';
+$string['administrationsite'] = 'Site Administration';
 $string['administrator'] = 'Administrator';
 $string['administratordescription'] = 'Administrators can usually do anything on the site, in all courses.';
 $string['administrators'] = 'Administrators';