修改了元数据附件解除关联的操作逻辑,增加了附件删除时的判断
This commit is contained in:
parent
438f831468
commit
426d442bc7
|
@ -33,17 +33,17 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
$uuid=trim($this->_request->getParam('uuid'));
|
||||
if ($source=="geonetwork" && empty($uuid) ) {
|
||||
//从geonetwork向WESTDC同步
|
||||
//对所有的新数据增加评审状态
|
||||
$sql="insert into mdstatus (uuid,status,ts_accepted,userid) select uuid,1,now(),?
|
||||
from geonetworkmetadata gn where uuid not in (select uuid from mdstatus)";
|
||||
$userid = Zend_Auth::getInstance()->getIdentity()->id;
|
||||
$this->db->query($sql,array($userid));
|
||||
//对所有的新数据增加评审状态
|
||||
$sql="insert into mdstatus (uuid,status,ts_accepted,userid) select uuid,1,now(),?
|
||||
from geonetworkmetadata gn where uuid not in (select uuid from mdstatus)";
|
||||
$userid = Zend_Auth::getInstance()->getIdentity()->id;
|
||||
$this->db->query($sql,array($userid));
|
||||
$sql="select uuid,data,source from geonetworkmetadata where schemaid='iso19115'";
|
||||
$rs=$this->db->fetchAll($sql);
|
||||
foreach($rs as $gmd) {
|
||||
$this->import($gmd->data);
|
||||
$this->db->query("update metadata set source=? where uuid=?",array($gmd->source,$gmd->uuid));
|
||||
}
|
||||
$this->db->query("update metadata set source=? where uuid=?",array($gmd->source,$gmd->uuid));
|
||||
}
|
||||
$this->view->msg='成功同步元数据!';
|
||||
} elseif ($source=="watergn" && empty($uuid) ) {
|
||||
//首先删除所有的黑河试验数据
|
||||
|
@ -51,11 +51,11 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
$sql="delete from metadata where uuid in (select uuid from watergn)";
|
||||
$this->db->query($sql);
|
||||
$sql="delete from responsible where id not in (select distinct(resid) from role)";
|
||||
$this->db->query($sql);
|
||||
//对所有的新数据增加评审状态
|
||||
$sql="insert into mdstatus (uuid,status,ts_accepted,userid) select uuid,1,now(),?
|
||||
from watergn where uuid not in (select uuid from mdstatus)";
|
||||
$userid = Zend_Auth::getInstance()->getIdentity()->id;
|
||||
$this->db->query($sql);
|
||||
//对所有的新数据增加评审状态
|
||||
$sql="insert into mdstatus (uuid,status,ts_accepted,userid) select uuid,1,now(),?
|
||||
from watergn where uuid not in (select uuid from mdstatus)";
|
||||
$userid = Zend_Auth::getInstance()->getIdentity()->id;
|
||||
$this->db->query($sql,array($userid));
|
||||
//同步黑河遥感实验的元数据
|
||||
$sql="select uuid,data,source from watergn where schemaid='iso19115'";
|
||||
|
@ -85,9 +85,9 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
$sql=$this->db->quoteInto("select data,source from geonetworkmetadata where uuid=?",$uuid);
|
||||
if ($rs=$this->db->fetchRow($sql)) {
|
||||
$this->import($rs->data);
|
||||
$this->db->exec($this->db->quoteInto("update metadata set source=? where uuid='$uuid'",$rs->source));
|
||||
$userid = Zend_Auth::getInstance()->getIdentity()->id;
|
||||
$this->db->query("insert into mdstatus (uuid,status,ts_accepted,userid) select uuid,1,now(),?
|
||||
$this->db->exec($this->db->quoteInto("update metadata set source=? where uuid='$uuid'",$rs->source));
|
||||
$userid = Zend_Auth::getInstance()->getIdentity()->id;
|
||||
$this->db->query("insert into mdstatus (uuid,status,ts_accepted,userid) select uuid,1,now(),?
|
||||
from geonetworkmetadata gn where uuid not in (select uuid from mdstatus) and uuid=?",array($userid,$uuid));
|
||||
$this->view->msg='成功同步元数据:'.$uuid;
|
||||
} else $this->view->msg='不存在此元数据:'.$uuid;
|
||||
|
@ -115,9 +115,9 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
$sql="select uuid,title from metadata where uuid not in (select uuid from geonetworkmetadata where schemaid='iso19115')";
|
||||
$this->view->metadata=$this->db->query($sql);
|
||||
} elseif ($list=='geonetwork') {
|
||||
$sql="select id,uuid,(regexp_matches(data,'<resTitle>(.*)</resTitle>'))[1] as title from geonetworkmetadata
|
||||
$sql="select id,uuid,(regexp_matches(data,'<resTitle>(.*)</resTitle>'))[1] as title from geonetworkmetadata
|
||||
where uuid not in (select uuid from metadata)";
|
||||
$this->view->metadata=$this->db->query($sql);
|
||||
$this->view->metadata=$this->db->query($sql);
|
||||
} elseif ($delete=='westdc') {
|
||||
$sql="delete from metadata where uuid not in (select uuid from geonetworkmetadata where schemaid='iso19115')";
|
||||
$this->db->query($sql);
|
||||
|
@ -659,8 +659,8 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
{
|
||||
//更新文献信息
|
||||
$sql="update mdref set refid=?,reftype=? where uuid=? and id=?";
|
||||
$td = $this->db->query($sql,array($row['id'],$formdata['reftype'],$formdata['uuid'],$edit));
|
||||
$sql="update reference set reference=?,link=? where id=?";
|
||||
$td = $this->db->query($sql,array($row['id'],$formdata['reftype'],$formdata['uuid'],$edit));
|
||||
$sql="update reference set reference=?,link=? where id=?";
|
||||
$this->db->query($sql,array($formdata['reference'],$formdata['link'],$row['id']));
|
||||
if($td)
|
||||
{
|
||||
|
@ -675,7 +675,7 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
{
|
||||
$row = $sth->fetch(PDO::FETCH_ASSOC);
|
||||
$sql="update mdref set refid=?,reftype=? where uuid=? and id=?";
|
||||
$td = $this->db->query($sql,array($row['id'],$formdata['reftype'],$formdata['uuid'],$edit));
|
||||
$td = $this->db->query($sql,array($row['id'],$formdata['reftype'],$formdata['uuid'],$edit));
|
||||
$this->messenger->addMessage('提示信息:您已经编辑该数据文献。');
|
||||
$this->_redirect('/admin/data/reference/show/'.$formdata['uuid']);
|
||||
}else
|
||||
|
@ -1215,6 +1215,7 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
$down = $this->_request->getParam('down');
|
||||
$uuid = $this->_request->getParam('uuid');
|
||||
$mdtitle = $this->_request->getParam('mdtitle');
|
||||
$mdattdel = $this->_request->getParam('mdattdel');
|
||||
|
||||
if(!empty($uuid)&&!empty($mdtitle))
|
||||
{
|
||||
|
@ -1230,6 +1231,28 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
$this->view->uuid = $uuid;
|
||||
}
|
||||
}//附件添加
|
||||
|
||||
else if($mdattdel)
|
||||
{
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
|
||||
|
||||
$sql = "delete from mdattach where uuid=? AND id=?";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$ds = $sth->execute(array($uuid,$mdattdel));
|
||||
if($ds)
|
||||
{
|
||||
$data = array("status"=>1); //操作状态代码 : 1=>成功 2=>失败
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}else{
|
||||
$data = array("error"=>"处理中出现错误");
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
else if($delete)
|
||||
{
|
||||
|
||||
|
@ -1243,6 +1266,29 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
|
||||
$filepath = $basepath.$info['filename'];
|
||||
|
||||
$sql = "SELECT * FROM mdattach WHERE id=?";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth->execute(array($delete));
|
||||
$rows = $sth->fetchAll();
|
||||
|
||||
if(count($rows)>0)
|
||||
{
|
||||
$this->messenger->addMessage('删除失败!该文件有对应元数据附件信息,不能直接删除');
|
||||
$this->_redirect("/admin/data/attachments/");
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM mdreviewattach WHERE attachid=?";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth->execute(array($delete));
|
||||
$rows = $sth->fetchAll();
|
||||
|
||||
if(count($rows)>0)
|
||||
{
|
||||
$this->messenger->addMessage('删除失败!该文件有对应评审附件信息,不能直接删除');
|
||||
$this->_redirect("/admin/data/attachments/");
|
||||
}
|
||||
|
||||
|
||||
if(unlink($filepath))
|
||||
{
|
||||
$sql = "delete from attachments where id='$delete'";
|
||||
|
@ -1436,7 +1482,7 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
exit();
|
||||
}
|
||||
|
||||
$files=new files();
|
||||
$files=new files();
|
||||
$msg = $files -> upload($this->view->config->upload,$_FILES['Filedata'],empty($uuid)?'file':'md');
|
||||
|
||||
if(empty($msg['error']))
|
||||
|
@ -1499,7 +1545,8 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
$userid = $user->id;
|
||||
$sql = "select m.*,a.*,d.title from mdattach m
|
||||
left join attachments a on m.id = a.id
|
||||
left join metadata d on m.uuid=d.uuid where m.uuid='$uuid'";
|
||||
left join metadata d on m.uuid=d.uuid where m.uuid='$uuid'
|
||||
ORDER BY a.ts_created ASC";
|
||||
$rs = $this->db->query($sql);
|
||||
$atts = $rs->fetchAll();
|
||||
|
||||
|
@ -1538,6 +1585,18 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
{
|
||||
$iso=new ISO19115();
|
||||
$iso->saveDB($this->db,$xml);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* jsonexit() 退出并返回json数据
|
||||
*
|
||||
* param array $data 要返回的JSON数据,可以是任意数组
|
||||
*
|
||||
* return JSON-response
|
||||
*/
|
||||
public function jsonexit($data){
|
||||
$this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(json_encode($data,JSON_NUMERIC_CHECK));
|
||||
return true;
|
||||
}//jsonexit() 退出并返回json数据
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
$this->breadcrumb('数据管理');
|
||||
$this->breadcrumb()->setSeparator(' > ');
|
||||
$this->headLink()->appendStylesheet('/static/js/uploadify/uploadify.css');
|
||||
$this->headScript()->appendFile('/js/jquery-1.6.4.min.js');
|
||||
$this->headScript()->appendFile('/static/js/jquery-1.7.2.min.js');
|
||||
$this->headScript()->appendFile('/js/jquery.colorbox-min.js');
|
||||
$this->headLink()->appendStylesheet('/css/colorbox.css');
|
||||
$this->headScript()->appendFile('/static/js/uploadify/swfobject.js');
|
||||
$this->headScript()->appendFile('/static/js/uploadify/jquery.uploadify.v2.1.4.min.js');
|
||||
?>
|
||||
|
@ -64,17 +66,21 @@ $('#file_upload').uploadify({
|
|||
alert(errorObj.type + ' Error: ' + errorObj.info);
|
||||
}
|
||||
});
|
||||
function deleteatt(attid){
|
||||
function deleteatt(id){
|
||||
$.ajax({
|
||||
type:"POST",
|
||||
url:'/service/delreviewatt/id/'+attid,
|
||||
data:'',
|
||||
success:function(html){
|
||||
$('#uploadedItem_'+attid).remove();
|
||||
},
|
||||
beforeSend:function(){
|
||||
$('#deletebtn_'+attid).html('<img src="/images/11887177066.gif" />');
|
||||
}
|
||||
'type': "POST",
|
||||
'url': "/admin/data/attachments/",
|
||||
'data': 'uuid=<?php echo $this->uuid?>&mdattdel='+id,
|
||||
'success': function(data){
|
||||
if(data==null){Alert('遇到错误,请重试');return false;}
|
||||
if(data.error!=null){Alert(data.error);return false;}
|
||||
if(data.status==1){$('#uploadedItem_'+id).fadeOut("slow");}
|
||||
},
|
||||
'beforeSend':function(){},
|
||||
'complete':function(){},
|
||||
'timeout': 20000,
|
||||
'dataType': 'json',
|
||||
'error': function(){Alert('处理中出现问题,请重试');}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -94,4 +100,7 @@ $('#file_upload').uploadify({
|
|||
}
|
||||
});
|
||||
});
|
||||
function Alert(html){
|
||||
$.colorbox({'innerWidth':'50%','html':'<h4>'+html+'</h4>'});
|
||||
}
|
||||
</script>
|
|
@ -5,6 +5,9 @@
|
|||
$this->headLink()->appendStylesheet('/css/admin.css');
|
||||
$this->breadcrumb('<a href="/">首页</a>');
|
||||
$this->breadcrumb('<a href="/admin">后台首页</a>');
|
||||
$this->headScript()->appendFile('/static/js/jquery-1.7.2.min.js');
|
||||
$this->headScript()->appendFile('/js/jquery.colorbox-min.js');
|
||||
$this->headLink()->appendStylesheet('/css/colorbox.css');
|
||||
$this->breadcrumb('数据管理');
|
||||
$this->breadcrumb()->setSeparator(' > ');
|
||||
?>
|
||||
|
@ -44,18 +47,40 @@
|
|||
{
|
||||
if($v['filesize']<1048576) $v['filesize'] = round(($v['filesize']/1024),2).'KB'; else $v['filesize'] = round(($v['filesize']/1024/1024),2).'MB';
|
||||
echo '
|
||||
<tr>
|
||||
<tr id="att_'.$v['id'].'">
|
||||
<td>'.$v['realname'].'</td>
|
||||
<td>'.$v['filetype'].'</td>
|
||||
<td>'.$v['filesize'].'</td>
|
||||
<td>'.$v['downtimes'].'</td>
|
||||
<td>'.date('Y-m-d H:i:s',strtotime($v['ts_created'])).'</td>
|
||||
<td>
|
||||
<a href="/admin/data/attachments/" onclick="return confirm(\'是否确定删除该附件?\')">从此元数据中移除</a>
|
||||
<a href="javascript:;" onclick="delmdatt('.$v['id'].')">从此元数据中移除</a>
|
||||
<a href="/service/attach/id/'.$v['id'].'">下载</a>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
?>
|
||||
</tbody></table>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function delmdatt(id){
|
||||
$.ajax({
|
||||
'type': "POST",
|
||||
'url': "/admin/data/attachments/",
|
||||
'data': 'uuid=<?php echo $this->uuid?>&mdattdel='+id,
|
||||
'success': function(data){
|
||||
if(data==null){Alert('遇到错误,请重试');return false;}
|
||||
if(data.error!=null){Alert(data.error);return false;}
|
||||
if(data.status==1){$('#att_'+id).fadeOut("slow");}
|
||||
},
|
||||
'beforeSend':function(){},
|
||||
'complete':function(){},
|
||||
'timeout': 20000,
|
||||
'dataType': 'json',
|
||||
'error': function(){Alert('处理中出现问题,请重试');}
|
||||
});
|
||||
}
|
||||
function Alert(html){
|
||||
$.colorbox({'innerWidth':'50%','html':'<h4>'+html+'</h4>'});
|
||||
}
|
||||
</script>
|
Loading…
Reference in New Issue