issue 2637 empty trash bug fix

git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@11946 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ovclas 2012-10-29 09:09:12 +00:00
parent 575f06afed
commit 75a56b8366
3 changed files with 73 additions and 10 deletions

View file

@ -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);