Skip to content

Commit

Permalink
Merge branch 'master' into install_master
Browse files Browse the repository at this point in the history
  • Loading branch information
AMOS bot committed Sep 28, 2013
2 parents 441972d + d45e65c commit 7800935
Show file tree
Hide file tree
Showing 2,932 changed files with 122,879 additions and 94,916 deletions.
7 changes: 5 additions & 2 deletions admin/auth.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
require_once('../config.php'); require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php'); require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/tablelib.php'); require_once($CFG->libdir.'/tablelib.php');
require_once($CFG->libdir.'/pluginlib.php');


require_login(); require_login();
require_capability('moodle/site:config', context_system::instance()); require_capability('moodle/site:config', context_system::instance());
Expand Down Expand Up @@ -51,7 +52,8 @@
if ($auth == $CFG->registerauth) { if ($auth == $CFG->registerauth) {
set_config('registerauth', ''); set_config('registerauth', '');
} }
session_gc(); // remove stale sessions \core\session\manager::gc(); // Remove stale sessions.
plugin_manager::reset_caches();
break; break;


case 'enable': case 'enable':
Expand All @@ -61,7 +63,8 @@
$authsenabled = array_unique($authsenabled); $authsenabled = array_unique($authsenabled);
set_config('auth', implode(',', $authsenabled)); set_config('auth', implode(',', $authsenabled));
} }
session_gc(); // remove stale sessions \core\session\manager::gc(); // Remove stale sessions.
plugin_manager::reset_caches();
break; break;


case 'down': case 'down':
Expand Down
76 changes: 0 additions & 76 deletions admin/block.php

This file was deleted.

15 changes: 8 additions & 7 deletions admin/blocks.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require_once('../config.php'); require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php'); require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/tablelib.php'); require_once($CFG->libdir.'/tablelib.php');
require_once($CFG->libdir.'/pluginlib.php');


admin_externalpage_setup('manageblocks'); admin_externalpage_setup('manageblocks');


Expand All @@ -29,16 +30,14 @@
$strprotect = get_string('blockprotect', 'admin'); $strprotect = get_string('blockprotect', 'admin');
$strunprotect = get_string('blockunprotect', 'admin'); $strunprotect = get_string('blockunprotect', 'admin');


// Purge all caches related to blocks administration.
cache::make('core', 'plugininfo_block')->purge();

/// If data submitted, then process and store. /// If data submitted, then process and store.


if (!empty($hide) && confirm_sesskey()) { if (!empty($hide) && confirm_sesskey()) {
if (!$block = $DB->get_record('block', array('id'=>$hide))) { if (!$block = $DB->get_record('block', array('id'=>$hide))) {
print_error('blockdoesnotexist', 'error'); print_error('blockdoesnotexist', 'error');
} }
$DB->set_field('block', 'visible', '0', array('id'=>$block->id)); // Hide block $DB->set_field('block', 'visible', '0', array('id'=>$block->id)); // Hide block
plugin_manager::reset_caches();
admin_get_root(true, false); // settings not required - only pages admin_get_root(true, false); // settings not required - only pages
} }


Expand All @@ -47,6 +46,7 @@
print_error('blockdoesnotexist', 'error'); print_error('blockdoesnotexist', 'error');
} }
$DB->set_field('block', 'visible', '1', array('id'=>$block->id)); // Show block $DB->set_field('block', 'visible', '1', array('id'=>$block->id)); // Show block
plugin_manager::reset_caches();
admin_get_root(true, false); // settings not required - only pages admin_get_root(true, false); // settings not required - only pages
} }


