From 84f287865e5382d7c01c11d1b518c97e8d2bd97b Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 6 Jan 2011 08:17:01 -0800 Subject: Don't allow moving an item into its own hierarchy. Just silently skip those sources for now. --- modules/organize/controllers/organize.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'modules') diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index 2ded8a2e..82f74c9e 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -81,6 +81,12 @@ class Organize_Controller extends Controller { $source = ORM::factory("item", $source_id); access::required("edit", $source->parent()); + if ($source->contains($new_parent) || $source->id == $new_parent->id) { + // Can't move an item into its own hierarchy. Silently skip this, + // since the UI shouldn't even allow this operation. + continue; + } + $source->parent_id = $new_parent->id; $source->save(); } -- cgit v1.2.3