本文整理汇总了PHP中upgrade_noncore函数的典型用法代码示例。如果您正苦于以下问题:PHP upgrade_noncore函数的具体用法?PHP upgrade_noncore怎么用?PHP upgrade_noncore使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了upgrade_noncore函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
global $CFG;
require_once $CFG->libdir . '/adminlib.php';
// various admin-only functions
require_once $CFG->libdir . '/upgradelib.php';
// general upgrade/install related functions
require_once $CFG->libdir . '/environmentlib.php';
require_once $CFG->libdir . '/pluginlib.php';
require_once $CFG->dirroot . '/course/lib.php';
//some variables you may want to use
//$this->cwd - the directory where moosh command was executed
//$this->mooshDir - moosh installation directory
//$this->expandedOptions - commandline provided options, merged with defaults
//$this->topDir - top Moodle directory
//$this->arguments[0] - first argument passed
//$options = $this->expandedOptions;
$split = explode('_', $this->arguments[0], 2);
uninstall_plugin($split[0], $split[1]);
upgrade_noncore(true);
/* if verbose mode was requested, show some more information/debug messages
if($this->verbose) {
echo "Say what you're doing now";
}
*/
}
开发者ID:dariogs,项目名称:moosh,代码行数:26,代码来源:ModuleReinstall.php
示例2: execute
public function execute()
{
global $CFG;
require_once $CFG->libdir . '/adminlib.php';
// various admin-only functions
require_once $CFG->libdir . '/upgradelib.php';
// general upgrade/install related functions
require_once $CFG->libdir . '/environmentlib.php';
require_once $CFG->dirroot . '/course/lib.php';
$pluginname = $this->arguments[0];
$moodleversion = $this->arguments[1];
$pluginversion = $this->arguments[2];
$pluginsfile = home_dir() . '/.moosh/plugins.json';
$stat = @stat($pluginsfile);
if (!$stat || time() - $stat['mtime'] > 60 * 60 * 24 || !$stat['size']) {
die("plugins.json file not found or too old. Run moosh plugin-list to download newest plugins.json file\n");
}
$pluginsdata = file_get_contents($pluginsfile);
$decodeddata = json_decode($pluginsdata);
$downloadurl = NULL;
$downloadurl = $this->get_plugin_url($decodeddata, $pluginname, $moodleversion, $pluginversion);
if (!$downloadurl) {
die("Couldn't find {$pluginname} {$moodleversion}\n");
}
$split = explode('_', $this->arguments[0], 2);
$tempdir = home_dir() . '/.moosh/moodleplugins/';
if (!file_exists($tempdir)) {
mkdir($tempdir);
}
if (!fopen($tempdir . $split[1] . ".zip", 'w')) {
echo "Failed to save plugin.\n";
return;
}
try {
file_put_contents($tempdir . $split[1] . ".zip", file_get_contents($downloadurl));
} catch (Exception $e) {
echo "Failed to download plugin. " . $e . "\n";
return;
}
try {
shell_exec("unzip " . $tempdir . $split[1] . ".zip -d " . home_dir() . "/.moosh/moodleplugins/");
shell_exec("cp -r " . $tempdir . $split[1] . "/ " . $this->get_install_path($split[0], $moodleversion));
} catch (Exception $e) {
echo "Failed to unzip plugin. " . $e . "\n";
return;
}
echo "Installing {$pluginname} {$moodleversion}\n";
upgrade_noncore(true);
echo "Done\n";
}
开发者ID:sergiohermes,项目名称:moosh,代码行数:50,代码来源:PluginInstall.php
示例3: execute
public function execute()
{
global $CFG;
require_once $CFG->libdir . '/adminlib.php';
// various admin-only functions
require_once $CFG->libdir . '/upgradelib.php';
// general upgrade/install related functions
require_once $CFG->libdir . '/environmentlib.php';
require_once $CFG->dirroot . '/course/lib.php';
$this->init();
$pluginname = $this->arguments[0];
$pluginversion = $this->arguments[1];
$downloadurl = $this->get_plugin_url($pluginname, $pluginversion);
$split = explode('_', $pluginname, 2);
$type = $split[0];
$component = $split[1];
$tempdir = home_dir() . '/.moosh/moodleplugins/';
$downloadedfile = $tempdir . $component . ".zip";
if (!file_exists($tempdir)) {
mkdir($tempdir);
}
if (!fopen($downloadedfile, 'w')) {
echo "Failed to save plugin - check permissions on {$tempdir}.\n";
return;
}
try {
file_put_contents($downloadedfile, file_get_contents($downloadurl));
} catch (Exception $e) {
die("Failed to download plugin from {$downloadurl}. " . $e . "\n");
}
$installpath = $this->get_install_path($type);
$targetpath = $installpath . DIRECTORY_SEPARATOR . $component;
if (file_exists($targetpath)) {
if ($this->expandedOptions['delete']) {
echo "Removing previously installed {$pluginname} from {$targetpath}\n";
run_external_command("rm -rf {$targetpath}");
} else {
die("Something already exists at {$targetpath} - please remove it and try again, or run with the -d option.\n");
}
}
run_external_command("unzip {$downloadedfile} -d {$installpath}");
run_external_command("rm {$downloadedfile}");
echo "Installing\n";
echo "\tname: {$pluginname}\n";
echo "\tversion: {$pluginversion}\n";
upgrade_noncore(true);
echo "Done\n";
}
开发者ID:tmuras,项目名称:moosh,代码行数:48,代码来源:PluginInstall.php
示例4: redirect
$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}");
}
// make sure admin user is created - this is the last step because we need
// session to be working properly in order to edit admin account
if (!empty($CFG->adminsetuppending)) {
$sessionstarted = optional_param('sessionstarted', 0, PARAM_BOOL);
if (!$sessionstarted) {
开发者ID:numbas,项目名称:moodle,代码行数:31,代码来源:index.php
示例5: install_cli_database
/**
* Install Moodle DB,
* config.php must exist, there must not be any tables in db yet.
*
* @param array $options adminpass is mandatory
* @param bool $interactive
* @return void
*/
function install_cli_database(array $options, $interactive)
{
global $CFG, $DB;
require_once $CFG->libdir . '/environmentlib.php';
require_once $CFG->libdir . '/upgradelib.php';
// show as much debug as possible
@error_reporting(E_ALL | E_STRICT);
@ini_set('display_errors', '1');
$CFG->debug = E_ALL | E_STRICT;
$CFG->debugdisplay = true;
$CFG->version = '';
$CFG->release = '';
$CFG->branch = '';
$version = null;
$release = null;
$branch = null;
// read $version and $release
require $CFG->dirroot . '/version.php';
if ($DB->get_tables()) {
cli_error(get_string('clitablesexist', 'install'));
}
if (empty($options['adminpass'])) {
cli_error('Missing required admin password');
}
// 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);
}
if (!$DB->setup_is_unicodedb()) {
if (!$DB->change_db_encoding()) {
// If could not convert successfully, throw error, and prevent installation
cli_error(get_string('unicoderequired', 'admin'));
}
}
if ($interactive) {
cli_separator();
cli_heading(get_string('databasesetup'));
}
// install core
install_core($version, true);
set_config('release', $release);
set_config('branch', $branch);
if (PHPUNIT_TEST) {
// mark as test database as soon as possible
set_config('phpunittest', 'na');
}
// install all plugins types, local, etc.
upgrade_noncore(true);
// set up admin user password
$DB->set_field('user', 'password', hash_internal_user_password($options['adminpass']), array('username' => 'admin'));
// rename admin username if needed
if (isset($options['adminuser']) and $options['adminuser'] !== 'admin' and $options['adminuser'] !== 'guest') {
$DB->set_field('user', 'username', $options['adminuser'], array('username' => 'admin'));
}
// indicate that this site is fully configured
set_config('rolesactive', 1);
upgrade_finished();
// log in as admin - we need do anything when applying defaults
$admins = get_admins();
$admin = reset($admins);
session_set_user($admin);
// apply all default settings, do it twice to fill all defaults - some settings depend on other setting
admin_apply_default_settings(NULL, true);
admin_apply_default_settings(NULL, true);
set_config('registerauth', '');
// set the site name
if (isset($options['shortname']) and $options['shortname'] !== '') {
$DB->set_field('course', 'shortname', $options['shortname'], array('format' => 'site'));
}
if (isset($options['fullname']) and $options['fullname'] !== '') {
$DB->set_field('course', 'fullname', $options['fullname'], array('format' => 'site'));
}
}
开发者ID:JP-Git,项目名称:moodle,代码行数:88,代码来源:installlib.php
示例6: 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
示例7: execute
public function execute()
{
global $CFG, $DB;
$CFG->debugdisplay = 0;
require_once $CFG->libdir . '/adminlib.php';
// various admin-only functions
require_once $CFG->libdir . '/upgradelib.php';
// general upgrade/install related functions
require_once $CFG->libdir . '/filelib.php';
$pluginname = $this->arguments[0];
if ($pluginname) {
$pluginman = core_plugin_manager::instance();
$pluginfo = $pluginman->get_plugin_info($pluginname);
// Make sure we know the plugin.
if (is_null($pluginfo)) {
echo 'core_plugin_manager::get_plugin_info() returned null for the plugin to be uninstalled' . PHP_EOL;
if ($CFG->debugdisplay) {
throw new moodle_exception('err_uninstalling_unknown_plugin', 'core_plugin', '', array('plugin' => $pluginname), 'core_plugin_manager::get_plugin_info() returned null for the plugin to be uninstalled');
}
die;
}
$pluginname = $pluginman->plugin_name($pluginfo->component);
echo "Uninstalling {$pluginname} plugin.\n";
if (!$pluginman->can_uninstall_plugin($pluginfo->component)) {
// Remove it form DB. if it is not installed properly.
if ($DB->get_record('config_plugins', array('plugin' => $pluginfo->component))) {
$ok = $DB->delete_records('config_plugins', array('plugin' => $pluginfo->component));
echo 'Plugin not installed properly, deleting redundant plugin records from mdl_config_plugins' . PHP_EOL;
upgrade_noncore(true);
die;
}
echo 'core_plugin_manager::can_uninstall_plugin() returned false' . PHP_EOL;
if ($CFG->debugdisplay) {
throw new moodle_exception('err_cannot_uninstall_plugin', 'core_plugin', '', array('plugin' => $pluginfo->component), 'core_plugin_manager::can_uninstall_plugin() returned false');
}
die;
}
// Make sure it is not installed.
if (is_null($pluginfo->versiondb)) {
echo 'core_plugin_manager::get_plugin_info() returned not-null versiondb for the plugin to be deleted' . PHP_EOL;
if ($CFG->debugdisplay) {
throw new moodle_exception('err_removing_installed_plugin', 'core_plugin', '', array('plugin' => $pluginfo->component, 'versiondb' => $pluginfo->versiondb), 'core_plugin_manager::get_plugin_info() returned not-null versiondb for the plugin to be deleted');
}
die;
}
if (empty($pluginfo->rootdir)) {
$pluginfo->rootdir = $pluginfo->typerootdir . '/' . $pluginfo->name;
//$CFG->dirroot.'/'.$pluginfo->type;
}
if (file_exists($pluginfo->rootdir)) {
// Make sure the folder is removable.
if (!$pluginman->is_plugin_folder_removable($pluginfo->component)) {
echo 'plugin root folder is not removable as expected ' . PHP_EOL;
echo ' Use CLI "sudo chmod -R +w ' . $pluginfo->rootdir . '" to enable write (delete) permission on that folder' . PHP_EOL;
if ($CFG->debugdisplay) {
throw new moodle_exception('err_removing_unremovable_folder', 'core_plugin', '', array('plugin' => $pluginfo->component, 'rootdir' => $pluginfo->rootdir), 'plugin root folder is not removable as expected' . PHP_EOL . ' Use CLI "sudo chmod -R +w ' . $pluginfo->rootdir . '" to enable write (delete) permission on that folder');
}
die;
}
} else {
echo 'Plugin folder (' . $pluginfo->rootdir . ') does not exist, skipping...' . PHP_EOL;
}
// Make sure the folder is within Moodle installation tree.
if (strpos($pluginfo->rootdir, $CFG->dirroot) !== 0) {
echo 'plugin root folder not in the moodle dirroot' . PHP_EOL;
if ($CFG->debugdisplay) {
throw new moodle_exception('err_unexpected_plugin_rootdir', 'core_plugin', '', array('plugin' => $pluginfo->component, 'rootdir' => $pluginfo->rootdir, 'dirroot' => $CFG->dirroot), 'plugin root folder not in the moodle dirroot');
}
die;
}
echo 'Uninstalling plugins...' . PHP_EOL;
$progress = new progress_trace_buffer(new text_progress_trace(), false);
$pluginman->uninstall_plugin($pluginfo->component, $progress);
$progress->finished();
// So long, and thanks for all the bugs.
if ($CFG->debugdisplay) {
print_r($pluginfo);
}
echo "Deleting folder: {$pluginfo->rootdir} (if exists)" . PHP_EOL;
fulldelete($pluginfo->rootdir);
// Reset op code caches.
if (function_exists('opcache_reset')) {
opcache_reset();
}
echo "Upgrade noncore." . PHP_EOL;
upgrade_noncore(true);
echo "Uninstalled :-) So long, and thanks for all the bugs." . PHP_EOL;
}
}
开发者ID:dariogs,项目名称:moosh,代码行数:89,代码来源:PluginUnInstall.php
注:本文中的upgrade_noncore函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论