diff --git a/application/admin/controllers/DataController.php b/application/admin/controllers/DataController.php index a1f9b1d8..9e881ed6 100755 --- a/application/admin/controllers/DataController.php +++ b/application/admin/controllers/DataController.php @@ -564,6 +564,7 @@ class Admin_DataController extends Zend_Controller_Action /* * commentAction() * 反馈管理 + * ALTER TABLE comments ADD COLUMN reply integer NOT NULL DEFAULT 0; */ function commentAction() { @@ -584,6 +585,44 @@ class Admin_DataController extends Zend_Controller_Action } $this->_redirect("/admin/data/comment"); } + + if($reply) + { + + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + + $body = $this->_getParam('content'); + if(empty($body)) + { + $data = array('error'=>"请输入回复内容"); + $this->jsonexit($data); + return true; + } + + $auth = Zend_Auth::getInstance(); + if($auth->hasIdentity()) + { + $user = $auth->getIdentity(); + $uid = $user->id; + } + + $sql = "INSERT INTO comments (uuid,author,reply,userid,content) VALUES (?,?,?,?,?)"; + $sth = $this->db->prepare($sql); + $rs = $sth->execute(array($uuid,$user->username,$reply,$uid,$body)); + + if($rs) + { + $data = array('status'=>1,'msg'=>'回复成功!'); + $this->jsonexit($data); + return true; + }else{ + $data = array('error'=>"回复失败,请重试"); + $this->jsonexit($data); + return true; + } + return true; + } if($uuid) { @@ -611,51 +650,13 @@ class Admin_DataController extends Zend_Controller_Action return true; } - if($reply) - { - - $this->_helper->layout->disableLayout(); - $this->_helper->viewRenderer->setNoRender(); - - $body = $this->_getParam('content'); - if(empty($body)) - { - $data = array('error'=>"请输入回复内容"); - $this->jsonexit($data); - return true; - } - - $auth = Zend_Auth::getInstance(); - if($auth->hasIdentity()) - { - $user = $auth->getIdentity(); - $uid = $user->id; - } - - $sql = "INSERT INTO comments_reply (cid,uid,body) VALUES (?,?,?)"; - $sth = $this->db->prepare($sql); - $rs = $sth->execute(array($reply,$uid,$body)); - - if($rs) - { - $data = array('status'=>1,'msg'=>'回复成功!'); - $this->jsonexit($data); - return true; - }else{ - $data = array('error'=>"回复失败,请重试"); - $this->jsonexit($data); - return true; - } - - } - if($replylist) { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); - $sql = "SELECT cr.id,cr.body,cr.cid,u.username,cr.ts_created FROM comments_reply cr - LEFT JOIN users u ON cr.uid=u.id WHERE cid=?"; + $sql = "SELECT cr.id,cr.content as body,cr.reply,u.username,cr.ts_created FROM comments cr + LEFT JOIN users u ON cr.userid=u.id WHERE cr.reply=?"; $sth = $this->db->prepare($sql); $sth->execute(array($replylist)); $rows = $sth->fetchAll(); @@ -670,7 +671,7 @@ class Admin_DataController extends Zend_Controller_Action $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); - $sql = "DELETE FROM comments_reply WHERE id=?"; + $sql = "DELETE FROM comments WHERE id=?"; $sth = $this->db->prepare($sql); $rs = $sth->execute(array($delreply)); @@ -695,6 +696,7 @@ class Admin_DataController extends Zend_Controller_Action $select=$this->db->select(); $select->from('comments') ->joinLeft('metadata','metadata.uuid=comments.uuid','title') + ->where('reply=0') ->order('comments.ts_created desc') ->order('comments.id desc'); $paginator = Zend_Paginator::factory($select); diff --git a/application/admin/views/scripts/data/comment.phtml b/application/admin/views/scripts/data/comment.phtml index ea8890a5..68e17add 100644 --- a/application/admin/views/scripts/data/comment.phtml +++ b/application/admin/views/scripts/data/comment.phtml @@ -40,7 +40,7 @@ EMAIL:= $item['email']; ?> [类型:= $item['type']; ?>,创建时间:= date('Y-m-d',strtotime($item['ts_created'])); ?> 。操作: 删除 回复]