mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 19:06:41 +02:00
MDL-45209 course: fixed navbar when creating,editing courses
This commit is contained in:
parent
83d08fcc21
commit
64fea720ce
1 changed files with 24 additions and 8 deletions
|
@ -31,9 +31,10 @@ $categoryid = optional_param('category', 0, PARAM_INT); // Course category - can
|
|||
$returnto = optional_param('returnto', 0, PARAM_ALPHANUM); // Generic navigation return page switch.
|
||||
|
||||
$PAGE->set_pagelayout('admin');
|
||||
$pageparams = array('id'=>$id);
|
||||
if (empty($id)) {
|
||||
$pageparams = array('category'=>$categoryid);
|
||||
if ($id) {
|
||||
$pageparams = array('id' => $id);
|
||||
} else {
|
||||
$pageparams = array('category' => $categoryid);
|
||||
}
|
||||
$PAGE->set_url('/course/edit.php', $pageparams);
|
||||
|
||||
|
@ -166,22 +167,37 @@ $stradministration = get_string("administration");
|
|||
$strcategories = get_string("categories");
|
||||
|
||||
if (!empty($course->id)) {
|
||||
$PAGE->navbar->add($streditcoursesettings);
|
||||
// Navigation note: The user is editing a course, the course will exist within the navigation and settings.
|
||||
// The navigation will automatically find the Edit settings page under course navigation.
|
||||
$pagedesc = $streditcoursesettings;
|
||||
$title = $streditcoursesettings;
|
||||
$fullname = $course->fullname;
|
||||
} else {
|
||||
$PAGE->navbar->add($stradministration, new moodle_url('/admin/index.php'));
|
||||
$PAGE->navbar->add($strcategories, new moodle_url('/course/index.php'));
|
||||
$PAGE->navbar->add($straddnewcourse);
|
||||
// The user is adding a course, this page isn't presented in the site navigation/admin.
|
||||
// Adding a new course is part of course category management territory.
|
||||
// We'd prefer to use the management interface URL without args.
|
||||
$managementurl = new moodle_url('/course/management.php');
|
||||
// These are the caps required in order to see the management interface.
|
||||
$managementcaps = array('moodle/category:manage', 'moodle/course:create');
|
||||
if ($categoryid && !has_any_capability($managementcaps, context_system::instance())) {
|
||||
// If the user doesn't have either manage caps then they can only manage within the given category.
|
||||
$managementurl->param('categoryid', $categoryid);
|
||||
}
|
||||
// Because the course category management interfaces are buried in the admin tree and that is loaded by ajax
|
||||
// we need to manually tell the navigation we need it loaded. The second arg does this.
|
||||
navigation_node::override_active_url($managementurl, true);
|
||||
|
||||
$pagedesc = $straddnewcourse;
|
||||
$title = "$site->shortname: $straddnewcourse";
|
||||
$fullname = $site->fullname;
|
||||
$PAGE->navbar->add($pagedesc);
|
||||
}
|
||||
|
||||
$PAGE->set_title($title);
|
||||
$PAGE->set_heading($fullname);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($streditcoursesettings);
|
||||
echo $OUTPUT->heading($pagedesc);
|
||||
|
||||
$editform->display();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue