function repository_make_upload_directory($directory, $shownotices = true) { global $CFG; $currdir = $directory; if (!repository_file_exists($currdir)) { if (!mkdir($currdir, $CFG->directorypermissions)) { if ($shownotices) { echo '<div class="notifyproblem" align="center">ERROR: Could not find or create a directory (' . $currdir . ')</div>' . "<br />\n"; } return false; } } return $currdir; }
/** * This function checks a potential filename against what's on the filesystem already and what's been saved already. * @param string $destination Destination directory (to check existing files against) * @param string $nametocheck The filename to be compared. * @param object $file The current file from $files we're processing. * return boolean */ function check_before_renaming($destination, $nametocheck, $file) { # HU, CS Repository plugin support if (!repository_file_exists($destination . '/' . $nametocheck)) { return true; } if ($this->config->deleteothers) { foreach ($this->files as $tocheck) { // if we're deleting files anyway, it's not THIS file and we care about it and it has the same name and has already been saved.. if ($file['tmp_name'] != $tocheck['tmp_name'] && $tocheck['clear'] && $nametocheck == $tocheck['name'] && $tocheck['saved']) { $collision = true; } } if (!$collision) { return true; } } return false; }
echo " <input type=\"hidden\" name=\"id\" value=\"{$id}\" />"; echo " <input type=\"hidden\" name=\"wdir\" value=\"{$wdir}\" />"; echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />"; echo " <input type=\"submit\" value=\"{$strcancel}\" />"; echo "</div>"; echo "</form>"; echo "</td></tr></table>"; } html_footer(); break; case "makedir": if ($name != '' and confirm_sesskey()) { html_header($course, $wdir); $name = clean_filename($name); # HU, CS Repository plugin support if (repository_file_exists("{$basedir}{$wdir}/{$name}")) { echo "Error: {$name} already exists!"; # HU, CS Repository plugin support } else { if (!repository_make_upload_directory($scheme . '://' . $course->id . $wdir . '/' . $name)) { echo "Error: could not create {$name}"; } } displaydir($wdir); } else { $strcreate = get_string("create"); $strcancel = get_string("cancel"); $strcreatefolder = get_string("createfolder", "moodle", $wdir); html_header($course, $wdir, "form.name"); echo "<p>{$strcreatefolder}:</p>"; echo "<table><tr><td>";