[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/blocks/feedback/ -> block_feedback.php (source)

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Feedback block.
  19   *
  20   * @package    block_feedback
  21   * @copyright  1999 onwards Martin Dougiamas (http://dougiamas.com)
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  if (is_file($CFG->dirroot.'/mod/feedback/lib.php')) {
  26      require_once($CFG->dirroot.'/mod/feedback/lib.php');
  27      define('FEEDBACK_BLOCK_LIB_IS_OK', true);
  28  }
  29  
  30  class block_feedback extends block_list {
  31  
  32      function init() {
  33          $this->title = get_string('feedback', 'block_feedback');
  34      }
  35  
  36      function applicable_formats() {
  37          return array('site' => true, 'course' => true);
  38      }
  39  
  40      function get_content() {
  41          global $CFG, $OUTPUT;
  42  
  43          if ($this->content !== NULL) {
  44              return $this->content;
  45          }
  46  
  47          $this->content = new stdClass;
  48          $this->content->items = array();
  49          $this->content->icons = array();
  50          $this->content->footer = '';
  51  
  52          if (!defined('FEEDBACK_BLOCK_LIB_IS_OK')) {
  53              $this->content->items = array(get_string('missing_feedback_module', 'block_feedback'));
  54              return $this->content;
  55          }
  56  
  57          $courseid = $this->page->course->id;
  58          if ($courseid <= 0) {
  59              $courseid = SITEID;
  60          }
  61  
  62          $icon = '<img src="'.$OUTPUT->pix_url('icon', 'feedback') . '" class="icon" alt="" />';
  63  
  64  
  65          if (empty($this->instance->pageid)) {
  66              $this->instance->pageid = SITEID;
  67          }
  68  
  69          if ($feedbacks = feedback_get_feedbacks_from_sitecourse_map($courseid)) {
  70              $baseurl = new moodle_url('/mod/feedback/view.php');
  71              foreach ($feedbacks as $feedback) {
  72                  $url = new moodle_url($baseurl);
  73                  $url->params(array('id'=>$feedback->cmid, 'courseid'=>$courseid));
  74                  $this->content->items[] = '<a href="'.$url->out().'">'.$icon.$feedback->name.'</a>';
  75              }
  76          }
  77  
  78          return $this->content;
  79      }
  80  }


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1