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.

Differences Between: [Versions 401 and 402] [Versions 401 and 403]

   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  namespace core_badges\output;
  18  
  19  use moodle_url;
  20  use renderer_base;
  21  use single_button;
  22  
  23  /**
  24   * Class recipients_action_bar - Display the action bar
  25   *
  26   * @package   core_badges
  27   * @copyright 2021 Peter Dias
  28   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  29   */
  30  class recipients_action_bar extends manage_badge_action_bar {
  31      /**
  32       * The template that this tertiary nav should use.
  33       *
  34       * @return string
  35       */
  36      public function get_template(): string {
  37          return 'core_badges/award_badge';
  38      }
  39  
  40      /**
  41       * Export the action bar
  42       *
  43       * @param renderer_base $output
  44       * @return array
  45       */
  46      public function export_for_template(renderer_base $output): array {
  47          $elements = parent::export_for_template($output);
  48  
  49          // Add button for badge manual award.
  50          if ($this->badge->has_manual_award_criteria()
  51                  && has_capability('moodle/badges:awardbadge', $this->page->context) && $this->badge->is_active()) {
  52              $url = new moodle_url('/badges/award.php', ['id' => $this->badge->id]);
  53              $button = new single_button($url, get_string('award', 'badges'), 'post', true);
  54              $elements['awardbutton'] = $button->export_for_template($output);
  55          }
  56          $thirdpartynav = $this->get_third_party_nav_action($output);
  57          $elements += $thirdpartynav ?: [];
  58  
  59          return $elements;
  60      }
  61  }