From b649a19e20f07c3a8962a293d3d1fcc199a3521d Mon Sep 17 00:00:00 2001 From: moodler Date: Wed, 6 Sep 2006 05:24:35 +0000 Subject: [PATCH] Some tidying up of admin blocks --- blocks/admin/block_admin.php | 299 +++++++----------- .../admin_bookmarks/block_admin_bookmarks.php | 4 +- blocks/admin_tree/block_admin_tree.php | 2 +- lang/en_utf8/moodle.php | 2 + 4 files changed, 125 insertions(+), 182 deletions(-) diff --git a/blocks/admin/block_admin.php b/blocks/admin/block_admin.php index 26d944ac77..c2379b49a8 100644 --- a/blocks/admin/block_admin.php +++ b/blocks/admin/block_admin.php @@ -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[] = ''.get_string('configuration').''; - $this->content->icons[] = ''; - } - - if (has_capability('moodle/site:config', $context)) { - $this->content->items[] = ''.get_string('users').''; - $this->content->icons[] = ''; - }*/ - - if (has_capability('moodle/site:backup', $context)) { - $this->content->items[]=''.get_string('backup').''; - $this->content->icons[]=''; - } - - if (has_capability('moodle/site:restore', $context)) { - $this->content->items[]=''.get_string('restore').''; - $this->content->icons[]=''; - } - - if (has_capability('moodle/course:create', $context)) { - $this->content->items[] = ''.get_string('courses').''; - $this->content->icons[] = ''; + return $this->content = ''; } - if (has_capability('moodle/site:config', $context)) { - $this->content->items[] = ''.get_string('logs').''; - $this->content->icons[] = ''; - - - $this->content->items[] = ''.get_string('reports').''; - $this->content->icons[] = ''; - - $this->content->items[] = ''.get_string('sitefiles').''; - $this->content->icons[] = ''; - if (file_exists($CFG->dirroot.'/admin/'.$CFG->dbtype)) { - $this->content->items[] = ''.get_string('managedatabase').''; - $this->content->icons[] = ''; - } - - if ($CFG->enrol == 'authorize') { - require_once($CFG->dirroot.'/enrol/authorize/const.php'); - $paymenturl = ''.get_string('payments').' '; - if ($cnt = count_records('enrol_authorize', 'status', AN_STATUS_AUTH)) { - $paymenturl .= ''.get_string('paymentpending', 'moodle', $cnt).''; - } - $this->content->items[] = $paymenturl; - $this->content->icons[] = ''; - } - - $this->content->footer = ''.get_string('admin').'...'; - } - } + $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[]=''; - if (isediting($this->instance->pageid)) { - $this->content->items[]=''.get_string('turneditingoff').''; - } else { - $this->content->items[]=''.get_string('turneditingon').''; - } - - $this->content->items[]=''.get_string('settings').''; - $this->content->icons[]=''; - } - - $fullname = fullname($USER, has_capability('moodle/site:viewfullnames', $context)); - $editmyprofile = ''.get_string('editmyprofile').''; - if (empty($USER->description)) { - //Accessibility: replace non-standard with CSS ( makes title visible in IE). - $text = get_string('profile').' '.get_string('missingdescription'); - $this->content->items[]= $editmyprofile.' *'.$text.''; + if (has_capability('moodle/course:update', $context)) { + $this->content->icons[]=''; + if (isediting($this->instance->pageid)) { + $this->content->items[]=''.get_string('turneditingoff').''; } else { - $this->content->items[]= $editmyprofile; + $this->content->items[]=''.get_string('turneditingon').''; } - $this->content->icons[]=''; + + $this->content->items[]=''.get_string('settings').''; + $this->content->icons[]=''; + } + - /// always need a role assignment link - if (has_capability('moodle/role:assign', $context)) { - $this->content->items[]=''.get_string('assignroles', 'role').''; - $this->content->icons[]=''; - } + /// Assign roles to the course + + if (has_capability('moodle/role:assign', $context)) { + $this->content->items[]=''.get_string('assignroles', 'role').''; + $this->content->icons[]=''; if ($course->metacourse) { $strchildcourses = get_string('childcourses'); $this->content->items[]=''.$strchildcourses.''; $this->content->icons[]=''; } - if (($course->groupmode || !$course->groupmodeforce) && has_capability('moodle/course:managegroups', $context)) { - $strgroups = get_string('groups'); - $this->content->items[]=''.$strgroups.''; - $this->content->icons[]=''; - } + } - if (has_capability('moodle/site:backup', $context)) { - $this->content->items[]=''.get_string('backup').''; - $this->content->icons[]=''; - } - - if (has_capability('moodle/site:restore', $context)) { - $this->content->items[]=''.get_string('restore').''; - $this->content->icons[]=''; - } - - if (has_capability('moodle/site:import', $context)) { - $this->content->items[]=''.get_string('import').''; - $this->content->icons[]=''; - } - - if (has_capability('moodle/course:reset', $context)) { - $this->content->items[]=''.get_string('reset').''; - $this->content->icons[]=''; - } - - if (has_capability('moodle/site:viewreports', $context)) { - $this->content->items[]=''.get_string('reports').''; - $this->content->icons[]=''; - } - - if (has_capability('moodle/course:managequestions', $context)) { - $this->content->items[]=''.get_string('questions', 'quiz').''; - $this->content->icons[]=''; - } - if (has_capability('moodle/course:managescales', $context)) { - $this->content->items[]=''.get_string('scales').''; - $this->content->icons[]=''; - } + /// Manage groups in this course + + if (($course->groupmode || !$course->groupmodeforce) && has_capability('moodle/course:managegroups', $context)) { + $strgroups = get_string('groups'); + $this->content->items[]=''.$strgroups.''; + $this->content->icons[]=''; + } + + /// Backup this course + + if (has_capability('moodle/site:backup', $context)) { + $this->content->items[]=''.get_string('backup').''; + $this->content->icons[]=''; + } - $this->content->items[]=''.get_string('grades').''; - $this->content->icons[]=''; + /// Restore to this course + if (has_capability('moodle/site:restore', $context)) { + $this->content->items[]=''.get_string('restore').''; + $this->content->icons[]=''; + } + + /// Import data from other courses + if (has_capability('moodle/site:import', $context)) { + $this->content->items[]=''.get_string('import').''; + $this->content->icons[]=''; + } + + /// Reset this course + if (has_capability('moodle/course:reset', $context)) { + $this->content->items[]=''.get_string('reset').''; + $this->content->icons[]=''; + } + + /// View course reports + if (has_capability('moodle/site:viewreports', $context)) { + $this->content->items[]=''.get_string('reports').''; + $this->content->icons[]=''; + } + + /// Manage questions + if (has_capability('moodle/course:managequestions', $context)) { + $this->content->items[]=''.get_string('questions', 'quiz').''; + $this->content->icons[]=''; + } - if (has_capability('moodle/course:managefiles', $context)) { - $this->content->items[]=''.get_string('files').''; - $this->content->icons[]=''; - } + /// Manage scales + if (has_capability('moodle/course:managescales', $context)) { + $this->content->items[]=''.get_string('scales').''; + $this->content->icons[]=''; + } + + /// Manage files + if (has_capability('moodle/course:managefiles', $context)) { + $this->content->items[]=''.get_string('files').''; + $this->content->icons[]=''; + } + + /// 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 = ''.get_string('payments').' '; @@ -201,49 +138,53 @@ class block_admin extends block_list { $this->content->items[] = $paymenturl; $this->content->icons[] = ''; } + } - $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[]=''.get_string('grades').''; + $this->content->icons[]=''; + } - $this->content->items[]=''.get_string('help').''; - $this->content->icons[]=''; + /// Person can unenrol themselves from this course + if (has_capability('moodle/role:unassignself', $context, NULL, false) and empty($course->metacourse)) { + $this->content->items[]=''.get_string('unenrolme', '', $course->shortname).''; + $this->content->icons[]=''; + } - } else if (has_capability('moodle/course:view', $context)) { // Students menu - if ($course->showgrades) { - $this->content->items[]=''.get_string('grades').''; - $this->content->icons[]=''; - } - if ($course->showreports) { - $this->content->items[]=''.get_string('activityreport').''; - $this->content->icons[]=''; - } - $fullname = fullname($USER, true); - $editmyprofile = ''.get_string('editmyprofile').''; - if (empty($USER->description)) { - //Accessibility: replace non-standard with CSS ( makes title visible in IE). - $text = get_string('profile').' '.get_string('missingdescription'); - $this->content->items[]= $editmyprofile.' *'.$text.''; - } else { - $this->content->items[]= $editmyprofile; - } - $this->content->icons[]=''; + /// Should the following two be in this block? - if (is_internal_auth()) { - $this->content->items[]=''.get_string('changepassword').''; - $this->content->icons[]=''; - } - - if ($CFG->allowunenroll && !$course->metacourse) { - $this->content->items[]=''.get_string('unenrolme', '', $course->shortname).''; - $this->content->icons[]=''; - } - } + + /// View own activity report +// if ($course->showreports) { +// $this->content->items[]=''.get_string('activityreport').''; +// $this->content->icons[]=''; +// } + + + /// Edit your own profile + +// $fullname = fullname($USER, has_capability('moodle/site:viewfullnames', $context)); +// $editmyprofile = ''.get_string('editmyprofile').''; +// if (empty($USER->description)) { +// //Accessibility: replace non-standard with CSS ( makes title visible in IE). +// $text = get_string('profile').' '.get_string('missingdescription'); +// $this->content->items[]= $editmyprofile.' *'.$text.''; +// } else { +// $this->content->items[]= $editmyprofile; +// } +// $this->content->icons[]=''; + + + + return $this->content; } function applicable_formats() { - return array('all' => true, 'mod' => false, 'my' => false, 'admin' => false); + return array('all' => false, 'course' => true); } } diff --git a/blocks/admin_bookmarks/block_admin_bookmarks.php b/blocks/admin_bookmarks/block_admin_bookmarks.php index 126e44b97d..13a9d63da0 100644 --- a/blocks/admin_bookmarks/block_admin_bookmarks.php +++ b/blocks/admin_bookmarks/block_admin_bookmarks.php @@ -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 +?> diff --git a/blocks/admin_tree/block_admin_tree.php b/blocks/admin_tree/block_admin_tree.php index 9aa8f55b54..663f384ff0 100644 --- a/blocks/admin_tree/block_admin_tree.php +++ b/blocks/admin_tree/block_admin_tree.php @@ -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; diff --git a/lang/en_utf8/moodle.php b/lang/en_utf8/moodle.php index 8a4dd8a2d2..908f1c3fe3 100644 --- a/lang/en_utf8/moodle.php +++ b/lang/en_utf8/moodle.php @@ -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'; -- 2.39.5