protected function definition() { global $CFG, $OUTPUT; $mform =& $this->_form; $indicators = $this->_customdata['indicators']; $mform->addElement('hidden', 'id', $this->_customdata['id']); // TODO: general course-level report settings. $mform->addElement('header', 'general', get_string('pluginname', 'coursereport_engagement')); $mform->addElement('header', 'weightings', get_string('weighting', 'coursereport_engagement')); $mform->addElement('static', 'weightings_desc', get_string('indicator', 'coursereport_engagement')); foreach ($indicators as $name => $path) { $grouparray = array(); $grouparray[] =& $mform->createElement('text', "weighting_{$name}", '', array('size' => 3)); $grouparray[] =& $mform->createElement('static', '', '', '%'); $mform->addGroup($grouparray, "weight_group_{$name}", get_string('pluginname', "engagementindicator_{$name}"), ' ', false); } $pluginman = plugin_manager::instance(); $instances = get_plugin_list('engagementindicator'); foreach ($indicators as $name => $path) { $plugin = coursereport_engagement_get_plugin_info($pluginman, 'engagementindicator_' . $name); $file = "{$CFG->dirroot}/mod/engagement/indicator/{$name}/thresholds_form.php"; if (file_exists($file) && $plugin->is_enabled()) { require_once $file; $class = "engagementindicator_{$name}_thresholds_form"; $subform = new $class(); $mform->addElement('header', 'general', get_string('pluginname', "engagementindicator_{$name}")); $subform->definition_inner($mform); } } $this->add_action_buttons(); }
/** * Get role capabilities of a virtual platform. * @param mixed $user The calling user. * @param string $role The role to read capabilities. * @param mixed $capabilities The capabilities to read (optional / may be string or array). */ function mnetadmin_rpc_get_plugins_info($user, $plugintype, $json_response = true) { global $CFG, $USER, $DB; // Invoke local user and check his rights if ($auth_response = invoke_local_user((array) $user, 'local/vmoodle:execute')) { if ($json_response) { return $auth_response; } else { return json_decode($auth_response); } } $response = new StdClass(); $response->errors = array(); $response->error = ''; // Creating response. $response->status = RPC_SUCCESS; // Getting role. $pm = plugin_manager::instance(); $allplugins = $pm->get_plugins(); if (!array_key_exists($plugintype, $allplugins)) { $response->status = RPC_FAILURE_RECORD; $response->errors[] = "Non existant plugin type {$plugintype}."; $response->error = "Non existant plugin type {$plugintype}."; if ($json_response) { return json_encode($response); } else { return $response; } } // Setting result value. $response->value = (array) $allplugins[$plugintype]; $actionclass = $plugintype . '_remote_control'; // Get activation status. foreach ($response->value as $pluginname => $foobar) { // Ignore non implemented. if (!class_exists($actionclass)) { debug_trace("failing running remote action on {$actionclass}. Class not found"); continue; } $control = new $actionclass($pluginname); $response->value[$pluginname]->enabled = $control->is_enabled(); } // Returning response. if ($json_response) { return json_encode($response); } else { return $response; } }
function coursereport_engagement_get_course_summary($courseid) { global $CFG, $DB; $risks = array(); // TODO: We want this to rely on enabled indicators in the course... require_once $CFG->libdir . '/pluginlib.php'; require_once $CFG->dirroot . '/course/report/engagement/locallib.php'; $pluginman = plugin_manager::instance(); $instances = get_plugin_list('engagementindicator'); if (!($weightings = $DB->get_records_menu('coursereport_engagement', array('course' => $courseid), '', 'indicator, weight'))) { // Setup default weightings, all equal. $weight = sprintf('%.2f', 1 / count($instances)); foreach ($instances as $name => $path) { $record = new stdClass(); $record->course = $courseid; $record->indicator = $name; $record->weight = $weight; $record->configdata = null; $wid = $DB->insert_record('coursereport_engagement', $record); $weightings[$name] = $weight; } } foreach ($instances as $name => $path) { $plugin = coursereport_engagement_get_plugin_info($pluginman, 'engagementindicator_' . $name); if ($plugin->is_enabled() && file_exists("{$path}/indicator.class.php")) { require_once "{$path}/indicator.class.php"; $classname = "indicator_{$name}"; $indicator = new $classname($courseid); $indicatorrisks = $indicator->get_course_risks(); $weight = isset($weightings[$name]) ? $weightings[$name] : 0; foreach ($indicatorrisks as $userid => $risk) { if (!isset($risks[$userid])) { $risks[$userid] = 0; } $risks[$userid] += $risk->risk * $weight; } } } return $risks; }
/** * Given the list of changes in available updates, pick those to send to site admins * * @param array $changes as returned by {@link self::compare_responses()} * @return array of available_update_info objects to send to site admins */ protected function cron_notifications(array $changes) { global $CFG; $notifications = array(); $pluginman = plugin_manager::instance(); $plugins = $pluginman->get_plugins(true); foreach ($changes as $component => $componentchanges) { if (empty($componentchanges)) { continue; } $componentupdates = $this->get_update_info($component, array('minmaturity' => $CFG->updateminmaturity, 'notifybuilds' => $CFG->updatenotifybuilds)); if (empty($componentupdates)) { continue; } // notify only about those $componentchanges that are present in $componentupdates // to respect the preferences foreach ($componentchanges as $componentchange) { foreach ($componentupdates as $componentupdate) { if ($componentupdate->version == $componentchange['version']) { if ($component == 'core') { // In case of 'core', we already know that the $componentupdate // is a real update with higher version ({@see self::get_update_info()}). // We just perform additional check for the release property as there // can be two Moodle releases having the same version (e.g. 2.4.0 and 2.5dev shortly // after the release). We can do that because we have the release info // always available for the core. if ((string) $componentupdate->release === (string) $componentchange['release']) { $notifications[] = $componentupdate; } } else { // Use the plugin_manager to check if the detected $componentchange // is a real update with higher version. That is, the $componentchange // is present in the array of {@link available_update_info} objects // returned by the plugin's available_updates() method. list($plugintype, $pluginname) = normalize_component($component); if (!empty($plugins[$plugintype][$pluginname])) { $availableupdates = $plugins[$plugintype][$pluginname]->available_updates(); if (!empty($availableupdates)) { foreach ($availableupdates as $availableupdate) { if ($availableupdate->version == $componentchange['version']) { $notifications[] = $componentupdate; } } } } } } } } } return $notifications; }
/** * Displays the list of plugins with unsatisfied dependencies * * @param double|string|int $version Moodle on-disk version * @param array $failed list of plugins with unsatisfied dependecies * @param moodle_url $reloadurl URL of the page to recheck the dependencies * @return string HTML */ public function unsatisfied_dependencies_page($version, array $failed, moodle_url $reloadurl) { $output = ''; $output .= $this->header(); $output .= $this->heading(get_string('pluginscheck', 'admin')); $output .= $this->warning(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed))))); $output .= $this->plugins_check_table(plugin_manager::instance(), $version, array('xdep' => true)); $output .= $this->warning(get_string('pluginschecktodo', 'admin')); $output .= $this->continue_button($reloadurl); $output .= $this->footer(); return $output; }
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once '../config.php'; require_once $CFG->libdir . '/adminlib.php'; require_once $CFG->libdir . '/pluginlib.php'; $action = required_param('action', PARAM_ALPHANUMEXT); $formatname = required_param('format', PARAM_PLUGIN); $confirm = optional_param('confirm', 0, PARAM_BOOL); $syscontext = context_system::instance(); $PAGE->set_url('/admin/courseformats.php'); $PAGE->set_context($syscontext); require_login(); require_capability('moodle/site:config', $syscontext); require_sesskey(); $return = new moodle_url('/admin/settings.php', array('section' => 'manageformats')); $allplugins = plugin_manager::instance()->get_plugins(); $formatplugins = $allplugins['format']; $sortorder = array_flip(array_keys($formatplugins)); if (!isset($formatplugins[$formatname])) { print_error('courseformatnotfound', 'error', $return, $formatname); } switch ($action) { case 'disable': if ($formatplugins[$formatname]->is_enabled()) { if (get_config('moodlecourse', 'format') === $formatname) { print_error('cannotdisableformat', 'error', $return); } set_config('disabled', 1, 'format_' . $formatname); } break; case 'enable':
/** * Returns localised list of available plugin types * * @return array (string)plugintype => (string)plugin name */ public function get_plugin_types_menu() { global $CFG; require_once $CFG->libdir . '/pluginlib.php'; $pluginman = plugin_manager::instance(); $menu = array('' => get_string('choosedots')); foreach (array_keys($pluginman->get_plugin_types()) as $plugintype) { $menu[$plugintype] = $pluginman->plugintype_name($plugintype) . ' (' . $plugintype . ')'; } return $menu; }
// 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/>. /** * UI for general plugins management * * @package core * @subpackage admin * @copyright 2011 David Mudrak <*****@*****.**> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once dirname(dirname(__FILE__)) . '/config.php'; require_once $CFG->libdir . '/adminlib.php'; require_once $CFG->libdir . '/pluginlib.php'; require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)); admin_externalpage_setup('pluginsoverview'); $output = $PAGE->get_renderer('core', 'admin'); echo $output->plugin_management_page(plugin_manager::instance());
/** * Return XHTML to display control * * @param mixed $data Unused * @param string $query * @return string highlight */ public function output_html($data, $query = '') { global $CFG, $OUTPUT; $return = ''; $return = $OUTPUT->heading(new lang_string('courseformats'), 3, 'main'); $return .= $OUTPUT->box_start('generalbox formatsui'); $formats = plugin_manager::instance()->get_plugins_of_type('format'); // display strings $txt = get_strings(array('settings', 'name', 'enable', 'disable', 'up', 'down', 'default', 'delete')); $txt->updown = "{$txt->up}/{$txt->down}"; $table = new html_table(); $table->head = array($txt->name, $txt->enable, $txt->updown, $txt->delete, $txt->settings); $table->align = array('left', 'center', 'center', 'center', 'center'); $table->width = '90%'; $table->attributes['class'] = 'manageformattable generaltable'; $table->data = array(); $cnt = 0; $defaultformat = get_config('moodlecourse', 'format'); $spacer = $OUTPUT->pix_icon('spacer', '', 'moodle', array('class' => 'iconsmall')); foreach ($formats as $format) { $url = new moodle_url('/admin/courseformats.php', array('sesskey' => sesskey(), 'format' => $format->name)); $isdefault = ''; if ($format->is_enabled()) { $strformatname = html_writer::tag('span', $format->displayname); if ($defaultformat === $format->name) { $hideshow = $txt->default; } else { $hideshow = html_writer::link($url->out(false, array('action' => 'disable')), $OUTPUT->pix_icon('t/hide', $txt->disable, 'moodle', array('class' => 'iconsmall'))); } } else { $strformatname = html_writer::tag('span', $format->displayname, array('class' => 'dimmed_text')); $hideshow = html_writer::link($url->out(false, array('action' => 'enable')), $OUTPUT->pix_icon('t/show', $txt->enable, 'moodle', array('class' => 'iconsmall'))); } $updown = ''; if ($cnt) { $updown .= html_writer::link($url->out(false, array('action' => 'up')), $OUTPUT->pix_icon('t/up', $txt->up, 'moodle', array('class' => 'iconsmall'))) . ''; } else { $updown .= $spacer; } if ($cnt < count($formats) - 1) { $updown .= ' ' . html_writer::link($url->out(false, array('action' => 'down')), $OUTPUT->pix_icon('t/down', $txt->down, 'moodle', array('class' => 'iconsmall'))); } else { $updown .= $spacer; } $cnt++; $settings = ''; if ($format->get_settings_url()) { $settings = html_writer::link($format->get_settings_url(), $txt->settings); } $uninstall = ''; if ($defaultformat !== $format->name) { $uninstall = html_writer::link($format->get_uninstall_url(), $txt->delete); } $table->data[] = array($strformatname, $hideshow, $updown, $uninstall, $settings); } $return .= html_writer::table($table); $link = html_writer::link(new moodle_url('/admin/settings.php', array('section' => 'coursesettings')), new lang_string('coursesettings')); $return .= html_writer::tag('p', get_string('manageformatsgotosettings', 'admin', $link)); $return .= $OUTPUT->box_end(); return highlight($query, $return); }
/** * Given the list of changes in available updates, pick those to send to site admins * * @param array $changes as returned by {@link self::compare_responses()} * @return array of available_update_info objects to send to site admins */ protected function cron_notifications(array $changes) { global $CFG; $notifications = array(); $pluginman = plugin_manager::instance(); $plugins = $pluginman->get_plugins(true); foreach ($changes as $component => $componentchanges) { if (empty($componentchanges)) { continue; } $componentupdates = $this->get_update_info($component, array('minmaturity' => $CFG->updateminmaturity, 'notifybuilds' => $CFG->updatenotifybuilds)); if (empty($componentupdates)) { continue; } // notify only about those $componentchanges that are present in $componentupdates // to respect the preferences foreach ($componentchanges as $componentchange) { foreach ($componentupdates as $componentupdate) { if ($componentupdate->version == $componentchange['version']) { if ($component == 'core') { // in case of 'core' this is enough, we already know that the // $componentupdate is a real update with higher version $notifications[] = $componentupdate; } else { // use the plugin_manager to check if the reported $componentchange // is a real update with higher version. such a real update must be // present in the 'availableupdates' property of one of the component's // available_update_info object list($plugintype, $pluginname) = normalize_component($component); if (!empty($plugins[$plugintype][$pluginname]->availableupdates)) { foreach ($plugins[$plugintype][$pluginname]->availableupdates as $availableupdate) { if ($availableupdate->version == $componentchange['version']) { $notifications[] = $componentupdate; } } } } } } } } return $notifications; }
* @copyright 2011 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once dirname(__FILE__) . '/../config.php'; require_once $CFG->libdir . '/questionlib.php'; require_once $CFG->libdir . '/adminlib.php'; require_once $CFG->libdir . '/pluginlib.php'; require_once $CFG->libdir . '/tablelib.php'; // Check permissions. require_login(); $systemcontext = context_system::instance(); require_capability('moodle/question:config', $systemcontext); admin_externalpage_setup('manageqbehaviours'); $thispageurl = new moodle_url('/admin/qbehaviours.php'); $behaviours = get_plugin_list('qbehaviour'); $pluginmanager = plugin_manager::instance(); // Get some data we will need - question counts and which types are needed. $counts = $DB->get_records_sql_menu("\n SELECT behaviour, COUNT(1)\n FROM {question_attempts} GROUP BY behaviour"); $needed = array(); $archetypal = array(); foreach ($behaviours as $behaviour => $notused) { if (!array_key_exists($behaviour, $counts)) { $counts[$behaviour] = 0; } $needed[$behaviour] = $counts[$behaviour] > 0 || $pluginmanager->other_plugins_that_require('qbehaviour_' . $behaviour); $archetypal[$behaviour] = question_engine::is_behaviour_archetypal($behaviour); } foreach ($counts as $behaviour => $count) { if (!array_key_exists($behaviour, $behaviours)) { $counts['missing'] += $count; }
/** * Builds the XHTML to display the control. * * @param string $data Unused * @param string $query * @return string */ public function output_html($data, $query = '') { global $CFG, $OUTPUT, $PAGE; require_once "{$CFG->libdir}/editorlib.php"; require_once "{$CFG->libdir}/pluginlib.php"; require_once __DIR__ . '/lib.php'; $tinymce = new tinymce_texteditor(); $pluginmanager = plugin_manager::instance(); // display strings $strbuttons = get_string('availablebuttons', 'editor_tinymce'); $strdisable = get_string('disable'); $strenable = get_string('enable'); $strname = get_string('name'); $strsettings = get_string('settings'); $struninstall = get_string('uninstallplugin', 'admin'); $strversion = get_string('version'); $subplugins = get_plugin_list('tinymce'); $return = $OUTPUT->heading(get_string('subplugintype_tinymce_plural', 'editor_tinymce'), 3, 'main', true); $return .= $OUTPUT->box_start('generalbox tinymcesubplugins'); $table = new html_table(); $table->head = array($strname, $strbuttons, $strversion, $strenable, $strsettings, $struninstall); $table->align = array('left', 'left', 'center', 'center', 'center', 'center'); $table->data = array(); $table->width = '100%'; // Iterate through subplugins. foreach ($subplugins as $name => $dir) { $namestr = get_string('pluginname', 'tinymce_' . $name); $version = get_config('tinymce_' . $name, 'version'); if ($version === false) { $version = ''; } $plugin = $tinymce->get_plugin($name); $plugininfo = $pluginmanager->get_plugin_info('tinymce_' . $name); // Add hide/show link. if (!$version) { $hideshow = ''; $displayname = html_writer::tag('span', $name, array('class' => 'error')); } else { if ($plugininfo->is_enabled()) { $url = new moodle_url('/lib/editor/tinymce/subplugins.php', array('sesskey' => sesskey(), 'return' => 'settings', 'disable' => $name)); $hideshow = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/hide'), 'class' => 'icon', 'alt' => $strdisable)); $hideshow = html_writer::link($url, $hideshow); $displayname = html_writer::tag('span', $namestr); } else { $url = new moodle_url('/lib/editor/tinymce/subplugins.php', array('sesskey' => sesskey(), 'return' => 'settings', 'enable' => $name)); $hideshow = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/show'), 'class' => 'icon', 'alt' => $strenable)); $hideshow = html_writer::link($url, $hideshow); $displayname = html_writer::tag('span', $namestr, array('class' => 'dimmed_text')); } } if ($PAGE->theme->resolve_image_location('icon', 'tinymce_' . $name)) { $icon = $OUTPUT->pix_icon('icon', '', 'tinymce_' . $name, array('class' => 'smallicon pluginicon')); } else { $icon = $OUTPUT->pix_icon('spacer', '', 'moodle', array('class' => 'smallicon pluginicon noicon')); } $displayname = $icon . ' ' . $displayname; // Add available buttons. $buttons = implode(', ', $plugin->get_buttons()); $buttons = html_writer::tag('span', $buttons, array('class' => 'tinymcebuttons')); // Add settings link. if (!$version) { $settings = ''; } else { if ($url = $plugininfo->get_settings_url()) { $settings = html_writer::link($url, $strsettings); } else { $settings = ''; } } // Add uninstall info. if ($version) { $url = new moodle_url($plugininfo->get_uninstall_url(), array('return' => 'settings')); $uninstall = html_writer::link($url, $struninstall); } else { $uninstall = ''; } // Add a row to the table. $table->data[] = array($displayname, $buttons, $version, $hideshow, $settings, $uninstall); } $return .= html_writer::table($table); $return .= html_writer::tag('p', get_string('tablenosave', 'admin')); $return .= $OUTPUT->box_end(); return highlight($query, $return); }
if (!moodle_needs_upgrading()) { cli_error(get_string('cliupgradenoneed', 'core_admin', $newversion), 0); } // Test environment first. list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE); if (!$envstatus) { $errors = environment_get_errors($environment_results); cli_heading(get_string('environment', 'admin')); foreach ($errors as $error) { list($info, $report) = $error; echo "!! {$info} !!\n{$report}\n\n"; } exit(1); } // Test plugin dependencies. if (!plugin_manager::instance()->all_plugins_ok($version)) { cli_error(get_string('pluginschecktodo', 'admin')); } if ($interactive) { $a = new stdClass(); $a->oldversion = $oldversion; $a->newversion = $newversion; echo cli_heading(get_string('databasechecking', '', $a)) . PHP_EOL; } // make sure we are upgrading to a stable release or display a warning if (isset($maturity)) { if ($maturity < MATURITY_STABLE and !$options['allow-unstable']) { $maturitylevel = get_string('maturity' . $maturity, 'admin'); if ($interactive) { cli_separator(); cli_heading(get_string('notice'));
function mnetadmin_rpc_upgrade($user, $json_response = true) { global $CFG, $USER; // Invoke local user and check his rights if ($auth_response = invoke_local_user((array) $user)) { if ($json_response) { return $auth_response; } else { return json_decode($auth_response); } } // Creating response $response = new stdclass(); $response->status = RPC_SUCCESS; require "{$CFG->dirroot}/version.php"; // defines $version, $release, $branch and $maturity $CFG->target_release = $release; // used during installation and upgrades if ($version < $CFG->version) { $response->status = RPC_FAILURE_RUN; $response->error = get_string('downgradedcore', 'error'); $response->errors[] = get_string('downgradedcore', 'error'); if ($json_response) { return json_encode($response); } else { return $response; } } $oldversion = "{$CFG->release} ({$CFG->version})"; $newversion = "{$release} ({$version})"; if (!moodle_needs_upgrading()) { $response->message = get_string('cliupgradenoneed', 'core_admin', $newversion); if ($json_response) { return json_encode($response); } else { return $response; } } // debug_trace('Remote Upgrade : Environment check'); list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_NEWER); if (!$envstatus) { $response->status = RPC_FAILURE_RUN; $response->error = vmoodle_get_string('environmentissues', 'vmoodleadminset_upgrade'); $response->errors[] = vmoodle_get_string('environmentissues', 'vmoodleadminset_upgrade'); $response->detail = $environment_results; if ($json_response) { return json_encode($response); } else { return $response; } } // Test plugin dependencies. // debug_trace('Remote Upgrade : Plugins check'); $failed = array(); if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) { $response->status = RPC_FAILURE_RUN; $response->error = get_string('pluginschecktodo', 'admin'); $response->errors[] = get_string('pluginschecktodo', 'admin'); if ($json_response) { return json_encode($response); } else { return $response; } } ob_start(); // debug_trace('Remote Upgrade : Upgrade core'); if ($version > $CFG->version) { upgrade_core($version, false); } set_config('release', $release); set_config('branch', $branch); // unconditionally upgrade // debug_trace('Remote Upgrade : Upgrade other'); upgrade_noncore(false); // log in as admin - we need doanything permission when applying defaults // debug_trace('Remote Upgrade : Turning ADMIN '); session_set_user(get_admin()); // apply all default settings, just in case do it twice to fill all defaults // debug_trace('Remote Upgrade : Applying settings '); admin_apply_default_settings(NULL, false); admin_apply_default_settings(NULL, false); ob_end_clean(); $response->message = vmoodle_get_string('upgradecomplete', 'vmoodleadminset_upgrade', $newversion); if ($json_response) { return json_encode($response); } else { return $response; } }
function action($action) { $allplugins = plugin_manager::instance()->get_plugins(); $formatplugins = $allplugins['format']; if (!isset($formatplugins[$this->plugin])) { return get_string('courseformatnotfound', 'error', $this->plugin); } switch ($action) { case 'enable': if (!$formatplugins[$this->plugin]->is_enabled()) { unset_config('disabled', 'format_' . $this->plugin); } break; case 'disable': if ($formatplugins[$this->plugin]->is_enabled()) { if (get_config('moodlecourse', 'format') === $this->plugin) { return get_string('cannotdisableformat', 'error'); } set_config('disabled', 1, 'format_' . $formatname); } break; } return 0; }
/** * Execute the command. * @param $hosts mixed The host where run the command (may be wwwroot or an array). * @throws Command_Exception. */ public function run($hosts) { global $CFG, $USER; // Adding constants. require_once $CFG->dirroot . '/local/vmoodle/rpclib.php'; // Checking capability to run. if (!has_capability('local/vmoodle:execute', \context_system::instance())) { throw new Command_Exception('insuffisantcapabilities'); } // Getting plugin. list($type, $plugin) = explode('/', $this->getParameter('plugin')->getValue()); // Getting the state. $state = $this->getParameter('state')->getValue(); $pm = \plugin_manager::instance(); $plugininfo = $pm->get_plugin_info($plugin); if (empty($plugininfo->type)) { if (empty($plugininfo)) { $plugininfo = new \StdClass(); } $plugininfo->type = $type; } $plugininfo->action = $state; $plugininfos[$plugin] = (array) $plugininfo; // Creating XMLRPC client to change remote configuration. $rpc_client = new \local_vmoodle\XmlRpc_Client(); $rpc_client->set_method('local/vmoodle/plugins/plugins/rpclib.php/mnetadmin_rpc_set_plugins_states'); $rpc_client->add_param($plugininfos, 'array'); // Initializing responses. $responses = array(); // Creating peers. $mnet_hosts = array(); if (!empty($hosts)) { foreach ($hosts as $host => $name) { $mnet_host = new \mnet_peer(); if ($mnet_host->bootstrap($host, null, 'moodle')) { $mnet_hosts[] = $mnet_host; } else { $responses[$host] = (object) array('status' => MNET_FAILURE, 'error' => get_string('couldnotcreateclient', 'local_vmoodle', $host)); } } } // Sending requests. foreach ($mnet_hosts as $mnet_host) { // Sending request. if (!$rpc_client->send($mnet_host)) { $response = new \StdClass(); $response->status = MNET_FAILURE; $response->errors[] = implode('<br/>', $rpc_client->getErrors($mnet_host)); if (debugging()) { echo '<pre>'; var_dump($rpc_client); echo '</pre>'; } } else { $response = json_decode($rpc_client->response); } // Recording response. $responses[$mnet_host->wwwroot] = $response; // Recording plugin descriptors. if ($response->status == RPC_SUCCESS) { $this->plugins[$mnet_host->wwwroot] = @$response->value; } } // Saving results $this->results = $responses + $this->results; }
// 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/>. /** * TinyMCE admin settings * * @package editor_tinymce * @copyright 2009 Petr Skoda (http://skodak.org) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die; $ADMIN->add('editorsettings', new admin_category('editortinymce', $editor->displayname, $editor->is_enabled() === false)); $settings = new admin_settingpage('editorsettingstinymce', new lang_string('settings', 'editor_tinymce')); if ($ADMIN->fulltree) { require_once __DIR__ . '/adminlib.php'; $settings->add(new tiynce_subplugins_settings()); $settings->add(new admin_setting_heading('tinymcegeneralheader', new lang_string('settings'), '')); $default = "fontselect,fontsizeselect,formatselect,|,undo,redo,|,search,replace,|,fullscreen\n\nbold,italic,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,|,cleanup,removeformat,pastetext,pasteword,|,forecolor,backcolor,|,ltr,rtl\n\nbullist,numlist,outdent,indent,|,link,unlink,|,image,nonbreaking,charmap,table,|,code"; $settings->add(new admin_setting_configtextarea('editor_tinymce/customtoolbar', get_string('customtoolbar', 'editor_tinymce'), get_string('customtoolbar_desc', 'editor_tinymce', 'http://www.tinymce.com/wiki.php/Buttons/controls'), $default, PARAM_RAW, 100, 8)); $settings->add(new admin_setting_configtextarea('editor_tinymce/fontselectlist', get_string('fontselectlist', 'editor_tinymce'), '', 'Trebuchet=Trebuchet MS,Verdana,Arial,Helvetica,sans-serif;Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,times new roman,times,serif;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times,serif;Verdana=verdana,arial,helvetica,sans-serif;Impact=impact;Wingdings=wingdings', PARAM_RAW, 100, 8)); $settings->add(new editor_tinymce_json_setting_textarea('editor_tinymce/customconfig', get_string('customconfig', 'editor_tinymce'), get_string('customconfig_desc', 'editor_tinymce'), '', PARAM_RAW, 100, 8)); } $ADMIN->add('editortinymce', $settings); unset($settings); require_once "{$CFG->libdir}/pluginlib.php"; foreach (plugin_manager::instance()->get_plugins_of_type('tinymce') as $plugin) { $plugin->load_settings($ADMIN, 'editortinymce', $hassiteconfig); } // TinyMCE does not have standard settings page. $settings = null;
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once '../config.php'; require_once $CFG->libdir . '/adminlib.php'; require_once $CFG->libdir . '/pluginlib.php'; $action = required_param('action', PARAM_ALPHANUMEXT); $formatname = required_param('format', PARAM_PLUGIN); $confirm = optional_param('confirm', 0, PARAM_BOOL); $syscontext = context_system::instance(); $PAGE->set_url('/admin/courseformats.php'); $PAGE->set_context($syscontext); require_login(); require_capability('moodle/site:config', $syscontext); require_sesskey(); $return = new moodle_url('/admin/settings.php', array('section' => 'manageformats')); $formatplugins = plugin_manager::instance()->get_plugins_of_type('format'); $sortorder = array_flip(array_keys($formatplugins)); if (!isset($formatplugins[$formatname])) { print_error('courseformatnotfound', 'error', $return, $formatname); } switch ($action) { case 'disable': if ($formatplugins[$formatname]->is_enabled()) { if (get_config('moodlecourse', 'format') === $formatname) { print_error('cannotdisableformat', 'error', $return); } set_config('disabled', 1, 'format_' . $formatname); } break; case 'enable': if (!$formatplugins[$formatname]->is_enabled()) {
/** * Get all message providers, validate their plugin existance and * system configuration * * @return mixed $processors array of objects containing information on message processors */ function get_message_providers() { global $CFG, $DB; require_once($CFG->libdir . '/pluginlib.php'); $pluginman = plugin_manager::instance(); $providers = $DB->get_records('message_providers', null, 'name'); // Remove all the providers whose plugins are disabled or don't exist foreach ($providers as $providerid => $provider) { $plugin = $pluginman->get_plugin_info($provider->component); if ($plugin) { if ($plugin->get_status() === plugin_manager::PLUGIN_STATUS_MISSING) { unset($providers[$providerid]); // Plugins does not exist continue; } if ($plugin->is_enabled() === false) { unset($providers[$providerid]); // Plugin disabled continue; } } } return $providers; }
/** * Process the plugin comparison. * @throws Commmand_Exception. */ private function _process() { global $CFG, $DB, $OUTPUT, $STANDARD_PLUGIN_TYPES, $PAGE; $renderer = $PAGE->get_renderer('local_vmoodle'); // Checking if command has been runned. if (!$this->isRunned()) { throw new Command_Exception('commandnotrun'); } // Getting examined plugintype. $plugintype = $this->getParameter('plugintype')->getValue(); // Getting hosts. $hosts = array_keys($this->plugins); $host_labels = get_available_platforms(); // Getting local plugin info. $pm = \plugin_manager::instance(); $localplugins = $pm->get_plugins(); $localtypeplugins = $localplugins[$plugintype]; /* * Creating html report. */ // Creating header. $this->report = '<link href="' . $CFG->wwwroot . '/local/vmoodle/plugins/plugins/theme/styles.css" rel="stylesheet" type="text/css">'; $this->report .= '<h3>' . vmoodle_get_string('compareplugins', 'vmoodleadminset_plugins', $STANDARD_PLUGIN_TYPES[$plugintype]) . '</h3>'; // Adding link to plugin management /* $this->report.= '<center><p>'.$OUTPUT->single_button(new moodle_url($CFG->wwwroot.'/admin/roles/define.php', array('roleid' => $role->id, 'action' => 'edit')), get_string('editrole', 'vmoodleadminset_roles'), 'get').'</p></center>'; */ // Creation form $this->report .= '<form action="' . $CFG->wwwroot . '/local/vmoodle/plugins/plugins/controller.pluginlib.sadmin.php?what=syncplugins" method="post" onsubmit="return validate_syncplugins()">'; $this->report .= '<input id="id_plugin" type="hidden" name="plugin" value=""/>'; $this->report .= '<input id="source_platform" type="hidden" name="source_platform" value=""/>'; // Creating table. $this->report .= '<table id="plugincompare" cellspacing="1" cellpadding="5" class="generaltable boxaligncenter" style="min-width: 75%;">'; $this->report .= '<tbody>'; // Creating header. $this->report .= '<tr><th scope="col" class="header c0" style="vertical-align: bottom; text-align: left;"> </th>'; $col = 1; foreach ($hosts as $host) { $this->report .= '<th id="plug_' . $col . '" scope="col" class="header c' . $col . '" style="vertical-align: bottom; text-align: center;">'; $this->report .= '<label for="platform_' . $col . '"><img src="' . $CFG->wwwroot . '/local/vmoodle/plugins/plugins/draw_platformname.php?caption=' . urlencode($host_labels[$host]) . '" alt="' . $host_labels[$host] . '"/></label><br/>'; $this->report .= '<input id="platform_' . $col . '" type="checkbox" name="platforms[]" value="' . $host . '" disabled="disabled"/></th>'; $col++; } $this->report .= '</tr>'; // Initializing variables. $row = 0; // Creating table data. foreach ($localtypeplugins as $plugin) { $col = 1; $this->report .= '<tr class="r' . $row % 2 . '">'; $this->report .= '<td id="plug_0_' . $row . '" class="cell c0" style="vertical-align: middle; text-align: left;" onClic="setPLugin(' . $col . ',' . $row . ',\'' . $plugin->name . '\',\'' . $host . '\')">'; $this->report .= $plugin->displayname; $this->report .= '</td>'; foreach ($hosts as $host) { $extra_class = false; $title = $plugin->displayname . ' | ' . $host_labels[$host]; if (array_key_exists($host, $this->plugins) && property_exists($this->plugins[$host], $plugin->name)) { $remote_plugin = $this->plugins[$host]->{$plugin->name}; if (is_null($remote_plugin)) { $cell = '<img src="' . $renderer->pix_url('notinstalled', 'vmoodleadminset_plugins') . ' alt="Not installed" title="' . $title . '" />'; } else { if ($remote_plugin->enabled) { $cell = '<img src="' . $renderer->pix_url('enabled', 'vmoodleadminset_plugins') . '" title="' . $title . '" />'; } else { $cell = '<img src="' . $renderer->pix_url('disabled', 'vmoodleadminset_plugins') . '" title="' . $title . '" />'; } if ($localtypeplugins[$plugin->name]->versiondb > $remote_plugin->versiondb) { $cell .= ' <img src="' . $renderer->pix_url('needsupgrade', 'vmoodleadminset_plugins') . '" title="' . $title . '" />'; } if ($remote_plugin->versiondisk > $remote_plugin->versiondb) { $cell .= ' <img src="' . $renderer->pix_url('needslocalupgrade', 'vmoodleadminset_plugins') . '" title="' . $title . '" />'; } } } else { $cell = '<img src="' . $renderer->pix_url('notinstalled', 'vmoodleadminset_plugins') . '" alt="Not installed" title="' . $title . '"/>'; } $this->report .= '<td id="plug_' . $col . '_' . $row . '" class="cell c' . $col . ($extra_class ? ' ' . $extra_class : '') . '" style="vertical-align: middle; text-align: center;" onmouseout="cellOut(' . $col . ',' . $row . ');" onmouseover="cellOver(' . $col . ',' . $row . ');">' . $cell . '</td>'; $col++; } $this->report .= '</tr>'; $row++; } // Closing table $this->report .= '</tboby></table><br/><center><input type="submit" value="' . get_string('synchronize', 'vmoodleadminset_plugins') . '"/><div id="plugincompare_validation_message"></div></center></form><br/><br/>'; }
/** * Provides access to the plugin_manager singleton. * * @return plugin_manmager */ protected function get_plugin_manager() { return plugin_manager::instance(); }
/** * Displays all known plugins and links to manage them * * This default implementation renders all plugins into one big table. * * @param array $plugininfo as returned by {@see plugin_manager::get_plugins()} * @return string HTML code */ public function plugins_control_panel(array $plugininfo) { if (empty($plugininfo)) { return ''; } $pluginman = plugin_manager::instance(); $table = new html_table(); $table->id = 'plugins-control-panel'; $table->head = array(get_string('displayname', 'core_plugin'), get_string('systemname', 'core_plugin'), get_string('source', 'core_plugin'), get_string('version', 'core_plugin'), get_string('availability', 'core_plugin'), get_string('settings', 'core_plugin'), get_string('uninstall', 'core_plugin')); $table->colclasses = array('displayname', 'systemname', 'source', 'version', 'availability', 'settings', 'uninstall'); foreach ($plugininfo as $type => $plugins) { $header = new html_table_cell($pluginman->plugintype_name_plural($type)); $header->header = true; $header->colspan = count($table->head); $header = new html_table_row(array($header)); $header->attributes['class'] = 'plugintypeheader type-' . $type; $table->data[] = $header; if (empty($plugins)) { $msg = new html_table_cell(get_string('noneinstalled', 'core_plugin')); $msg->colspan = count($table->head); $row = new html_table_row(array($msg)); $row->attributes['class'] .= 'msg msg-noneinstalled'; $table->data[] = $row; continue; } foreach ($plugins as $name => $plugin) { $row = new html_table_row(); $row->attributes['class'] = 'type-' . $plugin->type . ' name-' . $plugin->type . '_' . $plugin->name; if ($this->page->theme->resolve_image_location('icon', $plugin->type . '_' . $plugin->name)) { $icon = $this->output->pix_icon('icon', '', $plugin->type . '_' . $plugin->name, array('class' => 'smallicon pluginicon')); } else { $icon = $this->output->pix_icon('spacer', '', 'moodle', array('class' => 'smallicon pluginicon noicon')); } if ($plugin->get_status() === plugin_manager::PLUGIN_STATUS_MISSING) { $msg = html_writer::tag('span', get_string('status_missing', 'core_plugin'), array('class' => 'notifyproblem')); $row->attributes['class'] .= ' missingfromdisk'; } else { $msg = ''; } $displayname = $icon . ' ' . $plugin->displayname . ' ' . $msg; $displayname = new html_table_cell($displayname); $systemname = new html_table_cell($plugin->type . '_' . $plugin->name); if ($plugin->is_standard()) { $row->attributes['class'] .= ' standard'; $source = new html_table_cell(get_string('sourcestd', 'core_plugin')); } else { $row->attributes['class'] .= ' extension'; $source = new html_table_cell(get_string('sourceext', 'core_plugin')); } $version = new html_table_cell($plugin->versiondb); $isenabled = $plugin->is_enabled(); if (is_null($isenabled)) { $availability = new html_table_cell(''); } else { if ($isenabled) { $row->attributes['class'] .= ' enabled'; $icon = $this->output->pix_icon('i/hide', get_string('pluginenabled', 'core_plugin')); $availability = new html_table_cell($icon . ' ' . get_string('pluginenabled', 'core_plugin')); } else { $row->attributes['class'] .= ' disabled'; $icon = $this->output->pix_icon('i/show', get_string('plugindisabled', 'core_plugin')); $availability = new html_table_cell($icon . ' ' . get_string('plugindisabled', 'core_plugin')); } } $settingsurl = $plugin->get_settings_url(); if (is_null($settingsurl)) { $settings = new html_table_cell(''); } else { $settings = html_writer::link($settingsurl, get_string('settings', 'core_plugin')); $settings = new html_table_cell($settings); } $uninstallurl = $plugin->get_uninstall_url(); if (is_null($uninstallurl)) { $uninstall = new html_table_cell(''); } else { $uninstall = html_writer::link($uninstallurl, get_string('uninstall', 'core_plugin')); $uninstall = new html_table_cell($uninstall); } $row->cells = array($displayname, $systemname, $source, $version, $availability, $settings, $uninstall); $table->data[] = $row; } } return html_writer::table($table); }
// means core upgrade or installation was not already done if (!$confirmplugins) { $strplugincheck = get_string('plugincheck'); $PAGE->set_pagelayout('maintenance'); $PAGE->set_popup_notification_allowed(false); $PAGE->navbar->add($strplugincheck); $PAGE->set_title($strplugincheck); $PAGE->set_heading($strplugincheck); $PAGE->set_cacheable(false); if ($fetchupdates) { // no sesskey support guaranteed here available_update_checker::instance()->fetch(); redirect($PAGE->url); } $output = $PAGE->get_renderer('core', 'admin'); echo $output->upgrade_plugin_check_page(plugin_manager::instance(), available_update_checker::instance(), $version, $showallplugins, new moodle_url($PAGE->url), new moodle_url('/admin/index.php', array('confirmplugincheck' => 1))); die; } } // install/upgrade all plugins and other parts upgrade_noncore(true); } // If this is the first install, indicate that this site is fully configured // except the admin password if (during_initial_install()) { set_config('rolesactive', 1); // after this, during_initial_install will return false. set_config('adminsetuppending', 1); // we need this redirect to setup proper session upgrade_finished("index.php?sessionstarted=1&lang={$CFG->lang}"); }
/** * Adds and upgrades the selected plugins * * @param array $ingredients * @param string $path Path to the ingredient type file system * @param SimpleXMLElement $xml * @return array Problems during the ingredients deployment */ public function deploy_ingredients($ingredients, $path, SimpleXMLElement $xml) { // Using the $ingredients array keys to maintain coherence with the main deployment method $problems = array(); $pluginman = plugin_manager::instance(); $plugintypespaths = get_plugin_types(); $this->get_flavour_info($xml); foreach ($ingredients as $selection) { // [0] => ingredienttype, [1] => ingredientname $ingredientdata = explode('/', $selection); $type = $ingredientdata[0]; $ingredient = $ingredientdata[1]; if (empty($this->branches[$type]->branches[$ingredient])) { $problems[$selection]['pluginnotfound'] = $selection; continue; } $ingredientdata = $this->branches[$type]->branches[$ingredient]; // Adapter to the restrictions array if (!empty($ingredientdata->restrictions)) { $problems[$selection] = $ingredientdata->restrictions; continue; } if (empty($xml->{$type}) || empty($xml->{$type}->{$ingredient})) { $problems[$selection]['pluginnotfound'] = $selection; continue; } // Deploy then $ingredientpath = $plugintypespaths[$type] . '/' . $ingredient; // Remove old dir if present if (file_exists($ingredientpath)) { // Report if the old plugin directory can't be removed if (!$this->unlink($ingredientpath)) { $problems[$selection]['plugincantremove'] = $selection; continue; } } // Copy the new contents where the flavour says $tmppath = $path . '/' . $xml->{$type}->{$ingredient}->path; if (!$this->copy($tmppath, $ingredientpath)) { debugging('From : ' . $tmppath . ' To: ' . $ingredientpath); $problems[$selection]['plugincopyerror'] = $selection; } } // Execute the moodle upgrade process try { foreach ($plugintypespaths as $type => $location) { upgrade_plugins($type, 'flavours_print_upgrade_void', 'flavours_print_upgrade_void', false); } } catch (Exception $ex) { abort_all_db_transactions(); $info = get_exception_info($ex); upgrade_log(UPGRADE_LOG_ERROR, $ex->module, 'Exception: ' . get_class($ex), $info->message, $info->backtrace); } return $problems; }