mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
backupdata folder is no longer displayed in list of directories when setting up Directory Resource - partially related to MDL-6280 ; and some other typo fixes; get_directory_list() no accepts also array of exluded files
This commit is contained in:
parent
746a04c500
commit
7f5bc80b78
@ -3781,7 +3781,7 @@ function check_potential_filename($destination,$filename,$files) {
|
||||
* all subdirectories, relative to the given rootdir
|
||||
* @todo Finish documenting this function. Add examples of $excludefile usage.
|
||||
*/
|
||||
function get_directory_list($rootdir, $excludefile='', $descend=true, $getdirs=false, $getfiles=true) {
|
||||
function get_directory_list($rootdir, $excludefiles='', $descend=true, $getdirs=false, $getfiles=true) {
|
||||
|
||||
$dirs = array();
|
||||
|
||||
@ -3797,9 +3797,13 @@ function get_directory_list($rootdir, $excludefile='', $descend=true, $getdirs=f
|
||||
return $dirs;
|
||||
}
|
||||
|
||||
if (!is_array($excludefiles)) {
|
||||
$excludefiles = array($excludefiles);
|
||||
}
|
||||
|
||||
while (false !== ($file = readdir($dir))) {
|
||||
$firstchar = substr($file, 0, 1);
|
||||
if ($firstchar == '.' or $file == 'CVS' or $file == $excludefile) {
|
||||
if ($firstchar == '.' or $file == 'CVS' or in_array($file, $excludefiles)) {
|
||||
continue;
|
||||
}
|
||||
$fullfile = $rootdir .'/'. $file;
|
||||
@ -3808,7 +3812,7 @@ function get_directory_list($rootdir, $excludefile='', $descend=true, $getdirs=f
|
||||
$dirs[] = $file;
|
||||
}
|
||||
if ($descend) {
|
||||
$subdirs = get_directory_list($fullfile, $excludefile, $descend, $getdirs, $getfiles);
|
||||
$subdirs = get_directory_list($fullfile, $excludefiles, $descend, $getdirs, $getfiles);
|
||||
foreach ($subdirs as $subdir) {
|
||||
$dirs[] = $file .'/'. $subdir;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ function display() {
|
||||
error("The value for 'subdir' contains illegal characters!");
|
||||
}
|
||||
$relativepath = "$relativepath$subdir";
|
||||
if (stripos($relativepath, 'backupdata') !== FALSE) {
|
||||
if (stripos($relativepath, 'backupdata') !== FALSE or stripos($relativepath, $CFG->moddata) !== FALSE) {
|
||||
error("Access not allowed!");
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ function display() {
|
||||
"", "", true, update_module_button($cm->id, $course->id, $this->strresource),
|
||||
navmenu($course, $cm));
|
||||
|
||||
if (has_capabilities('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
if (has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
echo "<div align=\"right\"><img src=\"$CFG->pixpath/i/files.gif\" height=\"16\" width=\"16\" alt=\"\" /> ".
|
||||
"<a href=\"$CFG->wwwroot/files/index.php?id={$course->id}&wdir=/{$resource->reference}$subdir\">".
|
||||
get_string("editfiles")."...</a></div>";
|
||||
@ -80,7 +80,7 @@ function display() {
|
||||
print_spacer(10,10);
|
||||
}
|
||||
|
||||
$files = get_directory_list("$CFG->dataroot/$relativepath", 'moddata', false, true, true);
|
||||
$files = get_directory_list("$CFG->dataroot/$relativepath", array($CFG->moddata, 'backupdata'), false, true, true);
|
||||
|
||||
|
||||
if (!$files) {
|
||||
@ -102,9 +102,7 @@ function display() {
|
||||
"<th align=\"right\" class=\"header date\">$strmodified</th>".
|
||||
"</tr>";
|
||||
foreach ($files as $file) {
|
||||
if ($file == 'backupdata') {
|
||||
continue;
|
||||
} else if (is_dir("$CFG->dataroot/$relativepath/$file")) { // Must be a directory
|
||||
if (is_dir("$CFG->dataroot/$relativepath/$file")) { // Must be a directory
|
||||
$icon = "folder.gif";
|
||||
$relativeurl = "/view.php?blah";
|
||||
$filesize = display_size(get_directory_size("$CFG->dataroot/$relativepath/$file"));
|
||||
@ -157,7 +155,7 @@ function setup($form) {
|
||||
|
||||
parent::setup($form);
|
||||
|
||||
$rawdirs = get_directory_list("$CFG->dataroot/{$this->course->id}", 'moddata', true, true, false);
|
||||
$rawdirs = get_directory_list("$CFG->dataroot/{$this->course->id}", array($CFG->moddata, 'backupdata'), true, true, false);
|
||||
$dirs = array();
|
||||
foreach ($rawdirs as $rawdir) {
|
||||
$dirs[$rawdir] = $rawdir;
|
||||
|
@ -78,7 +78,7 @@
|
||||
/// Security Constraints (sesskey and isteacheredit)
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
} else if (!has_capabilities('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $courseid))) {
|
||||
} else if (!has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $courseid))) {
|
||||
error(get_string('onlyeditingteachers', 'error'));
|
||||
}
|
||||
|
||||
|
@ -334,7 +334,7 @@ class resource_ims extends resource_base {
|
||||
|
||||
/// If there are any error, show it instead of the resource page
|
||||
if ($errorcode) {
|
||||
if (!has_capabilities('moodle/course:activityvisibility', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
if (!has_capability('moodle/course:activityvisibility', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
/// Resource not available page
|
||||
$errortext = get_string('resourcenotavailable','resource');
|
||||
} else {
|
||||
|
@ -5,8 +5,8 @@
|
||||
// This fragment is called by /admin/index.php
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$module->version = 2006091201;
|
||||
$module->requires = 2006080900; // Requires this Moodle version
|
||||
$module->version = 2006091700;
|
||||
$module->requires = 2006091700; // Requires this Moodle version
|
||||
$module->cron = 0;
|
||||
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user