From edf2cfca6b14cc198c2f690810aa7140bda38045 Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Tue, 18 Sep 2012 09:14:41 +0000
Subject: [PATCH] =?UTF-8?q?#243=20=E5=B0=86=E8=AF=84=E8=AE=BA=E5=9B=9E?=
=?UTF-8?q?=E5=A4=8D=E4=B9=9F=E6=94=BE=E5=9C=A8=E8=AF=84=E8=AE=BA=E8=A1=A8?=
=?UTF-8?q?=E4=B8=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../admin/controllers/DataController.php | 84 ++++++++++---------
.../admin/views/scripts/data/comment.phtml | 6 +-
.../default/controllers/DataController.php | 6 +-
3 files changed, 49 insertions(+), 47 deletions(-)
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'])); ?>
。操作: 删除 回复]
@@ -56,12 +56,12 @@ EMAIL:= $item['email']; ?>
= $this->paginator; ?>