Merge branch 'MDL-34444' of git://github.com/danpoltawski/moodle into MOODLE_23_STABLE
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Wed, 22 Aug 2012 09:14:38 +0000 (11:14 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Wed, 22 Aug 2012 09:14:38 +0000 (11:14 +0200)
1  2 
course/format/renderer.php

@@@ -205,7 -205,9 +205,7 @@@ abstract class format_section_renderer_
              return array();
          }
  
 -        if (!has_capability('moodle/course:update', context_course::instance($course->id))) {
 -            return array();
 -        }
 +        $coursecontext = context_course::instance($course->id);
  
          if ($onsectionpage) {
              $baseurl = course_get_url($course, $section->section);
          $controls = array();
  
          $url = clone($baseurl);
 -        if ($section->visible) { // Show the hide/show eye.
 -            $strhidefromothers = get_string('hidefromothers', 'format_'.$course->format);
 -            $url->param('hide', $section->section);
 -            $controls[] = html_writer::link($url,
 -                html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/hide'),
 -                'class' => 'icon hide', 'alt' => $strhidefromothers)),
 -                array('title' => $strhidefromothers, 'class' => 'editing_showhide'));
 -        } else {
 -            $strshowfromothers = get_string('showfromothers', 'format_'.$course->format);
 -            $url->param('show',  $section->section);
 -            $controls[] = html_writer::link($url,
 -                html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/show'),
 -                'class' => 'icon hide', 'alt' => $strshowfromothers)),
 -                array('title' => $strshowfromothers, 'class' => 'editing_showhide'));
 +        if (has_capability('moodle/course:sectionvisibility', $coursecontext)) {
 +            if ($section->visible) { // Show the hide/show eye.
 +                $strhidefromothers = get_string('hidefromothers', 'format_'.$course->format);
 +                $url->param('hide', $section->section);
 +                $controls[] = html_writer::link($url,
 +                    html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/hide'),
 +                    'class' => 'icon hide', 'alt' => $strhidefromothers)),
 +                    array('title' => $strhidefromothers, 'class' => 'editing_showhide'));
 +            } else {
 +                $strshowfromothers = get_string('showfromothers', 'format_'.$course->format);
 +                $url->param('show',  $section->section);
 +                $controls[] = html_writer::link($url,
 +                    html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/show'),
 +                    'class' => 'icon hide', 'alt' => $strshowfromothers)),
 +                    array('title' => $strshowfromothers, 'class' => 'editing_showhide'));
 +            }
          }
  
 -        if (!$onsectionpage) {
 +        if (!$onsectionpage && has_capability('moodle/course:update', $coursecontext)) {
              $url = clone($baseurl);
              if ($section->section > 1) { // Add a arrow to move section up.
                  $url->param('section', $section->section);
          $o .= html_writer::tag('div', '', array('class' => 'right side'));
          $o .= html_writer::start_tag('div', array('class' => 'content'));
  
+         $title = get_section_name($course, $section);
          if ($section->uservisible) {
-             $title = html_writer::tag('a', get_section_name($course, $section),
+             $title = html_writer::tag('a', $title,
                      array('href' => course_get_url($course, $section->section), 'class' => $linkclasses));
-             $o .= $this->output->heading($title, 3, 'section-title');
          }
+         $o .= $this->output->heading($title, 3, 'section-title');
  
          $o.= html_writer::start_tag('div', array('class' => 'summarytext'));
          $o.= $this->format_summary_text($section);