Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
   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   * This file contains hooks and callbacks needed for the accessibility toolkit.
  19   *
  20   * @package     tool_brickfield
  21   * @category    admin
  22   * @copyright   2020 Brickfield Education Labs, https://www.brickfield.ie - Author: Karen Holland
  23   * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  use tool_brickfield\accessibility;
  27  use tool_brickfield\manager;
  28  use tool_brickfield\registration;
  29  
  30  /**
  31   * This function extends the navigation with the report items
  32   *
  33   * @param navigation_node $navigation The navigation node to extend
  34   * @param stdClass $course The course to object for the report
  35   * @param context $context The context of the course
  36   * @throws coding_exception
  37   * @throws moodle_exception
  38   */
  39  function tool_brickfield_extend_navigation_course(\navigation_node $navigation, \stdClass $course, \context $context) {
  40      if (!accessibility::is_accessibility_enabled()) {
  41          // The feature has been explicitly disabled.
  42          return;
  43      }
  44  
  45      if (!has_capability(accessibility::get_capability_name('viewcoursetools'), $context)) {
  46          // The user does not have the capability to view the course tools.
  47          return;
  48      }
  49  
  50      // Display in the navigation if the user has site:config ability, or if the site is registered.
  51      $enabled = has_capability('moodle/site:config', \context_system::instance());
  52      $enabled = $enabled || (new registration())->toolkit_is_active();
  53      if (!$enabled) {
  54          return;
  55      }
  56  
  57      $url = new moodle_url(accessibility::get_plugin_url(), ['courseid' => $course->id]);
  58      $navigation->add(
  59          get_string('pluginname', manager::PLUGINNAME),
  60          $url,
  61          navigation_node::TYPE_SETTING,
  62          null,
  63          null,
  64          new pix_icon('i/report', '')
  65      );
  66  }
  67  
  68  /**
  69   * Get icon mapping for font-awesome.
  70   * @return string[]
  71   */
  72  function tool_brickfield_get_fontawesome_icon_map() {
  73      return [
  74          manager::PLUGINNAME . ':f/award' => 'fa-tachometer',
  75          manager::PLUGINNAME . ':f/done' => 'fa-check-circle-o',
  76          manager::PLUGINNAME . ':f/done2' => 'fa-check-square-o',
  77          manager::PLUGINNAME . ':f/error' => 'fa-times-circle-o',
  78          manager::PLUGINNAME . ':f/find' => 'fa-bar-chart',
  79          manager::PLUGINNAME . ':f/total' => 'fa-calculator',
  80          manager::PLUGINNAME . ':f/form' => 'fa-pencil-square-o',
  81          manager::PLUGINNAME . ':f/image' => 'fa-image',
  82          manager::PLUGINNAME . ':f/layout' => 'fa-th-large',
  83          manager::PLUGINNAME . ':f/link' => 'fa-link',
  84          manager::PLUGINNAME . ':f/media' => 'fa-play-circle-o',
  85          manager::PLUGINNAME . ':f/table' => 'fa-table',
  86          manager::PLUGINNAME . ':f/text' => 'fa-font',
  87      ];
  88  }