| 1 | efrain | 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 | /**
 | 
        
           |  |  | 18 |  * Defines classes used for plugin info.
 | 
        
           |  |  | 19 |  *
 | 
        
           |  |  | 20 |  * @package    core
 | 
        
           |  |  | 21 |  * @copyright  2019 Andrew Nicols <andrew@nicols.co.uk>
 | 
        
           |  |  | 22 |  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 | 
        
           |  |  | 23 |  */
 | 
        
           |  |  | 24 | namespace core\plugininfo;
 | 
        
           |  |  | 25 |   | 
        
           |  |  | 26 | use moodle_url;
 | 
        
           |  |  | 27 |   | 
        
           |  |  | 28 | defined('MOODLE_INTERNAL') || die();
 | 
        
           |  |  | 29 |   | 
        
           |  |  | 30 | /**
 | 
        
           |  |  | 31 |  * Class for H5P libraries.
 | 
        
           |  |  | 32 |  */
 | 
        
           |  |  | 33 | class h5plib extends base {
 | 
        
           |  |  | 34 |   | 
        
           |  |  | 35 |     /**
 | 
        
           |  |  | 36 |      * Defines if there should be a way to uninstall the plugin via the administration UI.
 | 
        
           |  |  | 37 |      *
 | 
        
           |  |  | 38 |      * @return bool
 | 
        
           |  |  | 39 |      */
 | 
        
           |  |  | 40 |     public function is_uninstall_allowed(): bool {
 | 
        
           |  |  | 41 |         return true;
 | 
        
           |  |  | 42 |     }
 | 
        
           |  |  | 43 |   | 
        
           |  |  | 44 |     /**
 | 
        
           |  |  | 45 |      * H5P versions cannot be disabled.
 | 
        
           |  |  | 46 |      *
 | 
        
           |  |  | 47 |      * @return boolean
 | 
        
           |  |  | 48 |      */
 | 
        
           |  |  | 49 |     public function is_enabled(): bool {
 | 
        
           |  |  | 50 |         return true;
 | 
        
           |  |  | 51 |     }
 | 
        
           |  |  | 52 |   | 
        
           |  |  | 53 |     /**
 | 
        
           |  |  | 54 |      * Return URL used for management of plugins of this type.
 | 
        
           |  |  | 55 |      * @return moodle_url
 | 
        
           |  |  | 56 |      */
 | 
        
           |  |  | 57 |     public static function get_manage_url(): \moodle_url {
 | 
        
           |  |  | 58 |         return new moodle_url('/admin/settings.php', ['section' => 'h5psettings']);
 | 
        
           |  |  | 59 |     }
 | 
        
           |  |  | 60 |   | 
        
           |  |  | 61 |     /**
 | 
        
           |  |  | 62 |      * Loads plugin settings to the settings tree
 | 
        
           |  |  | 63 |      *
 | 
        
           |  |  | 64 |      * This function usually includes settings.php file in plugins folder.
 | 
        
           |  |  | 65 |      * Alternatively it can create a link to some settings page (instance of admin_externalpage)
 | 
        
           |  |  | 66 |      *
 | 
        
           |  |  | 67 |      * @param \part_of_admin_tree $adminroot
 | 
        
           |  |  | 68 |      * @param string $parentnodename
 | 
        
           |  |  | 69 |      * @param bool $hassiteconfig whether the current user has moodle/site:config capability
 | 
        
           |  |  | 70 |      */
 | 
        
           |  |  | 71 |     public function load_settings(\part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig) {
 | 
        
           |  |  | 72 |         global $CFG, $USER, $DB, $OUTPUT, $PAGE; // In case settings.php wants to refer to them.
 | 
        
           |  |  | 73 |         $ADMIN = $adminroot; // May be used in settings.php.
 | 
        
           |  |  | 74 |         $plugininfo = $this; // Also can be used inside settings.php.
 | 
        
           |  |  | 75 |   | 
        
           |  |  | 76 |         if (!$this->is_installed_and_upgraded()) {
 | 
        
           |  |  | 77 |             return;
 | 
        
           |  |  | 78 |         }
 | 
        
           |  |  | 79 |   | 
        
           |  |  | 80 |         if (!$hassiteconfig) {
 | 
        
           |  |  | 81 |             return;
 | 
        
           |  |  | 82 |         }
 | 
        
           |  |  | 83 |   | 
        
           |  |  | 84 |         if (file_exists($this->full_path('settings.php'))) {
 | 
        
           |  |  | 85 |             include($this->full_path('settings.php'));
 | 
        
           |  |  | 86 |         }
 | 
        
           |  |  | 87 |     }
 | 
        
           |  |  | 88 | }
 |