Skip to content

Commit

Permalink
MDL-45209 course: fixed navbar when creating,editing courses
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Hemelryk committed Jun 26, 2014
1 parent 83d08fc commit 64fea72
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions course/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@
$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);

Expand Down Expand Up @@ -166,22 +167,37 @@
$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();

Expand Down

0 comments on commit 64fea72

Please sign in to comment.