From 85489a5b42a1372b57e14f26b0b25f5c685a1ab2 Mon Sep 17 00:00:00 2001 From: moodler Date: Mon, 2 Oct 2006 14:57:00 +0000 Subject: [PATCH] Various little cleanups --- lib/weblib.php | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/lib/weblib.php b/lib/weblib.php index 058fac939d6..d782deaeffa 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -3058,8 +3058,6 @@ function print_user($user, $course, $messageselect=false, $return=false) { static $string; static $datestring; static $countries; - static $isadmin; - static $isteacher; $context = get_context_instance(CONTEXT_COURSE, $course->id); @@ -3086,8 +3084,6 @@ function print_user($user, $course, $messageselect=false, $return=false) { $datestring->secs = get_string('secs'); $countries = get_list_of_countries(); - $isteacher = isteacher($course->id); - $isadmin = isadmin(); } /// Get the hidden field list @@ -3571,7 +3567,7 @@ function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $v if ($usehtmleditor) { // not sure if this capability is appropriate - if (!empty($courseid) and has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $courseid))) { + if (!empty($courseid) and has_capability('moodle/course:trustcontent', get_context_instance(CONTEXT_COURSE, $courseid))) { $str .= ($scriptcount < 1) ? ''."\n" : ''; } else { @@ -3804,7 +3800,6 @@ function update_mymoodle_icon() { function update_module_button($moduleid, $courseid, $string) { global $CFG, $USER; - if (has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_MODULE, $moduleid))) { $string = get_string('updatethis', '', $string); return "
framename\" method=\"get\" action=\"$CFG->wwwroot/course/mod.php\">". @@ -4027,7 +4022,8 @@ function navmenu($course, $cm=NULL, $targetwindow='self') { if (!$modinfo = unserialize((string)$course->modinfo)) { return ''; } - $isteacher = isteacher($course->id); + $context = get_context_instance(CONTEXT_COURSE, $course->id); + $section = -1; $selected = ''; $url = ''; @@ -4042,8 +4038,7 @@ function navmenu($course, $cm=NULL, $targetwindow='self') { $sections = get_records('course_sections','course',$course->id,'section','section,visible,summary'); if (!empty($THEME->makenavmenulist)) { /// A hack to produce an XHTML navmenu list for use in themes - $THEME->navmenulist = navmenulist($course, $sections, $modinfo, - $isteacher, $strsection, $strjumpto, $width, $cm); + $THEME->navmenulist = navmenulist($course, $sections, $modinfo, $strsection, $strjumpto, $width, $cm); } foreach ($modinfo as $mod) { @@ -4058,7 +4053,8 @@ function navmenu($course, $cm=NULL, $targetwindow='self') { if ($mod->section > 0 and $section <> $mod->section) { $thissection = $sections[$mod->section]; - if ($thissection->visible or !$course->hiddensections or has_capability('moodle/course:viewhiddensections', get_context_instance(CONTEXT_COURSE, $course->id))) { + if ($thissection->visible or !$course->hiddensections or + has_capability('moodle/course:viewhiddensections', $context)) { $thissection->summary = strip_tags(format_string($thissection->summary,true)); if ($course->format == 'weeks' or empty($thissection->summary)) { $menu[] = '-------------- '. $strsection ." ". $mod->section .' --------------'; @@ -4105,24 +4101,27 @@ function navmenu($course, $cm=NULL, $targetwindow='self') { //Accessibility: added Alt text, replaced > < with 'silent' character and 'accesshide' text. check_theme_arrows(); - if ($selectmod and has_capability('moodle/site:viewreports', get_context_instance(CONTEXT_COURSE, $course->id))) { + if ($selectmod and has_capability('moodle/site:viewreports', $context)) { $logstext = get_string('alllogs'); - $logslink = "framename\" href=". - "\"$CFG->wwwroot/course/report/log/index.php?chooselog=1&user=0&date=0&id=$course->id&modid=$selectmod->cm\">". - "pixpath/i/log.gif\" alt=\"$logstext\" />"; + $logslink = ''. + ''.$logstext.''; } if ($backmod) { $backtext= get_string('activityprev', 'access'); - $backmod = "wwwroot/mod/$backmod->mod/view.php\" target=\"$CFG->framename\">". - "cm\" />". - "
"; + $backmod = '
'. + ''. + '
'; } if ($nextmod) { $nexttext= get_string('activitynext', 'access'); - $nextmod = "
wwwroot/mod/$nextmod->mod/view.php\" target=\"$CFG->framename\">". - "cm\" />". - "
"; + $nextmod = '
'. + ''. + '
'; } return "\n
".$logslink .''. $backmod .'' . @@ -4143,7 +4142,7 @@ function navmenu($course, $cm=NULL, $targetwindow='self') { * @return string * @todo Finish documenting this function */ -function navmenulist($course, $sections, $modinfo, $isteacher, $strsection, $strjumpto, $width=50, $cmid=0) { +function navmenulist($course, $sections, $modinfo, $strsection, $strjumpto, $width=50, $cmid=0) { global $CFG; @@ -4158,6 +4157,8 @@ function navmenulist($course, $sections, $modinfo, $isteacher, $strsection, $str $flag = false; $menu = array(); + $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); + $menu[] = '