コード例 #1
0
 public function addResponse()
 {
     $db = new ResponseModel();
     import("ORG.Util.Input");
     $rs['w_id'] = $_POST['w_id'];
     $rs['r_text'] = Input::forShow($_POST['r_text']);
     $rs['r_time'] = date('Y-m-d H:i:s');
     $rs['r_ip'] = $_SESSION['user_ip'];
     if (empty($_SESSION['userName'])) {
         $rs['flag'] = 0;
     } else {
         $rs['flag'] = 1;
     }
     if (strlen($rs['r_text']) > 300) {
         //判断提交的内容是否超过100个汉字
         $s = floor((strlen($rs['r_text']) - 300) / 3);
         $_SESSION['r_text'] = $rs['r_text'];
         $this->gError("你的评论超出了" . $s . "个汉字,", "__URL__/viewWorlds?id=" . $rs['w_id']);
     } elseif ($db->add($rs)) {
         //判断是否添加成功
         $this->gSuccess("你的评论“" . $rs['r_text'] . "“发表成功!", "__URL__/viewWorlds?id=" . $rs['w_id']);
     } else {
         $this->gError("呃,服务器开小差了~~~稍后再试,", "__URL__/viewWorlds?id=" . $rs['w_id']);
     }
 }
コード例 #2
0
ファイル: ResponseModel.php プロジェクト: humansky/qframe
 function __construct($args = array())
 {
     if (!isset(self::$responseTable)) {
         self::$responseTable = QFrame_Db_Table::getTable('response');
     }
     if (!isset(self::$questionPromptTable)) {
         self::$questionPromptTable = QFrame_Db_Table::getTable('question_prompt');
     }
     $args = array_merge(array('questionID' => null, 'instanceID' => null, 'responseText' => null, 'additionalInfo' => null, 'privateNote' => null, 'externalReference' => null, 'state' => null, 'dbUserID' => -1), $args);
     if (isset($args['responseID'])) {
         $responseRows = self::$responseTable->fetchRows('responseID', intval($args['responseID']));
         foreach ($responseRows as $r) {
             if (!$r->responseEndDate) {
                 $this->responseRow = $r;
             }
         }
         // response row assertion
         if ($this->responseRow === NULL) {
             throw new Exception('Response not found');
         }
         $this->dirty = 0;
     } else {
         $this->responseRow = self::$responseTable->createRow();
         $this->responseRow->questionID = intval($args['questionID']);
         $this->responseRow->instanceID = intval($args['instanceID']);
         $this->responseRow->pageID = intval($args['pageID']);
         $this->responseRow->sectionID = intval($args['sectionID']);
         $this->responseRow->responseText = $args['responseText'];
         $this->responseRow->additionalInfo = $args['additionalInfo'];
         $this->responseRow->privateNote = $args['privateNote'];
         $this->responseRow->externalReference = $args['externalReference'];
         $this->responseRow->state = $args['state'];
         $this->responseRow->dbUserID = $args['dbUserID'];
         $this->dirty = 1;
     }
 }
コード例 #3
0
ファイル: PageHelpers.php プロジェクト: humansky/qframe
 /**
  * Return HTML for the private notes box
  *
  * @param  ResponseModel response in queston
  * @return string
  */
 public function privateNote(ResponseModel $response)
 {
     $builder = new Tag_Builder();
     $class = 'privateNote';
     if ($response->hasPrivateNote()) {
         $class .= ' hasContent';
         $content = $this->view->h($response->privateNote);
         $style = '';
     } else {
         $style = 'display: none;';
         $content = 'Enter private notes here';
     }
     $privNote = "<br/>private notes:<br/>\n";
     $privNote .= $this->view->formTextarea("q{$response->parent->questionID}_privateNote", $content, array('class' => $class, 'style' => $style));
     $privNote = $builder->span(array('class' => 'privateNote_main', 'style' => $style), $privNote);
     $privNoteMod = $this->view->formHidden("q{$response->parent->questionID}_privateNote_mod", 0);
     return $privNote . $privNoteMod;
 }