MDL-31640 course: removed extra error message and using require_capability

This commit is contained in:
Rajesh Taneja
2012-03-19 13:08:54 +08:00
parent f9374e570a
commit b99ec3eabb
2 changed files with 14 additions and 9 deletions
+14 -8
View File
@@ -63,6 +63,11 @@
$USER->editing = $edit;
}
$adminediting = $PAGE->user_is_editing();
// Set perpage if user can edit in category
if ($perpage != 99999) {
$perpage = 30;
}
} else {
$adminediting = false;
}
@@ -84,10 +89,6 @@
}
}
if (has_any_capability($capabilities, get_context_instance(CONTEXT_SYSTEM)) && ($perpage != 99999)) {
$perpage = 30;
}
$displaylist = array();
$parentlist = array();
make_categories_list($displaylist, $parentlist);
@@ -137,10 +138,10 @@
if (preg_match('/^c\d+$/', $key)) {
$courseid = substr($key, 1);
// user must have category:manage and course:create capability for the course to be moved.
if (has_all_capabilities($capabilities, get_context_instance(CONTEXT_COURSE, $courseid))) {
$coursecontext = get_context_instance(CONTEXT_COURSE, $courseid);
foreach ($capabilities as $capability) {
require_capability($capability, $coursecontext);
array_push($courses, $courseid);
} else {
print_error('cannotmovecoursetocategory');
}
}
}
@@ -251,11 +252,16 @@
echo $OUTPUT->spacer(array('height'=>5, 'width'=>5, 'br'=>true)); // should be done with CSS instead
}
} else { //editing mode
echo "<form id=\"movecourses\" action=\"search.php?".$modulelink."\" method=\"post\">\n";
echo "<form id=\"movecourses\" action=\"search.php\" method=\"post\">\n";
echo "<div><input type=\"hidden\" name=\"sesskey\" value=\"".sesskey()."\" />\n";
echo "<input type=\"hidden\" name=\"search\" value=\"".s($search)."\" />\n";
echo "<input type=\"hidden\" name=\"page\" value=\"$page\" />\n";
echo "<input type=\"hidden\" name=\"perpage\" value=\"$perpage\" /></div>\n";
if (!empty($modulelist) and confirm_sesskey()) {
echo "<input type=\"hidden\" name=\"modulelist\" value=\"$modulelist\" /></div>\n";
} else if (!empty($blocklist) and confirm_sesskey()) {
echo "<input type=\"hidden\" name=\"blocklist\" value=\"$blocklist\" /></div>\n";
}
echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"4\" class=\"generalbox boxaligncenter\">\n<tr>\n";
echo "<th scope=\"col\">$strcourses</th>\n";
echo "<th scope=\"col\">$strcategory</th>\n";
-1
View File
@@ -103,7 +103,6 @@ $string['cannotmarktopic'] = 'Could not mark that topic for this course';
$string['cannotmigratedatacomments'] = 'Cannot migrate data module comments';
$string['cannotmodulename'] = 'Cannot get the module name in build navigation';
$string['cannotmoduletype'] = 'Cannot get the module type in build navigation';
$string['cannotmovecoursetocategory'] = 'You do not have capabilities to move the course into different category.';
$string['cannotmoverolewithid'] = 'Cannot move role with ID {$a}';
$string['cannotnetgeo'] = 'Cannot connect to NetGeo server at http://netgeo.caida.org, please check proxy settings or better install MaxMind GeoLite City data file';
$string['cannotopencsv'] = 'Cannot open CSV file';