/** * Loads plugin settings to the settings tree * * This function usually includes settings.php file in plugins folder. * Alternatively it can create a link to some settings page (instance of admin_externalpage) * * @param \part_of_admin_tree $adminroot * @param string $parentnodename * @param bool $hassiteconfig whether the current user has moodle/site:config capability */ public function load_settings(\part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig) { global $CFG, $USER, $DB, $OUTPUT, $PAGE; // In case settings.php wants to refer to them. $ADMIN = $adminroot; // May be used in settings.php. $plugininfo = $this; // Also can be used inside settings.php. if (!$this->is_installed_and_upgraded()) { return; } if (!$hassiteconfig or !file_exists($this->full_path('settings.php'))) { return; } $section = $this->get_settings_section_name(); $settings = new \admin_settingpage($section, $this->displayname, 'moodle/site:config', $this->is_enabled() === false); if ($adminroot->fulltree) { $shortsubtype = substr($this->type, strlen('assign')); include $this->full_path('settings.php'); } $adminroot->add($this->type . 'plugins', $settings); }
public function load_settings(part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig) { // plagiarism plugin just redirect to settings.php in the plugins directory if ($hassiteconfig && file_exists($this->full_path('settings.php'))) { $section = $this->get_settings_section_name(); $settingsurl = new moodle_url($this->get_dir() . '/settings.php'); $settings = new admin_externalpage($section, $this->displayname, $settingsurl, 'moodle/site:config', $this->is_enabled() === false); $adminroot->add($parentnodename, $settings); } }
/** * This function adds plugin pages to the navigation menu * * @static * @param string $subtype - The type of plugin (submission or feedback) * @param part_of_admin_tree $admin - The handle to the admin menu * @param admin_settingpage $settings - The handle to current node in the navigation tree * @param stdClass $module - The handle to the current module * @return None */ static function add_admin_assign_plugin_settings($subtype, part_of_admin_tree $admin, admin_settingpage $settings, stdClass $module) { global $CFG; $plugins = get_plugin_list_with_file($subtype, 'settings.php', false); $pluginsbyname = array(); foreach ($plugins as $plugin => $plugindir) { $pluginname = get_string('pluginname', $subtype . '_'.$plugin); $pluginsbyname[$pluginname] = $plugin; } ksort($pluginsbyname); foreach ($pluginsbyname as $pluginname => $plugin) { $settings = new admin_settingpage($subtype . '_'.$plugin, $pluginname, 'moodle/site:config', !$module->visible); if ($admin->fulltree) { $shortsubtype = substr($subtype, strlen('assign')); include($CFG->dirroot . "/mod/assign/$shortsubtype/$plugin/settings.php"); } $admin->add($subtype . 'plugins', $settings); } }