添加新数据提交功能,进入数据评审流程
This commit is contained in:
parent
e8e3625c30
commit
a5bada218c
|
@ -2108,6 +2108,121 @@ class AuthorController extends Zend_Controller_Action
|
|||
$this->view->templates=$sth->fetchAll();
|
||||
$this->_helper->viewRenderer('newdata-add');
|
||||
}
|
||||
|
||||
//提交数据
|
||||
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. 权限认定:当前用户必须和其owner相同
|
||||
// 数据应当没有评审状态,没有作者信息
|
||||
$sql="select gn.id from geonetworkmetadata gn
|
||||
left join mdstatus s on gn.uuid=s.uuid
|
||||
left join mdauthor a on s.uuid=a.uuid
|
||||
where s.id is not null and a.id is not null and gn.id=?";
|
||||
$sth=$this->db->prepare($sql);
|
||||
$sth->execute(array($id));
|
||||
$row=$sth->fetch();
|
||||
if (!emtpy($row))
|
||||
{
|
||||
$data = array("error"=>'错误的入口');
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
|
||||
$sql="select uuid from metadata where id=? and owner=?";
|
||||
$sth=$this->wdb->prepare($sql);
|
||||
$sth->execute(array($id,$u_id));
|
||||
$row=$sth->fetch();
|
||||
if (empty($row))
|
||||
{
|
||||
$data = array("error"=>'无权限修改数据');
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
// 保存数据作者信息
|
||||
$sql="insert into mdauthor (uuid,userid,ts_activated,status) values(?,?,now(),1)";
|
||||
$sth=$this->db->query($sql,array($row['uuid'],$u_id));
|
||||
|
||||
// 2. 保存变化记录 save changelog & userid for the latest version
|
||||
$sql = "UPDATE mdversion SET changelog=?,userid=? WHERE id in (select id from mdversion where uuid=? order by ts_created desc limit 1)";
|
||||
$this->db->query($sql,array($changelog,$u_id,$row['uuid']));
|
||||
|
||||
// 3. 保存数据评审状态
|
||||
//导入元数据
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//文献管理
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
$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/author.css');
|
||||
$this->headScript()->appendFile('/js/jquery-1.7.min.js');
|
||||
$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="/author">数据作者</a>');
|
||||
$this->breadcrumb('数据新闻');
|
||||
|
@ -37,7 +39,10 @@ $this->breadcrumb()->setSeparator(' > ');
|
|||
?>
|
||||
<li>
|
||||
<p><span class="title"><?php echo $item['title'];?></span>
|
||||
【<a href="/author/newdata/id/<?php echo $item['id']; ?>">在geonetwork里查看</a> | <a href="/service/geonetwork?metadata.edit?id=<?php echo $item['id']; ?>">在geonetwork里修改</a>】</p>
|
||||
【<a href="/service/geonetwork?metadata.show?id=<?php echo $item['id']; ?>">在geonetwork里查看</a>
|
||||
| <a href="/service/geonetwork?metadata.edit?id=<?php echo $item['id']; ?>">在geonetwork里修改</a>
|
||||
| <a onclick="$('#commit_submit').attr('onclick','commit(\'<?php echo $item['id'];?>\');');" href="#commitform" class="more inline">提交评审发布</a>
|
||||
】</p>
|
||||
</li>
|
||||
<?php
|
||||
endforeach;
|
||||
|
@ -52,4 +57,48 @@ $this->breadcrumb()->setSeparator(' > ');
|
|||
<script>
|
||||
$('#wapper').width($('body').width()-300);
|
||||
|
||||
</script>
|
||||
function action(ac,id){
|
||||
$.ajax({
|
||||
'type':"POST",
|
||||
'url':'/author/newdata/',
|
||||
'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>
|
Loading…
Reference in New Issue