Esempio n. 1
0
 /**
  * 完成 (确认)图度
  */
 public function doneAction()
 {
     $tuduIds = explode(',', $this->_request->getParam('tid'));
     $isDone = (bool) $this->_request->getParam('isdone');
     $score = (int) $this->_request->getParam('score');
     // 参数:图度ID必须存在
     if (!count($tuduIds)) {
         return $this->json(false, $this->lang['invalid_tuduid']);
     }
     $success = 0;
     //用于计数操作成功个数
     foreach ($tuduIds as $tuduId) {
         // 获得图度数据
         $tudu = $this->manager->getTuduById($tuduId, $this->_user->uniqueId);
         // 图度必须存在
         if (null == $tudu) {
             continue;
         }
         // 图度不能是已确定状态
         if ($tudu->isDone && $isDone) {
             continue;
         }
         // 操作人必须为图度发起人
         if ($tudu->sender != $this->_user->userName) {
             continue;
         }
         // 图度不能是“未开始”,“进行中”等状态
         if (($tudu->type != 'task' || $tudu->status < 2) && $isDone) {
             continue;
         }
         if (!$isDone) {
             $score = 0;
         }
         // 执行确认/取消确认图度操作
         $ret = $this->manager->doneTudu($tuduId, $isDone, $score, false, $tudu->parentId != null, $tudu->type);
         if ($ret) {
             $success++;
             $config = $this->bootstrap->getOption('httpsqs');
             if ($isDone) {
                 // 插入消息队列
                 $httpsqs = new Oray_Httpsqs($config['host'], $config['port'], $config['chartset'], $config['name']);
                 // 发送外部邮件(如果有),处理联系人
                 $data = implode(' ', array('send', 'tudu', '', http_build_query(array('tsid' => $this->_user->tsId, 'tuduid' => $tuduId, 'uniqueid' => $this->_user->uniqueId, 'to' => '', 'act' => 'confirm'))));
                 $httpsqs->put($data, 'send');
             }
             // 添加操作日志
             $this->_writeLog(Dao_Td_Log_Log::TYPE_TUDU, $tuduId, $isDone ? Dao_Td_Log_Log::ACTION_TUDU_DONE : Dao_Td_Log_Log::ACTION_TUDU_UNDONE, array('isdone' => $isDone, 'score' => $score));
         }
     }
     if ($success <= 0) {
         return $this->json(false, $this->lang['state_failure']);
     }
     return $this->json(true, $this->lang['state_success']);
 }