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

@ -0,0 +1,16 @@
<query id="getTrashList" action="select">
<tables>
<table name="trash" alias="T" />
<table name="member" alias="M" />
</tables>
<columns>
<column name="T.*" />
<column name="M.user_id" />
<column name="M.nick_name" />
</columns>
<conditions>
<condition operation="equal" column="T.remover_srl" default="M.member_srl" notnull="notnull" />
<condition operation="in" column="trash_srl" var="trashSrl" filter="number" pipe="and" />
<condition operation="in" column="origin_module" var="originModule" pipe="and" />
</conditions>
</query>

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

View file

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