diff --git a/modules/trash/queries/getTrashAllList.xml b/modules/trash/queries/getTrashAllList.xml new file mode 100644 index 000000000..67ab0e2ba --- /dev/null +++ b/modules/trash/queries/getTrashAllList.xml @@ -0,0 +1,16 @@ + + + +
+ + + + + + + + + + + + diff --git a/modules/trash/trash.admin.controller.php b/modules/trash/trash.admin.controller.php index 59273e311..0660eaeae 100644 --- a/modules/trash/trash.admin.controller.php +++ b/modules/trash/trash.admin.controller.php @@ -46,8 +46,13 @@ class trashAdminController extends trash $isAll = Context::get('is_all'); $originModule = Context::get('origin_module'); $tmpTrashSrls = Context::get('cart'); - if(is_array($tmpTrashSrls)) $trashSrls = $tmpTrashSrls; - else $trashSrls = explode('|@|', $tmpTrashSrls); + + $trashSrls = array(); + if($isAll != 'true') + { + if(is_array($tmpTrashSrls)) $trashSrls = $tmpTrashSrls; + else $trashSrls = explode('|@|', $tmpTrashSrls); + } //module relation data delete... $output = $this->_relationDataDelete($isAll, $trashSrls); @@ -69,18 +74,38 @@ class trashAdminController extends trash */ function _relationDataDelete($isAll, &$trashSrls) { - if($isAll == 'true') $trashSrls = array(); $oTrashModel = &getModel('trash'); - if(count($trashSrls) > 0) $args->trashSrl = $trashSrls; - $output = $oTrashModel->getTrashList($args); - if(!$output->toBool()) return new Object(-1, $output->message); + if($isAll == 'true') + { + $args = array(); + $output = $oTrashModel->getTrashAllList($args); + if(!$output->toBool()) + { + return new Object(-1, $output->message); + } + + if(is_array($output->data)) + { + foreach($output->data AS $key=>$value) + { + array_push($trashSrls, $value->getTrashSrl()); + } + } + } + else + { + $args->trashSrl = $trashSrls; + $output = $oTrashModel->getTrashList($args); + if(!$output->toBool()) + { + return new Object(-1, $output->message); + } + } if(is_array($output->data)) { foreach($output->data AS $key=>$oTrashVO) { - if($isAll == 'true') array_push($trashSrls, $oTrashVO->getTrashSrl()); - //class file check $classPath = ModuleHandler::getModulePath($oTrashVO->getOriginModule()); if(!is_dir(FileHandler::getRealPath($classPath))) return new Object(-1, 'not exist restore module directory'); @@ -92,8 +117,8 @@ class trashAdminController extends trash $oAdminController = &getAdminController($oTrashVO->getOriginModule()); if(!method_exists($oAdminController, 'emptyTrash')) return new Object(-1, 'not exist restore method in module class file'); - $output = $oAdminController->emptyTrash($oTrashVO->getSerializedObject()); - if(!$output->toBool()) return new Object(-1, $output->message); + $output2 = $oAdminController->emptyTrash($oTrashVO->getSerializedObject()); + if(!$output2->toBool()) return new Object(-1, $output2->message); } } return new Object(0, $lang->success_deleted); diff --git a/modules/trash/trash.model.php b/modules/trash/trash.model.php index dc870eb5c..dc892d897 100644 --- a/modules/trash/trash.model.php +++ b/modules/trash/trash.model.php @@ -51,6 +51,28 @@ class trashModel extends trash return $output; } + /** + * Get TrashVO all list + * @param object $args + * @param array $columnList + * @return object + */ + function getTrashAllList($args, $columnList = array()) + { + $output = executeQueryArray('trash.getTrashAllList', $args, $columnList); + + if(is_array($output->data)) + { + foreach($output->data AS $key=>$value) + { + $oTrashVO = new TrashVO(); + $this->_setTrashObject($oTrashVO, $value); + $output->data[$key] = $oTrashVO; + } + } + return $output; + } + /** * Set trash object from std object * @param TrashVO $oTrashVO