Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #380 from mbabker/batch

Joomla CMS [#26844] Improvements to batch processing
  • Loading branch information...
commit 2d72033fbe320bfad9d0be9effb80e9eb5d7a47c 2 parents cabe7cb + 9a4d50a
@eddieajau eddieajau authored
Showing with 29 additions and 13 deletions.
  1. +29 −13 libraries/joomla/application/component/modeladmin.php
View
42 libraries/joomla/application/component/modeladmin.php
@@ -168,28 +168,36 @@ public function batch($commands, $pks)
$done = false;
- if (!empty($commands['assetgroup_id']))
+ if (!empty($commands['category_id']))
{
- if (!$this->batchAccess($commands['assetgroup_id'], $pks))
+ $cmd = JArrayHelper::getValue($commands, 'move_copy', 'c');
+
+ if ($cmd == 'c')
+ {
+ $result = $this->batchCopy($commands['category_id'], $pks);
+ if (is_array($result))
+ {
+ $pks = $result;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else if ($cmd == 'm' && !$this->batchMove($commands['category_id'], $pks))
{
return false;
}
-
$done = true;
}
- if (!empty($commands['category_id']))
+ if (!empty($commands['assetgroup_id']))
{
- $cmd = JArrayHelper::getValue($commands, 'move_copy', 'c');
-
- if ($cmd == 'c' && !$this->batchCopy($commands['category_id'], $pks))
- {
- return false;
- }
- else if ($cmd == 'm' && !$this->batchMove($commands['category_id'], $pks))
+ if (!$this->batchAccess($commands['assetgroup_id'], $pks))
{
return false;
}
+
$done = true;
}
@@ -253,7 +261,7 @@ protected function batchAccess($value, $pks)
* @param integer $value The new category.
* @param array $pks An array of row IDs.
*
- * @return boolean True if successful, false otherwise and internal error is set.
+ * @return mixed An array of new IDs on success, boolean false on failure.
*
* @since 11.1
*/
@@ -263,6 +271,7 @@ protected function batchCopy($value, $pks)
$table = $this->getTable();
$db = $this->getDbo();
+ $i = 0;
// Check that the category exists
if ($categoryId)
@@ -351,12 +360,19 @@ protected function batchCopy($value, $pks)
$this->setError($table->getError());
return false;
}
+
+ // Get the new item ID
+ $newId = $table->get('id');
+
+ // Add the new ID to the array
+ $newIds[$i] = $newId;
+ $i++;
}
// Clean the cache
$this->cleanCache();
- return true;
+ return $newIds;
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.