当前位置: 首页>>代码示例>>PHP>>正文


PHP plugin_manager::instance方法代码示例

本文整理汇总了PHP中plugin_manager::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP plugin_manager::instance方法的具体用法?PHP plugin_manager::instance怎么用?PHP plugin_manager::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在plugin_manager的用法示例。


在下文中一共展示了plugin_manager::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: definition

 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();
 }
开发者ID:netspotau,项目名称:moodle-coursereport_engagement,代码行数:31,代码来源:edit_form.php

示例2: mnetadmin_rpc_get_plugins_info

/**
 * 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;
    }
}
开发者ID:gabrielrosset,项目名称:moodle-local_vmoodle,代码行数:55,代码来源:rpclib.php

示例3: coursereport_engagement_get_course_summary

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;
}
开发者ID:netspotau,项目名称:moodle-coursereport_engagement,代码行数:40,代码来源:lib.php

示例4: cron_notifications

 /**
  * 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;
 }
开发者ID:Burick,项目名称:moodle,代码行数:58,代码来源:pluginlib.php

示例5: unsatisfied_dependencies_page

 /**
  * 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;
 }
开发者ID:nicusX,项目名称:moodle,代码行数:20,代码来源:renderer.php

示例6: required_param

 * @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':
开发者ID:Burick,项目名称:moodle,代码行数:31,代码来源:courseformats.php

示例7: get_plugin_types_menu

 /**
  * 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;
 }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:16,代码来源:installer.php

示例8: dirname

// 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 <david@moodle.com>
 * @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());
开发者ID:nutanrajmalanai,项目名称:moodle,代码行数:29,代码来源:plugins.php

示例9: output_html

 /**
  * 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 .= '&nbsp;' . 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);
 }
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:68,代码来源:adminlib.php

示例10: cron_notifications

    /**
     * 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;
    }
开发者ID:nutanrajmalanai,项目名称:moodle,代码行数:52,代码来源:pluginlib.php

示例11: dirname

 * @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;
    }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:31,代码来源:qbehaviours.php

示例12: output_html

 /**
  * 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);
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:91,代码来源:adminlib.php

示例13: cli_error

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'));
开发者ID:nmicha,项目名称:moodle,代码行数:31,代码来源:upgrade.php

示例14: mnetadmin_rpc_upgrade

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;
    }
}
开发者ID:gabrielrosset,项目名称:moodle-local_vmoodle,代码行数:89,代码来源:rpclib.php

示例15: action

 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;
 }
开发者ID:OctaveBabel,项目名称:moodle-itop,代码行数:24,代码来源:pluginscontrolslib.php


注:本文中的plugin_manager::instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。