Beispiel #1
0
 public function remove_question($question_id)
 {
     if (!($question_info = $this->get_question_info_by_id($question_id))) {
         return false;
     }
     $this->model('answer')->remove_answers_by_question_id($question_id);
     // 删除关联的回复内容
     // 删除评论
     $this->delete('question_comments', 'question_id = ' . intval($question_id));
     $this->delete('question_focus', 'question_id = ' . intval($question_id));
     $this->delete('question_thanks', 'question_id = ' . intval($question_id));
     $this->delete('topic_relation', "`type` = 'question' AND item_id = " . intval($question_id));
     // 删除话题关联
     $this->delete('question_invite', 'question_id = ' . intval($question_id));
     // 删除邀请记录
     $this->delete('question_uninterested', 'question_id = ' . intval($question_id));
     // 删除不感兴趣的
     ACTION_LOG::delete_action_history('associate_type = ' . ACTION_LOG::CATEGORY_QUESTION . ' AND associate_id = ' . intval($question_id));
     // 删除动作
     ACTION_LOG::delete_action_history('associate_type = ' . ACTION_LOG::CATEGORY_QUESTION . ' AND associate_action = ' . ACTION_LOG::ANSWER_QUESTION . ' AND associate_attached = ' . intval($question_id));
     // 删除动作
     ACTION_LOG::delete_action_history('associate_type = ' . ACTION_LOG::CATEGORY_TOPIC . ' AND associate_action = ' . ACTION_LOG::ADD_TOPIC . ' AND associate_attached = ' . intval($question_id));
     // 删除动作
     // 删除附件
     if ($attachs = $this->model('publish')->get_attach('question', $question_id)) {
         foreach ($attachs as $key => $val) {
             $this->model('publish')->remove_attach($val['id'], $val['access_key']);
         }
     }
     $this->model('notify')->delete_notify('model_type = 1 AND source_id = ' . intval($question_id));
     // 删除相关的通知
     $this->shutdown_update('users', array('question_count' => $this->count('question', 'published_uid = ' . intval($question_info['published_uid']))), 'uid = ' . intval($question_info['published_uid']));
     $this->delete('redirect', "item_id = " . intval($question_id) . " OR target_id = " . intval($question_id));
     $this->model('posts')->remove_posts_index($question_id, 'question');
     $this->delete('geo_location', "`item_type` = 'question' AND `item_id` = " . intval($question_id));
     $this->delete('question', 'question_id = ' . intval($question_id));
     if ($question_info['weibo_msg_id']) {
         if ($question_info['ticket_id']) {
             remove_assoc('weibo_msg', 'question', $question_info['question_id']);
         } else {
             $this->model('openid_weibo_weibo')->del_msg_by_id($question_info['weibo_msg_id']);
         }
     }
     if ($question_info['received_email_id']) {
         if ($question_info['ticket_id']) {
             remove_assoc('received_email', 'question', $question_info['question_id']);
         } else {
             $this->model('edm')->remove_received_email($question_info['received_email_id']);
         }
     }
     if ($question_info['ticket_id']) {
         remove_assoc('ticket', 'question', $question_info['question_id']);
     }
 }
Beispiel #2
0
 public function remove_ticket($id)
 {
     $ticket_info = $this->get_ticket_info_by_id($id);
     if (!$ticket_info) {
         return false;
     }
     $this->delete('ticket', 'id = ' . $ticket_info['id']);
     $this->delete('ticket_reply', 'ticket_id = ' . $ticket_info['id']);
     $this->delete('ticket_log', 'ticket_id = ' . $ticket_info['id']);
     $this->delete('ticket_invite', 'ticket_id = ' . $ticket_info['id']);
     $attachs = $this->model('publish')->get_attach('ticket', $ticket_info['id']);
     if ($attachs) {
         foreach ($attachs as $attach) {
             $this->model('publish')->remove_attach($attach['id'], $attach['access_key']);
         }
     }
     if ($ticket_info['weibo_msg_id']) {
         if ($ticket_info['question_id']) {
             remove_assoc('weibo_msg', 'ticket', $ticket_info['id']);
         } else {
             $this->model('openid_weibo_weibo')->del_msg_by_id($ticket_info['weibo_msg_id']);
         }
     }
     if ($ticket_info['received_email_id']) {
         if ($ticket_info['question_id']) {
             remove_assoc('received_email', 'ticket', $ticket_info['id']);
         } else {
             $this->model('edm')->remove_received_email($ticket_info['received_email_id']);
         }
     }
     if ($ticket_info['question_id']) {
         remove_assoc('question', 'ticket', $ticket_info['id']);
     }
     return true;
 }