Skip to content

Commit

Permalink
major cleanup of unsupported and legacy external pages in admin/; cre…
Browse files Browse the repository at this point in the history
…ated new hidden unsupported category; some other minor fixes and changes
  • Loading branch information
skodak committed Sep 25, 2006
1 parent 6caa705 commit c9a49ce
Show file tree
Hide file tree
Showing 14 changed files with 149 additions and 117 deletions.
19 changes: 16 additions & 3 deletions admin/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
// BE VERY CAREFUL USING THIS!

require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');
$adminroot = admin_get_root();
admin_externalpage_setup('purgemoodledata', $adminroot);

require_login();

Expand All @@ -14,13 +17,22 @@

$deletedir = $CFG->dataroot; // The directory to delete!

admin_externalpage_print_header($adminroot);
print_heading('Purge moodledata');

if (empty($sure)) {
notice_yesno ('Are you completely sure you want to delete everything inside the directory '. $deletedir .' ?', 'delete.php?sure=yes&sesskey='.sesskey(), 'index.php');
$optionsyes = array('sure'=>'yes', 'sesskey'=>sesskey());
notice_yesno ('Are you completely sure you want to delete everything inside the directory '. $deletedir .' ?',
'delete.php', 'index.php', $optionsyes, NULL, 'post', 'get');
admin_externalpage_print_footer($adminroot);
exit;
}

if (empty($reallysure)) {
notice_yesno ('Are you REALLY REALLY completely sure you want to delete everything inside the directory '. $deletedir .' (this includes all user images, and any other course files that have been created) ?', 'delete.php?sure=yes&reallysure=yes&sesskey='.sesskey(), 'index.php');
if (!data_submitted() or empty($reallysure)) {
$optionsyes = array('sure'=>'yes', 'sesskey'=>sesskey(), 'reallysure'=>'yes');
notice_yesno ('Are you REALLY REALLY completely sure you want to delete everything inside the directory '. $deletedir .' (this includes all user images, and any other course files that have been created) ?',
'delete.php', 'index.php', $optionsyes, NULL, 'post', 'get');
admin_externalpage_print_footer($adminroot);
exit;
}

Expand All @@ -34,6 +46,7 @@

echo '<h1 align="center">Done!</h1>';
print_continue($CFG->wwwroot);
admin_externalpage_print_footer($adminroot);
exit;


Expand Down
15 changes: 7 additions & 8 deletions admin/health.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@
$extraws = '';
while (true) {
$extraws .= ob_get_contents();
if (!@ob_end_clean()) { //
if (!@ob_end_clean()) {
break;
}
}

require_once($CFG->libdir.'/adminlib.php');
$adminroot = admin_get_root();
admin_externalpage_setup('healthcenter', $adminroot);

define('SEVERITY_NOTICE', 'notice');
define('SEVERITY_ANNOYANCE', 'annoyance');
define('SEVERITY_SIGNIFICANT', 'significant');
Expand All @@ -23,13 +27,8 @@
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID));

$site = get_site();
$stradmin = get_string('administration');
$strhealthcenter = get_string('healthcenter');
$strmisc = get_string('miscellaneous');

print_header($site->shortname.': '.$strhealthcenter, $site->fullname,
'<a href="index.php">'.$stradmin.'</a> -> <a href="misc.php">'.$strmisc.'</a> ->'.
$strhealthcenter);
admin_externalpage_print_header($adminroot);

echo <<<STYLES
<style type="text/css">
Expand Down Expand Up @@ -101,7 +100,7 @@
}


print_footer();
admin_externalpage_print_footer($adminroot);


function health_find_problems() {
Expand Down
25 changes: 19 additions & 6 deletions admin/innodb.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,43 @@
<?php

require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');
$adminroot = admin_get_root();
admin_externalpage_setup('toinodb', $adminroot);

$confirm = optional_param('confirm', 0, PARAM_BOOL);

require_login();

require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID));

print_header("Convert all tables from MYISAM to InnoDB", "Convert all tables from MYISAM to InnoDB",
"Convert all tables from MYISAM to InnoDB");
admin_externalpage_print_header($adminroot);
print_heading('Convert all MySQL tables from MYISAM to InnoDB');

if ($CFG->dbtype != 'mysql') {
notice('This function is for MySQL databases only!', 'index.php');
}

