MDL-79162 badges: final removal of deprecated table renderer methods.

This commit is contained in:
Paul Holden
2025-01-17 14:42:00 +00:00
parent a2653cc924
commit 90b2370f34
3 changed files with 15 additions and 148 deletions
@@ -0,0 +1,9 @@
issueNumber: MDL-79162
notes:
core_badges:
- message: |-
The following previously deprecated renderer methods have been removed:
* `print_badge_table_actions`
* `render_badge_management`
type: removed
@@ -1,43 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Issued badge renderable.
*
* @package core
* @subpackage badges
* @copyright 2012 onwards Totara Learning Solutions Ltd {@link http://www.totaralms.com/}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Yuliya Bozhko <[email protected]>
*/
namespace core_badges\output;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir . '/badgeslib.php');
use renderable;
/**
* Collection of badges used at the index.php page
*
* @copyright 2012 onwards Totara Learning Solutions Ltd {@link http://www.totaralms.com/}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class badge_management extends badge_collection implements renderable {
}
+6 -105
View File
@@ -272,64 +272,11 @@ class core_badges_renderer extends plugin_renderer_base {
}
/**
* Prints action icons for the badge.
*
* @deprecated sinde Moodle 4.3
* @param \core_badges\badge $badge
* @param \context $context
* @return string
*/
public function print_badge_table_actions($badge, $context) {
debugging("print_badge_table_actions() is deprecated.", DEBUG_DEVELOPER);
$actions = "";
if (has_capability('moodle/badges:configuredetails', $context) && $badge->has_criteria()) {
// Activate/deactivate badge.
if ($badge->status == BADGE_STATUS_INACTIVE || $badge->status == BADGE_STATUS_INACTIVE_LOCKED) {
// "Activate" will go to another page and ask for confirmation.
$url = new moodle_url('/badges/action.php');
$url->param('id', $badge->id);
$url->param('activate', true);
$url->param('sesskey', sesskey());
$return = new moodle_url(qualified_me());
$url->param('return', $return->out_as_local_url(false));
$actions .= $this->output->action_icon($url, new pix_icon('t/show', get_string('activate', 'badges'))) . " ";
} else {
$url = new moodle_url(qualified_me());
$url->param('lock', $badge->id);
$url->param('sesskey', sesskey());
$actions .= $this->output->action_icon($url, new pix_icon('t/hide', get_string('deactivate', 'badges'))) . " ";
}
}
// Award badge manually.
if ($badge->has_manual_award_criteria() &&
has_capability('moodle/badges:awardbadge', $context) &&
$badge->is_active()) {
$url = new moodle_url('/badges/award.php', array('id' => $badge->id));
$actions .= $this->output->action_icon($url, new pix_icon('t/award', get_string('award', 'badges'))) . " ";
}
// Edit badge.
if (has_capability('moodle/badges:configuredetails', $context)) {
$url = new moodle_url('/badges/edit.php', array('id' => $badge->id, 'action' => 'badge'));
$actions .= $this->output->action_icon($url, new pix_icon('t/edit', get_string('edit'))) . " ";
}
// Duplicate badge.
if (has_capability('moodle/badges:createbadge', $context)) {
$url = new moodle_url('/badges/action.php', array('copy' => '1', 'id' => $badge->id, 'sesskey' => sesskey()));
$actions .= $this->output->action_icon($url, new pix_icon('t/copy', get_string('copy'))) . " ";
}
// Delete badge.
if (has_capability('moodle/badges:deletebadge', $context)) {
$url = new moodle_url(qualified_me());
$url->param('delete', $badge->id);
$actions .= $this->output->action_icon($url, new pix_icon('t/delete', get_string('delete'))) . " ";
}
return $actions;
#[\core\attribute\deprecated(null, reason: 'It is no longer used', since: '4.3', mdl: 'MDL-77061', final: true)]
public function print_badge_table_actions() {
\core\deprecation::emit_deprecation_if_present([self::class, __FUNCTION__]);
}
/**
@@ -497,57 +444,11 @@ class core_badges_renderer extends plugin_renderer_base {
}
/**
* Render a table of badges.
*
* @deprecated since Moodle 4.3
* @param \core_badges\output\badge_management $badges
* @return string
*/
protected function render_badge_management(\core_badges\output\badge_management $badges) {
debugging("render_badge_management() is deprecated.", DEBUG_DEVELOPER);
$paging = new paging_bar($badges->totalcount, $badges->page, $badges->perpage, $this->page->url, 'page');
// New badge button.
$htmlnew = '';
$htmlpagingbar = $this->render($paging);
$table = new html_table();
$table->attributes['class'] = 'table table-bordered table-striped';
$sortbyname = $this->helper_sortable_heading(get_string('name'),
'name', $badges->sort, $badges->dir);
$sortbystatus = $this->helper_sortable_heading(get_string('status', 'badges'),
'status', $badges->sort, $badges->dir);
$table->head = array(
$sortbyname,
$sortbystatus,
get_string('bcriteria', 'badges'),
get_string('awards', 'badges'),
get_string('actions')
);
$table->colclasses = array('name', 'status', 'criteria', 'awards', 'actions');
foreach ($badges->badges as $b) {
$style = !$b->is_active() ? array('class' => 'dimmed') : array();
$forlink = print_badge_image($b, $this->page->context) . ' ' .
html_writer::start_tag('span') . $b->name . html_writer::end_tag('span');
$name = html_writer::link(new moodle_url('/badges/overview.php', array('id' => $b->id)), $forlink, $style);
$status = $b->statstring;
$criteria = self::print_badge_criteria($b, 'short');
if (has_capability('moodle/badges:viewawarded', $this->page->context)) {
$awards = html_writer::link(new moodle_url('/badges/recipients.php', array('id' => $b->id)), $b->awards);
} else {
$awards = $b->awards;
}
$actions = self::print_badge_table_actions($b, $this->page->context);
$row = array($name, $status, $criteria, $awards, $actions);
$table->data[] = $row;
}
$htmltable = html_writer::table($table);
return $htmlnew . $htmlpagingbar . $htmltable . $htmlpagingbar;
#[\core\attribute\deprecated(null, reason: 'It is no longer used', since: '4.3', mdl: 'MDL-77061', final: true)]
protected function render_badge_management() {
\core\deprecation::emit_deprecation_if_present([self::class, __FUNCTION__]);
}
/**