コード例 #1
0
ファイル: MarkController.php プロジェクト: sanzhumu/nextwind
 public function domarkAction()
 {
     list($_credits, $tid, $pid, $reason, $isreply) = $this->getInput(array('credits', 'tid', 'pid', 'reason', 'isreply'), 'post');
     if (!$_credits) {
         $this->showError('还未添加评分哦');
     }
     if (!$reason) {
         $this->showError('请输入评分理由');
     }
     $credits = array();
     foreach ($_credits as $k => $v) {
         $v && ($credits[$k] = $v);
     }
     //检查权限
     if (($result = $this->_checkMarkRight($tid, $pid)) instanceof PwError) {
         $this->showError($result->getError());
     }
     //检查积分权限
     if (($result = $this->_checkMarkCreditsRight($credits)) instanceof PwError) {
         $this->showError($result->getError());
     }
     // 积分处理
     if (($info = $this->setCredits($credits, $tid, $pid)) instanceof PwError) {
         $this->showError($info->getError());
     }
     Wind::import('EXT:mark.service.dm.App_Mark_RecordDm');
     $newIds = array();
     foreach ($credits as $k => $v) {
         $dm = new App_Mark_RecordDm();
         $dm->setTid($tid)->setPid($pid)->setCreatedUserid($this->loginUser->uid)->setCreatedUsername($this->loginUser->username)->setPingUserid($info['created_userid'])->setReason($reason)->setCtype($k)->setCnum($v);
         if (($result = $this->_getDs()->addRecord($dm)) instanceof PwError) {
             $this->showError($result->getError());
         }
         $result && is_numeric($result) && ($newIds[] = $result);
     }
     // 回复帖子
     if ($isreply) {
         Wind::import('SRV:forum.srv.PwPost');
         Wind::import('SRV:forum.srv.post.PwReplyPost');
         $rpid = $pid ? $pid : 0;
         $pwPost = new PwPost(new PwReplyPost($tid, $this->loginUser));
         $postDm = $pwPost->getDm();
         $postDm->setContent($reason)->setReplyPid($rpid);
         $pwPost->execute($postDm);
     }
     // 更新帖子
     $this->_updateThreadAddMark($credits, $newIds, $info);
     $this->showMessage('success');
 }
コード例 #2
0
ファイル: App_Mark_Record.php プロジェクト: sanzhumu/nextwind
 /**
  * 编辑
  *
  * @param int $id
  * @param App_Mark_RecordDm $dm
  * @return array 
  */
 public function updateRecord($id, App_Mark_RecordDm $dm)
 {
     if (($result = $dm->beforeUpdate()) instanceof PwError) {
         return $result;
     }
     return $this->_getRecordDao()->update($id, $dm->getData());
 }