if ($confirm and confirm_sesskey()) {
if (data_submitted() and $confirm and confirm_sesskey()) {

print_heading("Please be patient and wait for this to complete...");
notify('Please be patient and wait for this to complete...', 'notifysuccess');

if ($tables = $db->MetaTables()) {
$db->debug = true;
foreach ($tables as $table) {
execute_sql("ALTER TABLE $table TYPE=INNODB; ");
}
$db->debug = false;
}
notify('... done.', 'notifysuccess');
print_continue('index.php');
admin_externalpage_print_footer($adminroot);

} else {
notice_yesno("Are you sure you want convert all your tables to the InnoDB format?",
"innodb.php?confirm=1&sesskey=".sesskey(), "index.php");
$optionsyes = array('confirm'=>'1', 'sesskey'=>sesskey());
notice_yesno('Are you sure you want convert all your tables to the InnoDB format?',
'innodb.php', 'index.php', $optionsyes, NULL, 'post', 'get');
admin_externalpage_print_footer($adminroot);
}

?>
13 changes: 7 additions & 6 deletions admin/oacleanup.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
if (!isset($CFG)) {

require('../config.php');
require_once($CFG->libdir.'/adminlib.php');
$adminroot = admin_get_root();
admin_externalpage_setup('oacleanup', $adminroot);

require_login();

require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID));

print_header_simple('Online Assignment Cleanup','Online Assignment Cleanup', 'Admin');

admin_externalpage_print_header($adminroot);
online_assignment_cleanup(true);

print_footer();
admin_externalpage_print_footer($adminroot);

}

Expand Down Expand Up @@ -72,7 +73,7 @@ function online_assignment_cleanup($output=false) {
/// cycle through the instances
foreach ($instances as $instance) {
/// is this an instance of an online assignment
$sql = "SELECT a.id
$sql = "SELECT a.id
FROM {$CFG->prefix}course_modules cm,
{$CFG->prefix}assignment a
WHERE cm.id = '$instance' AND
Expand Down Expand Up @@ -137,7 +138,7 @@ function online_assignment_cleanup($output=false) {

set_field('course_sections', 'sequence', $section->sequence, 'id', $section->id);


if ($output) echo 'Online Assignment (instance '.$instance.') moved from section '.$section->id.': to section '.$newsection.'<br />';

}
Expand Down
30 changes: 24 additions & 6 deletions admin/replace.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
/// Search and replace strings throughout all texts in the whole database

require_once('../config.php');
require_once($CFG->dirroot.'/course/lib.php');
require_once($CFG->libdir.'/adminlib.php');
$adminroot = admin_get_root();
admin_externalpage_setup('replace', $adminroot);

$search = optional_param('search', '', PARAM_RAW);
$replace = optional_param('replace', '', PARAM_RAW);
Expand All @@ -11,21 +15,24 @@
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID));

###################################################################
print_header('Search and replace throughout the whole database', 'Replace text within the whole database');
admin_externalpage_print_header($adminroot);

print_heading('Search and replace text throughout the whole database');

if (!$search or !$replace or !confirm_sesskey()) { /// Print a form

if (!data_submitted() or !$search or !$replace or !confirm_sesskey()) { /// Print a form

print_simple_box_start('center');
echo '<div align="center">';
echo '<form action="replace.php">';
echo '<form action="replace.php" method="post">';
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'">';
echo 'Search whole database for: <input type="text" name="search"><br />';
echo 'Replace with this string: <input type="text" name="replace"><br /></br />';
echo '<input type="submit" value="Yes, do it now"><br />';
echo '</form>';
echo '</div>';
print_simple_box_end();
admin_externalpage_print_footer($adminroot);
die;
}

Expand All @@ -35,6 +42,13 @@
}

print_simple_box_start('center');

/// Turn off time limits, sometimes upgrades can be slow.

@set_time_limit(0);
@ob_implicit_flush(true);
while(@ob_end_flush());

foreach ($tables as $table) {
if (in_array($table, array($CFG->prefix.'config'))) { // Don't process these
continue;
Expand All @@ -50,11 +64,15 @@
}
}

/// Clear course cache which might be corrupted now
execute_sql("UPDATE ".$CFG->prefix."course SET modinfo = '' WHERE id <> ".SITEID);

print_simple_box_end();

