// Is the user allowed to edit this course? require_capability('moodle/course:update', $course_context); // Display the page header $navigation = "<a href=\"{$CFG->wwwroot}/mod/sloodle/view_course.php?id={$course->id}#layouts\">" . get_string('courseconfig', 'sloodle') . "</a>"; print_header_simple(get_string('layoutpage', 'sloodle'), "", $navigation, "", "", true, '', navmenu($course)); //------------------------------------------------------ // Check the user's permissions regarding layouts $layouts_can_use = has_capability('mod/sloodle:uselayouts', $course_context); $layouts_can_edit = has_capability('mod/sloodle:editlayouts', $course_context); // Only display the layouts if they can use them if (!$layouts_can_edit) { print get_string('layoutmanager:nopermission', 'sloodle'); exit; } // Show a list of layouts, if there are any $layout_names = $sloodle_course->get_layout_names(); //------------------------------------------------------ if (isset($_POST['courseid'])) { /// Update $layoutid = required_param('layoutid', PARAM_INT); $layoutname = required_param('layoutname', PARAM_TEXT); if (in_array($layoutname, $layout_names)) { $layoutnamestoids = array_flip($layout_names); if ($layoutnamestoids[$layoutname] != $layoutid) { print get_string("layoutmanager:namealreadyexists", 'sloodle'); exit; } } // Define parameter names we will ignore $IGNORE_PARAMS = array('sloodleauthid', 'sloodledebug'); // This structure will store our values