* finish task #2267.
This commit is contained in:
@@ -30,6 +30,7 @@ $lang->action->trashTips = "Tips:The deleting actions in zentao are all log
|
||||
$lang->action->textDiff = 'Text mode';
|
||||
$lang->action->original = 'Original content';
|
||||
$lang->action->confirmHideAll = 'Are you sure you hide these records?';
|
||||
$lang->action->needEdit = 'To restore the %s name or code already exists, please change the editor.';
|
||||
|
||||
$lang->action->dynamic = new stdclass();
|
||||
$lang->action->dynamic->today = 'Today';
|
||||
|
||||
@@ -30,6 +30,7 @@ $lang->action->trashTips = '提示:为了保证系统的完整性,禅
|
||||
$lang->action->textDiff = '文本格式';
|
||||
$lang->action->original = '原始格式';
|
||||
$lang->action->confirmHideAll = '您确定要全部隐藏这些记录吗?';
|
||||
$lang->action->needEdit = '要还原%s的名称或代号已经存在,请编辑更改。';
|
||||
|
||||
$lang->action->dynamic = new stdclass();
|
||||
$lang->action->dynamic->today = '今天';
|
||||
|
||||
+22
-2
@@ -730,8 +730,28 @@ class actionModel extends model
|
||||
*/
|
||||
public function undelete($actionID)
|
||||
{
|
||||
$action = $this->loadModel('action')->getById($actionID);
|
||||
$action = $this->getById($actionID);
|
||||
if($action->action != 'deleted') return;
|
||||
if($action->objectType == 'product')
|
||||
{
|
||||
$product = $this->dao->select('name,code')->from(TABLE_PRODUCT)->where('id')->eq($action->objectID)->fetch();
|
||||
$count = $this->dao->select('COUNT(*) AS count')->from(TABLE_PRODUCT)->where('name')->eq($product->name)->orWhere('code')->eq($product->code)->fetch('count');
|
||||
if($count > 0)
|
||||
{
|
||||
echo js::alert(sprintf($this->lang->action->needEdit, $this->lang->action->objectTypes['product']));
|
||||
die(js::locate(helper::createLink('product', 'edit', "productID=$action->objectID&action=undelete&extra=$actionID"), 'parent'));
|
||||
}
|
||||
}
|
||||
elseif($action->objectType == 'project')
|
||||
{
|
||||
$project = $this->dao->select('name,code')->from(TABLE_PROJECT)->where('id')->eq($action->objectID)->fetch();
|
||||
$count = $this->dao->select('COUNT(*) AS count')->from(TABLE_PROJECT)->where('name')->eq($project->name)->orWhere('code')->eq($project->code)->fetch('count');
|
||||
if($count > 0)
|
||||
{
|
||||
echo js::alert(sprintf($this->lang->action->needEdit, $this->lang->action->objectTypes['project']));
|
||||
die(js::locate(helper::createLink('project', 'edit', "projectID=$action->objectID&action=undelete&extra=$actionID"), 'parent'));
|
||||
}
|
||||
}
|
||||
|
||||
/* Update deleted field in object table. */
|
||||
$table = $this->config->objectTables[$action->objectType];
|
||||
@@ -739,7 +759,7 @@ class actionModel extends model
|
||||
|
||||
/* Update action record in action table. */
|
||||
$this->dao->update(TABLE_ACTION)->set('extra')->eq(ACTIONMODEL::BE_UNDELETED)->where('id')->eq($actionID)->exec();
|
||||
$this->action->create($action->objectType, $action->objectID, 'undeleted');
|
||||
$this->create($action->objectType, $action->objectID, 'undeleted');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -221,12 +221,19 @@ class product extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function edit($productID)
|
||||
public function edit($productID, $action = 'edit', $extra = '')
|
||||
{
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$changes = $this->product->update($productID);
|
||||
if(dao::isError()) die(js::error(dao::getError()));
|
||||
if($action == 'undelete')
|
||||
{
|
||||
$this->loadModel('action');
|
||||
$this->dao->update(TABLE_PRODUCT)->set('deleted')->eq(0)->where('id')->eq($productID)->exec();
|
||||
$this->dao->update(TABLE_ACTION)->set('extra')->eq(ACTIONMODEL::BE_UNDELETED)->where('id')->eq($extra)->exec();
|
||||
$this->action->create('product', $productID, 'undeleted');
|
||||
}
|
||||
if($changes)
|
||||
{
|
||||
$actionID = $this->loadModel('action')->create('product', $productID, 'edited');
|
||||
|
||||
@@ -212,8 +212,8 @@ class productModel extends model
|
||||
->data($product)
|
||||
->autoCheck()
|
||||
->batchCheck('name,code', 'notempty')
|
||||
->check('name', 'unique')
|
||||
->check('code', 'unique')
|
||||
->check('name', 'unique', "deleted = '0'")
|
||||
->check('code', 'unique', "deleted = '0'")
|
||||
->exec();
|
||||
|
||||
$productID = $this->dao->lastInsertID();
|
||||
@@ -241,8 +241,8 @@ class productModel extends model
|
||||
->data($product)
|
||||
->autoCheck()
|
||||
->batchCheck('name,code', 'notempty')
|
||||
->check('name', 'unique', "id != $productID")
|
||||
->check('code', 'unique', "id != $productID")
|
||||
->check('name', 'unique', "id != $productID and deleted = '0'")
|
||||
->check('code', 'unique', "id != $productID and deleted = '0'")
|
||||
->where('id')->eq($productID)
|
||||
->exec();
|
||||
if(!dao::isError()) return common::createChanges($oldProduct, $product);
|
||||
@@ -276,8 +276,8 @@ class productModel extends model
|
||||
->data($product)
|
||||
->autoCheck()
|
||||
->batchCheck($this->config->product->edit->requiredFields , 'notempty')
|
||||
->check('name', 'unique', "id != $productID")
|
||||
->check('code', 'unique', "id != $productID")
|
||||
->check('name', 'unique', "id != $productID and deleted = '0'")
|
||||
->check('code', 'unique', "id != $productID and deleted = '0'")
|
||||
->where('id')->eq($productID)
|
||||
->exec();
|
||||
if(dao::isError()) die(js::error('product#' . $productID . dao::getError(true)));
|
||||
|
||||
@@ -911,7 +911,7 @@ class project extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function edit($projectID)
|
||||
public function edit($projectID, $action = 'edit', $extra = '')
|
||||
{
|
||||
$browseProjectLink = $this->createLink('project', 'browse', "projectID=$projectID");
|
||||
if(!empty($_POST))
|
||||
@@ -919,6 +919,13 @@ class project extends control
|
||||
$changes = $this->project->update($projectID);
|
||||
$this->project->updateProducts($projectID);
|
||||
if(dao::isError()) die(js::error(dao::getError()));
|
||||
if($action == 'undelete')
|
||||
{
|
||||
$this->loadModel('action');
|
||||
$this->dao->update(TABLE_PROJECT)->set('deleted')->eq(0)->where('id')->eq($projectID)->exec();
|
||||
$this->dao->update(TABLE_ACTION)->set('extra')->eq(ACTIONMODEL::BE_UNDELETED)->where('id')->eq($extra)->exec();
|
||||
$this->action->create('project', $projectID, 'undeleted');
|
||||
}
|
||||
if($changes)
|
||||
{
|
||||
$actionID = $this->loadModel('action')->create('project', $projectID, 'edited');
|
||||
|
||||
@@ -227,8 +227,8 @@ class projectModel extends model
|
||||
->checkIF($project->begin != '', 'begin', 'date')
|
||||
->checkIF($project->end != '', 'end', 'date')
|
||||
->checkIF($project->end != '', 'end', 'gt', $project->begin)
|
||||
->check('name', 'unique')
|
||||
->check('code', 'unique')
|
||||
->check('name', 'unique', "deleted='0'")
|
||||
->check('code', 'unique', "deleted='0'")
|
||||
->exec();
|
||||
|
||||
/* Add the creater to the team. */
|
||||
@@ -300,8 +300,8 @@ class projectModel extends model
|
||||
->checkIF($project->begin != '', 'begin', 'date')
|
||||
->checkIF($project->end != '', 'end', 'date')
|
||||
->checkIF($project->end != '', 'end', 'gt', $project->begin)
|
||||
->check('name', 'unique', "id!=$projectID")
|
||||
->check('code', 'unique', "id!=$projectID")
|
||||
->check('name', 'unique', "id!=$projectID and deleted='0'")
|
||||
->check('code', 'unique', "id!=$projectID and deleted='0'")
|
||||
->where('id')->eq($projectID)
|
||||
->limit(1)
|
||||
->exec();
|
||||
@@ -357,8 +357,8 @@ class projectModel extends model
|
||||
->checkIF($project->begin != '', 'begin', 'date')
|
||||
->checkIF($project->end != '', 'end', 'date')
|
||||
->checkIF($project->end != '', 'end', 'gt', $project->begin)
|
||||
->check('name', 'unique', "id!=$projectID")
|
||||
->check('code', 'unique', "id!=$projectID")
|
||||
->check('name', 'unique', "id!=$projectID and deleted='0'")
|
||||
->check('code', 'unique', "id!=$projectID and deleted='0'")
|
||||
->where('id')->eq($projectID)
|
||||
->limit(1)
|
||||
->exec();
|
||||
|
||||
Reference in New Issue
Block a user