aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authoricewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-04-30 10:34:39 +0000
committericewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-04-30 10:34:39 +0000
commit6e8d9721a081abd416270b66f7c599142129351c (patch)
tree4774813e62dd8864ec2bc9b7b69a5b839b036d41 /engine
parent763fe1cc1df66d65ab30b8eb62fe4815179df76d (diff)
downloadelgg-6e8d9721a081abd416270b66f7c599142129351c.tar.gz
elgg-6e8d9721a081abd416270b66f7c599142129351c.tar.bz2
Marcus Povey <marcus@dushka.co.uk>
* git-svn-id: https://code.elgg.org/elgg/trunk@572 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/filestore.php24
1 files changed, 20 insertions, 4 deletions
diff --git a/engine/lib/filestore.php b/engine/lib/filestore.php
index fb37fee57..5a4a60b8b 100644
--- a/engine/lib/filestore.php
+++ b/engine/lib/filestore.php
@@ -122,11 +122,27 @@
public function open(ElggFile $file, $mode)
{
- $name = $file->getFilename();
- $matrix = $this->make_file_matrix($name);
+ // Full path and filename
+ $fullname = $file->getFilename();
+
+ // Split into path and name
+ $ls = strrpos($fullname,"/");
+ if ($ls===false) $ls = 0;
+
+ $path = substr($fullname, 0, $ls);
+ $name = substr($fullname, $ls);
+
+ // Construct matrix out of user
+ $owner = $file->getOwnerEntity();
+ if (!$owner)
+ $owner = $_SESSION['user'];
+
+ if ((!$owner) || (!$owner->username)) throw InvalidParameterException("All files must have an owner!");
+
+ $matrix = $this->make_file_matrix($owner->username);
// Try and create the directory
- try { $this->make_directory_root($this->dir_root . $matrix); } catch (Exception $e){}
+ try { $this->make_directory_root($this->dir_root . $matrix . $path); } catch (Exception $e){}
switch ($mode)
{
@@ -136,7 +152,7 @@
default: throw new InvalidParameterException("Unrecognised file mode '$mode'");
}
- return fopen($this->dir_root . $matrix . $name, $mode);
+ return fopen($this->dir_root . $matrix . $fullname, $mode);
}
public function write($f, $data)