将数据作者管理功能和数据版本管理功能添加到了数据管理中
This commit is contained in:
parent
f27a31c567
commit
c4b9ecfd2a
|
@ -434,7 +434,7 @@ class Admin_AuthorController extends Zend_Controller_Action
|
|||
$paginator->setItemCountPerPage(15);
|
||||
$paginator->setView($this->view);
|
||||
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
||||
$this->view->paginator=$paginator;
|
||||
$this->view->paginator=$paginator;
|
||||
}
|
||||
|
||||
//查看所有版本列表
|
||||
|
|
|
@ -1595,6 +1595,711 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
//不输出错误
|
||||
}//获取附件
|
||||
|
||||
|
||||
/*
|
||||
versionAction 版本管理
|
||||
*/
|
||||
|
||||
public function versionAction(){
|
||||
|
||||
$ac = $this->_request->getParam('ac');
|
||||
$uuid = $this->_request->getParam('uuid');
|
||||
|
||||
$auth = Zend_Auth::getInstance();
|
||||
if($auth->hasIdentity())
|
||||
{
|
||||
$user = $auth->getIdentity();
|
||||
$u_id = $user->id;
|
||||
}
|
||||
|
||||
//查看单条数据的所有版本
|
||||
if (!empty($uuid) && empty($ac))
|
||||
{
|
||||
//view the versions of the data
|
||||
$sql = "SELECT md.title,md.uuid,v.ts_created,v.changelog,v.userid,v.id,u.username,u.realname FROM mdversion v
|
||||
LEFT JOIN metadata md ON md.uuid=v.uuid
|
||||
LEFT JOIN mdauthor a ON md.uuid=a.uuid
|
||||
left join users u on v.userid=u.id
|
||||
WHERE md.title IS NOT NULL AND v.uuid=? AND a.status=1
|
||||
order by v.ts_created desc
|
||||
";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth->execute(array($uuid));
|
||||
$rows = $sth->fetchAll();
|
||||
@$this->view->mdtitle=$rows[0]['title'];
|
||||
|
||||
$paginator = Zend_Paginator::factory($rows);
|
||||
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
||||
$paginator->setItemCountPerPage(15);
|
||||
$paginator->setView($this->view);
|
||||
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
||||
$this->view->paginator=$paginator;
|
||||
}
|
||||
|
||||
//查看所有版本列表
|
||||
else if((empty($ac) && empty($uuid))|| $ac=='list')
|
||||
{
|
||||
$sql = "SELECT md.title,md.uuid,v.ts_created,v.changelog,v.userid,v.id,u.username,u.realname FROM mdversion v
|
||||
LEFT JOIN metadata md ON md.uuid=v.uuid
|
||||
left join users u on v.userid=u.id
|
||||
WHERE md.title IS NOT NULL
|
||||
order by v.ts_created desc
|
||||
";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth->execute();
|
||||
$rows = $sth->fetchAll();
|
||||
|
||||
$paginator = Zend_Paginator::factory($rows);
|
||||
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
||||
$paginator->setItemCountPerPage(15);
|
||||
$paginator->setView($this->view);
|
||||
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
||||
$this->view->paginator=$paginator;
|
||||
}
|
||||
|
||||
//按数据浏览
|
||||
else if($ac=="bydata")
|
||||
{
|
||||
$keywords = $this->_request->getParam('q');
|
||||
if(!empty($keywords))
|
||||
$this->view->q = $keywords;
|
||||
$sql = "SELECT md.title,md.uuid,count(v.id) as c FROM mdversion v
|
||||
LEFT JOIN metadata md ON md.uuid=v.uuid
|
||||
WHERE md.title IS NOT NULL";
|
||||
if(!empty($keywords))
|
||||
{
|
||||
$search=new Search($keywords);
|
||||
$where=$search->sql_expr(array("md.title","md.description"));
|
||||
$sql.=' and '.$where;
|
||||
}
|
||||
$sql.=" group by md.uuid,md.title";
|
||||
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth->execute();
|
||||
$rows = $sth->fetchAll();
|
||||
|
||||
$paginator = Zend_Paginator::factory($rows);
|
||||
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
||||
$paginator->setItemCountPerPage(10);
|
||||
$paginator->setView($this->view);
|
||||
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
||||
$this->view->paginator=$paginator;
|
||||
|
||||
$this->_helper->viewRenderer('version-bydata');
|
||||
}
|
||||
|
||||
|
||||
//删除某个版本
|
||||
else if($ac=="delete")
|
||||
{
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
|
||||
$data = "";
|
||||
|
||||
try{
|
||||
$id = $this->_request->getParam('id');
|
||||
if(empty($id) || !is_numeric($id))
|
||||
{
|
||||
$data = array("error"=>"参数错误");
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM mdversion WHERE id=?";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$ex = $sth -> execute(array($id));
|
||||
|
||||
if($ex)
|
||||
{
|
||||
$data = array("deleted"=>$id,"error"=>$this->alertbox('ok','删除成功'));
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}else{
|
||||
$data = array("error"=>$this->alertbox('error','删除失败,请确认权限后重试'));
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
}catch(Exception $e) {
|
||||
$msg = "删除失败,请确认权限后重试";
|
||||
if($this->debug>0)
|
||||
{$msg .= $e->getMessage();}
|
||||
$data = array("error"=>$this->alertbox('error',$msg));
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//恢复到geonetwork
|
||||
else if($ac == "restore")
|
||||
{
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
|
||||
$data = "";
|
||||
try{
|
||||
$id = $this->_request->getParam('id');
|
||||
if(empty($id) || !is_numeric($id))
|
||||
{
|
||||
$data = array("error"=>"参数错误");
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->wdb=Zend_Db::factory($this->view->config->geonetwork);
|
||||
$sql = "SELECT v.xml,v.uuid FROM mdversion v
|
||||
WHERE v.id=?";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth ->execute(array($id));
|
||||
$row = $sth->fetch();
|
||||
|
||||
$sql = "SELECT data FROM metadata WHERE uuid=?";
|
||||
$sth = $this->wdb->prepare($sql);
|
||||
$sth ->execute(array($row['uuid']));
|
||||
$row_geo = $sth->fetch();
|
||||
|
||||
if($row['xml']==$row_geo['data'])
|
||||
{
|
||||
$data = array("error"=>$this->alertbox('warning','无须恢复,元数据相同'));
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
|
||||
$sql = "UPDATE metadata SET data=? WHERE uuid=?";
|
||||
$sth = $this->wdb->prepare($sql);
|
||||
$ex = $sth ->execute(array($row['xml'],$row['uuid']));
|
||||
|
||||
if($ex)
|
||||
{
|
||||
$data = array("error"=>$this->alertbox('ok','恢复成功'));
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}else{
|
||||
$data = array("error"=>$this->alertbox('error','恢复失败,请确认权限后重试'));
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
}catch(Exception $e) {
|
||||
$msg = "恢复失败,请确认权限后重试";
|
||||
if($this->debug>0)
|
||||
{$msg .= $e->getMessage();}
|
||||
$data = array("error"=>$this->alertbox('error',$msg));
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//发布到评审
|
||||
else if($ac == "commit")
|
||||
{
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
|
||||
$data = "";
|
||||
try{
|
||||
$id = $this->_request->getParam('id');
|
||||
if(empty($id) || !is_numeric($id))
|
||||
{
|
||||
$data = array("error"=>"参数错误");
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
|
||||
$changelog = $this->_request->getParam('changelog');
|
||||
if(empty($changelog))
|
||||
{
|
||||
$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. 保存变化记录 save changelog & userid
|
||||
$sql = "UPDATE mdversion SET changelog=?,userid=? WHERE id=?";
|
||||
$this->db->query($sql,array($changelog,$u_id,$id));
|
||||
|
||||
// 3. 获取数据评审状态
|
||||
$sql = "SELECT s.*,v.xml,m.title FROM mdstatus s left join mdversion v on s.uuid=v.uuid
|
||||
left join metadata m on s.uuid=m.uuid WHERE v.id=?";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth->execute(array($id));
|
||||
$row = $sth->fetch();
|
||||
|
||||
if (empty($row)) //无对应记录
|
||||
{
|
||||
$sql="select m.id from metadata m left join mdversion v on m.uuid=v.uuid where v.id=?";
|
||||
$sth=$this->db->prepare($sql);
|
||||
$sth->execute(array($id));
|
||||
$mrow=$sth->fetch();
|
||||
if (empty($mrow)) //说明是新数据
|
||||
{
|
||||
//导入元数据
|
||||
$iso=new ISO19115();
|
||||
$iso->saveDB($this->db,$row['xml']);
|
||||
//进入评审库
|
||||
$sql="insert into mdstatus (uuid,status,userid) select uuid,0,? from mdversion where id=?";
|
||||
$this->db->query($sql,array($u_id,$id));
|
||||
|
||||
//email to admin
|
||||
$mail=new WestdcMailer($this->view->config->smtp);
|
||||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mailtp=new EmailText($this->db,"metadata-new-admin",array(
|
||||
'user' => $user->username,
|
||||
'uuid' => $iso->uuid,
|
||||
'email'=> $user->email,
|
||||
//元数据标题
|
||||
'title'=> $iso->resTitle,
|
||||
));
|
||||
$mail->setBodyText($mailtp->getBody());
|
||||
$mail->setSubject($mailtp->getSubject());
|
||||
if($this->debug==0)
|
||||
{
|
||||
$mail->addTo($this->view->config->service->email);
|
||||
}else{
|
||||
$mail->addTo($this->debug_email);
|
||||
}
|
||||
$mail->send();
|
||||
|
||||
unset($mail);
|
||||
unset($mailtp);
|
||||
//email to author
|
||||
$mail=new WestdcMailer($this->view->config->smtp);
|
||||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mailtp=new EmailText($this->db,"metadata-new-author",array(
|
||||
'user' => $user->username,
|
||||
'uuid' => $iso->uuid,
|
||||
'email'=> $user->email,
|
||||
//元数据标题
|
||||
'title'=> $iso->resTitle,
|
||||
));
|
||||
$mail->setBodyText($mailtp->getBody());
|
||||
$mail->setSubject($mailtp->getSubject());
|
||||
if($this->debug==0)
|
||||
{
|
||||
$mail->addTo($user->email);
|
||||
$mail->addCc($this->view->config->service->email);
|
||||
}else{
|
||||
$mail->addTo($this->debug_email);
|
||||
}
|
||||
@$mail->send();
|
||||
|
||||
$data = array("commited"=>1,"error"=>$this->alertbox('ok','该版本已经成功提交,请等待数据中心进一步处理!'));
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
} else { //说明是已发布的数据且数据不存在评审信息
|
||||
//同步元数据
|
||||
$iso=new ISO19115();
|
||||
$iso->saveDB($this->db,$row['xml']);
|
||||
//移除中间版本
|
||||
$sql="delete from mdversion where uuid in (select uuid from mdversion where v.id=?) and char_length(changelog)<3";
|
||||
$this->db->query($sql,array($id));
|
||||
//修改评审状态为发布,且由其提交的用户进行管理
|
||||
$sql="insert into mdstatus (uuid,status,userid) select uuid,6,? from mdversion where id=?";
|
||||
$this->db->query($sql,array($u_id,$id));
|
||||
|
||||
//email to admin & author
|
||||
$mail=new WestdcMailer($this->view->config->smtp);
|
||||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mailtp=new EmailText($this->db,"metadata-release",array(
|
||||
'user' => $user->username,
|
||||
'uuid' => $row['uuid'],
|
||||
'email'=> $user->email,
|
||||
//元数据标题
|
||||
'title'=> $row['title'],
|
||||
'changelog'=>$changelog,
|
||||
));
|
||||
$mail->setBodyText($mailtp->getBody());
|
||||
$mail->setSubject($mailtp->getSubject());
|
||||
if($this->debug==0)
|
||||
{
|
||||
$mail->addTo($this->view->config->service->email);
|
||||
$mail->addCc($this->view->config->service->email);
|
||||
}else{
|
||||
$mail->addTo($this->debug_email);
|
||||
}
|
||||
@$mail->send();
|
||||
|
||||
$data = array("commited"=>1,"error"=>$this->alertbox('ok','该版本已经成功发布!'));
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if ($row['id']==-1 || $row['id']==0 || $row['id']==1) //取消发布的数据,初始状态,已接收
|
||||
{
|
||||
//同步元数据
|
||||
$iso=new ISO19115();
|
||||
$iso->saveDB($this->db,$row['xml']);
|
||||
//email to admin
|
||||
$mail=new WestdcMailer($this->view->config->smtp);
|
||||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mailtp=new EmailText($this->db,"version-commit-admin",array(
|
||||
'user' => $user->username,
|
||||
'uuid' => $row['uuid'],
|
||||
'email'=> $user->email,
|
||||
//元数据标题
|
||||
'title'=> $row['title'],
|
||||
'changelog'=>$changelog,
|
||||
));
|
||||
$mail->setBodyText($mailtp->getBody());
|
||||
$mail->setSubject($mailtp->getSubject());
|
||||
if($this->debug==0)
|
||||
{
|
||||
$mail->addTo($this->view->config->service->email);
|
||||
}else{
|
||||
$mail->addTo($this->debug_email);
|
||||
}
|
||||
$mail->send();
|
||||
|
||||
unset($mail);
|
||||
unset($mailtp);
|
||||
//email to author
|
||||
$mail=new WestdcMailer($this->view->config->smtp);
|
||||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mailtp=new EmailText($this->db,"version-commit-author",array(
|
||||
'user' => $user->username,
|
||||
'uuid' => $row['uuid'],
|
||||
'email'=> $user->email,
|
||||
//元数据标题
|
||||
'title'=> $row['title'],
|
||||
));
|
||||
$mail->setBodyText($mailtp->getBody());
|
||||
$mail->setSubject($mailtp->getSubject());
|
||||
if($this->debug==0)
|
||||
{
|
||||
$mail->addTo($user->email);
|
||||
$mail->addCc($this->view->config->service->email);
|
||||
}else{
|
||||
$mail->addTo($this->debug_email);
|
||||
}
|
||||
@$mail->send();
|
||||
|
||||
$data = array("commited"=>1,"error"=>$this->alertbox('ok','该版本已经成功提交并同步,请等待数据中心进一步处理!'));
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
else if ($row['id']==2 || $row['id']==3 || $row['id']==4)//已发送过外审邮件,需由编辑告知变化信息
|
||||
{
|
||||
//email to admin
|
||||
$mail=new WestdcMailer($this->view->config->smtp);
|
||||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mailtp=new EmailText($this->db,"version-commit-admin",array(
|
||||
'user' => $user->username,
|
||||
'uuid' => $row['uuid'],
|
||||
'email'=> $user->email,
|
||||
//元数据标题
|
||||
'title'=> $row['title'],
|
||||
'changelog'=>$changelog,
|
||||
));
|
||||
$mail->setBodyText($mailtp->getBody());
|
||||
$mail->setSubject($mailtp->getSubject());
|
||||
if($this->debug==0)
|
||||
{
|
||||
$mail->addTo($this->view->config->service->email);
|
||||
}else{
|
||||
$mail->addTo($this->debug_email);
|
||||
}
|
||||
$mail->send();
|
||||
|
||||
unset($mail);
|
||||
unset($mailtp);
|
||||
//email to author
|
||||
$mail=new WestdcMailer($this->view->config->smtp);
|
||||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mailtp=new EmailText($this->db,"version-commit-author",array(
|
||||
'user' => $user->username,
|
||||
'uuid' => $row['uuid'],
|
||||
'email'=> $user->email,
|
||||
//元数据标题
|
||||
'title'=> $row['title'],
|
||||
));
|
||||
$mail->setBodyText($mailtp->getBody());
|
||||
$mail->setSubject($mailtp->getSubject());
|
||||
if($this->debug==0)
|
||||
{
|
||||
$mail->addTo($user->email);
|
||||
$mail->addCc($this->view->config->service->email);
|
||||
}else{
|
||||
$mail->addTo($this->debug_email);
|
||||
}
|
||||
@$mail->send();
|
||||
|
||||
//email to experts, sync to database?
|
||||
//todo!!!
|
||||
//should generate new pdf? or user could not commit a new version when it is in the reviewing process?
|
||||
/*
|
||||
unset($mail);
|
||||
unset($mailtp);
|
||||
$mail=new WestdcMailer($this->view->config->smtp);
|
||||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mailtp=new EmailText($this->db,"version-commit-expert",array(
|
||||
'user' => $user->username,
|
||||
'uuid' => $row['uuid'],
|
||||
'email'=> $user->email,
|
||||
//元数据标题
|
||||
'title'=> $row['title'],
|
||||
));
|
||||
$mail->setBodyText($mailtp->getBody());
|
||||
$mail->setSubject($mailtp->getSubject());
|
||||
if($this->debug==0)
|
||||
{
|
||||
$mail->addTo($user->email);
|
||||
$mail->addCc($this->view->config->service->email);
|
||||
}else{
|
||||
$mail->addTo($this->debug_email);
|
||||
}
|
||||
@$mail->send();
|
||||
*/
|
||||
$data = array("commited"=>1,"error"=>$this->alertbox('ok','该版本已经成功提交,请等待数据中心进一步处理!'));
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
else if ($row['id']>=5)//数据已经发布,再次修改后将只通知管理员,保留发布状态
|
||||
{
|
||||
//同步元数据
|
||||
$iso=new ISO19115();
|
||||
$iso->saveDB($this->db,$row['xml']);
|
||||
//移除中间版本
|
||||
$sql="delete from mdversion where uuid in (select uuid from mdversion where v.id=?) and char_length(changelog)<3";
|
||||
$this->db->query($sql,array($id));
|
||||
|
||||
//email to admin & author
|
||||
$mail=new WestdcMailer($this->view->config->smtp);
|
||||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mailtp=new EmailText($this->db,"metadata-release",array(
|
||||
'user' => $user->username,
|
||||
'uuid' => $row['uuid'],
|
||||
'email'=> $user->email,
|
||||
//元数据标题
|
||||
'title'=> $row['title'],
|
||||
'changelog'=>$changelog,
|
||||
));
|
||||
$mail->setBodyText($mailtp->getBody());
|
||||
$mail->setSubject($mailtp->getSubject());
|
||||
if($this->debug==0)
|
||||
{
|
||||
$mail->addTo($this->view->config->service->email);
|
||||
$mail->addCc($this->view->config->service->email);
|
||||
}else{
|
||||
$mail->addTo($this->debug_email);
|
||||
}
|
||||
@$mail->send();
|
||||
|
||||
$data = array("commited"=>1,"error"=>$this->alertbox('ok','该版本已经成功发布!'));
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
}catch(Exception $e) {
|
||||
$msg = "提交失败,请确认权限后重试";
|
||||
if($this->debug>0)
|
||||
{$msg .= $e->getMessage();}
|
||||
$data = array("error"=>$this->alertbox('error',$msg));
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
}//发布到评审
|
||||
|
||||
//与前一个版本对比
|
||||
else if($ac == "diff")
|
||||
{
|
||||
$this->_helper->viewRenderer('version-diff');
|
||||
$id = $this->_request->getParam('id');
|
||||
if(empty($id) || !is_numeric($id))
|
||||
{
|
||||
$this->view->error = "参数错误";
|
||||
return true;
|
||||
}
|
||||
|
||||
$sql = "SELECT v.uuid,md.title FROM mdversion v
|
||||
LEFT JOIN metadata md ON v.uuid=md.uuid
|
||||
WHERE v.id=?";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth -> execute(array($id));
|
||||
|
||||
$row = $sth->fetch();
|
||||
|
||||
$sql = "SELECT v.* FROM mdversion v
|
||||
WHERE v.uuid=? AND v.id<=?
|
||||
ORDER BY v.ts_created DESC
|
||||
LIMIT ?";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth -> execute(array($row['uuid'],$id,2));
|
||||
|
||||
$rows = $sth->fetchAll();
|
||||
|
||||
if(count($rows)<2)
|
||||
{
|
||||
$this->view->error = "对比失败:之前没有版本可以对比";
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->view->info = $row;
|
||||
$this->view->data = $rows;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}//versionAction 版本控制
|
||||
|
||||
|
||||
/*
|
||||
authorAction() 数据作者
|
||||
|
||||
|
||||
*/
|
||||
public function authorAction(){
|
||||
|
||||
$ac = $this->_getParam('ac');
|
||||
|
||||
|
||||
if(empty($ac))
|
||||
{
|
||||
|
||||
$keywords = $this->_request->getParam('q');
|
||||
if(!empty($keywords))
|
||||
$this->view->q = $keywords;
|
||||
|
||||
$sql = "select md.id,md.title,md.uuid,count(a.userid) as c from metadata md
|
||||
LEFT JOIN mdauthor a ON md.uuid=a.uuid
|
||||
";
|
||||
|
||||
if(!empty($keywords))
|
||||
{
|
||||
$search=new Search($keywords);
|
||||
$where=$search->sql_expr(array("md.title"));
|
||||
$sql.=' and '.$where;
|
||||
}
|
||||
|
||||
$sql .= "GROUP by md.id,md.title,md.uuid,md.ts_created
|
||||
ORDER BY c DESC,md.ts_created DESC";
|
||||
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth-> execute();
|
||||
$rows = $sth->fetchAll();
|
||||
|
||||
$paginator = Zend_Paginator::factory($rows);
|
||||
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
||||
$paginator->setItemCountPerPage(15);
|
||||
$paginator->setView($this->view);
|
||||
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
||||
$this->view->paginator=$paginator;
|
||||
|
||||
}//列表
|
||||
|
||||
|
||||
if($ac == 'add')
|
||||
{
|
||||
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
|
||||
$username = $this->_getParam('username');
|
||||
$uuid = $this->_getParam('uuid');
|
||||
|
||||
if(!preg_match("/^[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{12}$/",$uuid))
|
||||
{
|
||||
$data = array("error"=>"uuid参数错误");
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(empty($username))
|
||||
{
|
||||
$data = array("error"=>'请输入要添加为该数据作者的用户名');
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM users WHERE username=?";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth->execute(array($username));
|
||||
$row = $sth->fetch();
|
||||
|
||||
if(empty($row['id']) || !isset($row['id']))
|
||||
{
|
||||
$data = array("error"=>'您输入的用户名无任何对应用户');
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
|
||||
$uid = $row['id'];
|
||||
|
||||
$sql = "SELECT * FROM mdauthor WHERE userid=? AND uuid=?";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth->execute(array($row['id'],$uuid));
|
||||
$row = $sth->fetch();
|
||||
|
||||
if(!empty($row['id']) && $row['status']==1)
|
||||
{
|
||||
$data = array("error"=>'该用户已经是此数据的作者');
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!empty($row['id']) && in_array($row['status'],array(0,-1)) )
|
||||
{
|
||||
$sql = "UPDATE mdauthor SET status=1 WHERE uuid=? AND userid=?";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$ds = $sth->execute(array($uuid,$uid));
|
||||
if($ds)
|
||||
{
|
||||
$data = array("msg"=>'该用户已被提升为数据作者','added'=>1);
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}else{
|
||||
$data = array("error"=>'处理中出现错误');
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($row['id']))
|
||||
{
|
||||
$sql = "INSERT INTO mdauthor (uuid,userid,status) VALUES (?,?,?)";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$ds = $sth->execute(array($uuid,$uid,1));
|
||||
if($ds)
|
||||
{
|
||||
$data = array("msg"=>'该用户已被添加为数据作者','added'=>1);
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}else{
|
||||
$data = array("error"=>"处理中出现错误");
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$data = array("error"=>"处理中出现错误");
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
|
||||
}//ajax 添加作者
|
||||
|
||||
|
||||
if($ac == "edit")
|
||||
{
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_helper->viewRenderer('author-edit');
|
||||
}// 作者管理弹窗
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}//authorAction() 数据作者管理
|
||||
|
||||
/*
|
||||
获得单个文件的信息
|
||||
return array row
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
$this->headTitle($this->config->title->site);
|
||||
$this->headTitle($this->config->title->author);
|
||||
$this->headTitle()->setSeparator(' - ');
|
||||
$this->headScript()->appendFile('/js/jquery-1.7.min.js');
|
||||
$this->headLink()->appendStylesheet('/css/admin.css');
|
||||
$this->headScript()->appendFile('/js/jquery.colorbox-min.js');
|
||||
$this->headLink()->appendStylesheet('/css/author.css');
|
||||
$this->headLink()->appendStylesheet('/css/colorbox.css');
|
||||
$this->breadcrumb('<a href="/">首页</a>');
|
||||
$this->breadcrumb('<a href="/admin/data">数据管理</a>');
|
||||
$this->breadcrumb('数据作者管理');
|
||||
$this->breadcrumb()->setSeparator(' > ');
|
||||
?>
|
||||
<!-- 左侧导航 -->
|
||||
<div id="leftPanel">
|
||||
<?= $this->partial('data/left.phtml'); ?>
|
||||
</div>
|
||||
<!-- //左侧导航 -->
|
||||
|
||||
<!-- 页面内容 -->
|
||||
<div id="rightPanel">
|
||||
<div>
|
||||
<p>请输入元数据标题关键字进行搜索</p>
|
||||
<form id="datasearch" class="search_form" action="/admin/data/author">
|
||||
<input type="text" id="keyword" name="q" value="<?php if(!empty($this->q)) echo $this->q; ?>" />
|
||||
<button type="submit" class="btn" id="search_btn">搜索</button>
|
||||
</form>
|
||||
</div>
|
||||
<div id="datalist">
|
||||
<?php
|
||||
if (count($this->paginator)):
|
||||
if ($this->mdtitle) echo "<h2>元数据:".$this->mdtitle."</h2>";
|
||||
echo "<ul>";
|
||||
$autoindex=0;
|
||||
foreach ($this->paginator as $item):
|
||||
$autoindex++;?>
|
||||
<li id="list_<?php echo $item['id'];?>">
|
||||
<p><a href="/data/<?php echo $item['uuid'];?>" target="_blank"><?php echo $item['title'];?></a> </p>
|
||||
<p>
|
||||
<?php if ($item['c']) : ?>
|
||||
作者数量 :<span id="sumAuthor_<?php echo $item['id'];?>"><?php echo $item['c']; ?></span> | <a href="/admin/data/author/ac/edit/uuid/<?php echo $item['uuid']; ?>" class="iframe">作者管理</a> |
|
||||
<?php endif; ?>
|
||||
<span id="addauthor_<?php echo $item['id'];?>"><a href="javascript:;" onclick="AddAuthor(<?php echo $item['id']; ?>,'<?php echo $item['uuid']; ?>')">添加作者</a></span>
|
||||
</p>
|
||||
</li>
|
||||
<?php endforeach;
|
||||
echo "</ul>";
|
||||
endif; ?>
|
||||
<div class="pagenavi"><?= $this->paginator; ?></div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- //页面内容 -->
|
||||
<script>
|
||||
function AddAuthor(id,uuid){
|
||||
$('#addauthor_'+id).html('用户名:<input type="text" id="authorInp_'+id+'"/><button class="btn btn-green" onclick="addAuthor('+id+',\''+uuid+'\')">添加</button>');
|
||||
}
|
||||
function addAuthor(id,uuid){
|
||||
$.ajax({
|
||||
'type':"POST",
|
||||
'url':'/admin/data/author',
|
||||
'data':'ac=add&uuid='+uuid+'&username='+$('#authorInp_'+id).val(),
|
||||
'success':function(data){
|
||||
if (typeof(data)=='object')
|
||||
{
|
||||
if(typeof(data.error)!='undefined')
|
||||
{Alert(data.error);return false;}
|
||||
if(typeof(data.msg)!='undefined')
|
||||
{Alert(data.msg);}
|
||||
if(typeof(data.added)!='undefined')
|
||||
{$('#addauthor_'+id).html('<a href="javascript:;" onclick="AddAuthor('+id+',\''+uuid+'\')">添加作者</a>');}
|
||||
}
|
||||
else{
|
||||
Alert('出现错误,请稍后再试');
|
||||
}
|
||||
},
|
||||
'timeout': 30000,
|
||||
'error': function(){
|
||||
$.colorbox({'innerWidth':'50%','html':'<img src="/images/alert_big_error.png" /><h4>处理中出现错误,请刷新页面后重试</h4>'});
|
||||
}
|
||||
});
|
||||
}
|
||||
$(".iframe").colorbox({iframe:true, width:"80%", height:"80%"});
|
||||
$(".inline").colorbox({inline:true, width:"50%"});
|
||||
function Alert(html){
|
||||
$.colorbox({'innerWidth':'50%','html':'<h4 style="font-size:16px;font-weight:bold;">'+html+'</h4>'});
|
||||
}
|
||||
</script>
|
|
@ -1,6 +1,8 @@
|
|||
<ul>
|
||||
<li class="title">数据管理</li>
|
||||
<li><a href="/admin/data/md">元数据管理</a></li>
|
||||
<li><a href="/admin/data/author">数据作者管理</a></li>
|
||||
<li><a href="/admin/data/version">版本管理</a></li>
|
||||
<li><a href="/admin/data/comment">数据反馈管理</a></li>
|
||||
<li><a href="/admin/data/reference">数据文献关联管理</a></li>
|
||||
<li><a href="/admin/data/import">上传元数据文件</a></li>
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
$this->headTitle($this->config->title->site);
|
||||
$this->headTitle($this->config->title->author);
|
||||
$this->headTitle()->setSeparator(' - ');
|
||||
$this->headScript()->appendFile('/js/jquery-1.7.min.js');
|
||||
$this->headLink()->appendStylesheet('/css/admin.css');
|
||||
$this->headLink()->appendStylesheet('/css/author.css');
|
||||
$this->breadcrumb('<a href="/">首页</a>');
|
||||
$this->breadcrumb('<a href="/admin/data">数据管理</a>');
|
||||
$this->breadcrumb('数据版本管理');
|
||||
$this->breadcrumb()->setSeparator(' > ');
|
||||
?>
|
||||
<!-- 左侧导航 -->
|
||||
<div id="leftPanel">
|
||||
<?= $this->partial('data/left.phtml'); ?>
|
||||
</div>
|
||||
<!-- //左侧导航 -->
|
||||
|
||||
<!-- 页面内容 -->
|
||||
<div id="rightPanel">
|
||||
<div id="tabs-controller">
|
||||
<ul>
|
||||
<li class="box-shadow"><a class="text-shadow" href="/admin/data/version/">所有版本概况</a></li>
|
||||
<li class="box-shadow active"><a class="text-shadow" href="/admin/data/version/ac/bydata">逐数据浏览</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<p>请输入元数据标题关键字进行搜索</p>
|
||||
<form id="datasearch" class="search_form" action="/admin/data/version/ac/bydata">
|
||||
<input type="text" id="keyword" name="q" value="<?php if(!empty($this->q)) echo $this->q; ?>" />
|
||||
<button type="submit" class="btn" id="search_btn">搜索</button>
|
||||
</form>
|
||||
<div id="datalist">
|
||||
<?php
|
||||
if (count($this->paginator)):
|
||||
echo "<ul>";
|
||||
$autoindex=0;
|
||||
foreach ($this->paginator as $item):
|
||||
$autoindex++;?>
|
||||
<li>
|
||||
<p><a href="/data/<?php echo $item['uuid'];?>" target="_blank"><?php echo $item['title'];?></a></p>
|
||||
<p>数据库中共有版本数:<?php echo $item['c'];?> (<a href="/admin/data/version/uuid/<?php echo $item['uuid'];?>">查看详细</a>)</p>
|
||||
</li>
|
||||
<?php endforeach;
|
||||
echo "</ul>";
|
||||
endif; ?>
|
||||
<div class="pagenavi"><?= $this->paginator; ?></div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- //页面内容 -->
|
||||
<script>
|
||||
$('#wapper').width($('body').width()-300);
|
||||
</script>
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
$this->headTitle($this->config->title->site);
|
||||
$this->headTitle($this->config->title->author);
|
||||
$this->headTitle()->setSeparator(' - ');
|
||||
$this->headScript()->appendFile('/js/jquery-1.7.min.js');
|
||||
$this->headScript()->appendFile('/js/diffview.js');
|
||||
$this->headScript()->appendFile('/js/difflib.js');
|
||||
$this->headLink()->appendStylesheet('/css/admin.css');
|
||||
$this->headLink()->appendStylesheet('/css/author.css');
|
||||
$this->headLink()->appendStylesheet('/css/diffview.css');
|
||||
$this->breadcrumb('<a href="/">首页</a>');
|
||||
$this->breadcrumb('<a href="/admin/data">数据管理</a>');
|
||||
$this->breadcrumb('查看数据作者');
|
||||
$this->breadcrumb()->setSeparator(' > ');
|
||||
?>
|
||||
<!-- 左侧导航 -->
|
||||
<div id="leftPanel">
|
||||
<?= $this->partial('data/left.phtml'); ?>
|
||||
</div>
|
||||
<!-- //左侧导航 -->
|
||||
|
||||
<!-- 页面内容 -->
|
||||
<div id="rightPanel">
|
||||
<div id="tabs-controller">
|
||||
<ul>
|
||||
<li class="box-shadow"><a class="text-shadow" href="/admin/data/version">所有版本概况</a></li>
|
||||
<li class="box-shadow"><a class="text-shadow" href="/admin/data/version/ac/bydata">逐数据浏览</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<?php
|
||||
if(!empty($this->error))
|
||||
{
|
||||
echo $this->error;
|
||||
}
|
||||
else
|
||||
{?>
|
||||
<h2><?php echo $this->info['title'];?></h2>
|
||||
<div id="diffoutput" style="width:100%"> </div>
|
||||
<textarea id="basetext" style="display:none;"><?php echo $this->data[1]['xml'];?></textarea>
|
||||
<textarea id="newtext" style="display:none;"><?php echo $this->data[0]['xml'];?></textarea>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- //页面内容 -->
|
||||
<script>
|
||||
$('#wapper').width($('body').width()-300);
|
||||
function diffUsingJS() {
|
||||
var base = difflib.stringAsLines($('#basetext').val());
|
||||
var newtxt = difflib.stringAsLines($('#newtext').val());
|
||||
|
||||
var sm = new difflib.SequenceMatcher(base, newtxt);
|
||||
|
||||
var opcodes = sm.get_opcodes();
|
||||
|
||||
$("#diffoutput").append(diffview.buildView({
|
||||
baseTextLines: base,
|
||||
newTextLines: newtxt,
|
||||
opcodes: opcodes,
|
||||
// set the display titles for each resource
|
||||
baseTextName: "<?php echo date("Y-m-d H:i",strtotime($this->data[1]['ts_created'])); ?>",
|
||||
newTextName: "<?php echo date("Y-m-d H:i",strtotime($this->data[0]['ts_created'])); ?>",
|
||||
contextSize: null,
|
||||
viewType: 0
|
||||
}));
|
||||
}
|
||||
diffUsingJS();
|
||||
</script>
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
$this->headTitle($this->config->title->site);
|
||||
$this->headTitle($this->config->title->author);
|
||||
$this->headTitle()->setSeparator(' - ');
|
||||
$this->headScript()->appendFile('/js/jquery-1.7.min.js');
|
||||
$this->headLink()->appendStylesheet('/css/admin.css');
|
||||
$this->headScript()->appendFile('/js/jquery.colorbox-min.js');
|
||||
$this->headLink()->appendStylesheet('/css/author.css');
|
||||
$this->headLink()->appendStylesheet('/css/colorbox.css');
|
||||
$this->breadcrumb('<a href="/">首页</a>');
|
||||
$this->breadcrumb('<a href="/admin/data">数据管理</a>');
|
||||
$this->breadcrumb('数据版本管理');
|
||||
$this->breadcrumb()->setSeparator(' > ');
|
||||
?>
|
||||
<!-- 左侧导航 -->
|
||||
<div id="leftPanel">
|
||||
<?= $this->partial('data/left.phtml'); ?>
|
||||
</div>
|
||||
<!-- //左侧导航 -->
|
||||
|
||||
<!-- 页面内容 -->
|
||||
<div id="rightPanel">
|
||||
<div id="tabs-controller">
|
||||
<ul>
|
||||
<li class="box-shadow <?php if(!$this->mdtitle) echo "active";?>"><a class="text-shadow" href="/admin/data/version">所有版本概况</a></li>
|
||||
<li class="box-shadow"><a class="text-shadow" href="/admin/data/version/ac/bydata">逐数据浏览</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="datalist">
|
||||
<?php
|
||||
if (count($this->paginator)):
|
||||
if ($this->mdtitle) echo "<h2>元数据:".$this->mdtitle."</h2>";
|
||||
echo "<ul>";
|
||||
$autoindex=0;
|
||||
foreach ($this->paginator as $item):
|
||||
$autoindex++;?>
|
||||
<li id="list_<?php echo $item['id'];?>">
|
||||
<p><a href="/data/<?php echo $item['uuid'];?>" target="_blank"><?php echo $item['title'];?></a>
|
||||
【<a href="/admin/data/version/uuid/<?php echo $item['uuid']; ?>">查看此数据所有版本</a>】</p>
|
||||
<p>版本创建时间: <?php echo date("Y-m-d H:i",strtotime($item['ts_created']));?>
|
||||
<?php if ($item['userid']) :
|
||||
echo "发布人: ".(empty($item['realname'])?$item['username']:$item['realname'])." 【";
|
||||
else :
|
||||
?>
|
||||
【<a onclick="return confirm('是否确定删除该版本?');" href="javascript:action('delete','<?php echo $item['id'];?>');" class="more">删除</a>
|
||||
<?php endif; ?>
|
||||
<a onclick="return confirm('是否确定将这个版本恢复到geonetwork?');" href="javascript:action('restore','<?php echo $item['id'];?>');" class="more">恢复到geonetwork</a>
|
||||
<a href="/admin/data/version/ac/diff/id/<?php echo $item['id'];?>" class="more">与前一版对比</a>
|
||||
<a onclick="$('#commit_submit').attr('onclick','commit(\'<?php echo $item['id'];?>\');');" href="#commitform" class="more inline">提交评审发布</a>
|
||||
】</p>
|
||||
<?php if ($item['changelog']) : ?>
|
||||
<p><?php echo $item['changelog']; ?></p>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php endforeach;
|
||||
echo "</ul>";
|
||||
endif; ?>
|
||||
<div class="pagenavi"><?= $this->paginator; ?></div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- //页面内容 -->
|
||||
<script>
|
||||
$('#wapper').width($('body').width()-300);
|
||||
function action(ac,id){
|
||||
$.ajax({
|
||||
'type':"POST",
|
||||
'url':'/admin/data/version/',
|
||||
'data':'ac='+ ac +'&id='+id,
|
||||
'success':function(data){
|
||||
if (typeof(data)=='object')
|
||||
{
|
||||
if(typeof(data.error)!='undefined')
|
||||
{$.colorbox({'innerWidth':'50%','html':data.error});}
|
||||
if(typeof(data.deleted)!='undefined')
|
||||
{$('#list_'+data.deleted).fadeOut("slow",function(){$(this).remove();});}
|
||||
if(typeof(data.commited)!='undefined')
|
||||
{$('#changelog').val('');$('#commit_submit').attr('onclick','');}
|
||||
}
|
||||
else{
|
||||
$.colorbox({'innerWidth':'50%','html':'<img src="/images/alert_big_warning.png" /><h4>出现错误,请稍候再试</h4>'});
|
||||
}
|
||||
},
|
||||
'timeout': 30000,
|
||||
'error': function(){
|
||||
$.colorbox({'innerWidth':'50%','html':'<img src="/images/alert_big_error.png" /><h4>处理中出现错误,请刷新页面后重试</h4>'});
|
||||
}
|
||||
});
|
||||
}
|
||||
$(".inline").colorbox({inline:true, width:"50%"});
|
||||
function commit(id){
|
||||
action('commit&changelog='+$('#changelog').val(),id);
|
||||
}
|
||||
</script>
|
||||
<div class="colorbox" style="display:none;">
|
||||
<div id="commitform">
|
||||
<form>
|
||||
<p>
|
||||
<label>版本改动:</label><br />
|
||||
<textarea class="full" style="resize:none;height:200px;" id="changelog"></textarea>
|
||||
<br /><small>请输入此版本与之前版本的差别</small>
|
||||
</p>
|
||||
<input type="button" onclick="" id="commit_submit" class="btn btn-green big" value="提交"/>
|
||||
</form>
|
||||
</div>
|
||||
<div class="error"><img src="/images/alert_big_error.png" /><span></span></div>
|
||||
<div class="ok"><img src="/images/alert_big_ok.png" /><span></span></div>
|
||||
<div class="warning"><img src="/images/alert_big_warning.png" /><span></span></div>
|
||||
</div>
|
|
@ -3,13 +3,12 @@
|
|||
<a href="/"><img src="/images/westdc-banner.jpg" alt="Westdc Logo" /></a>
|
||||
</div>
|
||||
<div class="nav">
|
||||
<div id="divNavi" style="width:100%;">
|
||||
<div id="divNavi">
|
||||
<ul>
|
||||
<!-- CSS Tabs -->
|
||||
<li><a href="/admin"><span>后台首页</span></a></li>
|
||||
<li><a href="/admin/data"><span>数据管理</span></a></li>
|
||||
<li><a href="/admin/down"><span>申请管理</span></a></li>
|
||||
<li><a href="/admin/author"><span>数据作者</span></a></li>
|
||||
<li><a href="/admin/user"><span>用户管理</span></a></li>
|
||||
<li><a href="/admin/review"><span>元数据评审</span></a></li>
|
||||
<li><a href="/admin/news"><span>新闻中心</span></a></li>
|
||||
|
|
Loading…
Reference in New Issue