fix bug #81. 修复登录用户不能留言的问题
This commit is contained in:
parent
64e4616cab
commit
125d2d97ce
|
@ -557,16 +557,11 @@ class DataController extends Zend_Controller_Action
|
|||
$user=Zend_Auth::getInstance()->getIdentity();
|
||||
$commentForm=new CommentForm();
|
||||
$formdata['uuid']=$uuid;
|
||||
$formdata['id']=0;//用户ID,默认为0,即未登录用户
|
||||
$formdata['uid']=0;//用户ID,默认为0,即未登录用户
|
||||
$this->view->addHelperPath('helper','Zend_View_Helper_');
|
||||
if ($this->_request->isPost()) {
|
||||
include_once("bcspamblock.php");
|
||||
$formdata=$this->_request->getPost();
|
||||
if ($user) {
|
||||
$formdata['id']=$user->id;
|
||||
$formdata['author']=$user->username;
|
||||
$formdata['email']=$user->email;
|
||||
}
|
||||
if (bcspamblock_verify() && $commentForm->isValid($formdata)) {
|
||||
$sql="insert into comments (userid,uuid,author,email,url,ip,content,agent,type) values(?,?,?,?,?,?,?,?,?)";
|
||||
$agent=$this->_request->getHeader('User-Agent');
|
||||
|
@ -575,12 +570,11 @@ class DataController extends Zend_Controller_Action
|
|||
$stripper = new Zend_Filter_StripTags('strong');//剔除特殊字符HTML
|
||||
$content=$stripper->filter($formdata['content']);
|
||||
$author=$stripper->filter($formdata['author']);
|
||||
$this->db->query($sql,array($formdata['id'],$formdata['uuid'],$author,$formdata['email'],$formdata['url'],$ip,$content,$agent,$type));
|
||||
$this->db->query($sql,array($formdata['uid'],$formdata['uuid'],$author,$formdata['email'],$formdata['url'],$ip,$content,$agent,$type));
|
||||
$formdata['content']='';
|
||||
}
|
||||
}
|
||||
if ($user) {
|
||||
$formdata['id']=$user->id;
|
||||
} elseif ($user) {
|
||||
$formdata['uid']=$user->id;
|
||||
$formdata['author']=$user->username;
|
||||
$formdata['email']=$user->email;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ class CommentForm extends Zend_Form
|
|||
$spam->addPrefixPath('Validator','validator/','validate')
|
||||
->addValidator('SpamBlock');
|
||||
|
||||
$id = new Zend_Form_Element_Hidden('id');
|
||||
$uid = new Zend_Form_Element_Hidden('uid');
|
||||
$uuid = new Zend_Form_Element_Hidden('uuid');
|
||||
|
||||
$redirect=new Zend_Form_Element_Hidden('redirect');
|
||||
|
@ -35,8 +35,7 @@ class CommentForm extends Zend_Form
|
|||
$submit = new Zend_Form_Element_Submit('submit');
|
||||
$submit->setLabel('评论');
|
||||
$submit->setAttrib('id', 'commentbutton');
|
||||
$this->addElements(array($author,$email, $url, $spam, $content, $submit,$id, $uuid));
|
||||
|
||||
$this->addElements(array($author,$email, $url, $spam, $content, $submit,$uid, $uuid));
|
||||
$this->clearDecorators();
|
||||
$this->addDecorator('FormElements')
|
||||
->addDecorator('HtmlTag', array('tag' => '<ul>','class'=>'commentform'))
|
||||
|
|
Loading…
Reference in New Issue