$errors = NULL;
- if ($action == 'sendform') {
+ if ($action == 'sendform' and confirm_sesskey()) {
if ($form = data_submitted()) {
if (empty($form->name)) {
$errors[$scaleid]->name = true;
//If action is edit or new, show the form
if ($action == "edit" || $action == "new") {
+
+ $sesskey = !empty($USER->id) ? $USER->sesskey : '';
+
//Check for teacher edit
if (! isteacheredit($course->id)) {
error("Only editing teachers can modify scales !");
echo "<tr>";
echo "<td colspan=\"2\" align=\"center\">";
echo "<input type=\"hidden\" name=\"id\" value=\"$course->id\" />";
+ echo "<input type=\"hidden\" name=\"sesskey\" value=\"$sesskey\" />";
echo "<input type=\"hidden\" name=\"courseid\" value=\"$scale->courseid\" />";
echo "<input type=\"hidden\" name=\"scaleid\" value=\"$scale->id\" />";
echo "<input type=\"hidden\" name=\"action\" value=\"sendform\" />";
}
//If action is delete, do it
- if ($action == "delete") {
+ if ($action == "delete" and confirm_sesskey()) {
//Check for teacher edit
if (! isteacheredit($course->id)) {
error("Only editing teachers can delete scales !");
}
//If action is down or up, do it
- if ($action == "down" || $action == "up" ) {
+ if (($action == "down" || $action == "up") and confirm_sesskey()) {
//Check for teacher edit
if (! isadmin()) {
error("Only administrators can move scales",$CFG->wwwroot.'/course/scales.php?id='.$course->id);
$buttons .= "<a title=\"$stredit\" href=\"$path/scales.php?id=$course->id&scaleid=$scale->id&action=edit\"><img".
" src=\"$pixpath/t/edit.gif\" hspace=\"2\" height=\"11\" width=\"11\" border=\"0\" alt=\"\" /></a> ";
if ($incustom && isadmin()) {
- $buttons .= "<a title=\"$strdown\" href=\"$path/scales.php?id=$course->id&scaleid=$scale->id&action=down\"><img".
+ $buttons .= "<a title=\"$strdown\" href=\"$path/scales.php?id=$course->id&scaleid=$scale->id&action=down&sesskey=$USER->sesskey\"><img".
" src=\"$pixpath/t/down.gif\" hspace=\"2\" height=\"11\" width=\"11\" border=\"0\" alt=\"\" /></a> ";
}
if (!$incustom && isadmin()) {
- $buttons .= "<a title=\"$strup\" href=\"$path/scales.php?id=$course->id&scaleid=$scale->id&action=up\"><img".
+ $buttons .= "<a title=\"$strup\" href=\"$path/scales.php?id=$course->id&scaleid=$scale->id&action=up&sesskey=$USER->sesskey\"><img".
" src=\"$pixpath/t/up.gif\" hspace=\"2\" height=\"11\" width=\"11\" border=\"0\" alt=\"\" /></a> ";
}
- $buttons .= "<a title=\"$strdelete\" href=\"$path/scales.php?id=$course->id&scaleid=$scale->id&action=delete\"><img".
+ $buttons .= "<a title=\"$strdelete\" href=\"$path/scales.php?id=$course->id&scaleid=$scale->id&action=delete&sesskey=$USER->sesskey\"><img".
" src=\"$pixpath/t/delete.gif\" hspace=\"2\" height=\"11\" width=\"11\" border=\"0\" alt=\"\" /></a> ";
}
$line[] = $buttons;