コード例 #1
0
    /**
     * 终止(取消)任务
     */
    public function cancelAction()
    {
        $tuduId = $this->_request->getParam('tid');
        // 参数:图度ID必须存在
        if (!$tuduId) {
            return $this->json(false, $this->lang['invalid_tuduid']);
        }
        $tudu = $this->manager->getTuduById($tuduId, $this->_user->uniqueId);
        // 图度必须存在
        if (null == $tudu) {
            return $this->json(false, $this->lang['tudu_not_exists']);
        }
        // 图度不能是已确定状态
        if ($tudu->isDone) {
            return $this->json(false, $this->lang['tudu_is_done']);
        }
        // 操作人必须为图度发起人
        if ($tudu->sender != $this->_user->userName) {
            return $this->json(false, $this->lang['perm_deny_cancel_tudu']);
        }
        // 执行终止(取消)操作
        $ret = $this->manager->cancelTudu($tuduId, true, '', $tudu->parentId);
        if (!$ret) {
            return $this->json(false, $this->lang['']);
        }
        // 添加操作日志
        $this->_writeLog(Dao_Td_Log_Log::TYPE_TUDU, $tuduId, Dao_Td_Log_Log::ACTION_TUDU_CANCEL, array('accepttime' => null, 'status' => Dao_Td_Tudu_Tudu::STATUS_CANCEL, 'isdone' => true, 'score' => ''));
        $config = $this->bootstrap->getOption('httpsqs');
        // 插入消息队列
        $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' => 'cancel'))));
        // 发送取消通知
        if ($tudu->type == 'meeting') {
            $tpl = <<<HTML
<strong>会议已取消</strong><br />
<a href="http://{$this->_request->getServer('HTTP_HOST')}/frame#m=view&tid=%s&page=1" target="_blank">%s</a><br />
发起人:{$tudu->from[0]}<br />
%s
HTML;
            $data = implode(' ', array('tudu', 'cancel', '', http_build_query(array('tuduid' => $tuduId, 'from' => $tudu->from[3], 'to' => implode(',', $tudu->accepter), 'content' => sprintf($tpl, $tudu->tuduId, $tudu->subject, date('Y-m-d H:i:s', time()), mb_substr(strip_tags($tudu->content), 0, 20, 'utf-8'))))));
            $httpsqs->put($data, 'im');
        }
        $httpsqs->put($data, 'send');
        return $this->json(true, $this->lang['cancel_success']);
    }