예제 #1
0
파일: Apply.php 프로젝트: bjtenao/tudu-web
 /**
  * 保存申请数据
  *
  * @param $data
  */
 public function onSave(Tudu_Model_Tudu_Entity_Tudu &$tudu, Tudu_Model_Tudu_Entity_Extension_Abstract $data)
 {
     /* @var $daoApply Dao_App_Attend_Apply */
     $daoApply = Tudu_Dao_Manager::getDao('Dao_App_Attend_Apply', Tudu_Dao_Manager::DB_APP);
     $params = $data->getAttributes();
     $params['tuduid'] = $tudu->tuduId;
     if (null !== ($apply = $daoApply->getApply(array('tuduid' => $tudu->tuduId)))) {
         if ($apply->status > 2) {
             $params['status'] = 1;
         }
         $ret = $daoApply->updateApply($apply->applyId, $params);
         $applyId = $apply->applyId;
     } else {
         $ret = $daoApply->createApply($params);
         $applyId = $ret;
     }
     $tudu->setAttribute('applyid', $applyId);
     if (!$ret) {
         require_once 'Tudu/Model/Tudu/Exception.php';
         throw new Tudu_Model_Tudu_Exception('Save apply failure');
     }
 }
예제 #2
0
 /**
  * 创建图度
  *
  * @param $tudu
  */
 public static function createTudu(Tudu_Model_Tudu_Entity_Tudu &$tudu)
 {
     $params = $tudu->getAttributes();
     $daoTudu = Tudu_Dao_Manager::getDao('Dao_Td_Tudu_Tudu', Tudu_Dao_Manager::DB_TS);
     $daoPost = Tudu_Dao_Manager::getDao('Dao_Td_Tudu_Post', Tudu_Dao_Manager::DB_TS);
     $params['to'] = !empty($params['to']) ? Tudu_Model_Entity_Tudu::formatReceiver($params['to']) : null;
     $params['cc'] = !empty($params['cc']) ? Tudu_Model_Entity_Tudu::formatReceiver($params['cc']) : null;
     $params['bcc'] = !empty($params['bcc']) ? Tudu_Model_Entity_Tudu::formatReceiver($params['bcc']) : null;
     $tuduId = $daoTudu->createTudu($params);
     if (!$tuduId) {
         require_once 'Tudu/Model/Tudu/Exception.php';
         throw new Tudu_Model_Tudu_Exception('Save tudu failed');
     }
     $post = array('orgid' => $params['orgid'], 'boardid' => $params['boardid'], 'tuduid' => $tuduId, 'uniqueid' => $params['uniqueid'], 'postid' => Dao_Td_Tudu_Post::getPostId(), 'poster' => $params['poster'], 'email' => $params['email'], 'content' => !empty($params['content']) ? $params['content'] : '', 'isfirst' => 1, 'issend' => 1);
     $attachments = $tudu->getAttachments();
     $attachNum = 0;
     foreach ($attachments as $attach) {
         if ($attach['isattach']) {
             $attachNum++;
         }
     }
     $post['attachnum'] = $attachNum;
     $postId = $daoPost->createPost($post);
     if (!$postId) {
         $daoTudu->deleteTudu($tuduId);
         require_once 'Tudu/Model/Tudu/Exception.php';
         throw new Tudu_Model_Tudu_Exception('Save tudu failed');
     }
     if (count($attachments) > 0) {
         $daoFile = Tudu_Dao_Manager::getDao('Dao_Td_Attachment_File', Tudu_Dao_Manager::DB_TS);
         foreach ($attachments as $attach) {
             $daoFile->addPost($tuduId, $postId, $attach['fileid'], (bool) $attach['isattach']);
         }
     }
     $output['tuduid'] = $tuduId;
     $tudu->setAttribute(array('tuduid' => $tuduId, 'postid' => $post['postid']));
     return $tuduId;
 }