MDL-82567 core: Add has_capability method

Co-authored-by: David Woloszyn <[email protected]>
Co-authored-by: Jun Pataleta <[email protected]>
This commit is contained in:
Marina Glancy
2024-08-26 04:01:20 +00:00
committed by Jenkins
co-authored by David Woloszyn Jun Pataleta
parent a2c405ba5f
commit aca6d79b91
8 changed files with 81 additions and 0 deletions
+15
View File
@@ -211,6 +211,21 @@ class flexible_table {
TABLE_VAR_RESET => 'treset',
TABLE_VAR_DIR => 'tdir',
);
static $notified = [];
if (!(defined('AJAX_SCRIPT') && AJAX_SCRIPT) &&
$this instanceof \core_table\dynamic &&
!method_exists($this, 'has_capability') &&
empty($notified[get_class($this)])) {
// Classes implementing \core_table\dynamic must have a method has_capability():bool .
// This will be enforced in Moodle 4.5.
\core\notification::add(
get_string('codingerror', 'debug',
'Error in class '.get_class($this).'. Some functionality may be available to admins only.'),
\core\notification::WARNING
);
$notified[get_class($this)] = true;
}
}
/**