增加了附件删除时是否为文献附件的判断,修改了附件操作方式
This commit is contained in:
parent
426d442bc7
commit
d53a234a26
|
@ -1255,6 +1255,9 @@ class Admin_DataController extends Zend_Controller_Action
|
||||||
|
|
||||||
else if($delete)
|
else if($delete)
|
||||||
{
|
{
|
||||||
|
$this->_helper->layout->disableLayout();
|
||||||
|
$this->_helper->viewRenderer->setNoRender();
|
||||||
|
|
||||||
|
|
||||||
//需要删除文件,通过Zend_Registry::get('upload')获得上传文件的根目录
|
//需要删除文件,通过Zend_Registry::get('upload')获得上传文件的根目录
|
||||||
|
|
||||||
|
@ -1273,8 +1276,9 @@ class Admin_DataController extends Zend_Controller_Action
|
||||||
|
|
||||||
if(count($rows)>0)
|
if(count($rows)>0)
|
||||||
{
|
{
|
||||||
$this->messenger->addMessage('删除失败!该文件有对应元数据附件信息,不能直接删除');
|
$data = array("error"=>'删除失败!该文件有元数据附件信息,不能直接删除',"status"=>0);
|
||||||
$this->_redirect("/admin/data/attachments/");
|
$this->jsonexit($data);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT * FROM mdreviewattach WHERE attachid=?";
|
$sql = "SELECT * FROM mdreviewattach WHERE attachid=?";
|
||||||
|
@ -1284,18 +1288,42 @@ class Admin_DataController extends Zend_Controller_Action
|
||||||
|
|
||||||
if(count($rows)>0)
|
if(count($rows)>0)
|
||||||
{
|
{
|
||||||
$this->messenger->addMessage('删除失败!该文件有对应评审附件信息,不能直接删除');
|
$data = array("error"=>'删除失败!该文件有对应评审附件信息,不能直接删除',"status"=>0);
|
||||||
$this->_redirect("/admin/data/attachments/");
|
$this->jsonexit($data);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$sql = "SELECT link FROM reference WHERE link!=''";
|
||||||
|
$sth = $this->db->prepare($sql);
|
||||||
|
$sth->execute();
|
||||||
|
$rows = $sth->fetchAll();
|
||||||
|
|
||||||
|
$ids = array();
|
||||||
|
foreach($rows as $k=>$v)
|
||||||
|
{
|
||||||
|
if(preg_match("/service/i",$v['link']))
|
||||||
|
{
|
||||||
|
$ids[] = str_replace("/service/attach/id/","",$v['link']);
|
||||||
|
}
|
||||||
|
unset($rows[$k]);
|
||||||
|
}
|
||||||
|
unset($rows);
|
||||||
|
|
||||||
|
if(in_array($delete,$ids))
|
||||||
|
{
|
||||||
|
$data = array("error"=>'删除失败!该文件有对应文献附件信息,不能直接删除',"status"=>0);
|
||||||
|
$this->jsonexit($data);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if(unlink($filepath))
|
if(unlink($filepath))
|
||||||
{
|
{
|
||||||
$sql = "delete from attachments where id='$delete'";
|
$sql = "delete from attachments where id='$delete'";
|
||||||
if($this->db->exec($sql)>0)
|
if($this->db->exec($sql)>0)
|
||||||
{
|
{
|
||||||
$this->messenger->addMessage('删除文件成功');
|
$data = array("status"=>1);
|
||||||
$this->_redirect("/admin/data/attachments/");
|
$this->jsonexit($data);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1303,8 +1331,9 @@ class Admin_DataController extends Zend_Controller_Action
|
||||||
$sql = "delete from attachments where id='$delete'";
|
$sql = "delete from attachments where id='$delete'";
|
||||||
if($this->db->exec($sql)>0)
|
if($this->db->exec($sql)>0)
|
||||||
{
|
{
|
||||||
$this->messenger->addMessage('文件删除失败,仅删除数据库记录,请手动删除文件:'.$info['filename']);
|
$data = array("error"=>'文件删除失败,仅删除数据库记录,请手动删除文件:'.$info['filename'],"status"=>0);
|
||||||
$this->_redirect("/admin/data/attachments/");
|
$this->jsonexit($data);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
$this->breadcrumb('<a href="/">首页</a>');
|
$this->breadcrumb('<a href="/">首页</a>');
|
||||||
$this->breadcrumb('<a href="/admin">后台首页</a>');
|
$this->breadcrumb('<a href="/admin">后台首页</a>');
|
||||||
$this->breadcrumb('数据管理');
|
$this->breadcrumb('数据管理');
|
||||||
|
$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()->setSeparator(' > ');
|
$this->breadcrumb()->setSeparator(' > ');
|
||||||
?>
|
?>
|
||||||
<div id="leftPanel">
|
<div id="leftPanel">
|
||||||
|
@ -37,43 +40,46 @@
|
||||||
|
|
||||||
<?php if (count($this->paginator)): ?>
|
<?php if (count($this->paginator)): ?>
|
||||||
<form method="get" action="/admin/data/md/att/1/addatts/1">
|
<form method="get" action="/admin/data/md/att/1/addatts/1">
|
||||||
<table>
|
<table class="stylized">
|
||||||
<thead><tr>
|
<thead><tr>
|
||||||
<?php
|
<?php
|
||||||
if(!empty($this->uuid))
|
if(!empty($this->uuid))
|
||||||
echo '<th width="40">选择</th>';
|
echo '<th width="40">选择</th>';
|
||||||
?>
|
?>
|
||||||
|
<th width="50">ID</th>
|
||||||
<th width='100'>上传文件名</th>
|
<th width='100'>上传文件名</th>
|
||||||
<th width='200'>描述</th>
|
|
||||||
<th width='80'>类型</th>
|
<th width='80'>类型</th>
|
||||||
<th width='80'>大小</th>
|
<th width='80'>大小</th>
|
||||||
<th width='80'>下载次数</th>
|
<th width='80'>下载次数</th>
|
||||||
<th width='150'>上传时间</th>
|
<th width='150'>上传时间</th>
|
||||||
<th width="150">操作</th>
|
<th width="150">操作</th>
|
||||||
</tr></thead>
|
</tr></thead>
|
||||||
<tbody>
|
<tbody id="list">
|
||||||
<?php $autoindex=0;?>
|
<?php $autoindex=0;?>
|
||||||
<?php foreach ($this->paginator as $item): ?>
|
<?php foreach ($this->paginator as $item): ?>
|
||||||
<?php $autoindex++;?>
|
<?php $autoindex++;?>
|
||||||
<tr class="<?php if($autoindex%2 == 0) echo 'even'; else echo 'odd'; ?>">
|
<tr id="att_<?php echo $item['id'];?>">
|
||||||
<?php
|
<?php
|
||||||
if(!empty($this->uuid))
|
if(!empty($this->uuid))
|
||||||
echo '<td><input type="checkbox" value="'.$item['id'].'" name="ids[]" /></td>';
|
echo '<td><input type="checkbox" value="'.$item['id'].'" name="ids[]" /></td>';
|
||||||
?>
|
?>
|
||||||
|
<td><?php echo $item['id'];?></td>
|
||||||
<td><?php echo $item['realname'] ;?></td>
|
<td><?php echo $item['realname'] ;?></td>
|
||||||
<td><?php echo $item['filedesc'] ;?></td>
|
|
||||||
<td><?php
|
<td><?php
|
||||||
if($item['filetype']=='image') echo '图片' ;
|
if($item['filetype']=='image') echo '图片' ;
|
||||||
if($item['filetype']=='file') echo '文件' ;
|
if($item['filetype']=='file') echo '文件' ;
|
||||||
if($item['filetype']=='media') echo '多媒体' ;
|
if($item['filetype']=='media') echo '多媒体' ;
|
||||||
if($item['filetype']=='reviewatt') echo '评审附件' ;
|
if($item['filetype']=='reviewatt') echo '评审附件' ;
|
||||||
|
if($item['filetype']=='md') echo "数据文件";
|
||||||
|
if($item['filetype']=='literature')echo "文献";
|
||||||
|
if($item['filetype']=='document') echo "文档";
|
||||||
?></td>
|
?></td>
|
||||||
<td><?php if($item['filesize']<1048576) echo round(($item['filesize']/1024),2).'KB'; else echo round(($item['filesize']/1024/1024),2).'MB'; ?></td>
|
<td><?php if($item['filesize']<1048576) echo round(($item['filesize']/1024),2).'KB'; else echo round(($item['filesize']/1024/1024),2).'MB'; ?></td>
|
||||||
<td><?= $item['downtimes']; ?></td>
|
<td><?= $item['downtimes']; ?></td>
|
||||||
<td><?= date('Y-m-d H:i:s',strtotime($item['ts_created'])); ?></td>
|
<td><?= date('Y-m-d H:i:s',strtotime($item['ts_created'])); ?></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="/admin/data/attachments/edit/<?= $item['id']; ?>">编辑</a> |
|
<a href="/admin/data/attachments/edit/<?= $item['id']; ?>">编辑</a> |
|
||||||
<a href="/admin/data/attachments/delete/<?= $item['id']; ?>" onclick="return confirm('是否确定删除该附件?')">删除</a> |
|
<a href="javascript:delatt(<?= $item['id']; ?>);" onclick="return confirm('是否确定删除该附件?')">删除</a> |
|
||||||
<a href="/admin/data/attachments/down/<?= $item['id']; ?>">下载</a>
|
<a href="/admin/data/attachments/down/<?= $item['id']; ?>">下载</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -87,4 +93,27 @@ echo '<input type="hidden" name="uuid" value="'.$this->uuid.'" /><input type="hi
|
||||||
</form>
|
</form>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<div class="pagenavi"><?= $this->paginator; ?></div>
|
<div class="pagenavi"><?= $this->paginator; ?></div>
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
function delatt(id){
|
||||||
|
$.ajax({
|
||||||
|
'type': "POST",
|
||||||
|
'url': "/admin/data/attachments/",
|
||||||
|
'data': 'delete='+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>'});
|
||||||
|
}
|
||||||
|
$("#list tr").mouseover(function(){$(this).addClass("high")}).mouseout(function(){$(this).removeClass("high")})
|
||||||
|
</script>
|
Loading…
Reference in New Issue