summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/helpers/module.php2
-rw-r--r--core/models/item.php11
-rw-r--r--core/tests/ORM_MPTT_Test.php19
3 files changed, 29 insertions, 3 deletions
diff --git a/core/helpers/module.php b/core/helpers/module.php
index ca5b5cfb..c841ca94 100644
--- a/core/helpers/module.php
+++ b/core/helpers/module.php
@@ -60,7 +60,7 @@ class module_Core {
$class = "{$module->name}_event";
$function = str_replace(".", "_", $name);
if (method_exists($class, $function)) {
- call_user_func_array(array($class, $function), array($data));
+ call_user_func_array(array($class, $function), array(&$data));
}
}
}
diff --git a/core/models/item.php b/core/models/item.php
index 495508ec..f1a979ee 100644
--- a/core/models/item.php
+++ b/core/models/item.php
@@ -63,11 +63,18 @@ class Item_Model extends ORM_MPTT {
$this->lock();
try {
$original_path = $this->file_path();
+ $original_resize_path = $this->resize_path();
+ $original_thumbnail_path = $this->thumbnail_path();
parent::moveTo($target, true);
- $new_path = $this->file_path();
- rename($original_path, $new_path);
+ rename($original_path, $this->file_path());
+ if (file_exists($original_resize_path)) {
+ rename($original_resize_path, $this->resize_path());
+ }
+ if (file_exists($original_thumbnail_path)) {
+ rename($original_thumbnail_path, $this->thumbnail_path());
+ }
} catch (Exception $e) {
$this->unlock();
diff --git a/core/tests/ORM_MPTT_Test.php b/core/tests/ORM_MPTT_Test.php
index 733b30ea..cd6b38eb 100644
--- a/core/tests/ORM_MPTT_Test.php
+++ b/core/tests/ORM_MPTT_Test.php
@@ -55,6 +55,25 @@ class ORM_MPTT_Test extends Unit_Test_Case {
$this->assert_equal(3, $album1->right - $album1->left);
}
+ public function move_to_test() {
+ $album1 = album::create(1, "move_to_test_1", "move_to_test_1");
+ $album1_1 = album::create($album1->id, "move_to_test_1_1", "move_to_test_1_1");
+ $album1_2 = album::create($album1->id, "move_to_test_1_2", "move_to_test_1_2");
+ $album1_1_1 = album::create($album1_1->id, "move_to_test_1_1_1", "move_to_test_1_1_1");
+ $album1_1_2 = album::create($album1_1->id, "move_to_test_1_1_2", "move_to_test_1_1_2");
+
+ $album1_2->reload();
+ $album1_1_1->reload();
+
+ $album1_1_1->moveTo($album1_2);
+
+ $album1_1->reload();
+ $album1_2->reload();
+
+ $this->assert_equal(3, $album1_1->right - $album1_1->left);
+ $this->assert_equal(3, $album1_2->right - $album1_2 ->left);
+ }
+
public function parent_test() {
$album = ORM::factory("item")->add_to_parent(1);