Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402]

   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   * List of enabled backpacks for the site.
  19   *
  20   * @package    core_badges
  21   * @copyright  2019 Damyon Wiese
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  namespace core_badges\output;
  26  
  27  defined('MOODLE_INTERNAL') || die();
  28  
  29  require_once($CFG->libdir . '/tablelib.php');
  30  require_once($CFG->libdir . '/badgeslib.php');
  31  
  32  use html_writer;
  33  use moodle_url;
  34  use table_sql;
  35  
  36  /**
  37   * Backpacks table class.
  38   *
  39   * @package    core_badges
  40   * @copyright  2019 Damyon Wiese
  41   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  42   */
  43  class external_backpacks_table extends table_sql {
  44  
  45      /**
  46       * Sets up the table.
  47       */
  48      public function __construct() {
  49          parent::__construct('backpacks');
  50  
  51          $context = \context_system::instance();
  52          // This object should not be used without the right permissions.
  53          require_capability('moodle/badges:manageglobalsettings', $context);
  54  
  55          // Define columns in the table.
  56          $this->define_table_columns();
  57  
  58          // Define configs.
  59          $this->define_table_configs();
  60      }
  61  
  62      /**
  63       * Setup the headers for the table.
  64       */
  65      protected function define_table_columns() {
  66          $cols = [
  67              'backpackweburl' => get_string('backpackurl', 'core_badges'),
  68              'sortorder' => '',
  69          ];
  70  
  71          $this->define_columns(array_keys($cols));
  72          $this->define_headers(array_values($cols));
  73      }
  74  
  75      /**
  76       * Define table configs.
  77       */
  78      protected function define_table_configs() {
  79          $this->collapsible(false);
  80          $this->sortable(false);
  81          $this->pageable(false);
  82      }
  83  
  84  }