MDL-12531, make the new member value available to all the affected plugins, thanks...
[moodle-linuxchix.git] / admin / delete.php
blob1498dbfcaa29d7cb7800404e10c2ae6fc3f00448
1 <?PHP //$Id$
3 // Deletes the moodledata directory, COMPLETELY!!
4 // BE VERY CAREFUL USING THIS!
6 require_once('../config.php');
7 require_once($CFG->libdir.'/adminlib.php');
9 admin_externalpage_setup('purgemoodledata');
11 require_login();
13 $sure = optional_param('sure', 0, PARAM_BOOL);
14 $reallysure = optional_param('reallysure', 0, PARAM_BOOL);
16 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID));
18 $deletedir = $CFG->dataroot; // The directory to delete!
20 admin_externalpage_print_header();
21 print_heading('Purge moodledata');
23 if (empty($sure)) {
24 $optionsyes = array('sure'=>'yes', 'sesskey'=>sesskey());
25 notice_yesno ('Are you completely sure you want to delete everything inside the directory '. $deletedir .' ?',
26 'delete.php', 'index.php', $optionsyes, NULL, 'post', 'get');
27 admin_externalpage_print_footer();
28 exit;
31 if (!data_submitted() or empty($reallysure)) {
32 $optionsyes = array('sure'=>'yes', 'sesskey'=>sesskey(), 'reallysure'=>'yes');
33 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) ?',
34 'delete.php', 'index.php', $optionsyes, NULL, 'post', 'get');
35 admin_externalpage_print_footer();
36 exit;
39 if (!confirm_sesskey()) {
40 error('This script was called wrongly');
43 /// OK, here goes ...
45 delete_subdirectories($deletedir);
47 echo '<h1 align="center">Done!</h1>';
48 print_continue($CFG->wwwroot);
49 admin_externalpage_print_footer();
50 exit;
53 function delete_subdirectories($rootdir) {
55 $dir = opendir($rootdir);
57 while (false !== ($file = readdir($dir))) {
58 if ($file != '.' and $file != '..') {
59 $fullfile = $rootdir .'/'. $file;
60 if (filetype($fullfile) == 'dir') {
61 delete_subdirectories($fullfile);
62 echo 'Deleting '. $fullfile .' ... ';
63 if (rmdir($fullfile)) {
64 echo 'Done.<br />';
65 } else {
66 echo 'FAILED.<br />';
68 } else {
69 echo 'Deleting '. $fullfile .' ... ';
70 if (unlink($fullfile)) {
71 echo 'Done.<br />';
72 } else {
73 echo 'FAILED.<br />';
78 closedir($dir);