diff --git a/application/admin/controllers/DataController.php b/application/admin/controllers/DataController.php index f99a2177..c10cf6df 100755 --- a/application/admin/controllers/DataController.php +++ b/application/admin/controllers/DataController.php @@ -1255,6 +1255,9 @@ class Admin_DataController extends Zend_Controller_Action else if($delete) { + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + //需要删除文件,通过Zend_Registry::get('upload')获得上传文件的根目录 @@ -1273,8 +1276,9 @@ class Admin_DataController extends Zend_Controller_Action if(count($rows)>0) { - $this->messenger->addMessage('删除失败!该文件有对应元数据附件信息,不能直接删除'); - $this->_redirect("/admin/data/attachments/"); + $data = array("error"=>'删除失败!该文件有元数据附件信息,不能直接删除',"status"=>0); + $this->jsonexit($data); + return true; } $sql = "SELECT * FROM mdreviewattach WHERE attachid=?"; @@ -1284,18 +1288,42 @@ class Admin_DataController extends Zend_Controller_Action if(count($rows)>0) { - $this->messenger->addMessage('删除失败!该文件有对应评审附件信息,不能直接删除'); - $this->_redirect("/admin/data/attachments/"); + $data = array("error"=>'删除失败!该文件有对应评审附件信息,不能直接删除',"status"=>0); + $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)) { $sql = "delete from attachments where id='$delete'"; if($this->db->exec($sql)>0) { - $this->messenger->addMessage('删除文件成功'); - $this->_redirect("/admin/data/attachments/"); + $data = array("status"=>1); + $this->jsonexit($data); + return true; } } else @@ -1303,8 +1331,9 @@ class Admin_DataController extends Zend_Controller_Action $sql = "delete from attachments where id='$delete'"; if($this->db->exec($sql)>0) { - $this->messenger->addMessage('文件删除失败,仅删除数据库记录,请手动删除文件:'.$info['filename']); - $this->_redirect("/admin/data/attachments/"); + $data = array("error"=>'文件删除失败,仅删除数据库记录,请手动删除文件:'.$info['filename'],"status"=>0); + $this->jsonexit($data); + return true; } } diff --git a/application/admin/views/scripts/data/attachments.phtml b/application/admin/views/scripts/data/attachments.phtml index c2113549..6f407d48 100644 --- a/application/admin/views/scripts/data/attachments.phtml +++ b/application/admin/views/scripts/data/attachments.phtml @@ -6,6 +6,9 @@ $this->breadcrumb('首页'); $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(' > '); ?>