diff --git a/.upgradenotes/MDL-82503-2024081605172847.yml b/.upgradenotes/MDL-82503-2024081605172847.yml new file mode 100644 index 00000000000..4eb3439ce89 --- /dev/null +++ b/.upgradenotes/MDL-82503-2024081605172847.yml @@ -0,0 +1,7 @@ +issueNumber: MDL-82503 +notes: + core_badges: + - message: >- + The $showmanage parameter in the core_badges\output\standard_action_bar + constructor has been deprecated and should not be used anymore. + type: deprecated diff --git a/badges/award.php b/badges/award.php index b503ac19234..7b71559c2b2 100644 --- a/badges/award.php +++ b/badges/award.php @@ -84,7 +84,12 @@ if (!$badge->is_active()) { $returnurl = new moodle_url('recipients.php', array('id' => $badge->id)); $returnlink = html_writer::link($returnurl, $strrecipients); -$actionbar = new \core_badges\output\standard_action_bar($PAGE, $badge->type, false, false, $returnurl); +$actionbar = new \core_badges\output\standard_action_bar( + page: $PAGE, + type: $badge->type, + showaddbadge: false, + backurl: $returnurl +); $output = $PAGE->get_renderer('core', 'badges'); $tertiarynav = $output->render_tertiary_navigation($actionbar); diff --git a/badges/classes/output/standard_action_bar.php b/badges/classes/output/standard_action_bar.php index 619eb7719bd..3011d20b803 100644 --- a/badges/classes/output/standard_action_bar.php +++ b/badges/classes/output/standard_action_bar.php @@ -29,29 +29,29 @@ use single_button; * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class standard_action_bar extends base_action_bar { - /** @var bool $showmanage Whether or not to show the manage badges button. */ - protected $showmanage; - - /** @var bool $showaddbadge Whether or not to show the add badges button. */ - protected $showaddbadge; - - /** @var moodle_url $backurl BackURL to be used when the back button is required. */ - protected $backurl; - /** - * standard_action_bar constructor + * The constructor. * - * @param moodle_page $page The page object - * @param int $type The type of badge we are operating with - * @param bool $showmanage Whether or not to show the manage badges button - * @param bool $showaddbadge Whether or not to show the add badges button - * @param moodle_url|null $backurl The backurl to be used */ - public function __construct(moodle_page $page, int $type, bool $showmanage = true, - $showaddbadge = true, ?moodle_url $backurl = null) { + public function __construct( + moodle_page $page, + int $type, + /** @var null|bool $showmanage This parameter has been deprecated since 4.5 and should not be used anymore. */ + ?bool $showmanage = null, + /** @var bool $showaddbadge Whether or not to show the add badges button. */ + protected bool $showaddbadge = true, + /** @var moodle_url $backurl BackURL to be used when the back button is required. */ + protected ?moodle_url $backurl = null, + ) { parent::__construct($page, $type); - $this->showmanage = $showmanage; + if ($showmanage !== null) { + debugging( + 'The showmanage argument has been deprecated. Please remove it from your method calls.', + DEBUG_DEVELOPER, + ); + } + $this->showaddbadge = $showaddbadge; $this->backurl = $backurl; } @@ -82,11 +82,6 @@ class standard_action_bar extends base_action_bar { $params['id'] = $this->page->context->instanceid; } - if ($this->showmanage) { - $buttons[] = new single_button(new moodle_url('/badges/index.php', $params), - get_string('managebadges', 'core_badges'), 'get'); - } - if ($this->showaddbadge && has_capability('moodle/badges:createbadge', $this->page->context)) { $editparams = ['action' => 'new']; if (array_key_exists('id', $params)) {