/// Rebuild course cache which might be incorrect now
notify('Rebuilding course cache...');
rebuild_course_cache();
notify('...finished');

print_continue('index.php');

admin_externalpage_print_footer($adminroot);

?>
26 changes: 0 additions & 26 deletions admin/report.php

This file was deleted.

4 changes: 1 addition & 3 deletions admin/report/courseoverview/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
$strreports = get_string('reports');
$strcourseoverview = get_string('courseoverview');

$strnav = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/index.php">'.get_string('administration').'</a> -> <a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/report.php">'.$strreports.'</a> -> '.$strcourseoverview;

$reportoptions = stats_get_report_options($course->id,STATS_MODE_RANKED);

$tableprefix = $CFG->prefix.'stats_';
Expand Down Expand Up @@ -66,7 +64,7 @@

if (!empty($report) && !empty($time)) {
$param = stats_get_parameters($time,$report,SITEID,STATS_MODE_RANKED);

if (!empty($param->sql)) {
$sql = $param->sql ." LIMIT ".$numcourses;
} else {
Expand Down
2 changes: 1 addition & 1 deletion admin/report/stats/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

$adminroot = admin_get_root();

admin_externalpage_setup('reportcourseoverview', $adminroot);
admin_externalpage_setup('reportstats', $adminroot);

admin_externalpage_print_header($adminroot);

Expand Down
6 changes: 5 additions & 1 deletion admin/settings/misc.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
// * Miscellaneous settings (still to be sorted)

$ADMIN->add('misc', new admin_externalpage('stickyblocks', get_string('stickyblocks', 'admin'), "$CFG->wwwroot/$CFG->admin/stickyblocks.php"));

$ADMIN->add('misc', new admin_externalpage('xmldbeditor', get_string('xmldbeditor'), "$CFG->wwwroot/$CFG->admin/xmldb/"));

// hidden scripts linked from elsewhere
$ADMIN->add('misc', new admin_externalpage('oacleanup', 'Online Assignment Cleanup', $CFG->wwwroot.'/'.$CFG->admin.'/oacleanup.php', 'moodle/site:config', true));
$ADMIN->add('misc', new admin_externalpage('upgradeforumread', 'Upgrade forum', $CFG->wwwroot.'/'.$CFG->admin.'/upgradeforumread.php', 'moodle/site:config', true));
$ADMIN->add('misc', new admin_externalpage('upgradelogs', 'Upgrade logs', $CFG->wwwroot.'/'.$CFG->admin.'/upgradelogs.php', 'moodle/site:config', true));

?>
4 changes: 3 additions & 1 deletion admin/settings/top.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@

$ADMIN->add('root', new admin_category('reports', get_string('reports')));
foreach(get_list_of_plugins('admin/report') as $plugin) {
$ADMIN->add('reports', new admin_externalpage('report' . $plugin, get_string($plugin, 'admin'), "$CFG->wwwroot/$CFG->admin/report/$plugin/index.php"));
$ADMIN->add('reports', new admin_externalpage('report'.$plugin, get_string($plugin, 'admin'), "$CFG->wwwroot/$CFG->admin/report/$plugin/index.php"));
}

$ADMIN->add('root', new admin_category('misc', get_string('miscellaneous')));

// hidden unsupported category
$ADMIN->add('root', new admin_category('unsupported', get_string('unsupported', 'admin'), true));

?>
11 changes: 11 additions & 0 deletions admin/settings/unsupported.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php // $Id$

// This file defines settingpages and externalpages in the "unsupported" hidden category, use wisely!

$ADMIN->add('unsupported', new admin_externalpage('purgemoodledata', 'Purge moodledata', $CFG->wwwroot.'/'.$CFG->admin.'/delete.php'));
$ADMIN->add('unsupported', new admin_externalpage('healthcenter', get_string('healthcenter'), $CFG->wwwroot.'/'.$CFG->admin.'/health.php'));
$ADMIN->add('unsupported', new admin_externalpage('toinodb', 'Convert to InnoDB', $CFG->wwwroot.'/'.$CFG->admin.'/innodb.php'));
$ADMIN->add('unsupported', new admin_externalpage('replace', 'Search and replace', $CFG->wwwroot.'/'.$CFG->admin.'/replace.php'));


?>
Loading

0 comments on commit c9a49ce

Please sign in to comment.