<?php
- // Allows the admin to configure blocks (hide/show, delete and configure)
+ // Allows the admin to configure blocks (hide/show, uninstall and configure)
require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');
$confirm = optional_param('confirm', 0, PARAM_BOOL);
$hide = optional_param('hide', 0, PARAM_INT);
$show = optional_param('show', 0, PARAM_INT);
- $delete = optional_param('delete', 0, PARAM_INT);
$unprotect = optional_param('unprotect', 0, PARAM_INT);
$protect = optional_param('protect', 0, PARAM_INT);
/// Print headings
$strmanageblocks = get_string('manageblocks');
- $strdelete = get_string('delete');
+ $struninstall = get_string('uninstallplugin', 'core_admin');
$strversion = get_string('version');
$strhide = get_string('hide');
$strshow = get_string('show');
admin_get_root(true, false); // settings not required - only pages
}
- if (!empty($delete) && confirm_sesskey()) {
- echo $OUTPUT->header();
- echo $OUTPUT->heading($strmanageblocks);
-
- if (!$block = blocks_get_record($delete)) {
- print_error('blockdoesnotexist', 'error');
- }
-
- if (get_string_manager()->string_exists('pluginname', "block_$block->name")) {
- $strblockname = get_string('pluginname', "block_$block->name");
- } else {
- $strblockname = $block->name;
- }
-
- if (!$confirm) {
- echo $OUTPUT->confirm(get_string('blockdeleteconfirm', '', $strblockname), 'blocks.php?delete='.$block->id.'&confirm=1', 'blocks.php');
- echo $OUTPUT->footer();
- exit;
-
- } else {
- uninstall_plugin('block', $block->name);
-
- $a = new stdClass();
- $a->block = $strblockname;
- $a->directory = $CFG->dirroot.'/blocks/'.$block->name;
- notice(get_string('blockdeletefiles', '', $a), 'blocks.php');
- }
- }
-
echo $OUTPUT->header();
echo $OUTPUT->heading($strmanageblocks);
$table = new flexible_table('admin-blocks-compatible');
- $table->define_columns(array('name', 'instances', 'version', 'hideshow', 'undeletable', 'delete', 'settings'));
- $table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strprotecthdr, $strdelete, $strsettings));
+ $table->define_columns(array('name', 'instances', 'version', 'hideshow', 'undeletable', 'uninstall', 'settings'));
+ $table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strprotecthdr, $struninstall, $strsettings));
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/blocks.php');
$table->set_attribute('class', 'admintable blockstable generaltable');
$table->set_attribute('id', 'compatibleblockstable');
}
}
- $delete = '<a href="blocks.php?delete='.$blockid.'&sesskey='.sesskey().'">'.$strdelete.'</a>';
+ if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('block_'.$blockname)) {
+ $uninstall = html_writer::link($uninstallurl, $struninstall);
+ } else {
+ $uninstall = '';
+ }
$settings = ''; // By default, no configuration
if ($blockobject and $blockobject->has_config()) {
'<span'.$class.'>'.$version.'</span>',
$visible,
$undeletable,
- $delete,
+ $uninstall,
$settings
);
$table->add_data($row);
$table = new flexible_table('admin-blocks-incompatible');
- $table->define_columns(array('block', 'delete'));
- $table->define_headers(array($strname, $strdelete));
+ $table->define_columns(array('block', 'uninstall'));
+ $table->define_headers(array($strname, $struninstall));
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/blocks.php');
$table->set_attribute('class', 'incompatibleblockstable generaltable');
$table->setup();
foreach ($incompatible as $block) {
+ if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('block_'.$block->name)) {
+ $uninstall = html_writer::link($uninstallurl, $struninstall);
+ } else {
+ $uninstall = '';
+ }
$table->add_data(array(
$block->name,
- '<a href="blocks.php?delete='.$block->id.'&sesskey='.sesskey().'">'.$strdelete.'</a>',
+ $uninstall,
));
}
$table->print_html();
--- /dev/null
+<?php
+// 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/>.
+
+/**
+ * This hack is intended for clustered sites that do not want
+ * to use shared cachedir for component cache.
+ *
+ * This file needs to be called after any change in PHP files in dataroot,
+ * that is before upgrade and install.
+ *
+ * @package core
+ * @copyright 2013 Petr Skoda (skodak) {@link http://skodak.org}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+
+define('CLI_SCRIPT', true);
+define('ABORT_AFTER_CONFIG', true); // We need just the values from config.php.
+define('CACHE_DISABLE_ALL', true); // This prevents reading of existing caches.
+define('IGNORE_COMPONENT_CACHE', true);
+
+require(__DIR__.'/../../config.php');
+require_once($CFG->libdir.'/clilib.php');
+
+// Now get cli options.
+list($options, $unrecognized) = cli_get_params(
+ array(
+ 'file' => false,
+ 'rebuild' => false,
+ 'print' => false,
+ 'help' => false
+ ),
+ array(
+ 'h' => 'help'
+ )
+);
+
+if ($unrecognized) {
+ $unrecognized = implode("\n ", $unrecognized);
+ cli_error(get_string('cliunknowoption', 'admin', $unrecognized), 2);
+}
+
+if (!$options['rebuild'] and !$options['file'] and !$options['print']) {
+ $help =
+"Create alternative component cache file
+
+Options:
+-h, --help Print out this help
+--rebuild Rebuild \$CFG->alternative_component_cache file
+--file=filepath Save component cache to file
+--print Print component cache file content
+
+Example:
+\$ php admin/cli/rebuild_alternative_component_cache.php --rebuild
+";
+
+ echo $help;
+ exit(0);
+}
+
+error_reporting(E_ALL | E_STRICT);
+ini_set('display_errors', 1);
+
+$content = core_component::get_cache_content();
+
+if ($options['print']) {
+ echo $content;
+ exit(0);
+}
+
+if ($options['rebuild']) {
+ if (empty($CFG->alternative_component_cache)) {
+ fwrite(STDERR, 'config.php does not contain $CFG->alternative_component_cache setting');
+ fwrite(STDERR, "\n");
+ exit(2);
+ }
+ $target = $CFG->alternative_component_cache;
+} else {
+ $target = $options['file'];
+}
+
+if (!$target) {
+ fwrite(STDERR, "Invalid target file $target");
+ fwrite(STDERR, "\n");
+ exit(1);
+}
+
+$bytes = file_put_contents($target, $content);
+
+if (!$bytes) {
+ fwrite(STDERR, "Error writing to $target");
+ fwrite(STDERR, "\n");
+ exit(1);
+}
+
+// Success.
+echo "File $target was updated\n";
+exit(0);
exit(1);
}
+// Force OPcache reset if used, we do not want any stale caches
+// when preparing test environment.
+if (function_exists('opcache_reset')) {
+ opcache_reset();
+}
+
$help =
"Command line Moodle installer, creates config.php and initializes database.
Please note you must execute this script with the same uid as apache
define('PHPUNIT_TEST', false);
+define('IGNORE_COMPONENT_CACHE', true);
+
// Check that PHP is of a sufficient version
if (version_compare(phpversion(), "5.3.3") < 0) {
$phpversion = phpversion();
ini_set('include_path', $CFG->libdir.'/pear' . PATH_SEPARATOR . ini_get('include_path'));
require_once($CFG->libdir.'/classes/component.php');
+require_once($CFG->libdir.'/classes/text.php');
require_once($CFG->libdir.'/installlib.php');
require_once($CFG->libdir.'/clilib.php');
require_once($CFG->libdir.'/setuplib.php');
-require_once($CFG->libdir.'/textlib.class.php');
require_once($CFG->libdir.'/weblib.php');
require_once($CFG->libdir.'/dmllib.php');
require_once($CFG->libdir.'/moodlelib.php');
//Database types
$databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'native'),
+ 'mariadb'=> moodle_database::get_driver_instance('mariadb', 'native'),
'pgsql' => moodle_database::get_driver_instance('pgsql', 'native'),
'oci' => moodle_database::get_driver_instance('oci', 'native'),
'sqlsrv' => moodle_database::get_driver_instance('sqlsrv', 'native'), // MS SQL*Server PHP driver
}
}
$CFG->directorypermissions = $chmod;
+$CFG->filepermissions = ($CFG->directorypermissions & 0666);
+$CFG->umaskpermissions = (($CFG->directorypermissions & 0777) ^ 0777);
//We need wwwroot before we test dataroot
$wwwroot = clean_param($options['wwwroot'], PARAM_URL);
cli_error(get_string('pathserrcreatedataroot', 'install', $a));
}
}
-$CFG->tempdir = $CFG->dataroot.'/temp';
-$CFG->cachedir = $CFG->dataroot.'/cache';
+$CFG->tempdir = $CFG->dataroot.'/temp';
+$CFG->cachedir = $CFG->dataroot.'/cache';
+$CFG->localcachedir = $CFG->dataroot.'/localcache';
// download required lang packs
if ($CFG->lang !== 'en') {
exit(1);
}
+// Force OPcache reset if used, we do not want any stale caches
+// when preparing test environment.
+if (function_exists('opcache_reset')) {
+ opcache_reset();
+}
+
$help =
"Advanced command line Moodle database installer.
Please note you must execute this script with the same uid as apache.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+// Force OPcache reset if used, we do not want any stale caches
+// when detecting if upgrade necessary or when running upgrade.
+if (function_exists('opcache_reset') and !isset($_SERVER['REMOTE_ADDR'])) {
+ opcache_reset();
+}
+
define('CLI_SCRIPT', true);
define('CACHE_DISABLE_ALL', true);
$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');
set_config('format_plugins_sortorder', implode(',', $seq));
}
break;
- case 'uninstall':
- echo $OUTPUT->header();
- echo $OUTPUT->heading(get_string('courseformats', 'moodle'));
-
- $coursecount = $DB->count_records('course', array('format' => $formatname));
- if ($coursecount) {
- // Check that default format is set. It will be used to convert courses
- // using this format
- $defaultformat = get_config('moodlecourse', 'format');
- $defaultformat = $formatplugins[get_config('moodlecourse', 'format')];
- if (!$defaultformat) {
- echo $OUTPUT->error_text(get_string('defaultformatnotset', 'admin'));
- echo $OUTPUT->footer();
- exit;
- }
- }
-
- $format = $formatplugins[$formatname];
- $deleteurl = $format->get_uninstall_url();
- if (!$deleteurl) {
- // somebody was trying to cheat and type non-existing link
- echo $OUTPUT->error_text(get_string('cannotuninstall', 'admin', $format->displayname));
- echo $OUTPUT->footer();
- exit;
- }
-
- if (!$confirm) {
- if ($coursecount) {
- $message = get_string('formatuninstallwithcourses', 'admin',
- (object)array('count' => $coursecount, 'format' => $format->displayname,
- 'defaultformat' => $defaultformat->displayname));
- } else {
- $message = get_string('formatuninstallconfirm', 'admin', $format->displayname);
- }
- $deleteurl->param('confirm', 1);
- echo $OUTPUT->confirm($message, $deleteurl, $return);
- } else {
- $a = new stdClass();
- $a->plugin = $format->displayname;
- $a->directory = $format->rootdir;
- uninstall_plugin('format', $formatname);
- echo $OUTPUT->notification(get_string('formatuninstalled', 'admin', $a), 'notifysuccess');
- echo $OUTPUT->continue_button($return);
- }
-
- echo $OUTPUT->footer();
- exit;
}
redirect($return);
}
break;
- case 'uninstall':
- if ($editor === 'textarea') {
- redirect($returnurl);
- }
- if (get_string_manager()->string_exists('pluginname', 'editor_'.$editor)) {
- $strplugin = get_string('pluginname', 'editor_'.$editor);
- } else {
- $strplugin = $editor;
- }
-
- $PAGE->set_title($strplugin);
- echo $OUTPUT->header();
-
- if (!$confirm) {
- echo $OUTPUT->heading(get_string('editors', 'core_editor'));
-
- $deleteurl = new moodle_url('/admin/editors.php', array('action'=>'uninstall', 'editor'=>$editor, 'sesskey'=>sesskey(), 'confirm'=>1));
-
- echo $OUTPUT->confirm(get_string('editordeleteconfirm', 'core_editor', $strplugin),
- $deleteurl, $returnurl);
- echo $OUTPUT->footer();
- die();
-
- } else {
- // Remove from enabled list.
- $key = array_search($editor, $active_editors);
- unset($active_editors[$key]);
- set_config('texteditors', implode(',', $active_editors));
-
- // Delete everything!!
- uninstall_plugin('editor', $editor);
-
- $a = new stdClass();
- $a->name = $strplugin;
- $a->directory = "$CFG->dirroot/lib/editor/$editor";
- echo $OUTPUT->notification(get_string('plugindeletefiles', '', $a), 'notifysuccess');
- echo $OUTPUT->continue_button($returnurl);
- echo $OUTPUT->footer();
- die();
- }
-
default:
break;
}
$action = required_param('action', PARAM_ALPHANUMEXT);
$enrol = required_param('enrol', PARAM_PLUGIN);
$confirm = optional_param('confirm', 0, PARAM_BOOL);
-$migrate = optional_param('migrate', 0, PARAM_BOOL);
$PAGE->set_url('/admin/enrol.php');
$PAGE->set_context(context_system::instance());
set_config('enrol_plugins_enabled', implode(',', $enabled));
break;
- case 'uninstall':
+ case 'migrate':
if (get_string_manager()->string_exists('pluginname', 'enrol_'.$enrol)) {
$strplugin = get_string('pluginname', 'enrol_'.$enrol);
} else {