From: skodak Date: Wed, 20 May 2009 21:17:58 +0000 (+0000) Subject: MDL-15906 removing obsoleted code, now in filelib.php X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=0589769fcf95b8005cd4904ad6857595956dbeae;p=moodle.git MDL-15906 removing obsoleted code, now in filelib.php --- diff --git a/lib/file/file_storage.php b/lib/file/file_storage.php index ae4243fe59..3d3d0630b4 100644 --- a/lib/file/file_storage.php +++ b/lib/file/file_storage.php @@ -777,75 +777,6 @@ class file_storage { return $this->create_file_from_string($file_record, $content); } - /** - * Move one or more files from a given itemid location in the current user's draft files - * to a new filearea. Note that you can't rename files using this function. - * @param int $itemid - existing itemid in user draft_area with one or more files - * @param int $newcontextid - the new contextid to move files to - * @param string $newfilearea - the new filearea to move files to - * @param int $newitemid - the new itemid to use (this is ignored and automatically set to 0 when moving to a user's user_private area) - * @param string $newfilepath - the new path to move all files to - * @param bool $overwrite - overwrite files from the destination if they exist - * @param int $newuserid - new userid if required - * @return mixed stored_file object or false if error; may throw exception if duplicate found - * @return array(contenthash, filesize, newfile) - */ - public function move_draft_to_final($itemid, $newcontextid, $newfilearea, $newitemid, - $newfilepath='/', $overwrite=false) { - - global $USER; - - /// Get files from the draft area - if (!$usercontext = get_context_instance(CONTEXT_USER, $USER->id)) { - return false; - } - if (!$files = $this->get_area_files($usercontext->id, 'user_draft', $itemid, 'filename', false)) { - return false; - } - - $newcontext = get_context_instance_by_id($newcontextid); - if (($newcontext->contextlevel == CONTEXT_USER) && ($newfilearea != 'user_draft')) { - $newitemid = 0; - } - - /// Process each file in turn - - $returnfiles = array(); - foreach ($files as $file) { - - /// Delete any existing files in destination if required - if ($oldfile = $this->get_file($newcontextid, $newfilearea, $newitemid, - $newfilepath, $file->get_filename())) { - if ($overwrite) { - $oldfile->delete(); - } else { - $returnfiles[] = $oldfile; - continue; // Can't overwrite the existing file so skip it - } - } - - /// Create the new file - $newrecord = new object(); - $newrecord->contextid = $newcontextid; - $newrecord->filearea = $newfilearea; - $newrecord->itemid = $newitemid; - $newrecord->filepath = $newfilepath; - $newrecord->filename = $file->get_filename(); - $newrecord->timecreated = $file->get_timecreated(); - $newrecord->timemodified = $file->get_timemodified(); - $newrecord->mimetype = $file->get_mimetype(); - $newrecord->userid = $file->get_userid(); - - if ($newfile = $this->create_file_from_storedfile($newrecord, $file->get_id())) { - $file->delete(); - $returnfiles[] = $newfile; - } - } - - return $returnfiles; - } - - /** * Add file content to sha1 pool * @param string $pathname path to file