* 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();
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;
$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;
}
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!");
}
"", "", 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>";
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) {
"<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"));
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;
/// 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'));
}
/// 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 {
// 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;
?>