Ticket #204 完善了数据评审意见发布的功能

This commit is contained in:
Li Jianxuan 2011-10-17 03:22:00 +00:00
parent 69502b9a80
commit 489f6cbc50
2 changed files with 79 additions and 23 deletions

View File

@ -274,30 +274,33 @@ class ReviewController extends Zend_Controller_Action
$submit = $this->_request->getParam('submit'); $submit = $this->_request->getParam('submit');
$conclusion = $this->_request->getParam('conclusion');
$mdcomment = $this->replace(trim($this->_request->getParam('mdcomment')));
$datacomment = $this->replace(trim($this->_request->getParam('datacomment')));
$editorcomment = $this->replace(trim($this->_request->getParam('editorcomment')));
if(!empty($submit)){ if(!empty($submit)){
$redirectlink='/review/review/uuid/'.$uuid; $redirectlink='/review/review/uuid/'.$uuid.'/';
$auth = Zend_Auth::getInstance(); $auth = Zend_Auth::getInstance();
if($auth->hasIdentity()) if($auth->hasIdentity())
{ {
$user = $auth->getIdentity(); $user = $auth->getIdentity();
$userid = $user->id; $userid = $user->id;
$sql = "select id,userid from mdreview where userid='$userid'";
$rs = $this->db->query($sql);
$row = $rs->fetch();
if($row['id']!='')
{
$this->messenger->addMessage('您已经对该元数据发表过评审了');
$this->_redirect($redirectlink);
}
}else{ }else{
$this->messenger->addMessage('读取用户信息失败,请刷新页面后重试 :('); $this->messenger->addMessage('读取用户信息失败,请刷新页面后重试 :(');
$this->_redirect($redirectlink); $this->_redirect($redirectlink);
} }
$conclusion = $this->_request->getParam('conclusion');
$mdcomment = $this->replace(trim($this->_request->getParam('mdcomment')));
$datacomment = $this->replace(trim($this->_request->getParam('datacomment')));
$editorcomment = $this->replace(trim($this->_request->getParam('editorcomment')));
$this->view->conclusion = $_POST['conclusion'];
$this->view->mdcomment = $mdcomment;
$this->view->datacomment = $datacomment;
$this->view->editorcomment = $editorcomment;
if(empty($conclusion)) if(empty($conclusion))
{ {
$this->messenger->addMessage('请选择评审意见'); $this->messenger->addMessage('请选择评审意见');
@ -313,7 +316,7 @@ class ReviewController extends Zend_Controller_Action
$this->messenger->addMessage('请填写元数据意见后再发布 :('); $this->messenger->addMessage('请填写元数据意见后再发布 :(');
$this->_redirect($redirectlink); $this->_redirect($redirectlink);
} }
if(!empty($_FILES['Filedata'])) if(!empty($_FILES['Filedata']['name']))
{ {
$files=new files(); $files=new files();
$msg = $files -> upload(Zend_Registry::get('upload'),$_FILES['Filedata'],$_POST['dir']); $msg = $files -> upload(Zend_Registry::get('upload'),$_FILES['Filedata'],$_POST['dir']);
@ -328,7 +331,9 @@ class ReviewController extends Zend_Controller_Action
$sql = "insert into attachments (filename,filetype,filedesc,userid,filesize) values ('$filename','$filetype','$filedesc','$userid','$filesize') RETURNING id"; $sql = "insert into attachments (filename,filetype,filedesc,userid,filesize) values ('$filename','$filetype','$filedesc','$userid','$filesize') RETURNING id";
$sth = $this->db->prepare($sql); $sth = $this->db->prepare($sql);
$sth->execute(); $sth->execute();
$temp = $sth->fetch(); $att = $sth->fetch(PDO::FETCH_ASSOC);
$attid = $att['id'];
}else{ }else{
$this->messenger->addMessage('附件上传失败:'.$msg['error']); $this->messenger->addMessage('附件上传失败:'.$msg['error']);
@unlink($filename); @unlink($filename);
@ -336,7 +341,60 @@ class ReviewController extends Zend_Controller_Action
} }
} }
$sql = ""; try{
$sql = "select id from mdexperts where id='$userid'";
$rs = $this->db->query($sql);
$row = $rs->fetch();
$data = array(
'userid' => $userid,
'uuid' => $uuid,
'mdcomment' => $mdcomment,
'ts_created' => 'now()',
'datacomment' => $datacomment,
'editorcomment' => $editorcomment,
'conclusion' => $conclusion
);
if($row['id']!='')
{
$data['is_expert'] = 'true';
}
$keys = array();
$values = array();
foreach ($data as $k=>$v)
{
$keys[]=$k;
$values[]=$v;
}
$keys = join(",",$keys);
$values = "'".join("','",$values)."'";
$sql = "insert into mdreview ($keys) values ($values) RETURNING id";
$sth = $this->db->prepare($sql);
$sth->execute();
$review = $sth->fetch(PDO::FETCH_ASSOC);
$reviewid=$review['id'];
if(!empty($_FILES['Filedata']['name']))
{
$sql = "insert into mdreviewattach (attachid,reviewid) values ('$attid','$reviewid')";
$this->db->exec($sql);
}
$this->messenger->addMessage('提交成功');
$this->_redirect($redirectlink);
}catch (Exception $e){
$this->messenger->addMessage('提交失败,请重试'.$sql.'aa'.$review['id'].$e->getMessage());
$this->_redirect($redirectlink);
}
} }
}//reviewAction() }//reviewAction()

View File

@ -36,8 +36,7 @@
if($auth->hasIdentity()) if($auth->hasIdentity())
{ {
?> ?>
<form method="post" id="postcomment" action="/review/review"> <form id="postcomment" action="/review/review/uuid/<?php echo $md['uuid'];?>" method="POST" enctype='multipart/form-data'>
<input type="hidden" name="uuid" value="<?php echo $md['uuid'];?>" />
<input type="hidden" name="submit" value="1" /> <input type="hidden" name="submit" value="1" />
<p> <p>
评审意见(必选)<br /> 评审意见(必选)<br />
@ -48,7 +47,7 @@
</p> </p>
<p> <p>
元数据意见(必填)<br/> 元数据意见(必填)<br/>
<textarea id="mdcomment" class="medium half" name="mdcomment"><?php echo $this->mdcomment;?></textarea> <textarea id="mdcomment" class="medium half" name="mdcomment"><?php echo $this->keyword.$this->mdcomment;?></textarea>
</p> </p>
<p> <p>
对数据的意见:<br/> 对数据的意见:<br/>
@ -60,13 +59,12 @@
</p> </p>
<p> <p>
评审附件:<br/> 评审附件:<br/>
<input type="file" name="Filedata" class="half" /> <select name="dir" style="width:100px;">
<select name="dir" style="width:100px;float:left;">
<option value="file">文件</option> <option value="file">文件</option>
<option value="image">图片</option> <option value="image">图片</option>
<option value="media">媒体</option> <option value="media">媒体</option>
</select> </select>
<input type="file" name="Filedata" class="half" />
</p> </p>
<p> <p>
<input id="submit" type="submit" value="提交" class="btn" onclick="return confirm('是否确定提交评审意见?')" /> <input id="submit" type="submit" value="提交" class="btn" onclick="return confirm('是否确定提交评审意见?')" />