Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / admin / roles / tabs.php
blobf6d02e08c224e6c8b54aa014a09ff3762a607d5f
1 <?php // $Id$
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
10 if ($currenttab != 'update') {
11 switch ($context->contextlevel) {
13 case CONTEXT_SYSTEM:
14 $stradministration = get_string('administration');
15 print_header($SITE->fullname, "$SITE->fullname","<a href=\"../index.php\">$stradministration</a> -> $straction");
16 break;
18 case CONTEXT_PERSONAL:
19 break;
21 case CONTEXT_USER:
22 print_header();
23 break;
25 case CONTEXT_COURSECAT:
26 $category = get_record('course_categories', 'id', $context->instanceid);
27 $strcategories = get_string("categories");
28 $strcategory = get_string("category");
29 $strcourses = get_string("courses");
30 print_header("$SITE->shortname: $category->name", "$SITE->fullname: $strcourses",
31 "<a href=\"$CFG->wwwroot/course/index.php\">$strcategories</a> -> <a href=\"$CFG->wwwroot/course/category.php?id=$category->id\">$category->name</a> -> $straction", "", "", true);
32 break;
34 case CONTEXT_COURSE:
35 if ($context->instanceid != SITEID) {
36 $streditcoursesettings = get_string("editcoursesettings");
38 $course = get_record('course', 'id', $context->instanceid);
40 require_login($course);
42 print_header($streditcoursesettings, $course->fullname,
43 "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> -> $straction");
45 break;
47 case CONTEXT_GROUP:
48 break;
50 case CONTEXT_MODULE:
51 // get module type?
52 if (!$cm = get_record('course_modules','id',$context->instanceid)) {
53 error('Bad course module ID');
55 if (!$module = get_record('modules','id',$cm->module)) { //$module->name;
56 error('Bad module ID');
58 if (!$course = get_record('course','id',$cm->course)) {
59 error('Bad course ID');
61 if (!$instance = get_record($module->name, 'id', $cm->instance)) {
62 error("The required instance of this module doesn't exist");
65 require_login($course);
67 $strnav = "<a href=\"$CFG->wwwroot/mod/$module->name/view.php?id=$cm->id\">$instance->name</a> ->";
68 $fullmodulename = get_string("modulename", $module->name);
69 $streditinga = get_string("editinga", "moodle", $fullmodulename);
70 $strmodulenameplural = get_string("modulenameplural", $module->name);
72 if ($module->name == "label") {
73 $focuscursor = "";
74 } else {
75 $focuscursor = "form.name";
78 print_header_simple($streditinga, '',
79 "<a href=\"$CFG->wwwroot/mod/$module->name/index.php?id=$course->id\">$strmodulenameplural</a> ->
80 $strnav <a href=\"$CFG->wwwroot/course/mod.php?update=$cm->id&amp;sesskey=".sesskey()."\">$streditinga</a> -> $straction", $focuscursor, "", false);
82 break;
84 case CONTEXT_BLOCK:
85 if ($blockinstance = get_record('block_instance', 'id', $context->instanceid)) {
86 if ($block = get_record('block', 'id', $blockinstance->blockid)) {
87 $blockname = print_context_name($context);
88 $navigation = $blockname. ' -> '.$straction;
90 switch ($blockinstance->pagetype) {
91 case 'course-view':
92 if ($course = get_record('course', 'id', $blockinstance->pageid)) {
94 require_login($course);
96 if ($course->id != SITEID) {
97 $navigation = "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> -> $navigation";
99 print_header("$straction: $blockname", $course->fullname, $navigation);
101 break;
103 case 'blog-view':
104 $strblogs = get_string('blogs','blog');
105 $navigation = '<a href="'.$CFG->wwwroot.'/blog/index.php">'.
106 $strblogs.'</a> -> '.$navigation;
107 print_header("$straction: $strblogs", $SITE->fullname, $navigation);
108 break;
110 default:
111 print_header("$straction: $blockname", $SITE->fullname, $navigation);
112 break;
116 break;
118 default:
119 error ('This is an unknown context (' . $context->contextlevel . ') in admin/roles/tabs.php!');
120 return false;
126 if ($context->contextlevel != CONTEXT_SYSTEM) { // Print tabs for anything except SYSTEM context
128 if ($context->contextlevel == CONTEXT_MODULE) { // only show update button if module?
130 $toprow[] = new tabobject('update', $CFG->wwwroot.'/course/mod.php?update='.
131 $context->instanceid.'&amp;return=true&amp;sesskey='.sesskey(), get_string('update'));
135 $toprow[] = new tabobject('roles', $CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.
136 $context->id, get_string('roles'));
138 if (!empty($tabsmode)) {
140 if (!empty($assignableroles)) {
141 $secondrow[] = new tabobject('assign',
142 $CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$context->id,
143 get_string('assignroles', 'role'),
144 get_string('showallroles', 'role'),
145 true);
148 if (!empty($overridableroles)) {
149 $secondrow[] = new tabobject('override',
150 $CFG->wwwroot.'/'.$CFG->admin.'/roles/override.php?contextid='.$context->id,
151 get_string('overrideroles', 'role'),
152 get_string('showallroles', 'role'),
153 true);
156 $inactive[] = 'roles';
157 $activetwo = array('roles');
158 $currenttab = $tabsmode;
160 } else {
161 $inactive[] = '';
162 $activetwo = array();
165 /// Here other core tabs should go (always calling tabs.php files)
166 /// All the logic to decide what to show must be self-cointained in the tabs file
167 /// ej.:
168 /// include_once($CFG->dirroot . '/grades/tabs.php');
170 /// Finally, we support adding some 'on-the-fly' tabs here
171 /// All the logic to decide what to show must be self-cointained in the tabs file
172 if (isset($CFG->extratabs) && !empty($CFG->extratabs)) {
173 if ($extratabs = explode(',', $CFG->extratabs)) {
174 asort($extratabs);
175 foreach($extratabs as $extratab) {
176 /// Each extra tab mus be one $CFG->dirroot relative file
177 if (file_exists($CFG->dirroot . '/' . $extratab)) {
178 include_once($CFG->dirroot . '/' . $extratab);
184 if (!empty($secondrow)) {
185 $tabs = array($toprow, $secondrow);
186 } else {
187 $tabs = array($toprow);
190 print_tabs($tabs, $currenttab, $inactive, $activetwo);