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>"; echo "<form action=\"index.php\" method=\"post\">"; echo "<fieldset class=\"invisiblefieldset\">"; echo ' <input type="hidden" name="choose" value="' . $choose . '" />'; echo " <input type=\"hidden\" name=\"id\" value=\"{$id}\" />";
/** * Moves all the files to the destination directory. * * @uses $CFG * @uses $USER * @param string $destination The destination directory. * @return boolean status; */ function save_files($destination) { global $CFG, $USER; if (!$this->status) { // preprocess_files hasn't been run $this->preprocess_files(); } // if there are no files, bail before we create an empty directory. if (empty($this->config->somethingtosave)) { return true; } $savedsomething = false; if ($this->status) { if (!(strpos($destination, $CFG->dataroot) === false)) { // take it out for giving to make_upload_directory $destination = substr($destination, strlen($CFG->dataroot) + 1); } if ($destination[strlen($destination) - 1] == '/') { // strip off a trailing / if we have one $destination = substr($destination, 0, -1); } # HU, CS Repository plugin support if (!repository_make_upload_directory($destination, true)) { //TODO maybe put this function here instead of moodlelib.php now. $this->status = false; return false; } # HU, CS Repository plugin support // $destination = $CFG->dataroot .'/'. $destination; // now add it back in so we have a full path $exceptions = array(); //need this later if we're deleting other files. foreach (array_keys($this->files) as $i) { if (!$this->files[$i]['clear']) { // not ok to save continue; } if ($this->config->handlecollisions) { $this->handle_filename_collision($destination, $this->files[$i]); } # HU, CS Repository plugin support if (repository_move_uploaded_file($this->files[$i]['tmp_name'], $destination . '/' . $this->files[$i]['name'])) { repository_chmod($destination . '/' . $this->files[$i]['name'], $CFG->directorypermissions); $this->files[$i]['fullpath'] = $destination . '/' . $this->files[$i]['name']; $this->files[$i]['uploadlog'] .= "\n" . get_string('uploadedfile'); $this->files[$i]['saved'] = true; $exceptions[] = $this->files[$i]['name']; // now add it to the log (this is important so we know who to notify if a virus is found later on) clam_log_upload($this->files[$i]['fullpath'], $this->course); $savedsomething = true; } } if ($savedsomething && $this->config->deleteothers) { $this->delete_other_files($destination, $exceptions); } } if (empty($savedsomething)) { $this->status = false; if (empty($this->config->allownull) && !empty($this->inputname) || empty($this->inputname) && empty($this->config->allownullmultiple)) { notify(get_string('uploadnofilefound')); } return false; } return $this->status; }
function update_rss() { if ($this->path == '') { return; } // make sure stream is registered $r = $this->get_repository(true); if (!$r) { return false; } $dirname = dirname($this->path); $destpath = $r->prefix . '://' . $dirname; $destfile = $r->prefix . '://' . $this->path; repository_make_upload_directory($destpath); $format = podcaster_format::create_format($this->format); $format->set_data($this); $format->write_xml($w = new podcaster_filestreamwriter($destfile)); return true; }