Expand Down Expand Up @@ -120,12 +120,13 @@
foreach ($blocknames as $blockid=>$strblockname) { foreach ($blocknames as $blockid=>$strblockname) {
$block = $blocks[$blockid]; $block = $blocks[$blockid];
$blockname = $block->name; $blockname = $block->name;
$dbversion = get_config('block_'.$block->name, 'version');


if (!file_exists("$CFG->dirroot/blocks/$blockname/block_$blockname.php")) { if (!file_exists("$CFG->dirroot/blocks/$blockname/block_$blockname.php")) {
$blockobject = false; $blockobject = false;
$strblockname = '<span class="notifyproblem">'.$strblockname.' ('.get_string('missingfromdisk').')</span>'; $strblockname = '<span class="notifyproblem">'.$strblockname.' ('.get_string('missingfromdisk').')</span>';
$plugin = new stdClass(); $plugin = new stdClass();
$plugin->version = $block->version; $plugin->version = $dbversion;


} else { } else {
$plugin = new stdClass(); $plugin = new stdClass();
Expand Down Expand Up @@ -186,10 +187,10 @@
$class = ' class="dimmed_text"'; // Leading space required! $class = ' class="dimmed_text"'; // Leading space required!
} }


if ($block->version == $plugin->version) { if ($dbversion == $plugin->version) {
$version = $block->version; $version = $dbversion;
} else { } else {
$version = "$block->version ($plugin->version)"; $version = "$dbversion ($plugin->version)";
} }


if (!$blockobject) { if (!$blockobject) {
Expand Down
29 changes: 29 additions & 0 deletions admin/cli/install.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
} }


// set up configuration // set up configuration
global $CFG;
$CFG = new stdClass(); $CFG = new stdClass();
$CFG->lang = 'en'; $CFG->lang = 'en';
$CFG->dirroot = dirname(dirname(dirname(__FILE__))); $CFG->dirroot = dirname(dirname(dirname(__FILE__)));
Expand Down Expand Up @@ -189,9 +190,37 @@
require_once($CFG->libdir.'/componentlib.class.php'); require_once($CFG->libdir.'/componentlib.class.php');
require_once($CFG->dirroot.'/cache/lib.php'); require_once($CFG->dirroot.'/cache/lib.php');


// Register our classloader, in theory somebody might want to replace it to load other hacked core classes.
// Required because the database checks below lead to session interaction which is going to lead us to requiring autoloaded classes.
if (defined('COMPONENT_CLASSLOADER')) {
spl_autoload_register(COMPONENT_CLASSLOADER);
} else {
spl_autoload_register('core_component::classloader');
}

require($CFG->dirroot.'/version.php'); require($CFG->dirroot.'/version.php');
$CFG->target_release = $release; $CFG->target_release = $release;


$_SESSION = array();
$_SESSION['SESSION'] = new stdClass();
$_SESSION['SESSION']->lang = $CFG->lang;
$_SESSION['USER'] = new stdClass();
$_SESSION['USER']->id = 0;
$_SESSION['USER']->mnethostid = 1;

global $SESSION;
global $USER;
$SESSION = &$_SESSION['SESSION'];
$USER = &$_SESSION['USER'];

global $COURSE;
$COURSE = new stdClass();
$COURSE->id = 1;

global $SITE;
$SITE = $COURSE;
define('SITEID', 1);

//Database types //Database types
$databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'native'), $databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'native'),
'mariadb'=> moodle_database::get_driver_instance('mariadb', 'native'), 'mariadb'=> moodle_database::get_driver_instance('mariadb', 'native'),
Expand Down
2 changes: 1 addition & 1 deletion admin/cli/upgrade.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
upgrade_noncore(true); upgrade_noncore(true);


// log in as admin - we need doanything permission when applying defaults // log in as admin - we need doanything permission when applying defaults
session_set_user(get_admin()); \core\session\manager::set_user(get_admin());


// apply all default settings, just in case do it twice to fill all defaults // apply all default settings, just in case do it twice to fill all defaults
admin_apply_default_settings(NULL, false); admin_apply_default_settings(NULL, false);
Expand Down
2 changes: 2 additions & 0 deletions admin/courseformats.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@
print_error('cannotdisableformat', 'error', $return); print_error('cannotdisableformat', 'error', $return);
} }
set_config('disabled', 1, 'format_'. $formatname); set_config('disabled', 1, 'format_'. $formatname);
plugin_manager::reset_caches();
} }
break; break;
case 'enable': case 'enable':
if (!$formatplugins[$formatname]->is_enabled()) { if (!$formatplugins[$formatname]->is_enabled()) {
unset_config('disabled', 'format_'. $formatname); unset_config('disabled', 'format_'. $formatname);
plugin_manager::reset_caches();
} }
break; break;
case 'up': case 'up':
Expand Down
2 changes: 1 addition & 1 deletion admin/cron.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
require_once($CFG->libdir.'/cronlib.php'); require_once($CFG->libdir.'/cronlib.php');


// extra safety // extra safety
session_get_instance()->write_close(); \core\session\manager::write_close();


// check if execution allowed // check if execution allowed
if (!empty($CFG->cronclionly)) { if (!empty($CFG->cronclionly)) {
Expand Down
2 changes: 2 additions & 0 deletions admin/editors.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
require_once('../config.php'); require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php'); require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/tablelib.php'); require_once($CFG->libdir.'/tablelib.php');
require_once($CFG->libdir.'/pluginlib.php');


$action = required_param('action', PARAM_ALPHANUMEXT); $action = required_param('action', PARAM_ALPHANUMEXT);
$editor = required_param('editor', PARAM_PLUGIN); $editor = required_param('editor', PARAM_PLUGIN);
Expand Down Expand Up @@ -93,6 +94,7 @@
} }


set_config('texteditors', implode(',', $active_editors)); set_config('texteditors', implode(',', $active_editors));
plugin_manager::reset_caches();


