diff --git a/administrator/components/com_banners/models/banner.php b/administrator/components/com_banners/models/banner.php index e4c2af9b7ed4d..1dda6b02c9fde 100644 --- a/administrator/components/com_banners/models/banner.php +++ b/administrator/components/com_banners/models/banner.php @@ -72,7 +72,11 @@ public function batch($commands, $pks, $contexts) if (is_array($result)) { - $pks = $result; + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); } else { @@ -182,7 +186,7 @@ protected function batchCopy($value, $pks, $contexts) $categoryId = (int) $value; $table = $this->getTable(); - $i = 0; + $newIds = array(); // Check that the category exists if ($categoryId) @@ -287,8 +291,7 @@ protected function batchCopy($value, $pks, $contexts) $newId = $table->get('id'); // Add the new ID to the array - $newIds[$i] = $newId; - $i++; + $newIds[$pk] = $newId; } // Clean the cache diff --git a/administrator/components/com_categories/models/category.php b/administrator/components/com_categories/models/category.php index baa9af5c84ed0..34670890d7bc4 100644 --- a/administrator/components/com_categories/models/category.php +++ b/administrator/components/com_categories/models/category.php @@ -786,7 +786,7 @@ protected function batchCopy($value, $pks, $contexts) $db = $this->getDbo(); $extension = JFactory::getApplication()->input->get('extension', '', 'word'); - $i = 0; + $newIds = array(); // Check that the parent exists if ($parentId) @@ -952,8 +952,7 @@ protected function batchCopy($value, $pks, $contexts) $newId = $this->table->get('id'); // Add the new ID to the array - $newIds[$i] = $newId; - $i++; + $newIds[$pk] = $newId; // Now we log the old 'parent' to the new 'parent' $parents[$oldId] = $this->table->id; diff --git a/administrator/components/com_contact/models/contact.php b/administrator/components/com_contact/models/contact.php index 5c68d5d922067..131a1308dea8f 100644 --- a/administrator/components/com_contact/models/contact.php +++ b/administrator/components/com_contact/models/contact.php @@ -91,7 +91,11 @@ public function batch($commands, $pks, $contexts) if (is_array($result)) { - $pks = $result; + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); } else { @@ -175,7 +179,7 @@ protected function batchCopy($value, $pks, $contexts) $categoryId = (int) $value; $table = $this->getTable(); - $i = 0; + $newIds = array(); if (!parent::checkCategoryId($categoryId)) { @@ -246,8 +250,7 @@ protected function batchCopy($value, $pks, $contexts) $newId = $this->table->get('id'); // Add the new ID to the array - $newIds[$i] = $newId; - $i++; + $newIds[$pk] = $newId; } // Clean the cache diff --git a/administrator/components/com_content/models/article.php b/administrator/components/com_content/models/article.php index 9902d2a4a2bb9..3d3bd19efa593 100644 --- a/administrator/components/com_content/models/article.php +++ b/administrator/components/com_content/models/article.php @@ -49,7 +49,7 @@ protected function batchCopy($value, $pks, $contexts) { $categoryId = (int) $value; - $i = 0; + $newIds = array(); if (!parent::checkCategoryId($categoryId)) { @@ -125,8 +125,7 @@ protected function batchCopy($value, $pks, $contexts) $newId = $this->table->get('id'); // Add the new ID to the array - $newIds[$i] = $newId; - $i++; + $newIds[$pk] = $newId; // Check if the article was featured and update the #__content_frontpage table if ($featured == 1) diff --git a/administrator/components/com_menus/models/item.php b/administrator/components/com_menus/models/item.php index ba58a4b18ac04..9a5b1726efb8f 100644 --- a/administrator/components/com_menus/models/item.php +++ b/administrator/components/com_menus/models/item.php @@ -109,7 +109,11 @@ public function batch($commands, $pks, $contexts) if (is_array($result)) { - $pks = $result; + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); } else { @@ -175,7 +179,7 @@ protected function batchCopy($value, $pks, $contexts) $table = $this->getTable(); $db = $this->getDbo(); $query = $db->getQuery(true); - $i = 0; + $newIds = array(); // Check that the parent exists if ($parentId) @@ -328,8 +332,7 @@ protected function batchCopy($value, $pks, $contexts) $newId = $table->get('id'); // Add the new ID to the array - $newIds[$i] = $newId; - $i++; + $newIds[$pk] = $newId; // Now we log the old 'parent' to the new 'parent' $parents[$oldId] = $table->id; diff --git a/administrator/components/com_modules/models/module.php b/administrator/components/com_modules/models/module.php index 379ad9ba8e0ba..210e960fc99e4 100644 --- a/administrator/components/com_modules/models/module.php +++ b/administrator/components/com_modules/models/module.php @@ -126,28 +126,29 @@ public function batch($commands, $pks, $contexts) { $cmd = JArrayHelper::getValue($commands, 'move_copy', 'c'); - if (!empty($commands['position_id'])) + if ($cmd == 'c') { - if ($cmd == 'c') - { - $result = $this->batchCopy($commands['position_id'], $pks, $contexts); + $result = $this->batchCopy($commands['position_id'], $pks, $contexts); - if (is_array($result)) - { - $pks = $result; - } - else + if (is_array($result)) + { + foreach ($result as $old => $new) { - return false; + $contexts[$new] = $contexts[$old]; } + $pks = array_values($result); } - elseif ($cmd == 'm' && !$this->batchMove($commands['position_id'], $pks, $contexts)) + else { return false; } - - $done = true; } + elseif ($cmd == 'm' && !$this->batchMove($commands['position_id'], $pks, $contexts)) + { + return false; + } + + $done = true; } if (!empty($commands['assetgroup_id'])) @@ -200,7 +201,6 @@ protected function batchCopy($value, $pks, $contexts) $user = JFactory::getUser(); $table = $this->getTable(); $newIds = array(); - $i = 0; foreach ($pks as $pk) { @@ -246,8 +246,7 @@ protected function batchCopy($value, $pks, $contexts) $newId = $table->get('id'); // Add the new ID to the array - $newIds[$i] = $newId; - $i++; + $newIds[$pk] = $newId; // Now we need to handle the module assignments $db = $this->getDbo(); diff --git a/administrator/components/com_newsfeeds/models/newsfeed.php b/administrator/components/com_newsfeeds/models/newsfeed.php index 892618ea4aaf5..b936e3a143dc9 100644 --- a/administrator/components/com_newsfeeds/models/newsfeed.php +++ b/administrator/components/com_newsfeeds/models/newsfeed.php @@ -50,7 +50,7 @@ protected function batchCopy($value, $pks, $contexts) { $categoryId = (int) $value; - $i = 0; + $newIds = array(); if (!parent::checkCategoryId($categoryId)) { @@ -120,8 +120,7 @@ protected function batchCopy($value, $pks, $contexts) $newId = $this->table->get('id'); // Add the new ID to the array - $newIds[$i] = $newId; - $i++; + $newIds[$pk] = $newId; } // Clean the cache diff --git a/libraries/legacy/model/admin.php b/libraries/legacy/model/admin.php index 3cf25324693f0..0494bb15e6f0c 100644 --- a/libraries/legacy/model/admin.php +++ b/libraries/legacy/model/admin.php @@ -197,8 +197,6 @@ public function batch($commands, $pks, $contexts) $this->type = $type->getTypeByAlias($this->typeAlias); } - $typeAlias = $this->type->type_alias; - $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); if (!empty($commands['category_id'])) @@ -211,7 +209,11 @@ public function batch($commands, $pks, $contexts) if (is_array($result)) { - $pks = $result; + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); } else { @@ -349,8 +351,6 @@ protected function batchCopy($value, $pks, $contexts) $this->type = $this->contentType->getTypeByTable($this->tableClassName); } - $i = 0; - $categoryId = $value; if (!static::checkCategoryId($categoryId)) @@ -358,6 +358,8 @@ protected function batchCopy($value, $pks, $contexts) return false; } + $newIds = array(); + // Parent exists so let's proceed while (!empty($pks)) { @@ -430,8 +432,7 @@ protected function batchCopy($value, $pks, $contexts) $newId = $this->table->get('id'); // Add the new ID to the array - $newIds[$i] = $newId; - $i++; + $newIds[$pk] = $newId; } // Clean the cache