From: scyrma Date: Thu, 4 Sep 2008 05:42:17 +0000 (+0000) Subject: MDL-14589: Enforce itemid to always be 0 for user_private. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=882eb7905f31ed0b460b10832b274b5ec549959d;p=moodle.git MDL-14589: Enforce itemid to always be 0 for user_private. --- diff --git a/lib/file/file_storage.php b/lib/file/file_storage.php index aa70666809..bc243c357b 100644 --- a/lib/file/file_storage.php +++ b/lib/file/file_storage.php @@ -585,6 +585,7 @@ class file_storage { * @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 @@ -604,6 +605,11 @@ class file_storage { return false; } + $newcontext = get_context_instance_by_id($newcontextid); + if (($newcontext->contextlevel == CONTEXT_USER) && ($newfilearea == 'user_private')) { + $newitemid = 0; + } + /// Process each file in turn $returnfiles = array();