mirror of
https://github.com/moodle/moodle.git
synced 2025-04-20 16:04:25 +02:00
MDL-73169 core_course: Update course category breadcrumb nodes
This commit is contained in:
parent
3a333176d1
commit
805a9eebf5
@ -228,13 +228,15 @@ if (!empty($course->id)) {
|
||||
// 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
|
||||
// Because the course category 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);
|
||||
navigation_node::override_active_url(new moodle_url('/course/index.php', ['categoryid' => $category->id]), true);
|
||||
$PAGE->set_primary_active_tab('home');
|
||||
$PAGE->navbar->add(get_string('coursemgmt', 'admin'), $managementurl);
|
||||
|
||||
$pagedesc = $straddnewcourse;
|
||||
$title = "$site->shortname: $straddnewcourse";
|
||||
$fullname = $site->fullname;
|
||||
$fullname = format_string($category->name);
|
||||
$PAGE->navbar->add($pagedesc);
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,10 @@ if ($id) {
|
||||
$coursecat = core_course_category::get($id, MUST_EXIST, true);
|
||||
$category = $coursecat->get_db_record();
|
||||
$context = context_coursecat::instance($id);
|
||||
navigation_node::override_active_url(new moodle_url('/course/index.php', ['categoryid' => $category->id]));
|
||||
$PAGE->navbar->add(get_string('settings'));
|
||||
$PAGE->set_primary_active_tab('home');
|
||||
$PAGE->set_secondary_active_tab('edit');
|
||||
|
||||
$url->param('id', $id);
|
||||
$strtitle = new lang_string('editcategorysettings');
|
||||
@ -48,21 +52,33 @@ if ($id) {
|
||||
} else {
|
||||
$parent = required_param('parent', PARAM_INT);
|
||||
$url->param('parent', $parent);
|
||||
$strtitle = get_string('addnewcategory');
|
||||
if ($parent) {
|
||||
$DB->record_exists('course_categories', array('id' => $parent), '*', MUST_EXIST);
|
||||
$parentcategory = $DB->get_record('course_categories', array('id' => $parent), '*', MUST_EXIST);
|
||||
$context = context_coursecat::instance($parent);
|
||||
navigation_node::override_active_url(new moodle_url('/course/index.php', ['categoryid' => $parent]));
|
||||
$fullname = format_string($parentcategory->name, true, ['context' => $context->id]);
|
||||
$title = "$fullname: $strtitle";
|
||||
$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 (!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', $parent);
|
||||
}
|
||||
$PAGE->set_primary_active_tab('home');
|
||||
$PAGE->navbar->add(get_string('coursemgmt', 'admin'), $managementurl);
|
||||
$PAGE->navbar->add(get_string('addcategory', 'admin'));
|
||||
} else {
|
||||
$context = context_system::instance();
|
||||
$fullname = $SITE->fullname;
|
||||
$title = "$SITE->shortname: $strtitle";
|
||||
}
|
||||
navigation_node::override_active_url(new moodle_url('/course/editcategory.php', array('parent' => $parent)));
|
||||
|
||||
$category = new stdClass();
|
||||
$category->id = 0;
|
||||
$category->parent = $parent;
|
||||
$strtitle = new lang_string("addnewcategory");
|
||||
$itemid = null; // Set this explicitly, so files for parent category should not get loaded in draft area.
|
||||
$title = "$SITE->shortname: ".get_string('addnewcategory');
|
||||
$fullname = $SITE->fullname;
|
||||
}
|
||||
|
||||
require_capability('moodle/category:manage', $context);
|
||||
|
@ -60,6 +60,7 @@ if ($categoryid) {
|
||||
}
|
||||
|
||||
$PAGE->set_pagelayout('coursecategory');
|
||||
$PAGE->set_primary_active_tab('home');
|
||||
$PAGE->add_body_class('limitedwidth');
|
||||
$courserenderer = $PAGE->get_renderer('core', 'course');
|
||||
|
||||
|
@ -100,7 +100,7 @@ if ($modulelist !== '') {
|
||||
}
|
||||
|
||||
$strmanagement = new lang_string('coursecatmanagement');
|
||||
$pageheading = format_string($SITE->fullname, true, array('context' => $systemcontext));
|
||||
$pageheading = $category->get_formatted_name();
|
||||
|
||||
$PAGE->set_context($context);
|
||||
$PAGE->set_url($url);
|
||||
@ -122,6 +122,21 @@ if (!core_course_category::has_capability_on_any(array('moodle/category:manage',
|
||||
redirect($url);
|
||||
}
|
||||
|
||||
if (!$issearching && $category !== null) {
|
||||
$parents = core_course_category::get_many($category->get_parents());
|
||||
$parents[] = $category;
|
||||
foreach ($parents as $parent) {
|
||||
$PAGE->navbar->add(
|
||||
$parent->get_formatted_name(),
|
||||
new moodle_url('/course/index.php', array('categoryid' => $parent->id))
|
||||
);
|
||||
}
|
||||
if ($course instanceof core_course_list_element) {
|
||||
// Use the list name so that it matches whats being displayed below.
|
||||
$PAGE->navbar->add($course->get_formatted_name());
|
||||
}
|
||||
}
|
||||
|
||||
// If the user poses any of these capabilities then they will be able to see the admin
|
||||
// tree and the management link within it.
|
||||
// This is the most accurate form of navigation.
|
||||
@ -133,32 +148,19 @@ $capabilities = array(
|
||||
'moodle/site:approvecourse'
|
||||
);
|
||||
if ($category && !has_any_capability($capabilities, $systemcontext)) {
|
||||
// If the user doesn't poses any of these system capabilities then we're going to mark the manage link in the settings block
|
||||
// as active, tell the page to ignore the active path and just build what the user would expect.
|
||||
// If the user doesn't poses any of these system capabilities then we're going to mark the category link in the
|
||||
// settings block as active, tell the page to ignore the active path and just build what the user would expect.
|
||||
// This will at least give the page some relevant navigation.
|
||||
navigation_node::override_active_url(new moodle_url('/course/management.php', array('categoryid' => $category->id)));
|
||||
navigation_node::override_active_url(new moodle_url('/course/index.php', array('categoryid' => $category->id)));
|
||||
$PAGE->set_category_by_id($category->id);
|
||||
$PAGE->navbar->ignore_active(true);
|
||||
$PAGE->navbar->add(get_string('coursemgmt', 'admin'), $PAGE->url->out_omit_querystring());
|
||||
} else {
|
||||
// If user has system capabilities, make sure the "Manage courses and categories" item in Administration block is active.
|
||||
// If user has system capabilities, make sure the "Category" item in Administration block is active.
|
||||
navigation_node::require_admin_tree();
|
||||
navigation_node::override_active_url(new moodle_url('/course/management.php'));
|
||||
}
|
||||
if (!$issearching && $category !== null) {
|
||||
$parents = core_course_category::get_many($category->get_parents());
|
||||
$parents[] = $category;
|
||||
foreach ($parents as $parent) {
|
||||
$PAGE->navbar->add(
|
||||
$parent->get_formatted_name(),
|
||||
new moodle_url('/course/management.php', array('categoryid' => $parent->id))
|
||||
);
|
||||
}
|
||||
if ($course instanceof core_course_list_element) {
|
||||
// Use the list name so that it matches whats being displayed below.
|
||||
$PAGE->navbar->add($course->get_formatted_name());
|
||||
}
|
||||
navigation_node::override_active_url(new moodle_url('/course/index.php'));
|
||||
}
|
||||
$PAGE->navbar->add(get_string('coursemgmt', 'admin'), $PAGE->url->out_omit_querystring());
|
||||
$PAGE->set_primary_active_tab('home');
|
||||
|
||||
$notificationspass = array();
|
||||
$notificationsfail = array();
|
||||
|
@ -71,7 +71,9 @@ $requestform->set_data($data);
|
||||
|
||||
$strtitle = get_string('courserequest');
|
||||
$PAGE->set_title($strtitle);
|
||||
$PAGE->set_heading($strtitle);
|
||||
$coursecategory = core_course_category::get($categoryid, MUST_EXIST, true);
|
||||
$PAGE->set_heading($coursecategory->get_formatted_name());
|
||||
$PAGE->set_primary_active_tab('home');
|
||||
|
||||
// Standard form processing if statement.
|
||||
if ($requestform->is_cancelled()){
|
||||
@ -84,6 +86,12 @@ if ($requestform->is_cancelled()){
|
||||
notice(get_string('courserequestsuccess'), $returnurl);
|
||||
}
|
||||
|
||||
$categoryurl = new moodle_url('/course/index.php');
|
||||
if ($categoryid) {
|
||||
$categoryurl->param('categoryid', $categoryid);
|
||||
}
|
||||
navigation_node::override_active_url($categoryurl);
|
||||
|
||||
$PAGE->navbar->add($strtitle);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($strtitle);
|
||||
|
@ -153,16 +153,6 @@ Feature: We can change the visibility of categories in the management interface.
|
||||
And I toggle visibility of category "CAT3" in management listing
|
||||
# Redirect.
|
||||
And I should see the "Course categories and courses" management page
|
||||
And I click on "Cat 1" "link"
|
||||
# Redirect.
|
||||
And I should see the "Course categories and courses" management page
|
||||
And category in management listing should be visible "CAT1"
|
||||
And category in management listing should be visible "CAT2"
|
||||
And category in management listing should be dimmed "CAT3"
|
||||
And category in management listing should be visible "CAT4"
|
||||
And course in management listing should be visible "C1"
|
||||
And course in management listing should be dimmed "C2"
|
||||
And course in management listing should be visible "C3"
|
||||
And I toggle visibility of category "CAT1" in management listing
|
||||
# Redirect.
|
||||
And I should see the "Course categories and courses" management page
|
||||
|
Loading…
x
Reference in New Issue
Block a user