### Eclipse Workspace Patch 1.0 #P moodle-HEAD Index: lib/accesslib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/accesslib.php,v retrieving revision 1.258 diff -u -r1.258 accesslib.php --- lib/accesslib.php 15 May 2007 03:19:01 -0000 1.258 +++ lib/accesslib.php 20 May 2007 14:21:51 -0000 @@ -2643,7 +2643,7 @@ /** * prints human readable context identifier. */ -function print_context_name($context) { +function print_context_name($context, $withprefix = true, $short = false) { $name = ''; switch ($context->contextlevel) { @@ -2658,30 +2658,45 @@ case CONTEXT_USER: if ($user = get_record('user', 'id', $context->instanceid)) { - $name = get_string('user').': '.fullname($user); + if ($withprefix){ + $name = get_string('user').': '; + } + $name .= fullname($user); } break; case CONTEXT_COURSECAT: // Coursecat -> coursecat or site if ($category = get_record('course_categories', 'id', $context->instanceid)) { - $name = get_string('category').': '. format_string($category->name); + if ($withprefix){ + $name = get_string('category').': '; + } + $name .=format_string($category->name); } break; case CONTEXT_COURSE: // 1 to 1 to course cat if ($course = get_record('course', 'id', $context->instanceid)) { - - if ($context->instanceid == SITEID) { - $name = get_string('site').': '. format_string($course->fullname); - } else { - $name = get_string('course').': '. format_string($course->fullname); + if ($withprefix){ + if ($context->instanceid == SITEID) { + $name = get_string('site').': '; + } else { + $name = get_string('course').': '; + } } + if ($short){ + $name .=format_string($course->shortname); + } else { + $name .=format_string($course->fullname); + } + } break; case CONTEXT_GROUP: // 1 to 1 to course if ($name = groups_get_group_name($context->instanceid)) { - $name = get_string('group').': '. $name; + if ($withprefix){ + $name = get_string('group').': '. $name; + } } break; @@ -2689,7 +2704,10 @@ if ($cm = get_record('course_modules','id',$context->instanceid)) { if ($module = get_record('modules','id',$cm->module)) { if ($mod = get_record($module->name, 'id', $cm->instance)) { - $name = get_string('activitymodule').': '.$mod->name; + if ($withprefix){ + $name = get_string('activitymodule').': '; + } + $name .= $mod->name; } } } @@ -2703,7 +2721,10 @@ require_once("$CFG->dirroot/blocks/$block->name/block_$block->name.php"); $blockname = "block_$block->name"; if ($blockobject = new $blockname()) { - $name = $blockobject->title.' ('.get_string('block').')'; + if ($withprefix){ + $name = get_string('block').': '; + } + $name .= $blockobject->title; } } }