Skip to content
This repository has been archived by the owner on Nov 26, 2017. It is now read-only.

Joomla CMS [#26844] Improvements to batch processing #380

Merged
merged 4 commits into from Sep 23, 2011
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 29 additions & 13 deletions libraries/joomla/application/component/modeladmin.php
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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
*/
Expand All @@ -263,6 +271,7 @@ protected function batchCopy($value, $pks)

$table = $this->getTable();
$db = $this->getDbo();
$i = 0;

// Check that the category exists
if ($categoryId)
Expand Down Expand Up @@ -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;
}

/**
Expand Down