. namespace core\plugininfo; use core_plugin_manager; use moodle_url; /** * AI placement plugin info class. * * @package core * @copyright 2024 Matt Porritt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class aiprovider extends base { /** @var string Enable a plugin */ public const ENABLE = 'enable'; /** @var string Disable a plugin */ public const DISABLE = 'disable'; /** @var string Move a plugin up in the plugin order */ public const UP = 'up'; /** @var string Move a plugin down in the plugin order */ public const DOWN = 'down'; #[\Override] public function is_uninstall_allowed(): bool { return true; } #[\Override] public function get_settings_section_name(): string { return $this->type . '_' . $this->name; } #[\Override] public static function get_manage_url(): moodle_url { return new moodle_url('/admin/settings.php', [ 'section' => 'aiprovider', ]); } #[\Override] public static function get_enabled_plugins(): ?array { $pluginmanager = core_plugin_manager::instance(); $plugins = $pluginmanager->get_installed_plugins('aiprovider'); if (!$plugins) { return []; } $plugins = array_keys($plugins); // Filter to return only enabled plugins. $enabled = []; foreach ($plugins as $plugin) { $disabled = get_config('aiprovider_' . $plugin, 'disabled'); if (empty($disabled)) { $enabled[$plugin] = $plugin; } } return $enabled; } /** * Returns the list of available actions with provider. * * @return array */ public static function get_provider_actions(): array { return [self::UP, self::DOWN]; } }