diff -ruN moodle-1.7/course/category.php public_html/course/category.php
--- moodle-1.7/course/category.php 2006-11-19 14:03:52.000000000 +0000
+++ public_html/course/category.php 2006-11-19 14:47:33.000000000 +0000
@@ -32,7 +32,7 @@
error("Category not known!");
}
- if (has_capability('moodle/course:create', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
+ if (has_capability('moodle/course:create', $context )) {
if ($categoryedit !== -1) {
$USER->categoryediting = $categoryedit;
}
@@ -50,7 +50,7 @@
}
- if (has_capability('moodle/category:update', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
+ if (has_capability('moodle/category:update', $context )) {
/// Rename the category if requested
if (!empty($rename) and confirm_sesskey()) {
$category->name = $rename;
@@ -217,7 +217,7 @@
if ($subcategories = get_records("course_categories", "parent", $category->id, "sortorder ASC")) {
$firstentry = true;
foreach ($subcategories as $subcategory) {
- if ($subcategory->visible or has_capability('moodle/course:create', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
+ if ($subcategory->visible or has_capability('moodle/course:create', $context)) {
$subcategorieswereshown = true;
if ($firstentry) {
echo '
';
@@ -304,7 +304,7 @@
foreach ($courses as $acourse) {
- $context = get_context_instance(CONTEXT_COURSE, $acourse->id);
+ $coursecontext = get_context_instance(CONTEXT_COURSE, $acourse->id);
$count++;
$up = ($count > 1 || !$atfirstpage);
@@ -315,22 +315,22 @@
echo '| '.$acourse->fullname.' | ';
if ($creatorediting) {
echo "";
- if (has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $acourse->id))) {
+ if (has_capability('moodle/course:update', $coursecontext)) {
echo ''.
' '; }
// role assignment link
- if (has_capability('moodle/role:assign', $context)) {
- echo' ';
+ if (has_capability('moodle/role:assign', $coursecontext)) {
+ echo' ';
}
- if (has_capability('moodle/course:delete', $context)) {
+ if (has_capability('moodle/course:delete', $coursecontext)) {
echo ''.
' ';
}
- if (has_capability('moodle/course:visibility', $context)) {
+ if (has_capability('moodle/course:visibility', $coursecontext)) {
if (!empty($acourse->visible)) {
echo ''.
@@ -342,18 +342,18 @@
}
}
- if (has_capability('moodle/site:backup', $context)) {
+ if (has_capability('moodle/site:backup', $coursecontext)) {
echo ''.
' ';
}
- if (has_capability('moodle/site:restore', $context)) {
+ if (has_capability('moodle/site:restore', $coursecontext)) {
echo ''.
' ';
}
- if (has_capability('moodle/category:update', $context)) {
+ if (has_capability('moodle/category:update', $coursecontext)) {
if ($up) {
echo ''.
@@ -414,7 +414,7 @@
echo '';
- if (has_capability('moodle/category:update', get_context_instance(CONTEXT_SYSTEM, SITEID)) and $numcourses > 1) { /// Print button to re-sort courses by name
+ if (has_capability('moodle/category:update', $context) and $numcourses > 1) { /// Print button to re-sort courses by name
unset($options);
$options['id'] = $category->id;
$options['resort'] = 'name';
@@ -422,7 +422,6 @@
print_single_button('category.php', $options, get_string('resortcoursesbyname'), 'get');
}
- $context = get_context_instance(CONTEXT_SYSTEM, SITEID);
if (has_capability('moodle/course:create', $context)) { /// Print button to create a new course
unset($options);
$options['category'] = $category->id;
@@ -430,7 +429,6 @@
echo ' ';
}
- $context = get_context_instance(CONTEXT_COURSECAT, $id);
if (has_capability('moodle/category:update', $context)) { /// Print form to rename the category
$strrename= get_string('rename');
echo ' |