明确了数据版本提交的流程

This commit is contained in:
wlx 2012-03-29 15:12:37 +00:00
parent 8328fff993
commit 6236ca494d
1 changed files with 74 additions and 41 deletions

View File

@ -1586,7 +1586,7 @@ class AuthorController extends Zend_Controller_Action
$sql = "DELETE FROM mdversion v $sql = "DELETE FROM mdversion v
USING mdauthor a USING mdauthor a
WHERE v.id=? AND a.userid=? AND a.status=1"; WHERE v.uuid=a.uuid and v.id=? AND a.userid=? AND a.status=1";
$sth = $this->db->prepare($sql); $sth = $this->db->prepare($sql);
$ex = $sth -> execute(array($id,$u_id)); $ex = $sth -> execute(array($id,$u_id));
@ -1626,48 +1626,40 @@ class AuthorController extends Zend_Controller_Action
return true; return true;
} }
$db = Zend_Db::factory('Pdo_Pgsql', array( $this->wdb=Zend_Db::factory($this->view->config->geonetwork);
'host' => 'localhost',
'username' => 'postgres',
'password' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'dbname' => 'geonetwork',
'persistent' => true
));
$sql = "SELECT v.xml,v.uuid FROM mdversion v $sql = "SELECT v.xml,v.uuid FROM mdversion v
LEFT JOIN mdauthor a ON a.uuid=v.uuid LEFT JOIN mdauthor a ON a.uuid=v.uuid
WHERE v.id=? AND a.userid=? AND a.status=1"; WHERE v.id=? AND a.userid=? AND a.status=1";
$sth = $this->db->prepare($sql); $sth = $this->db->prepare($sql);
$sth ->execute(array($id,$u_id)); $sth ->execute(array($id,$u_id));
$row = $sth->fetch(); $row = $sth->fetch();
$sql = "SELECT data FROM metadata WHERE uuid=?"; $sql = "SELECT data FROM metadata WHERE uuid=?";
$sth = $db->prepare($sql); $sth = $this->wdb->prepare($sql);
$sth ->execute(array($row['uuid'])); $sth ->execute(array($row['uuid']));
$row_geo = $sth->fetch(); $row_geo = $sth->fetch();
if($row['xml']==$row_geo['data']) if($row['xml']==$row_geo['data'])
{ {
$data = array("error"=>$this->alertbox('warning','恢复失败,目前两个版本中的内容相同')); $data = array("error"=>$this->alertbox('warning','无须恢复,元数据相同'));
$this->jsonexit($data); $this->jsonexit($data);
return true; return true;
} }
$sql = "UPDATE metadata SET data=? WHERE uuid=?"; $sql = "UPDATE metadata SET data=? WHERE uuid=?";
$sth = $db->prepare($sql); $sth = $this->wdb->prepare($sql);
$ex = $sth ->execute(array($row['xml'],$row['uuid'])); $ex = $sth ->execute(array($row['xml'],$row['uuid']));
if($ex) if($ex)
{ {
$data = array("error"=>$this->alertbox('ok','恢复成功')); $data = array("error"=>$this->alertbox('ok','恢复成功'));
$this->jsonexit($data); $this->jsonexit($data);
return true; return true;
}else{ }else{
$data = array("error"=>$this->alertbox('error','恢复失败,请确认权限后重试')); $data = array("error"=>$this->alertbox('error','恢复失败,请确认权限后重试'));
$this->jsonexit($data); $this->jsonexit($data);
return true; return true;
} }
}catch(Exception $e) { }catch(Exception $e) {
$msg = "恢复失败,请确认权限后重试"; $msg = "恢复失败,请确认权限后重试";
if($this->debug>0) if($this->debug>0)
@ -1694,14 +1686,61 @@ class AuthorController extends Zend_Controller_Action
return true; return true;
} }
$sql = "SELECT * FROM mdstatus s $changelog = $this->_request->getParam('changelog');
LEFT JOIN mdversion v ON v.uuid=s.uuid if(empty($changelog))
LEFT JOIN mdauthor a ON a.uuid=v.uuid {
WHERE v.id=? AND a.userid=? AND a.status=1"; $data = array("error"=>$this->alertbox('warning','请输入变更信息'));
$this->jsonexit($data);
return true;
}
// 1. 权限认定
$sql="select a.* from mdauthor a left join mdversion v on a.uuid=v.uuid
where a.status=1 and a.userid=? and v.id=?";
$sth=$this->db->prepare($sql);
$sth->execute(array($u_id,$id));
$row=$sth->fetch();
if (empty($row))
{
$data = array("error"=>'无权限修改数据');
$this->jsonexit($data);
return true;
}
// 2. 获取数据评审状态
$sql = "SELECT s.* FROM mdstatus s left join mdversion v on s.uuid=v.uuid WHERE v.id=?";
$sth = $this->db->prepare($sql); $sth = $this->db->prepare($sql);
$sth->execute(array($id,$u_id)); $sth->execute(array($id));
$row = $sth->fetch(); $row = $sth->fetch();
if (empty($row)) //无对应记录
{
// do
}
else if ($row['id']==-1) //取消发布的数据
{
//do something.
}
else if ($row['id']==0) //初始状态
{
//do
}
else if ($row['id']==1)//接收
{
//
}
else if ($row['id']==2)//已发送过外审邮件,需由编辑告知变化信息
{
//do
}
else if ($row['id']==3 || $row['id']==4)//专家在审理中
{
//do
}
else if ($row['id']==5)//数据已经发布,再次修改后将只通知管理员,保留发布状态
{
//do
}
if(!empty($row['id'])) if(!empty($row['id']))
{ {
@ -1710,16 +1749,10 @@ class AuthorController extends Zend_Controller_Action
return true; return true;
} }
$changelog = $this->_request->getParam('changelog');
if(empty($changelog)) $sql = "UPDATE mdversion SET changelog=?,userid=? WHERE id=?";
{
$data = array("error"=>$this->alertbox('warning','请输入变更信息'));
$this->jsonexit($data);
return true;
}
$sql = "UPDATE mdversion SET changelog=? WHERE id=?";
$sth = $this->db->prepare($sql); $sth = $this->db->prepare($sql);
$ex_changelog = $sth->execute(array($changelog,$id)); $ex_changelog = $sth->execute(array($changelog,$u_id,$id));
if($ex_changelog){ if($ex_changelog){