/** * 创建图度 * * @param array $params * @return string|false */ public function createTudu(array $params) { if (empty($params['orgid']) || empty($params['boardid']) || empty($params['type']) || empty($params['from']) || empty($params['poster']) || empty($params['uniqueid']) || empty($params['email']) || !isset($params['subject']) || !isset($params['content'])) { $this->_message = 'missing params'; return false; } $attachment = array(); if (!empty($params['attachment']) && is_array($params['attachment'])) { foreach ($params['attachment'] as $item) { $attachment[] = array('fileid' => $item, 'isattach' => true); } unset($params['attachment']); } if (!empty($params['file']) && is_array($params['file'])) { foreach ($params['file'] as $item) { $attachment[] = array('fileid' => $item, 'isattach' => false); } unset($params['file']); } if (!empty($params['vote'])) { $params['special'] = Dao_Td_Tudu_Tudu::SPECIAL_VOTE; } $tuduId = isset($params['tuduid']) ? $params['tuduid'] : $this->_getTuduId(); $postId = $this->_getPostId($tuduId); $params['tuduid'] = $tuduId; $params['postid'] = $postId; $params['isfirst'] = true; // 处理周期任务 if (!empty($params['cycle'])) { $params['special'] = Dao_Td_Tudu_Tudu::SPECIAL_CYCLE; $daoCycle = new Dao_Td_Tudu_Cycle($this->_db); $cycleId = Dao_Td_Tudu_Cycle::getCycleId(); $params['cycle']['cycleid'] = $cycleId; if (!$daoCycle->createCycle($params['cycle'])) { $this->_message = 'create cycle fail'; return false; } $params['cycleid'] = $cycleId; } // 会议 if (!empty($params['meeting'])) { $params['meeting']['tuduid'] = $tuduId; $params['meeting']['orgid'] = $params['orgid']; $this->updateMeeting($params['meeting']); } if (!$this->_tuduDao->createTudu($params)) { $this->_message = 'create tudu fail'; return false; } unset($params['percent']); if (!$this->_postDao->createPost($params)) { $this->_tuduDao->deleteTudu($tuduId); $this->_message = 'create post fail'; return false; } if (!empty($params['vote'])) { $params['vote']['tuduid'] = $tuduId; $this->updateVote($params['vote']); } if (!empty($attachment)) { $this->addAttachment($tuduId, $postId, $attachment); } return $tuduId; }