Hello
(For jd3.9.7.2) The "Batch Move" on the backend doesn't seem to be moving the files to the target folder (the category ids for the downloads are being changed ok).
In administrator/components/com_jdownloads/models/download.php, method batchMove, there doesn't seem to be any code to move the files.
I assume batchMove _should_ be moving files (as it used to). I've applied an emergency patch (basically copying code from batchCopy), but haven't tested it carefully:
diff --git a/htdocs/administrator/components/com_jdownloads/models/download.php b/htdocs/administrator/components/com_jdownloads/models/download.php
index c66604df..18fc75fd 100644
--- a/htdocs/administrator/components/com_jdownloads/models/download.php
+++ b/htdocs/administrator/components/com_jdownloads/models/download.php
@@ -886,6 +886,14 @@ class jdownloadsModelDownload extends JModelAdmin
return false;
}
}
+
+ // Build the file path from the Downloads target category
+ if ($categoryTable->cat_dir_parent != ''){
+ $target_path = $categoryTable->cat_dir_parent.'/'.$categoryTable->cat_dir;
+ } else {
+ $target_path = $categoryTable->cat_dir;
+ }
+
}
if (empty($categoryId)) {
@@ -923,6 +931,50 @@ class jdownloadsModelDownload extends JModelAdmin
}
}
+ // Move file
+ $source_path = '';
+
+ if ($categoryId > 1 && $table->url_download != ''){
+ $copy_filename = $table->url_download;
+ $source_cat_id = $table->catid;
+ $target_cat_id = $categoryId;
+
+ // We must only move when we have a different cat id.
+ if ($source_cat_id != $target_cat_id){
+
+ // Get the data from the source category
+ $sourceCategoryTable = JTable::getInstance('category', 'jdownloadsTable');
+ if (!$sourceCategoryTable->load($source_cat_id)){
+ if ($error = $sourceCategoryTable->getError()){
+ // Fatal error
+ $this->setError($error);
+ return false;
+ } else {
+ // Category not found
+ $this->setError(JText::_('COM_JDOWNLOADS_BATCH_MOVE_ROW_NOT_FOUND'));
+ return false;
+ }
+ }
+
+ // Build the file path from the Downloads source category
+ if ($sourceCategoryTable->cat_dir_parent != ''){
+ $source_path = $sourceCategoryTable->cat_dir_parent.'/'.$sourceCategoryTable->cat_dir.'/'.$copy_filename;
+ } else {
+ $source_path = $sourceCategoryTable->cat_dir.'/'.$copy_filename;
+ }
+
+ if ($source_path && $target_path){
+ if (!JFile::exists($params->get('files_uploaddir') . '/'. $source_path)){
+ $this->setError(JText::sprintf('COM_JDOWNLOADS_BATCH_CANNOT_FIND_COPY_FILE', $source_path));
+ }
+
+ if (!JFile::move($params->get('files_uploaddir') . '/' . $source_path, $params->get('files_uploaddir') . '/' . $target_path.'/'.$copy_filename)){
+ $this->setError(JText::sprintf('COM_JDOWNLOADS_BATCH_CANNOT_COPY_FILES', $source_path));
+ }
+ }
+ }
+ }
+
// Set the new category ID
$table->catid = $categoryId;
Thanks, David