Skip to content

Commit

Permalink
MDL-15906 removing obsoleted code, now in filelib.php
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed May 20, 2009
1 parent 25aebf0 commit 0589769
Showing 1 changed file with 0 additions and 69 deletions.
69 changes: 0 additions & 69 deletions lib/file/file_storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -777,75 +777,6 @@ public function convert_image($file_record, $fid, $newwidth=null, $newheight=nul
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
Expand Down

0 comments on commit 0589769

Please sign in to comment.