aboutsummaryrefslogtreecommitdiff
path: root/engine/classes
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-03-19 02:18:51 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-03-19 02:18:51 +0000
commitad5fe640659b720ab329d4b06747c1b3bfe74d97 (patch)
tree81557d00464c94001799a650fee26a84a7ce72c9 /engine/classes
parent28c8c03eea840ca932d47208d1fdc556125b3343 (diff)
downloadelgg-ad5fe640659b720ab329d4b06747c1b3bfe74d97.tar.gz
elgg-ad5fe640659b720ab329d4b06747c1b3bfe74d97.tar.bz2
Fixes #3160. ElggFile->getFilehandler() is less horrible.
git-svn-id: http://code.elgg.org/elgg/trunk@8762 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/classes')
-rw-r--r--engine/classes/ElggFile.php51
1 files changed, 24 insertions, 27 deletions
diff --git a/engine/classes/ElggFile.php b/engine/classes/ElggFile.php
index 961a6ef13..a6ed44a68 100644
--- a/engine/classes/ElggFile.php
+++ b/engine/classes/ElggFile.php
@@ -313,44 +313,41 @@ class ElggFile extends ElggObject {
return $this->filestore;
}
- // If filestore meta set then retrieve filestore
- // @todo Better way of doing this?
- // ^ Yes....yes there is.
- $metas = elgg_get_metadata(array(
- 'guid' => $this->guid,
- 'limit' => 0
- ));
- $parameters = array();
- if (is_array($metas)) {
- foreach ($metas as $meta) {
- if (strpos($meta->name, "filestore::") !== false) {
- // Filestore parameter tag
- $comp = explode("::", $meta->name);
- $name = $comp[1];
-
- $parameters[$name] = $meta->value;
+ // ask for entity specific filestore
+ // saved as filestore::className in metadata.
+ // need to get all filestore::* metadata because the rest are "parameters" that
+ // get passed to filestore::setParameters()
+ if ($this->guid) {
+ $db_prefix = elgg_get_config('dbprefix');
+ $options = array(
+ 'guid' => $this->guid,
+ 'where' => array("n.string LIKE 'filestore::%'"),
+ );
+
+ $mds = elgg_get_metadata($options);
+
+ $parameters = array();
+ foreach ($mds as $md) {
+ list($foo, $name) = explode("::", $md->name);
+ if ($name == 'filestore') {
+ $filestore = $md->value;
}
+ $parameters[$name] = $md->value;
}
- }
- if (isset($parameters['filestore'])) {
- if (!class_exists($parameters['filestore'])) {
+ if (!class_exists($filestore)) {
$msg = elgg_echo('ClassNotFoundException:NotFoundNotSavedWithFile',
- array($parameters['filestore'],
+ array($filestore,
$this->guid));
throw new ClassNotFoundException($msg);
}
- // Create new filestore object
- $this->filestore = new $parameters['filestore']();
-
+ $this->filestore = new $filestore();
$this->filestore->setParameters($parameters);
- } else {
- // @todo - should we log error if filestore not set
}
-
- // if still nothing then set filestore to default
+ // sometimes it doesn't get saved in the metadata.
+ // fallback to default...
if (!$this->filestore) {
$this->filestore = get_default_filestore();
}