if ($return) { if ($return) {
redirect ($returnurl); redirect ($returnurl);
Expand Down
3 changes: 3 additions & 0 deletions admin/enrol.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@


require_once('../config.php'); require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php'); require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/pluginlib.php');


$action = required_param('action', PARAM_ALPHANUMEXT); $action = required_param('action', PARAM_ALPHANUMEXT);
$enrol = required_param('enrol', PARAM_PLUGIN); $enrol = required_param('enrol', PARAM_PLUGIN);
Expand All @@ -50,6 +51,7 @@
case 'disable': case 'disable':
unset($enabled[$enrol]); unset($enabled[$enrol]);
set_config('enrol_plugins_enabled', implode(',', array_keys($enabled))); set_config('enrol_plugins_enabled', implode(',', array_keys($enabled)));
plugin_manager::reset_caches();
$syscontext->mark_dirty(); // resets all enrol caches $syscontext->mark_dirty(); // resets all enrol caches
break; break;


Expand All @@ -60,6 +62,7 @@
$enabled = array_keys($enabled); $enabled = array_keys($enabled);
$enabled[] = $enrol; $enabled[] = $enrol;
set_config('enrol_plugins_enabled', implode(',', $enabled)); set_config('enrol_plugins_enabled', implode(',', $enabled));
plugin_manager::reset_caches();
$syscontext->mark_dirty(); // resets all enrol caches $syscontext->mark_dirty(); // resets all enrol caches
break; break;


Expand Down
42 changes: 6 additions & 36 deletions admin/filters.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@


require_once(dirname(__FILE__) . '/../config.php'); require_once(dirname(__FILE__) . '/../config.php');
require_once($CFG->libdir . '/adminlib.php'); require_once($CFG->libdir . '/adminlib.php');
require_once($CFG->libdir . '/pluginlib.php');


$action = optional_param('action', '', PARAM_ALPHANUMEXT); $action = optional_param('action', '', PARAM_ALPHANUMEXT);
$filterpath = optional_param('filterpath', '', PARAM_SAFEDIR); $filterpath = optional_param('filterpath', '', PARAM_SAFEDIR);
Expand All @@ -44,9 +45,6 @@
$returnurl = "$CFG->wwwroot/$CFG->admin/filters.php"; $returnurl = "$CFG->wwwroot/$CFG->admin/filters.php";
admin_externalpage_setup('managefilters'); admin_externalpage_setup('managefilters');


// Purge all caches related to filter administration.
cache::make('core', 'plugininfo_filter')->purge();

$filters = filter_get_global_states(); $filters = filter_get_global_states();


// In case any new filters have been installed, but not put in the table yet. // In case any new filters have been installed, but not put in the table yet.
Expand All @@ -59,7 +57,7 @@
/// Process actions ============================================================ /// Process actions ============================================================


if ($action) { if ($action) {
if (!isset($filters[$filterpath]) && !isset($newfilters[$filterpath])) { if ($action !== 'delete' and !isset($filters[$filterpath]) and !isset($newfilters[$filterpath])) {
throw new moodle_exception('filternotinstalled', 'error', $returnurl, $filterpath); throw new moodle_exception('filternotinstalled', 'error', $returnurl, $filterpath);
} }


Expand Down Expand Up @@ -97,38 +95,6 @@
filter_set_global_state($filterpath, $filters[$filterpath]->active, -1); filter_set_global_state($filterpath, $filters[$filterpath]->active, -1);
} }
break; break;

case 'delete':
// If not yet confirmed, display a confirmation message.
if (!optional_param('confirm', '', PARAM_BOOL)) {
$filtername = filter_get_name($filterpath);

$title = get_string('deletefilterareyousure', 'admin', $filtername);
echo $OUTPUT->header();
echo $OUTPUT->heading($title);

$linkcontinue = new moodle_url($returnurl, array('action' => 'delete', 'filterpath' => $filterpath, 'confirm' => 1));
$formcancel = new single_button(new moodle_url($returnurl), get_string('no'), 'get');
echo $OUTPUT->confirm(get_string('deletefilterareyousuremessage', 'admin', $filtername), $linkcontinue, $formcancel);
echo $OUTPUT->footer();
exit;
}

// Do the deletion.
$title = get_string('deletingfilter', 'admin', $filterpath);
echo $OUTPUT->header();
echo $OUTPUT->heading($title);

// Delete all data for this plugin.
filter_delete_all_for_filter($filterpath);

$a = new stdClass;
$a->filter = $filterpath;
$a->directory = "$CFG->dirroot/filter/$filterpath";
echo $OUTPUT->box(get_string('deletefilterfiles', 'admin', $a), 'generalbox', 'notice');
echo $OUTPUT->continue_button($returnurl);
echo $OUTPUT->footer();
exit;
} }


// Add any missing filters to the DB table. // Add any missing filters to the DB table.
Expand All @@ -138,6 +104,7 @@


// Reset caches and return // Reset caches and return
if ($action) { if ($action) {
plugin_manager::reset_caches();
reset_text_filters_cache(); reset_text_filters_cache();
redirect($returnurl); redirect($returnurl);
} }
Expand Down Expand Up @@ -212,6 +179,9 @@
/// Display helper functions =================================================== /// Display helper functions ===================================================


function filters_action_url($filterpath, $action) { function filters_action_url($filterpath, $action) {
if ($action === 'delete') {
return new moodle_url('/admin/plugins.php', array('sesskey'=>sesskey(), 'uninstall'=>'filter_'.$filterpath));
}
return new moodle_url('/admin/filters.php', array('sesskey'=>sesskey(), 'filterpath'=>$filterpath, 'action'=>$action)); return new moodle_url('/admin/filters.php', array('sesskey'=>sesskey(), 'filterpath'=>$filterpath, 'action'=>$action));
} }


Expand Down
Loading

0 comments on commit 7800935

Please sign in to comment.