3 // Handles headers and tabs for the roles control at any level apart from SYSTEM level
4 // We also assume that $currenttab, $assignableroles and $overridableroles are defined
6 if (!defined('MOODLE_INTERNAL')) {
7 die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
11 if ($currenttab != 'update') {
12 switch ($context->contextlevel
) {
15 $stradministration = get_string('administration');
16 $navlinks[] = array('name' => $stradministration, 'link' => '../index.php', 'type' => 'misc');
17 $navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc');
18 $navigation = build_navigation($navlinks);
19 print_header($SITE->fullname
, "$SITE->fullname", $navigation);
22 case CONTEXT_PERSONAL
:
29 case CONTEXT_COURSECAT
:
30 $category = get_record('course_categories', 'id', $context->instanceid
);
31 $strcategories = get_string("categories");
32 $strcategory = get_string("category");
33 $strcourses = get_string("courses");
35 $navlinks[] = array('name' => $strcategories,
36 'link' => "$CFG->wwwroot/course/index.php",
38 $navlinks[] = array('name' => $category->name
,
39 'link' => "$CFG->wwwroot/course/category.php?id=$category->id",
41 $navigation = build_navigation($navlinks);
43 print_header("$SITE->shortname: $category->name", "$SITE->fullname: $strcourses", $navigation, "", "", true);
47 if ($context->instanceid
!= SITEID
) {
48 $streditcoursesettings = get_string("editcoursesettings");
50 $course = get_record('course', 'id', $context->instanceid
);
52 require_login($course);
53 $navlinks[] = array('name' => $course->shortname
,
54 'link' => "$CFG->wwwroot/course/view.php?id=$course->id",
56 $navigation = build_navigation($navlinks);
57 print_header($streditcoursesettings, $course->fullname
, $navigation);
66 if (!$cm = get_record('course_modules','id',$context->instanceid
)) {
67 error('Bad course module ID');
69 if (!$module = get_record('modules','id',$cm->module
)) { //$module->name;
70 error('Bad module ID');
72 if (!$course = get_record('course','id',$cm->course
)) {
73 error('Bad course ID');
75 if (!$instance = get_record($module->name
, 'id', $cm->instance
)) {
76 error("The required instance of this module doesn't exist");
79 require_login($course);
81 $fullmodulename = get_string("modulename", $module->name
);
82 $streditinga = get_string("editinga", "moodle", $fullmodulename);
83 $strmodulenameplural = get_string("modulenameplural", $module->name
);
85 if ($module->name
== "label") {
88 $focuscursor = "form.name";
91 $navlinks[] = array('name' => $strmodulenameplural,
92 'link' => "$CFG->wwwroot/mod/$module->name/index.php?id=$course->id",
95 $navlinks[] = array('name' => $instance->name
,
96 'link' => "$CFG->wwwroot/mod/$module->name/view.php?id=$cm->id",
99 $navlinks[] = array('name' => $streditinga,
100 'link' => "$CFG->wwwroot/course/mod.php?update=$cm->id&sesskey=".sesskey(),
103 $navigation = build_navigation($navlinks);
105 print_header_simple($streditinga, '', $navigation, $focuscursor, "", false);
110 if ($blockinstance = get_record('block_instance', 'id', $context->instanceid
)) {
111 if ($block = get_record('block', 'id', $blockinstance->blockid
)) {
112 $blockname = print_context_name($context);
114 // Prepare the last part of the breadcrumbs first
115 $navlinks[98] = array('name' => $blockname, 'link' => null, 'type' => 'misc');
116 $navlinks[99] = array('name' => $straction, 'link' => null, 'type' => 'misc');
118 switch ($blockinstance->pagetype
) {
120 if ($course = get_record('course', 'id', $blockinstance->pageid
)) {
122 require_login($course);
124 if ($course->id
!= SITEID
) {
125 $navlinks[0] = array('name' => $course->shortname
,
126 'link' => "$CFG->wwwroot/course/view.php?id=$course->id",
129 $navigation = build_navigation($navlinks);
130 print_header("$straction: $blockname", $course->fullname
, $navigation);
135 $strblogs = get_string('blogs','blog');
136 $navlinks[0] = array('name' => $strblogs,
137 'link' => $CFG->wwwroot
.'/blog/index.php',
139 $navigation = build_navigation($navlinks);
140 print_header("$straction: $strblogs", $SITE->fullname
, $navigation);
144 print_header("$straction: $blockname", $SITE->fullname
, $navigation);
152 error ('This is an unknown context (' . $context->contextlevel
. ') in admin/roles/tabs.php!');
159 if ($context->contextlevel
!= CONTEXT_SYSTEM
) { // Print tabs for anything except SYSTEM context
161 if ($context->contextlevel
== CONTEXT_MODULE
) { // only show update button if module?
163 $toprow[] = new tabobject('update', $CFG->wwwroot
.'/course/mod.php?update='.
164 $context->instanceid
.'&return=true&sesskey='.sesskey(), get_string('update'));
168 $toprow[] = new tabobject('roles', $CFG->wwwroot
.'/'.$CFG->admin
.'/roles/assign.php?contextid='.
169 $context->id
, get_string('roles'));
171 if (!empty($tabsmode)) {
173 if (!empty($assignableroles)) {
174 $secondrow[] = new tabobject('assign',
175 $CFG->wwwroot
.'/'.$CFG->admin
.'/roles/assign.php?contextid='.$context->id
,
176 get_string('assignroles', 'role'),
177 get_string('showallroles', 'role'),
181 if (!empty($overridableroles)) {
182 $secondrow[] = new tabobject('override',
183 $CFG->wwwroot
.'/'.$CFG->admin
.'/roles/override.php?contextid='.$context->id
,
184 get_string('overrideroles', 'role'),
185 get_string('showallroles', 'role'),
189 $inactive[] = 'roles';
190 $activetwo = array('roles');
191 $currenttab = $tabsmode;
195 $activetwo = array();
198 /// Here other core tabs should go (always calling tabs.php files)
199 /// All the logic to decide what to show must be self-cointained in the tabs file
201 /// include_once($CFG->dirroot . '/grades/tabs.php');
203 /// Finally, we support adding some 'on-the-fly' tabs here
204 /// All the logic to decide what to show must be self-cointained in the tabs file
205 if (isset($CFG->extratabs
) && !empty($CFG->extratabs
)) {
206 if ($extratabs = explode(',', $CFG->extratabs
)) {
208 foreach($extratabs as $extratab) {
209 /// Each extra tab mus be one $CFG->dirroot relative file
210 if (file_exists($CFG->dirroot
. '/' . $extratab)) {
211 include_once($CFG->dirroot
. '/' . $extratab);
217 if (!empty($secondrow)) {
218 $tabs = array($toprow, $secondrow);
220 $tabs = array($toprow);
223 print_tabs($tabs, $currenttab, $inactive, $activetwo);