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);
26 case CONTEXT_COURSECAT
:
27 $category = get_record('course_categories', 'id', $context->instanceid
);
28 $strcategories = get_string("categories");
29 $strcategory = get_string("category");
30 $strcourses = get_string("courses");
32 $navlinks[] = array('name' => $strcategories,
33 'link' => "$CFG->wwwroot/course/index.php",
35 $navlinks[] = array('name' => $category->name
,
36 'link' => "$CFG->wwwroot/course/category.php?id=$category->id",
38 $navigation = build_navigation($navlinks);
40 print_header("$SITE->shortname: $category->name", "$SITE->fullname: $strcourses", $navigation, "", "", true);
44 if ($context->instanceid
!= SITEID
) {
45 $streditcoursesettings = get_string("editcoursesettings");
47 $course = get_record('course', 'id', $context->instanceid
);
49 require_login($course);
50 $navlinks[] = array('name' => get_string('roles'),
51 'link' => "$CFG->wwwroot/admin/roles/assign.php?contextid=$context->id",
53 $navigation = build_navigation($navlinks);
54 print_header($streditcoursesettings, $course->fullname
, $navigation);
63 if (!$cm = get_record('course_modules','id',$context->instanceid
)) {
64 error('Bad course module ID');
66 if (!$module = get_record('modules','id',$cm->module
)) { //$module->name;
67 error('Bad module ID');
69 if (!$course = get_record('course','id',$cm->course
)) {
70 error('Bad course ID');
72 if (!$instance = get_record($module->name
, 'id', $cm->instance
)) {
73 error("The required instance of this module doesn't exist");
76 require_login($course);
78 $fullmodulename = get_string("modulename", $module->name
);
79 $streditinga = get_string("editinga", "moodle", $fullmodulename);
80 $strmodulenameplural = get_string("modulenameplural", $module->name
);
82 if ($module->name
== "label") {
85 $focuscursor = "form.name";
88 $navlinks[] = array('name' => $strmodulenameplural,
89 'link' => "$CFG->wwwroot/mod/$module->name/index.php?id=$course->id",
92 $navlinks[] = array('name' => $instance->name
,
93 'link' => "$CFG->wwwroot/mod/$module->name/view.php?id=$cm->id",
96 $navlinks[] = array('name' => $streditinga,
97 'link' => "$CFG->wwwroot/course/mod.php?update=$cm->id&sesskey=".sesskey(),
100 $navigation = build_navigation($navlinks);
102 print_header_simple($streditinga, '', $navigation, $focuscursor, "", false);
107 if ($blockinstance = get_record('block_instance', 'id', $context->instanceid
)) {
108 if ($block = get_record('block', 'id', $blockinstance->blockid
)) {
109 $blockname = print_context_name($context);
112 switch ($blockinstance->pagetype
) {
114 if ($course = get_record('course', 'id', $blockinstance->pageid
)) {
116 require_login($course);
118 $navlinks[] = array('name' => $blockname, 'link' => null, 'type' => 'misc');
119 $navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc');
120 $navigation = build_navigation($navlinks);
121 print_header("$straction: $blockname", $course->fullname
, $navigation);
126 $strblogs = get_string('blogs','blog');
127 $navlinks[] = array('name' => $strblogs,
128 'link' => $CFG->wwwroot
.'/blog/index.php',
130 $navlinks[] = array('name' => $blockname, 'link' => null, 'type' => 'misc');
131 $navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc');
132 $navigation = build_navigation($navlinks);
133 print_header("$straction: $strblogs", $SITE->fullname
, $navigation);
137 $strtags = get_string('tags');
138 $navlinks[] = array('name' => $strtags,
139 'link' => $CFG->wwwroot
.'/tag/index.php',
141 $navlinks[] = array('name' => $blockname, 'link' => null, 'type' => 'misc');
142 $navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc');
143 $navigation = build_navigation($navlinks);
144 print_header("$straction: $strtags", $SITE->fullname
, $navigation);
148 $navlinks[] = array('name' => $blockname, 'link' => null, 'type' => 'misc');
149 $navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc');
150 $navigation = build_navigation($navlinks);
151 print_header("$straction: $blockname", $SITE->fullname
, $navigation);
159 error ('This is an unknown context (' . $context->contextlevel
. ') in admin/roles/tabs.php!');
168 $activetwo = array();
171 if ($context->contextlevel
!= CONTEXT_SYSTEM
) { // Print tabs for anything except SYSTEM context
173 if ($context->contextlevel
== CONTEXT_MODULE
) { // Only show update button if module
175 $toprow[] = new tabobject('update', $CFG->wwwroot
.'/course/mod.php?update='.
176 $context->instanceid
.'&return=true&sesskey='.sesskey(), get_string('settings'));
180 if (!empty($assignableroles)) {
181 $toprow[] = new tabobject('assign',
182 $CFG->wwwroot
.'/'.$CFG->admin
.'/roles/assign.php?contextid='.$context->id
,
183 get_string('localroles', 'role'),
184 get_string('showallroles', 'role'),
188 if (!empty($overridableroles)) {
189 $toprow[] = new tabobject('override',
190 $CFG->wwwroot
.'/'.$CFG->admin
.'/roles/override.php?contextid='.$context->id
,
191 get_string('overridepermissions', 'role'),
192 get_string('showallroles', 'role'),
198 /// Here other core tabs should go (always calling tabs.php files)
199 /// All the logic to decide what to show must be self-contained 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 must be one $CFG->dirroot relative file
210 if (file_exists($CFG->dirroot
. '/' . $extratab)) {
211 include_once($CFG->dirroot
. '/' . $extratab);
217 $inactive[] = $currenttab;
219 $tabs = array($toprow);
221 /// If there are any secondrow defined, let's introduce it
222 if (isset($secondrow) && is_array($secondrow) && !empty($secondrow)) {
223 $tabs[] = $secondrow;
226 print_tabs($tabs, $currenttab, $inactive, $activetwo);