コード例 #1
0
ファイル: ajax.php プロジェクト: chenruixuan/wecenter
 public function questions_list_action()
 {
     if ($_GET['feature_id']) {
         $topic_ids = $this->model('feature')->get_topics_by_feature_id($_GET['feature_id']);
         if ($topic_ids) {
             $answers = $this->model('reader')->fetch_answers_list_by_topic_ids($topic_ids, $_GET['page'], 20);
         }
     } else {
         $answers = $this->model('reader')->fetch_answers_list($_GET['page'], 20);
     }
     $output = array();
     if ($answers) {
         foreach ($answers as $key => $val) {
             $question_ids[$val['question_id']] = $val['question_id'];
             $uids[$val['uid']] = $val['uid'];
         }
         $questions_info = $this->model('question')->get_question_info_by_ids($question_ids);
         $question_topics = $this->model('topic')->get_topics_by_item_ids($question_ids, 'question');
         $users_info = $this->model('account')->get_user_info_by_uids($uids, TRUE);
         foreach ($answers as $key => $val) {
             $output['answers'][$val['answer_id']] = array('answer_id' => $val['answer_id'], 'question_id' => $val['question_id'], 'avatar' => get_avatar_url($val['uid'], 'mid'), 'user_name' => $users_info[$val['uid']]['user_name'], 'signature' => $users_info[$val['uid']]['signature'], 'agree_count' => $val['agree_count'], 'agree_users' => $this->model('answer')->get_vote_user_by_answer_id($val['answer_id']), 'answer_content' => FORMAT::parse_attachs(nl2br(FORMAT::parse_markdown($val['answer_content']))), 'add_time' => date_friendly($val['add_time']), 'uid' => $val['uid']);
         }
         foreach ($questions_info as $key => $val) {
             $output['questions'][$val['question_id']] = array('question_id' => $val['question_id'], 'question_content' => $val['question_content'], 'question_detail' => FORMAT::parse_attachs(nl2br(FORMAT::parse_markdown($val['question_detail']))), 'answer_users' => $val['answer_users'], 'focus_count' => $val['focus_count'], 'view_count' => $val['view_count'], 'topics' => $question_topics[$val['question_id']]);
         }
     }
     echo json_encode($output);
 }
コード例 #2
0
ファイル: ajax.php プロジェクト: tenstone/wecenter
 public function save_answer_action()
 {
     if ($this->user_info['integral'] < 0 and get_setting('integral_system_enabled') == 'Y') {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('你的剩余积分已经不足以进行此操作')));
     }
     if (!($question_info = $this->model('question')->get_question_info_by_id($_POST['question_id']))) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('问题不存在')));
     }
     if ($question_info['lock'] and !($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'])) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('已经锁定的问题不能回复')));
     }
     $answer_content = trim($_POST['answer_content'], "\r\n\t");
     if (!$answer_content) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('请输入回复内容')));
     }
     // 判断是否是问题发起者
     if (get_setting('answer_self_question') == 'N' and $question_info['published_uid'] == $this->user_id) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('不能回复自己发布的问题,你可以修改问题内容')));
     }
     // 判断是否已回复过问题
     if (get_setting('answer_unique') == 'Y' and $this->model('answer')->has_answer_by_uid($question_info['question_id'], $this->user_id)) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('一个问题只能回复一次,你可以编辑回复过的回复')));
     }
     if (strlen($answer_content) < get_setting('answer_length_lower')) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('回复内容字数不得少于 %s 字节', get_setting('answer_length_lower'))));
     }
     if (!$this->user_info['permission']['publish_url'] and FORMAT::outside_url_exists($answer_content)) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('你所在的用户组不允许发布站外链接')));
     }
     if (!$this->model('publish')->insert_attach_is_self_upload($answer_content, $_POST['attach_ids'])) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('只允许插入当前页面上传的附件')));
     }
     if (human_valid('answer_valid_hour') and !AWS_APP::captcha()->is_validate($_POST['seccode_verify'])) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('请填写正确的验证码')));
     }
     // !注: 来路检测后面不能再放报错提示
     if (!valid_post_hash($_POST['post_hash'])) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('页面停留时间过长,或内容已提交,请刷新页面')));
     }
     $this->model('draft')->delete_draft($question_info['question_id'], 'answer', $this->user_id);
     if ($this->publish_approval_valid($answer_content)) {
         $this->model('publish')->publish_approval('answer', array('question_id' => $question_info['question_id'], 'answer_content' => $answer_content, 'anonymous' => $_POST['anonymous'], 'attach_access_key' => $_POST['attach_access_key'], 'auto_focus' => $_POST['auto_focus']), $this->user_id, $_POST['attach_access_key']);
         H::ajax_json_output(AWS_APP::RSM(array('url' => get_js_url('/publish/wait_approval/question_id-' . $question_info['question_id'] . '__is_mobile-' . $_POST['_is_mobile'])), 1, null));
     } else {
         $answer_id = $this->model('publish')->publish_answer($question_info['question_id'], $answer_content, $this->user_id, $_POST['anonymous'], $_POST['attach_access_key'], $_POST['auto_focus']);
         if ($_POST['_is_mobile']) {
             //$url = get_js_url('/m/question/id-' . $question_info['question_id'] . '__item_id-' . $answer_id . '__rf-false');
             $this->model('answer')->set_answer_publish_source($answer_id, 'mobile');
         } else {
             //$url = get_js_url('/question/' . $question_info['question_id'] . '?item_id=' . $answer_id . '&rf=false');
         }
         $answer_info = $this->model('answer')->get_answer_by_id($answer_id);
         if ($answer_info['has_attach']) {
             $answer_info['attachs'] = $this->model('publish')->get_attach('answer', $answer_id, 'min');
             $answer_info['insert_attach_ids'] = FORMAT::parse_attachs($answer_info['answer_content'], true);
         }
         $answer_info['user_info'] = $this->user_info;
         $answer_info['answer_content'] = $this->model('question')->parse_at_user(FORMAT::parse_attachs(nl2br(FORMAT::parse_bbcode($answer_info['answer_content']))));
         TPL::assign('answer_info', $answer_info);
         if (is_mobile()) {
             H::ajax_json_output(AWS_APP::RSM(array('ajax_html' => TPL::output('m/ajax/question_answer', false)), 1, null));
         } else {
             H::ajax_json_output(AWS_APP::RSM(array('ajax_html' => TPL::output('question/ajax/answer', false)), 1, null));
         }
     }
 }
コード例 #3
0
 public function index_action()
 {
     if (!($question_info = $this->model('question')->get_question_info_by_id($_GET['id']))) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('问题不存在或已被删除')));
     }
     if (!$_GET['sort'] or $_GET['sort'] != 'ASC') {
         $_GET['sort'] = 'DESC';
     } else {
         $_GET['sort'] = 'ASC';
     }
     if (get_setting('unfold_question_comments') == 'Y') {
         $_GET['comment_unfold'] = 'all';
     }
     $question_info['redirect'] = $this->model('question')->get_redirect($question_info['question_id']);
     if ($question_info['redirect']['target_id']) {
         $target_question = $this->model('question')->get_question_info_by_id($question_info['redirect']['target_id']);
     }
     if (is_digits($_GET['rf']) and $_GET['rf']) {
         if ($from_question = $this->model('question')->get_question_info_by_id($_GET['rf'])) {
             $redirect_message[] = AWS_APP::lang()->_t('从问题 %s 跳转而来', '<a href="' . get_js_url('/question/' . $_GET['rf'] . '?rf=false') . '">' . $from_question['question_content'] . '</a>');
         }
     }
     if ($question_info['redirect'] and !$_GET['rf']) {
         if ($target_question) {
             HTTP::redirect('/question/' . $question_info['redirect']['target_id'] . '?rf=' . $question_info['question_id']);
         } else {
             $redirect_message[] = AWS_APP::lang()->_t('重定向目标问题已被删除, 将不再重定向问题');
         }
     } else {
         if ($question_info['redirect']) {
             if ($target_question) {
                 $message = AWS_APP::lang()->_t('此问题将跳转至') . ' <a href="' . get_js_url('/question/' . $question_info['redirect']['target_id'] . '?rf=' . $question_info['question_id']) . '">' . $target_question['question_content'] . '</a>';
                 if ($this->user_id and ($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'] or !$this->question_info['lock'] and $this->user_info['permission']['redirect_question'])) {
                     $message .= '&nbsp; (<a href="javascript:;" onclick="AWS.ajax_request(G_BASE_URL + \'/question/ajax/redirect/\', \'item_id=' . $question_info['question_id'] . '\');">' . AWS_APP::lang()->_t('撤消重定向') . '</a>)';
                 }
                 $redirect_message[] = $message;
             } else {
                 $redirect_message[] = AWS_APP::lang()->_t('重定向目标问题已被删除, 将不再重定向问题');
             }
         }
     }
     $question_info['user_info'] = $this->model('account')->get_user_info_by_uid($question_info['published_uid'], true);
     if ($_GET['column'] != 'log') {
         $this->model('question')->calc_popular_value($question_info['question_id']);
         $this->model('question')->update_views($question_info['question_id']);
         if (is_digits($_GET['uid'])) {
             $answer_list_where[] = 'uid = ' . intval($_GET['uid']);
             $answer_count_where = 'uid = ' . intval($_GET['uid']);
         } else {
             if ($_GET['uid'] == 'focus' and $this->user_id) {
                 if ($friends = $this->model('follow')->get_user_friends($this->user_id, false)) {
                     foreach ($friends as $key => $val) {
                         $follow_uids[] = $val['uid'];
                     }
                 } else {
                     $follow_uids[] = 0;
                 }
                 $answer_list_where[] = 'uid IN(' . implode($follow_uids, ',') . ')';
                 $answer_count_where = 'uid IN(' . implode($follow_uids, ',') . ')';
                 $answer_order_by = 'add_time ASC';
             } else {
                 if ($_GET['sort_key'] == 'add_time') {
                     $answer_order_by = $_GET['sort_key'] . " " . $_GET['sort'];
                 } else {
                     $answer_order_by = "agree_count " . $_GET['sort'] . ", against_count ASC, add_time ASC";
                 }
             }
         }
         if ($answer_count_where) {
             $answer_count = $this->model('answer')->get_answer_count_by_question_id($question_info['question_id'], $answer_count_where);
         } else {
             $answer_count = $question_info['answer_count'];
         }
         if (isset($_GET['answer_id']) and (!$this->user_id or $_GET['single'])) {
             $answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . intval($_GET['answer_id']));
         } else {
             if (!$this->user_id and !$this->user_info['permission']['answer_show']) {
                 if ($question_info['best_answer']) {
                     $answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . intval($question_info['best_answer']));
                 } else {
                     $answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, null, 'agree_count DESC');
                 }
             } else {
                 if ($answer_list_where) {
                     $answer_list_where = implode(' AND ', $answer_list_where);
                 }
                 $answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], calc_page_limit($_GET['page'], 100), $answer_list_where, $answer_order_by);
             }
         }
         // 最佳回复预留
         $answers[0] = '';
         if (!is_array($answer_list)) {
             $answer_list = array();
         }
         $answer_ids = array();
         $answer_uids = array();
         foreach ($answer_list as $answer) {
             $answer_ids[] = $answer['answer_id'];
             $answer_uids[] = $answer['uid'];
             if ($answer['has_attach']) {
                 $has_attach_answer_ids[] = $answer['answer_id'];
             }
         }
         if (!in_array($question_info['best_answer'], $answer_ids) and intval($_GET['page']) < 2) {
             $answer_list = array_merge($this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . $question_info['best_answer']), $answer_list);
         }
         if ($answer_ids) {
             $answer_vote_status = $this->model('answer')->get_answer_vote_status($answer_ids, $this->user_id);
             $answer_users_rated_thanks = $this->model('answer')->users_rated('thanks', $answer_ids, $this->user_id);
             $answer_users_rated_uninterested = $this->model('answer')->users_rated('uninterested', $answer_ids, $this->user_id);
         }
         foreach ($answer_list as $answer) {
             $answer['user_rated_thanks'] = $answer_users_rated_thanks[$answer['answer_id']];
             $answer['user_rated_uninterested'] = $answer_users_rated_uninterested[$answer['answer_id']];
             $answer['answer_content'] = cjk_substr(strip_ubb($answer['answer_content']), 0, 100);
             //$answer['agree_users'] = $answer_agree_users[$answer['answer_id']];
             $answer['agree_status'] = $answer_vote_status[$answer['answer_id']];
             $answer['user_info']['avatar_file'] = get_avatar_url($answer['uid']);
             if ($question_info['best_answer'] == $answer['answer_id'] and intval($_GET['page']) < 2) {
                 $answers[0] = $answer;
             } else {
                 $answers[] = $answer;
             }
         }
         if (!$answers[0]) {
             unset($answers[0]);
         }
         $question_info['user_answered'] = 0;
         //如果系统设置了用户只能回答一次
         if (get_setting('answer_unique') == 'Y') {
             if ($this->model('answer')->has_answer_by_uid($question_info['question_id'], $this->user_id)) {
                 $question_info['user_answered'] = 1;
             } else {
                 $question_info['user_answered'] = 0;
             }
         }
     }
     $question_info['user_follow_check'] = 0;
     $question_info['user_question_focus'] = 0;
     $question_info['user_thanks'] = 0;
     if ($this->user_id) {
         if ($this->model('question')->get_question_thanks($question_info['question_id'], $this->user_id)) {
             $question_info['user_thanks'] = 1;
         }
         //当前用户是否已关注该问题作者
         if ($this->model('follow')->user_follow_check($this->user_id, $question_info['published_uid'])) {
             $question_info['user_follow_check'] = 1;
         }
         if ($this->model('question')->has_focus_question($question_info['question_id'], $this->user_id)) {
             $question_info['user_question_focus'] = 1;
         }
     }
     $question_info['question_detail'] = FORMAT::parse_attachs(nl2br(FORMAT::parse_bbcode($question_info['question_detail'])));
     $question_topics = $this->model('topic')->get_topics_by_item_id($question_info['question_id'], 'question');
     $question_info['answer_count'] = $answer_count;
     //clean
     $question_key = array('question_id', 'question_content', 'question_detail', 'add_time', 'update_time', 'answer_count', 'view_count', 'agree_count', 'focus_count', 'against_count', 'thanks_count', 'comment_count', 'user_info', 'user_answered', 'user_thanks', 'user_follow_check', 'user_question_focus');
     $user_key = array('uid', 'user_name', 'namecard_pic', 'signature');
     $topics_key = array('topic_id', 'topic_title');
     foreach ($question_info as $k => $v) {
         if (!in_array($k, $question_key)) {
             unset($question_info[$k]);
         }
     }
     //作者信息
     if (!empty($question_info['user_info'])) {
         foreach ($question_info['user_info'] as $k => $v) {
             if (!in_array($k, $user_key)) {
                 unset($question_info['user_info'][$k]);
             }
         }
         $question_info['user_info']['avatar_file'] = get_avatar_url($question_info['user_info']['uid'], 'mid');
     }
     if (!empty($answers)) {
         foreach ($answers as $key => $value) {
             if (!empty($value['user_info'])) {
                 foreach ($value['user_info'] as $k => $v) {
                     if (!in_array($k, $user_key)) {
                         unset($answers[$key]['user_info'][$k]);
                     }
                 }
                 $answers[$key]['user_info']['avatar_file'] = get_avatar_url($answers[$key]['user_info']['uid'], 'mid');
             }
             $answers[$key]['answer_content'] = strip_tags($value['answer_content']);
         }
     }
     if (!empty($question_topics)) {
         foreach ($question_topics as $key => $val) {
             foreach ($val as $k => $v) {
                 if (!in_array($k, $topics_key)) {
                     unset($question_topics[$key][$k]);
                 }
             }
         }
     }
     //$question_info['answers'] = $answers;
     H::ajax_json_output(AWS_APP::RSM(array('question_info' => $question_info, 'question_topics' => $question_topics, 'answers' => array_values($answers)), 1, null));
 }
コード例 #4
0
ファイル: ajax.php プロジェクト: egogg/wecenter-dev
 function load_answers_action()
 {
     // 获取问题
     if (!($question_info = $this->model('question')->get_question_info_by_id($_GET['question_id']))) {
         return;
     }
     $this->model('question')->calc_popular_value($question_info['question_id']);
     $this->model('question')->update_views($question_info['question_id']);
     if (!$_GET['sort'] or $_GET['sort'] != 'ASC') {
         $_GET['sort'] = 'DESC';
     } else {
         $_GET['sort'] = 'ASC';
     }
     if (is_digits($_GET['uid'])) {
         $answer_list_where[] = 'uid = ' . intval($_GET['uid']);
         $answer_count_where = 'uid = ' . intval($_GET['uid']);
     } else {
         if ($_GET['uid'] == 'focus' and $this->user_id) {
             if ($friends = $this->model('follow')->get_user_friends($this->user_id, false)) {
                 foreach ($friends as $key => $val) {
                     $follow_uids[] = $val['uid'];
                 }
             } else {
                 $follow_uids[] = 0;
             }
             $answer_list_where[] = 'uid IN(' . implode($follow_uids, ',') . ')';
             $answer_count_where = 'uid IN(' . implode($follow_uids, ',') . ')';
             $answer_order_by = 'add_time ASC';
         } else {
             if ($_GET['sort_key'] == 'popularity') {
                 $answer_order_by = "agree_count " . $_GET['sort'] . ", against_count ASC, add_time ASC";
             } else {
                 $answer_order_by = "add_time " . $_GET['sort'];
             }
         }
     }
     if ($answer_count_where) {
         $answer_count = $this->model('answer')->get_answer_count_by_question_id($question_info['question_id'], $answer_count_where);
     } else {
         $answer_count = $question_info['answer_count'];
     }
     if (isset($_GET['answer_id']) and (!$this->user_id or $_GET['single'])) {
         $answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . intval($_GET['answer_id']));
     } else {
         if (!$this->user_id and !$this->user_info['permission']['answer_show']) {
             if ($question_info['best_answer']) {
                 $answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . intval($question_info['best_answer']));
             } else {
                 $answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, null, 'agree_count DESC');
             }
         } else {
             if ($answer_list_where) {
                 $answer_list_where = implode(' AND ', $answer_list_where);
             }
             $answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], calc_page_limit($_GET['page'], 100), $answer_list_where, $answer_order_by);
         }
     }
     // 最佳回复预留
     $answers[0] = '';
     if (!is_array($answer_list)) {
         $answer_list = array();
     }
     $answer_ids = array();
     $answer_uids = array();
     foreach ($answer_list as $answer) {
         $answer_ids[] = $answer['answer_id'];
         $answer_uids[] = $answer['uid'];
         if ($answer['has_attach']) {
             $has_attach_answer_ids[] = $answer['answer_id'];
         }
     }
     if (!in_array($question_info['best_answer'], $answer_ids) and intval($_GET['page']) < 2) {
         $answer_list = array_merge($this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . $question_info['best_answer']), $answer_list);
     }
     if ($answer_ids) {
         $answer_agree_users = $this->model('answer')->get_vote_user_by_answer_ids($answer_ids);
         $answer_vote_status = $this->model('answer')->get_answer_vote_status($answer_ids, $this->user_id);
         $answer_users_rated_thanks = $this->model('answer')->users_rated('thanks', $answer_ids, $this->user_id);
         $answer_users_rated_uninterested = $this->model('answer')->users_rated('uninterested', $answer_ids, $this->user_id);
         $answer_attachs = $this->model('publish')->get_attachs('answer', $has_attach_answer_ids, 'min');
     }
     foreach ($answer_list as $answer) {
         if ($answer['has_attach']) {
             $answer['attachs'] = $answer_attachs[$answer['answer_id']];
             $answer['insert_attach_ids'] = FORMAT::parse_attachs($answer['answer_content'], true);
         }
         $answer['user_rated_thanks'] = $answer_users_rated_thanks[$answer['answer_id']];
         $answer['user_rated_uninterested'] = $answer_users_rated_uninterested[$answer['answer_id']];
         $answer['answer_content'] = $this->model('question')->parse_at_user(FORMAT::parse_attachs(nl2br(FORMAT::parse_bbcode($answer['answer_content']))));
         $answer['agree_users'] = $answer_agree_users[$answer['answer_id']];
         $answer['agree_status'] = $answer_vote_status[$answer['answer_id']];
         if ($question_info['best_answer'] == $answer['answer_id'] and intval($_GET['page']) < 2) {
             $answers[0] = $answer;
         } else {
             $answers[] = $answer;
         }
         // 获取回答评论列表
         $comments = $this->model('answer')->get_answer_comments($answer['answer_id']);
         $user_infos = $this->model('account')->get_user_info_by_uids(fetch_array_value($comments, 'uid'));
         foreach ($comments as $key => $val) {
             $comments[$key]['message'] = FORMAT::parse_links($this->model('question')->parse_at_user($comments[$key]['message']));
             $comments[$key]['user_name'] = $user_infos[$val['uid']]['user_name'];
             $comments[$key]['url_token'] = $user_infos[$val['uid']]['url_token'];
         }
         $answer_comments[$answer['answer_id']] = $comments;
     }
     if (!$answers[0]) {
         unset($answers[0]);
     }
     if ($this->model('answer')->has_answer_by_uid($question_info['question_id'], $this->user_id)) {
         $user_answered = true;
     } else {
         $user_answered = false;
     }
     // 评论附件
     TPL::assign('attach_access_key', md5($this->user_id . time()));
     TPL::assign('user_answered', $user_answered);
     TPL::assign('answers', $answers);
     TPL::assign('comments', $answer_comments);
     TPL::assign('answer_count', $answer_count);
     TPL::output('question/ajax/answer_list');
 }
コード例 #5
0
ファイル: publish.php プロジェクト: chenruixuan/wecenter
 public function insert_attach_is_self_upload($message, $attach_ids = null)
 {
     if (!$message) {
         return true;
     }
     if (!$attach_ids) {
         $attach_ids = array();
     }
     if ($question_attachs_ids = FORMAT::parse_attachs($message, true)) {
         foreach ($question_attachs_ids as $attach_id) {
             if (!in_array($attach_id, $attach_ids)) {
                 return false;
             }
         }
     }
     return true;
 }
コード例 #6
0
 public function question_action()
 {
     TPL::assign('body_class', 'active');
     if (!$this->user_id and !$this->user_info['permission']['visit_question']) {
         HTTP::redirect('/m/login/url-' . base64_encode(get_js_url($_SERVER['QUERY_STRING'])));
     }
     if (!isset($_GET['id'])) {
         HTTP::redirect('/m/explore/');
     }
     if ($_GET['notification_id']) {
         $this->model('notify')->read_notification($_GET['notification_id'], $this->user_id);
     }
     if (!($question_info = $this->model('question')->get_question_info_by_id($_GET['id']))) {
         H::redirect_msg(AWS_APP::lang()->_t('问题不存在或已被删除'), '/m/explore/');
     }
     $question_info['redirect'] = $this->model('question')->get_redirect($question_info['question_id']);
     if ($question_info['redirect']['target_id']) {
         $target_question = $this->model('question')->get_question_info_by_id($question_info['redirect']['target_id']);
     }
     if (is_digits($_GET['rf']) and $_GET['rf']) {
         if ($from_question = $this->model('question')->get_question_info_by_id($_GET['rf'])) {
             $redirect_message[] = AWS_APP::lang()->_t('从问题') . ' <a href="' . get_js_url('/m/question/' . $_GET['rf'] . '?rf=false') . '">' . $from_question['question_content'] . '</a> ' . AWS_APP::lang()->_t('跳转而来');
         }
     }
     if ($question_info['redirect'] and !$_GET['rf']) {
         if ($target_question) {
             HTTP::redirect('/m/question/' . $question_info['redirect']['target_id'] . '?rf=' . $question_info['question_id']);
         } else {
             $redirect_message[] = AWS_APP::lang()->_t('重定向目标问题已被删除, 将不再重定向问题');
         }
     } else {
         if ($question_info['redirect']) {
             if ($target_question) {
                 $message = AWS_APP::lang()->_t('此问题将跳转至') . ' <a href="' . get_js_url('/m/question/' . $question_info['redirect']['target_id'] . '?rf=' . $question_info['question_id']) . '">' . $target_question['question_content'] . '</a>';
                 if ($this->user_id and ($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'] or !$this->question_info['lock'] and $this->user_info['permission']['redirect_question'])) {
                     $message .= '&nbsp; (<a href="javascript:;" onclick="AWS.ajax_request(G_BASE_URL + \'/question/ajax/redirect/\', \'item_id=' . $question_info['question_id'] . '\');">' . AWS_APP::lang()->_t('撤消重定向') . '</a>)';
                 }
                 $redirect_message[] = $message;
             } else {
                 $redirect_message[] = AWS_APP::lang()->_t('重定向目标问题已被删除, 将不再重定向问题');
             }
         }
     }
     if ($question_info['has_attach']) {
         $question_info['attachs'] = $this->model('publish')->get_attach('question', $question_info['question_id'], 'min');
         $question_info['attachs_ids'] = FORMAT::parse_attachs($question_info['question_detail'], true);
     }
     $this->model('question')->update_views($question_info['question_id']);
     if (get_setting('answer_unique') == 'Y') {
         if ($this->model('answer')->has_answer_by_uid($question_info['question_id'], $this->user_id)) {
             TPL::assign('user_answered', TRUE);
         }
     }
     $question_info['question_detail'] = FORMAT::parse_attachs(nl2br(FORMAT::parse_bbcode($question_info['question_detail'])));
     TPL::assign('question_id', $question_info['question_id']);
     TPL::assign('question_info', $question_info);
     TPL::assign('question_focus', $this->model('question')->has_focus_question($question_info['question_id'], $this->user_id));
     TPL::assign('question_topics', $this->model('topic')->get_topics_by_item_id($question_info['question_id'], 'question'));
     $this->crumb($question_info['question_content'], '/m/question/' . $question_info['question_id']);
     TPL::assign('redirect_message', $redirect_message);
     if ($this->user_id) {
         TPL::assign('question_thanks', $this->model('question')->get_question_thanks($question_info['question_id'], $this->user_id));
         TPL::assign('invite_users', $this->model('question')->get_invite_users($question_info['question_id']));
         //TPL::assign('user_follow_check', $this->model("follow")->user_follow_check($this->user_id, $question_info['published_uid']));
         if ($this->user_info['draft_count'] > 0) {
             TPL::assign('draft_content', $this->model('draft')->get_data($question_info['question_id'], 'answer', $this->user_id));
         }
     }
     if (isset($_GET['answer_id']) and (!$this->user_id or $_GET['single'])) {
         $answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . intval($_GET['answer_id']));
     } else {
         if (!$this->user_id and !$this->user_info['permission']['answer_show']) {
             if ($question_info['best_answer']) {
                 $answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . intval($question_info['best_answer']));
             } else {
                 $answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, null, 'agree_count DESC');
             }
         } else {
             $answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], calc_page_limit($_GET['page'], 20), null, 'agree_count DESC, against_count ASC, add_time ASC');
         }
     }
     // 最佳回复预留
     $answers[0] = '';
     if (!is_array($answer_list)) {
         $answer_list = array();
     }
     $answer_ids = array();
     $answer_uids = array();
     foreach ($answer_list as $answer) {
         $answer_ids[] = $answer['answer_id'];
         $answer_uids[] = $answer['uid'];
         if ($answer['has_attach']) {
             $has_attach_answer_ids[] = $answer['answer_id'];
         }
     }
     if (!in_array($question_info['best_answer'], $answer_ids) and intval($_GET['page']) < 2) {
         $answer_list = array_merge($this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . $question_info['best_answer']), $answer_list);
     }
     if ($answer_ids) {
         $answer_agree_users = $this->model('answer')->get_vote_user_by_answer_ids($answer_ids);
         $answer_vote_status = $this->model('answer')->get_answer_vote_status($answer_ids, $this->user_id);
         $answer_users_rated_thanks = $this->model('answer')->users_rated('thanks', $answer_ids, $this->user_id);
         $answer_users_rated_uninterested = $this->model('answer')->users_rated('uninterested', $answer_ids, $this->user_id);
         $answer_attachs = $this->model('publish')->get_attachs('answer', $has_attach_answer_ids, 'min');
     }
     foreach ($answer_list as $answer) {
         if ($answer['has_attach']) {
             $answer['attachs'] = $answer_attachs[$answer['answer_id']];
             $answer['insert_attach_ids'] = FORMAT::parse_attachs($answer['answer_content'], true);
         }
         $answer['user_rated_thanks'] = $answer_users_rated_thanks[$answer['answer_id']];
         $answer['user_rated_uninterested'] = $answer_users_rated_uninterested[$answer['answer_id']];
         $answer['answer_content'] = $this->model('question')->parse_at_user(FORMAT::parse_attachs(FORMAT::parse_bbcode($answer['answer_content'])));
         $answer['agree_users'] = $answer_agree_users[$answer['answer_id']];
         $answer['agree_status'] = $answer_vote_status[$answer['answer_id']];
         if ($question_info['best_answer'] == $answer['answer_id'] and intval($_GET['page']) < 2) {
             $answers[0] = $answer;
         } else {
             $answers[] = $answer;
         }
     }
     if (!$answers[0]) {
         unset($answers[0]);
     }
     if (get_setting('answer_unique') == 'Y') {
         if ($this->model('answer')->has_answer_by_uid($question_info['question_id'], $this->user_id)) {
             TPL::assign('user_answered', TRUE);
         }
     }
     TPL::assign('answers_list', $answers);
     TPL::assign('attach_access_key', md5($this->user_id . time()));
     TPL::assign('human_valid', human_valid('answer_valid_hour'));
     $question_related_list = $this->model('question')->get_related_question_list($question_info['question_id'], $question_info['question_content']);
     TPL::assign('question_related_list', $question_related_list);
     TPL::assign('question_related_links', $this->model('related')->get_related_links('question', $question_info['question_id']));
     if ($this->user_id) {
         if ($question_topics) {
             foreach ($question_topics as $key => $val) {
                 $question_topic_ids[] = $val['topic_id'];
             }
         }
         if ($helpful_users = $this->model('topic')->get_helpful_users_by_topic_ids($question_topic_ids, 12)) {
             foreach ($helpful_users as $key => $val) {
                 if ($val['user_info']['uid'] == $this->user_id) {
                     unset($helpful_users[$key]);
                 } else {
                     $helpful_users[$key]['has_invite'] = $this->model('question')->has_question_invite($question_info['question_id'], $val['user_info']['uid'], $this->user_id);
                 }
             }
             TPL::assign('helpful_users', $helpful_users);
         }
     }
     $total_page = $question_info['answer_count'] / 20;
     if ($total_page > intval($total_page)) {
         $total_page = intval($total_page) + 1;
     }
     if (!$_GET['page']) {
         $_GET['page'] = 1;
     }
     if ($_GET['page'] < $total_page) {
         $_GET['page'] = $_GET['page'] + 1;
         TPL::assign('next_page', $_GET['page']);
     }
     TPL::import_js(array('js/fileupload.js'));
     TPL::output('m/question');
 }
コード例 #7
0
ファイル: main.php プロジェクト: chenruixuan/wecenter
 public function index_action()
 {
     if ($_GET['notification_id']) {
         $this->model('notify')->read_notification($_GET['notification_id'], $this->user_id);
     }
     if (is_mobile()) {
         HTTP::redirect('/m/article/' . $_GET['id']);
     }
     if (!($article_info = $this->model('article')->get_article_info_by_id($_GET['id']))) {
         H::redirect_msg(AWS_APP::lang()->_t('文章不存在或已被删除'), '/');
     }
     if ($article_info['has_attach']) {
         $article_info['attachs'] = $this->model('publish')->get_attach('article', $article_info['id'], 'min');
         $article_info['attachs_ids'] = FORMAT::parse_attachs($article_info['message'], true);
     }
     $article_info['user_info'] = $this->model('account')->get_user_info_by_uid($article_info['uid'], true);
     $article_info['message'] = FORMAT::parse_attachs(nl2br(FORMAT::parse_markdown($article_info['message'])));
     if ($this->user_id) {
         $article_info['vote_info'] = $this->model('article')->get_article_vote_by_id('article', $article_info['id'], null, $this->user_id);
     }
     $article_info['vote_users'] = $this->model('article')->get_article_vote_users_by_id('article', $article_info['id'], 1, 10);
     TPL::assign('article_info', $article_info);
     $article_topics = $this->model('topic')->get_topics_by_item_id($article_info['id'], 'article');
     if ($article_topics) {
         TPL::assign('article_topics', $article_topics);
         foreach ($article_topics as $topic_info) {
             $article_topic_ids[] = $topic_info['topic_id'];
         }
     }
     TPL::assign('reputation_topics', $this->model('people')->get_user_reputation_topic($article_info['user_info']['uid'], $user['reputation'], 5));
     $this->crumb($article_info['title'], '/article/' . $article_info['id']);
     TPL::assign('human_valid', human_valid('answer_valid_hour'));
     if ($_GET['item_id']) {
         $comments[] = $this->model('article')->get_comment_by_id($_GET['item_id']);
     } else {
         $comments = $this->model('article')->get_comments($article_info['id'], $_GET['page'], 100);
     }
     if ($comments and $this->user_id) {
         foreach ($comments as $key => $val) {
             $comments[$key]['vote_info'] = $this->model('article')->get_article_vote_by_id('comment', $val['id'], 1, $this->user_id);
         }
     }
     if ($this->user_id) {
         TPL::assign('user_follow_check', $this->model('follow')->user_follow_check($this->user_id, $article_info['uid']));
     }
     TPL::assign('question_related_list', $this->model('question')->get_related_question_list(null, $article_info['title']));
     $this->model('article')->update_views($article_info['id']);
     TPL::assign('comments', $comments);
     TPL::assign('comments_count', $article_info['comments']);
     TPL::assign('human_valid', human_valid('answer_valid_hour'));
     TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/article/id-' . $article_info['id']), 'total_rows' => $article_info['comments'], 'per_page' => 100))->create_links());
     TPL::set_meta('keywords', implode(',', $this->model('system')->analysis_keyword($article_info['title'])));
     TPL::set_meta('description', $article_info['title'] . ' - ' . cjk_substr(str_replace("\r\n", ' ', strip_tags($article_info['message'])), 0, 128, 'UTF-8', '...'));
     TPL::assign('attach_access_key', md5($this->user_id . time()));
     $recommend_posts = $this->model('posts')->get_recommend_posts_by_topic_ids($article_topic_ids);
     if ($recommend_posts) {
         foreach ($recommend_posts as $key => $value) {
             if ($value['id'] and $value['id'] == $article_info['id']) {
                 unset($recommend_posts[$key]);
                 break;
             }
         }
         TPL::assign('recommend_posts', $recommend_posts);
     }
     if (get_setting('advanced_editor_enable') == 'Y') {
         TPL::import_js('js/editor/prettify.js');
     }
     TPL::output('article/index');
 }
コード例 #8
0
ファイル: main.php プロジェクト: elelianghh/wecenter
 public function index_action()
 {
     $this->pre_page = 100;
     if ($_GET['notification_id']) {
         $this->model('notify')->read_notification($_GET['notification_id'], $this->user_id);
     }
     $ticket_info = $this->model('ticket')->get_ticket_info_by_id($_GET['id']);
     if (!$ticket_info) {
         H::redirect_msg(AWS_APP::lang()->_t('工单不存在或已被删除'), '/');
     }
     if (!$this->user_info['permission']['is_administortar'] and !$this->user_info['permission']['is_service'] and $ticket_info['uid'] != $this->user_id and !$this->model('ticket')->has_invited($this->user_id)) {
         H::redirect_msg(AWS_APP::lang()->_t('你没有权限查看该工单'));
     }
     $this->crumb($ticket_info['title'], '/ticket/' . $ticket_info['id']);
     $uids[] = $ticket_info['uid'];
     if ($ticket_info['service']) {
         $uids[] = $ticket_info['service'];
     }
     if ($_GET['column']) {
         if ($_GET['column'] == 'log') {
             $ticket_log = $this->model('ticket')->parse_ticket_log($ticket_info['id']);
             if ($ticket_log) {
                 foreach ($ticket_log as $log_info) {
                     $uids[] = $log_info['uid'];
                 }
             }
         }
     } else {
         if (!$_GET['page']) {
             $_GET['page'] = 1;
         }
         if ($_GET['reply_id']) {
             $replies_list = array($this->model('ticket')->get_ticket_reply_by_id($_GET['reply_id']));
         } else {
             $replies_list = $this->model('ticket')->get_replies_list_by_ticket_id($ticket_info['id'], $_GET['page'], $this->pre_page);
         }
         if ($replies_list) {
             foreach ($replies_list as $reply_info) {
                 $uids[] = $reply_info['uid'];
             }
         }
         $replies_count = $this->model('ticket')->found_rows();
         TPL::assign('replies_count', $replies_count);
         TPL::assign('draft_content', $this->model('draft')->get_data(1, 'ticket_reply', $this->user_id));
         TPL::assign('attach_access_key', md5($this->user_id . time()));
         TPL::assign('human_valid', human_valid('answer_valid_hour'));
         if (get_setting('advanced_editor_enable') == 'Y') {
             import_editor_static_files();
         }
         if (get_setting('upload_enable') == 'Y') {
             // fileupload
             TPL::import_js('js/fileupload.js');
         }
     }
     $ticket_topics = $this->model('topic')->get_topics_by_item_id($ticket_info['id'], 'ticket');
     if ($ticket_topics) {
         TPL::assign('ticket_topics', $ticket_topics);
     }
     $invite_users = $this->model('ticket')->get_invite_users($ticket_info['id']);
     if ($invite_users) {
         foreach ($invite_users as $invite_info) {
             $uids[] = $invite_info['recipient_uid'];
         }
     }
     $users_list = $this->model('account')->get_user_info_by_uids($uids);
     $ticket_info['user_info'] = $users_list[$ticket_info['uid']];
     $ticket_info['service_info'] = $users_list[$ticket_info['service']];
     $ticket_info['message'] = nl2br(FORMAT::parse_markdown($ticket_info['message']));
     if ($ticket_info['has_attach']) {
         $ticket_info['attachs'] = $this->model('publish')->get_attach('ticket', $ticket_info['id'], 'min');
         $ticket_info['insert_attach_ids'] = FORMAT::parse_attachs($ticket_info['message'], true);
         $ticket_info['message'] = FORMAT::parse_attachs($ticket_info['message']);
     }
     if ($ticket_log) {
         foreach ($ticket_log as $key => $log_info) {
             $ticket_log[$key]['user_info'] = $users_list[$log_info['uid']];
         }
         TPL::assign('ticket_log', $ticket_log);
     }
     if ($replies_list) {
         foreach ($replies_list as $key => $reply_info) {
             $replies_list[$key]['user_info'] = $users_list[$reply_info['uid']];
             $replies_list[$key]['message'] = nl2br(FORMAT::parse_markdown($reply_info['message']));
             if ($reply_info['has_attach']) {
                 $has_attach_reply_ids[] = $reply_info['id'];
             }
         }
         if ($has_attach_reply_ids) {
             $reply_attachs = $this->model('publish')->get_attachs('ticket_reply', $has_attach_reply_ids, 'min');
             foreach ($replies_list as $key => $reply_info) {
                 if ($reply_info['has_attach']) {
                     $replies_list[$key]['attachs'] = $reply_attachs[$reply_info['id']];
                     $replies_list[$key]['insert_attach_ids'] = FORMAT::parse_attachs($reply_info['message'], true);
                     $replies_list[$key]['message'] = FORMAT::parse_attachs($reply_info['message']);
                 }
             }
         }
         TPL::assign('replies_list', $replies_list);
         TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/ticket/id-' . $ticket_info['id']), 'total_rows' => $replies_count, 'per_page' => $this->pre_page))->create_links());
     }
     if ($invite_users) {
         foreach ($invite_users as $key => $invite_info) {
             $invite_users[$key]['recipient_info'] = $users_list[$invite_info['recipient_uid']];
         }
         TPL::assign('invite_users', $invite_users);
     }
     TPL::assign('ticket_info', $ticket_info);
     TPL::output('ticket/index');
 }
コード例 #9
0
ファイル: ajax.php プロジェクト: elelianghh/wecenter
 public function reply_action()
 {
     $_POST['message'] = trim($_POST['message']);
     if (!$_POST['message']) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请输入回复内容')));
     }
     if (!$_POST['id']) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请选择要回复的工单')));
     }
     $ticket_info = $this->model('ticket')->get_ticket_info_by_id($_POST['id']);
     if (!$ticket_info) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('工单不存在')));
     }
     if ($ticket_info['status'] == 'closed') {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('工单已关闭')));
     }
     if (!$this->user_info['permission']['is_administortar'] and !$this->user_info['permission']['is_service'] and $ticket_info['uid'] != $this->user_id and !$this->model('ticket')->has_invited($this->user_id)) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('你没有权限回复该工单')));
     }
     $reply_id = $this->model('ticket')->reply_ticket($ticket_info['id'], $_POST['message'], $this->user_id, $_POST['attach_access_key']);
     if (!$reply_id) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('回复失败')));
     }
     $this->model('draft')->delete_draft(1, 'ticket_reply', $this->user_id);
     $reply_info = $this->model('ticket')->get_ticket_reply_by_id($reply_id);
     if ($ticket_info['uid'] != $this->user_id) {
         $this->model('notify')->send($reply_info['uid'], $ticket_info['uid'], notify_class::TYPE_TICKET_REPLIED, notify_class::CATEGORY_TICKET, 0, array('from_uid' => $reply_info['uid'], 'ticket_id' => $ticket_info['id'], 'reply_id' => $reply_info['id']));
     }
     $reply_info['user_info'] = $this->user_info;
     $reply_info['message'] = nl2br(FORMAT::parse_markdown($reply_info['message']));
     if ($reply_info['has_attach']) {
         $reply_info['attachs'] = $this->model('publish')->get_attach('ticket', $reply_info['id'], 'min');
         $reply_info['insert_attach_ids'] = FORMAT::parse_attachs($reply_info['message'], true);
         $reply_info['message'] = FORMAT::parse_attachs($reply_info['message']);
     }
     if (!$ticket_info['service'] and $ticket_info['uid'] != $this->user_id and ($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_service'])) {
         $this->model('ticket')->assign_service($ticket_info['id'], $this->user_id);
     }
     TPL::assign('reply_info', $reply_info);
     H::ajax_json_output(AWS_APP::RSM(array('ajax_html' => TPL::output('ticket/ajax/reply', false)), 1, null));
 }
コード例 #10
0
ファイル: topic.php プロジェクト: nerverwind/wecenter_ios_sdk
 public function topic_best_answer_list_action()
 {
     if (!$_GET['topic_id']) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('参数错误')));
     }
     $_GET['page'] = $_GET['page'] ? $_GET['page'] - 1 : 0;
     $per_page = get_setting('contents_per_page');
     if ($_GET['per_page']) {
         $per_page = intval($_GET['per_page']);
     }
     //$action_list = $this->model('topic')->get_topic_best_answer_action_list(intval($_GET['topic_id']), $this->user_id, intval($_GET['page']) * get_setting('contents_per_page') . ', ' . get_setting('contents_per_page'));
     $action_list = $this->model('topic')->get_topic_best_answer_action_list(intval($_GET['topic_id']), $this->user_id, intval($_GET['page']) * $per_page . ', ' . $per_page);
     $question_info_key = array('question_id', 'question_content');
     $answer_info_key = array('answer_id', 'answer_content', 'add_time', 'against_count', 'agree_count', 'comment_count', 'thanks_count', 'agree_status');
     if ($action_list) {
         foreach ($action_list as $key => $val) {
             foreach ($val as $kk => $vv) {
                 if (!in_array($kk, array('question_info', 'user_info', 'answer_info'))) {
                     unset($action_list[$key][$kk]);
                 }
                 if ($kk == 'question_info') {
                     foreach ($vv as $k => $v) {
                         if (!in_array($k, $question_info_key)) {
                             unset($action_list[$key][$kk][$k]);
                         }
                     }
                 }
                 if ($kk == 'user_info') {
                     $action_list[$key][$kk] = $this->model('myapi')->get_clean_user_info($vv);
                 }
                 if ($kk == 'answer_info') {
                     foreach ($vv as $k => $v) {
                         if (!in_array($k, $answer_info_key)) {
                             unset($action_list[$key][$kk][$k]);
                         }
                     }
                     $vv['answer_content'] = $this->model('question')->parse_at_user(FORMAT::parse_attachs(nl2br(FORMAT::parse_bbcode($vv['answer_content']))));
                     $action_list[$key][$kk]['answer_content'] = cjk_substr(trim(strip_tags($vv['answer_content'])), 0, 100);
                 }
             }
         }
     } else {
         $action_list = null;
     }
     H::ajax_json_output(AWS_APP::RSM(array('total_rows' => count($action_list), 'rows' => array_values($action_list)), 1, null));
 }
コード例 #11
0
ファイル: question.php プロジェクト: egogg/wecenter-dev
 public function load_detailed_question_info($question_id)
 {
     if (!($question_info = $this->get_question_info_by_id($question_id))) {
         return false;
     }
     $question_info['user_info'] = $this->model('account')->get_user_info_by_uid($question_info['published_uid'], true);
     if ($question_info['category_id'] and get_setting('category_enable') == 'Y') {
         $question_info['category_info'] = $this->model('system')->get_category_info($question_info['category_id']);
     }
     if ($question_info['has_attach']) {
         $question_info['attachs'] = $this->model('publish')->get_attach('question', $question_info['question_id'], 'min');
         $question_info['attachs_ids'] = FORMAT::parse_attachs($question_info['question_detail'], true);
     }
     $question_info['question_detail'] = FORMAT::parse_attachs(nl2br(FORMAT::parse_bbcode($question_info['question_detail'])));
     // 答题选项
     if (intval($question_info['quiz_id']) > 0) {
         $question_info['question_quiz'] = $this->model('quiz')->get_question_quiz_info_by_id($question_info['quiz_id']);
     }
     return $question_info;
 }
コード例 #12
0
ファイル: main.php プロジェクト: elelianghh/wecenter
 public function index_action()
 {
     if ($_GET['id']) {
         if ($_GET['notification_id']) {
             $this->model('notify')->read_notification($_GET['notification_id'], $this->user_id);
         }
         /*if (is_mobile() AND HTTP::get_cookie('_ignore_ua_check') != 'TRUE')
         		{
         			HTTP::redirect('/m/project/' . $_GET['id']);
         		}*/
         if (!($project_info = $this->model('project')->get_project_info_by_id($_GET['id']))) {
             H::redirect_msg(AWS_APP::lang()->_t('项目不存在或已被删除'));
         }
         if ($project_info['approved'] != 1 or $project_info['status'] == 'OFFLINE') {
             if (!$this->user_info['permission']['is_administortar'] and !$this->user_info['permission']['is_moderator'] and $project_info['uid'] != $this->user_id) {
                 H::redirect_msg(AWS_APP::lang()->_t('项目目前待审核中或已下线'));
             }
         }
         $this->crumb($project_info['title'], '/project/' . $project_info['id']);
         $project_info['attachs'] = $this->model('publish')->get_attach('project', $project_info['id'], 'min');
         $project_info['attachs_ids'] = FORMAT::parse_attachs($project_info['description'], true);
         $project_info['description'] = FORMAT::parse_attachs(nl2br(FORMAT::parse_markdown($project_info['description'])));
         $project_info['user_info'] = $this->model('account')->get_user_info_by_uid($project_info['uid']);
         $project_info['category_info'] = $this->model('system')->get_category_info($project_info['category_id']);
         $project_topics = $this->model('topic')->get_topics_by_item_id($project_info['id'], 'project');
         TPL::assign('project_topics', $project_topics);
         TPL::assign('project_products', $this->model('project')->get_products_by_project_id($project_info['id']));
         foreach ($project_topics as $key => $val) {
             $project_topics_ids[] = $val['topic_id'];
         }
         TPL::assign('question_related_list', $this->model('posts')->get_posts_list('question', 1, 10, null, $project_topics_ids));
         TPL::assign('sponsored_users', $this->model('project')->get_sponsored_users($project_info['id'], $project_info['sponsored_users'], $project_info['project_type']));
         if ($this->user_id) {
             TPL::assign('like_status', $this->model('project')->get_like_status_by_uid($project_info['id'], $this->user_id));
             $project_order = $this->model('project')->get_single_project_order_by_uid($this->user_id, $project_info['id']);
             if (get_setting('upload_enable') == 'Y' and $project_info['project_type'] == 'EVENT' and $project_order) {
                 TPL::import_js('js/fileupload.js');
                 TPL::assign('attach_access_key', md5($this->user_id . time()));
             }
             TPL::assign('project_order', $project_order);
         }
         if ($this->model('posts')->get_posts_list_total() != $project_info['discuss_count']) {
             $this->model('project')->update_project_discuss_count($project_info['id'], $this->model('posts')->get_posts_list_total());
         }
         TPL::assign('project_info', $project_info);
         TPL::output('project/index');
     } else {
         /*if (is_mobile() AND HTTP::get_cookie('_ignore_ua_check') != 'TRUE')
         		{
         			HTTP::redirect('/m/project_square/');
         		}*/
         switch ($_GET['sort']) {
             default:
                 $order_by = 'add_time DESC';
                 break;
             case 'amount':
             case 'sponsored_users':
             case 'update_time':
                 $order_by = $_GET['sort'] . ' DESC';
                 break;
         }
         if (get_setting('category_enable') == 'Y') {
             TPL::assign('category_list', $this->model('menu')->get_nav_menu_list('project'));
         }
         if ($project_list = $this->model('project')->get_projects_list($_GET['category_id'], 1, 'ONLINE', $_GET['page'], 9, $order_by)) {
             TPL::assign('project_list', $project_list);
         }
         TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/project/'), 'total_rows' => $this->model('project')->found_rows(), 'per_page' => get_setting('contents_per_page')))->create_links());
         TPL::output('project/square');
     }
 }
コード例 #13
0
ファイル: main.php プロジェクト: egogg/wecenter-dev
 public function index_action()
 {
     if ($_GET['notification_id']) {
         $this->model('notify')->read_notification($_GET['notification_id'], $this->user_id);
     }
     if (!($article_info = $this->model('article')->get_article_info_by_id($_GET['id']))) {
         H::redirect_msg(AWS_APP::lang()->_t('文章不存在或已被删除'), '/');
     }
     if ($article_info['has_attach']) {
         $article_info['attachs'] = $this->model('publish')->get_attach('article', $article_info['id'], 'min');
         $article_info['attachs_ids'] = FORMAT::parse_attachs($article_info['message'], true);
     }
     $article_info['user_info'] = $this->model('account')->get_user_info_by_uid($article_info['uid'], true);
     $article_info['message'] = FORMAT::parse_attachs(nl2br(FORMAT::parse_bbcode($article_info['message'])));
     if ($this->user_id) {
         $article_info['vote_info'] = $this->model('article')->get_article_vote_by_id('article', $article_info['id'], null, $this->user_id);
     }
     $article_info['vote_users'] = $this->model('article')->get_article_vote_users_by_id('article', $article_info['id'], 1, 10);
     // 是否为推荐到首页
     $article_info['is_recommend_homepage'] = $this->model('recommend')->recommend_homepage_check('article', $article_info['id']);
     TPL::assign('article_info', $article_info);
     $article_topics = $this->model('topic')->get_topics_by_item_id($article_info['id'], 'article');
     if ($article_topics) {
         TPL::assign('article_topics', $article_topics);
         foreach ($article_topics as $topic_info) {
             $article_topic_ids[] = $topic_info['topic_id'];
         }
     }
     TPL::assign('reputation_topics', $this->model('people')->get_user_reputation_topic($article_info['user_info']['uid'], $user['reputation'], 5));
     $this->crumb($article_info['title'], '/article/' . $article_info['id']);
     TPL::assign('human_valid', human_valid('answer_valid_hour'));
     if ($_GET['item_id']) {
         $comments[] = $this->model('article')->get_comment_by_id($_GET['item_id']);
     } else {
         $comments = $this->model('article')->get_comments($article_info['id'], $_GET['page'], 50);
     }
     if ($comments and $this->user_id) {
         foreach ($comments as $key => $val) {
             $comments[$key]['vote_info'] = $this->model('article')->get_article_vote_by_id('comment', $val['id'], 1, $this->user_id);
             $comments[$key]['message'] = $this->model('question')->parse_at_user($val['message']);
         }
     }
     if ($this->user_id) {
         TPL::assign('user_follow_check', $this->model('follow')->user_follow_check($this->user_id, $article_info['uid']));
     }
     TPL::assign('question_related_list', $this->model('question')->get_related_question_list(null, $article_info['title']));
     // 最新推荐文章
     $hot_articles = $this->model('article')->get_articles_list(null, 1, 5, 'votes DESC', null);
     foreach ($hot_articles as $key => $val) {
         $article_ids[] = $val['id'];
     }
     $article_attachs = $this->model('publish')->get_attachs('article', $article_ids, 'min');
     foreach ($hot_articles as $key => $val) {
         $hot_articles[$key]['attachs'] = $article_attachs[$val['id']];
     }
     TPL::assign('hot_articles', $hot_articles);
     // 推荐专题
     if (TPL::is_output('block/sidebar_hot_topics.tpl.htm', 'question/square')) {
         TPL::assign('sidebar_hot_topics', $this->model('module')->sidebar_hot_topics($_GET['category'], 4));
     }
     $this->model('article')->update_views($article_info['id']);
     TPL::assign('comments', $comments);
     TPL::assign('comments_count', $article_info['comments']);
     TPL::assign('human_valid', human_valid('answer_valid_hour'));
     TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/article/id-' . $article_info['id']), 'total_rows' => $article_info['comments'], 'per_page' => 50))->create_links());
     TPL::set_meta('keywords', implode(',', $this->model('system')->analysis_keyword($article_info['title'])));
     TPL::set_meta('description', $article_info['title'] . ' - ' . cjk_substr(str_replace("\r\n", ' ', strip_tags($article_info['message'])), 0, 128, 'UTF-8', '...'));
     TPL::assign('attach_access_key', md5($this->user_id . time()));
     $recommend_posts = $this->model('posts')->get_recommend_posts_by_topic_ids($article_topic_ids);
     if ($recommend_posts) {
         foreach ($recommend_posts as $key => $value) {
             if ($value['id'] and $value['id'] == $article_info['id']) {
                 unset($recommend_posts[$key]);
                 break;
             }
         }
         TPL::assign('recommend_posts', $recommend_posts);
     }
     // 收藏数量
     $bookmark_count = $this->model('favorite')->get_favorite_counts('article', $article_info['id']);
     TPL::assign('bookmark_count', $bookmark_count);
     TPL::import_js('js/sweetalert.min.js');
     TPL::import_css('css/sweetalert.css');
     TPL::import_js('js/jquery-qrcode.min.js');
     TPL::import_js('js/share.js');
     TPL::output('article/index');
 }
コード例 #14
0
ファイル: main.php プロジェクト: egogg/wecenter-dev
 public function index_action()
 {
     if ($_GET['notification_id']) {
         $this->model('notify')->read_notification($_GET['notification_id'], $this->user_id);
     }
     if ($_GET['column'] == 'log' and !$this->user_id) {
         HTTP::redirect('/question/' . $_GET['id']);
     }
     if (!($question_info = $this->model('question')->get_question_info_by_id($_GET['id']))) {
         H::redirect_msg(AWS_APP::lang()->_t('问题不存在或已被删除'), '/question/');
     }
     if (!$_GET['sort'] or $_GET['sort'] != 'ASC') {
         $_GET['sort'] = 'DESC';
     } else {
         $_GET['sort'] = 'ASC';
     }
     if (get_setting('unfold_question_comments') == 'Y') {
         $_GET['comment_unfold'] = 'all';
     }
     $question_info['redirect'] = $this->model('question')->get_redirect($question_info['question_id']);
     if ($question_info['redirect']['target_id']) {
         $target_question = $this->model('question')->get_question_info_by_id($question_info['redirect']['target_id']);
     }
     if (is_digits($_GET['rf']) and $_GET['rf']) {
         if ($from_question = $this->model('question')->get_question_info_by_id($_GET['rf'])) {
             $redirect_message[] = AWS_APP::lang()->_t('从问题 %s 跳转而来', '<a href="' . get_js_url('/question/' . $_GET['rf'] . '?rf=false') . '">' . $from_question['question_content'] . '</a>');
         }
     }
     if ($question_info['redirect'] and !$_GET['rf']) {
         if ($target_question) {
             HTTP::redirect('/question/' . $question_info['redirect']['target_id'] . '?rf=' . $question_info['question_id']);
         } else {
             $redirect_message[] = AWS_APP::lang()->_t('重定向目标问题已被删除, 将不再重定向问题');
         }
     } else {
         if ($question_info['redirect']) {
             if ($target_question) {
                 $message = AWS_APP::lang()->_t('此问题将跳转至') . ' <a href="' . get_js_url('/question/' . $question_info['redirect']['target_id'] . '?rf=' . $question_info['question_id']) . '">' . $target_question['question_content'] . '</a>';
                 if ($this->user_id and ($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'] or !$this->question_info['lock'] and $this->user_info['permission']['redirect_question'])) {
                     $message .= '&nbsp; (<a href="javascript:;" onclick="AWS.ajax_request(G_BASE_URL + \'/question/ajax/redirect/\', \'item_id=' . $question_info['question_id'] . '\');">' . AWS_APP::lang()->_t('撤消重定向') . '</a>)';
                 }
                 $redirect_message[] = $message;
             } else {
                 $redirect_message[] = AWS_APP::lang()->_t('重定向目标问题已被删除, 将不再重定向问题');
             }
         }
     }
     if ($question_info['has_attach']) {
         $question_info['attachs'] = $this->model('publish')->get_attach('question', $question_info['question_id'], 'min');
         $question_info['attachs_ids'] = FORMAT::parse_attachs($question_info['question_detail'], true);
     }
     $question_info['user_info'] = $this->model('account')->get_user_info_by_uid($question_info['published_uid'], true);
     // 分类信息
     if ($question_info['category_id']) {
         $question_info['category_info'] = $this->model('system')->get_category_info($question_info['category_id']);
     }
     if (intval($question_info['quiz_id']) > 0) {
         $question_info['question_quiz'] = $this->model('quiz')->get_question_quiz_info_by_id($question_info['quiz_id']);
     }
     $this->model('question')->calc_popular_value($question_info['question_id']);
     $this->model('question')->update_views($question_info['question_id']);
     // if ($_GET['column'] != 'log')
     // {
     // $this->model('question')->calc_popular_value($question_info['question_id']);
     // $this->model('question')->update_views($question_info['question_id']);
     // if (is_digits($_GET['uid']))
     // {
     // 	$answer_list_where[] = 'uid = ' . intval($_GET['uid']);
     // 	$answer_count_where = 'uid = ' . intval($_GET['uid']);
     // }
     // else if ($_GET['uid'] == 'focus' and $this->user_id)
     // {
     // 	if ($friends = $this->model('follow')->get_user_friends($this->user_id, false))
     // 	{
     // 		foreach ($friends as $key => $val)
     // 		{
     // 			$follow_uids[] = $val['uid'];
     // 		}
     // 	}
     // 	else
     // 	{
     // 		$follow_uids[] = 0;
     // 	}
     // 	$answer_list_where[] = 'uid IN(' . implode($follow_uids, ',') . ')';
     // 	$answer_count_where = 'uid IN(' . implode($follow_uids, ',') . ')';
     // 	$answer_order_by = 'add_time ASC';
     // }
     // else if ($_GET['sort_key'] == 'add_time')
     // {
     // 	$answer_order_by = $_GET['sort_key'] . " " . $_GET['sort'];
     // }
     // else
     // {
     // 	$answer_order_by = "agree_count " . $_GET['sort'] . ", against_count ASC, add_time ASC";
     // }
     // if ($answer_count_where)
     // {
     // 	$answer_count = $this->model('answer')->get_answer_count_by_question_id($question_info['question_id'], $answer_count_where);
     // }
     // else
     // {
     // 	$answer_count = $question_info['answer_count'];
     // }
     // if (isset($_GET['answer_id']) and (! $this->user_id OR $_GET['single']))
     // {
     // 	$answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . intval($_GET['answer_id']));
     // }
     // else if (! $this->user_id AND !$this->user_info['permission']['answer_show'])
     // {
     // 	if ($question_info['best_answer'])
     // 	{
     // 		$answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . intval($question_info['best_answer']));
     // 	}
     // 	else
     // 	{
     // 		$answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, null, 'agree_count DESC');
     // 	}
     // }
     // else
     // {
     // 	if ($answer_list_where)
     // 	{
     // 		$answer_list_where = implode(' AND ', $answer_list_where);
     // 	}
     // 	$answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], calc_page_limit($_GET['page'], 100), $answer_list_where, $answer_order_by);
     // }
     // // 最佳回复预留
     // $answers[0] = '';
     // if (! is_array($answer_list))
     // {
     // 	$answer_list = array();
     // }
     // $answer_ids = array();
     // $answer_uids = array();
     // foreach ($answer_list as $answer)
     // {
     // 	$answer_ids[] = $answer['answer_id'];
     // 	$answer_uids[] = $answer['uid'];
     // 	if ($answer['has_attach'])
     // 	{
     // 		$has_attach_answer_ids[] = $answer['answer_id'];
     // 	}
     // }
     // if (!in_array($question_info['best_answer'], $answer_ids) AND intval($_GET['page']) < 2)
     // {
     // 	$answer_list = array_merge($this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . $question_info['best_answer']), $answer_list);
     // }
     // if ($answer_ids)
     // {
     // 	$answer_agree_users = $this->model('answer')->get_vote_user_by_answer_ids($answer_ids);
     // 	$answer_vote_status = $this->model('answer')->get_answer_vote_status($answer_ids, $this->user_id);
     // 	$answer_users_rated_thanks = $this->model('answer')->users_rated('thanks', $answer_ids, $this->user_id);
     // 	$answer_users_rated_uninterested = $this->model('answer')->users_rated('uninterested', $answer_ids, $this->user_id);
     // 	$answer_attachs = $this->model('publish')->get_attachs('answer', $has_attach_answer_ids, 'min');
     // }
     // foreach ($answer_list as $answer)
     // {
     // 	if ($answer['has_attach'])
     // 	{
     // 		$answer['attachs'] = $answer_attachs[$answer['answer_id']];
     // 		$answer['insert_attach_ids'] = FORMAT::parse_attachs($answer['answer_content'], true);
     // 	}
     // 	$answer['user_rated_thanks'] = $answer_users_rated_thanks[$answer['answer_id']];
     // 	$answer['user_rated_uninterested'] = $answer_users_rated_uninterested[$answer['answer_id']];
     // 	$answer['answer_content'] = $this->model('question')->parse_at_user(FORMAT::parse_attachs(nl2br(FORMAT::parse_bbcode($answer['answer_content']))));
     // 	$answer['agree_users'] = $answer_agree_users[$answer['answer_id']];
     // 	$answer['agree_status'] = $answer_vote_status[$answer['answer_id']];
     // 	if ($question_info['best_answer'] == $answer['answer_id'] AND intval($_GET['page']) < 2)
     // 	{
     // 		$answers[0] = $answer;
     // 	}
     // 	else
     // 	{
     // 		$answers[] = $answer;
     // 	}
     // 	// 获取回答评论列表
     // 	$comments = $this->model('answer')->get_answer_comments($answer['answer_id']);
     // 	$user_infos = $this->model('account')->get_user_info_by_uids(fetch_array_value($comments, 'uid'));
     // 	foreach ($comments as $key => $val)
     // 	{
     // 		$comments[$key]['message'] = FORMAT::parse_links($this->model('question')->parse_at_user($comments[$key]['message']));
     // 		$comments[$key]['user_name'] = $user_infos[$val['uid']]['user_name'];
     // 		$comments[$key]['url_token'] = $user_infos[$val['uid']]['url_token'];
     // 	}
     // 	$answer_comments[$answer['answer_id']] = $comments;
     // }
     // if (! $answers[0])
     // {
     // 	unset($answers[0]);
     // }
     // if (get_setting('answer_unique') == 'Y')
     // {
     // if ($this->model('answer')->has_answer_by_uid($question_info['question_id'], $this->user_id))
     // {
     // 	TPL::assign('user_answered', 1);
     // }
     // else
     // {
     // 	TPL::assign('user_answered', 0);
     // }
     // }
     $user_answered = $this->model('answer')->has_answer_by_uid($question_info['question_id'], $this->user_id);
     $answer_count = $question_info['answer_count'];
     TPL::assign('user_answered', $user_answered);
     // TPL::assign('answers', $answers);
     // TPL::assign('comments', $answer_comments);
     TPL::assign('answer_count', $answer_count);
     // }
     // 用户是否通过答题
     $passed_quiz = $this->model('quiz')->user_question_quiz_passed($question_info['question_id'], $this->user_id);
     $show_answers = ($question_info['published_uid'] == $this->user_id or $this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'] or $user_answered or $passed_quiz);
     TPL::assign('show_answers', $show_answers);
     if ($this->user_id) {
         TPL::assign('question_thanks', $this->model('question')->get_question_thanks($question_info['question_id'], $this->user_id));
         // TPL::assign('invite_users', $this->model('question')->get_invite_users($question_info['question_id']));
         TPL::assign('user_follow_check', $this->model('follow')->user_follow_check($this->user_id, $question_info['published_uid']));
         if ($this->user_info['draft_count'] > 0) {
             TPL::assign('draft_content', $this->model('draft')->get_data($question_info['question_id'], 'answer', $this->user_id));
         }
     }
     $question_info['question_detail'] = FORMAT::parse_attachs(nl2br(FORMAT::parse_bbcode($question_info['question_detail'])));
     // 获取答题选项类型
     if ($question_info['quiz_id']) {
         $question_info['quiz_info'] = $this->model('quiz')->get_question_quiz_info_by_id($question_info['quiz_id']);
     }
     TPL::assign('question_info', $question_info);
     TPL::assign('question_focus', $this->model('question')->has_focus_question($question_info['question_id'], $this->user_id));
     $question_topics = $this->model('topic')->get_topics_by_item_id($question_info['question_id'], 'question');
     if (sizeof($question_topics) == 0 and $this->user_id) {
         $related_topics = $this->model('question')->get_related_topics($question_info['question_content']);
         TPL::assign('related_topics', $related_topics);
     }
     TPL::assign('question_topics', $question_topics);
     // 可能喜欢的问题
     $exclude_qids[] = $question_info['question_id'];
     $recommend_questions = $this->model('question')->get_recommend_question_list_by_category($question_info['question_id'], $exclude_qids, $this->user_id, 8);
     if ($recommend_questions) {
         foreach ($recommend_questions as $key => $value) {
             // 获取相关问题的附加图片
             if ($value['has_attach']) {
                 $recommend_questions[$key]['attachs'] = $this->model('publish')->get_attach('question', $value['question_id'], 'min');
             }
             // 获取是否为限时答题信息
             $is_countdown = false;
             if ($value['quiz_id']) {
                 $quiz_info = $this->model('quiz')->get_question_quiz_info_by_id($value['quiz_id']);
                 $is_countdown = $quiz_info['countdown'] > 0;
             }
             $recommend_questions[$key]['is_countdown'] = $is_countdown;
         }
         TPL::assign('recommend_question_list', $recommend_questions);
     }
     TPL::assign('question_related_links', $this->model('related')->get_related_links('question', $question_info['question_id']));
     // 推荐用户答题功能
     $exclude_uids[] = $question_info['published_uid'];
     if ($this->user_id) {
         $exclude_uids[] = $this->user_id;
     }
     $invited_uids = $this->model('question')->get_invited_user_ids($question_info['question_id']);
     if ($invited_uids) {
         foreach ($invited_uids as $key => $val) {
             $exclude_uids[] = $val['uid'];
         }
     }
     if ($question_info['quiz_id']) {
         $answered_uids = $this->model('question')->get_quized_uids($question_info['question_id']);
     } else {
         $answered_uids = $this->model('question')->get_commented_uids($question_info['question_id']);
     }
     if ($answered_uids) {
         foreach ($answered_uids as $val) {
             if (!in_array($val, $exclude_uids)) {
                 $exclude_uids[] = $val['uid'];
             }
         }
     }
     TPL::assign('exclude_uids', $exclude_uids);
     $recommend_users = $this->model('question')->get_recommend_users_by_category_id($question_info['category_id'], $exclude_uids, get_setting('user_question_invite_recommend'));
     if ($recommend_users) {
         $uids = null;
         foreach ($recommend_users as $key => $val) {
             $uids[] = $val['uid'];
         }
         $users_info = $this->model('account')->get_user_info_by_uids($uids, true);
         foreach ($recommend_users as $key => $val) {
             $recommend_users[$key]['user_info'] = $users_info[$val['uid']];
         }
     }
     TPL::assign('recommend_users', $recommend_users);
     TPL::assign('invited_user_count', $this->model('question')->get_invited_user_count($question_info['question_id']));
     // if ($this->user_id)
     // {
     // 	if ($question_topics)
     // 	{
     // 		foreach ($question_topics AS $key => $val)
     // 		{
     // 			$question_topic_ids[] = $val['topic_id'];
     // 		}
     // 	}
     // 	if ($recommend_users = $this->model('topic')->get_recommend_users_by_topic_ids($question_topic_ids, 17))
     // 	{
     // 		foreach ($recommend_users AS $key => $val)
     // 		{
     // 			if ($val['user_info']['uid'] == $this->user_id)
     // 			{
     // 				unset($recommend_users[$key]);
     // 			}
     // 			else
     // 			{
     // 				$recommend_users[$key]['has_invite'] = $this->model('question')->has_question_invite($question_info['question_id'], $val['user_info']['uid'], $this->user_id);
     // 				$recommend_users[$key]['experience'] = end($recommend_users[$key]['experience']);
     // 			}
     // 		}
     // 		TPL::assign('recommend_users', $recommend_users);
     // 	}
     // }
     $this->crumb($question_info['question_content'], '/question/' . $question_info['question_id']);
     if ($_GET['column'] == 'log') {
         // $this->crumb(AWS_APP::lang()->_t('日志'), '/question/id-' . $question_info['question_id'] . '__column-log');
     } else {
         TPL::assign('human_valid', human_valid('answer_valid_hour'));
         if ($this->user_id) {
             TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/question/id-' . $question_info['question_id'] . '__sort_key-' . $_GET['sort_key'] . '__sort-' . $_GET['sort'] . '__uid-' . $_GET['uid']), 'total_rows' => $answer_count, 'per_page' => 100))->create_links());
         }
     }
     TPL::set_meta('keywords', implode(',', $this->model('system')->analysis_keyword($question_info['question_content'])));
     TPL::set_meta('description', $question_info['question_content'] . ' - ' . cjk_substr(str_replace("\r\n", ' ', strip_tags($question_info['question_detail'])), 0, 128, 'UTF-8', '...'));
     if (get_setting('advanced_editor_enable') == 'Y') {
         import_editor_static_files();
     }
     if (get_setting('upload_enable') == 'Y') {
         // fileupload
         TPL::import_js('js/fileupload.js');
     }
     TPL::assign('redirect_message', $redirect_message);
     $recommend_posts = $this->model('posts')->get_recommend_posts_by_topic_ids($question_topic_ids);
     if ($recommend_posts) {
         foreach ($recommend_posts as $key => $value) {
             if ($value['question_id'] and $value['question_id'] == $question_info['question_id']) {
                 unset($recommend_posts[$key]);
                 break;
             }
         }
         TPL::assign('recommend_posts', $recommend_posts);
     }
     // 是否进行出题成功提示
     if ($this->user_id == $question_info['published_uid'] and $question_info['is_first']) {
         TPL::assign('is_first_visited', true);
         TPL::assign('publish_integral', get_setting('integral_system_config_new_question'));
         TPL::assign('user_integral', $this->user_info['integral']);
         $this->model('question')->set_is_first_visited($question_info['question_id'], 0);
     }
     // 答题动态信息
     $question_quiz_record = $this->model('quiz')->get_question_quiz_record_list_page($question_info['question_id'], 1, 5);
     TPL::assign('question_quiz_record', $question_quiz_record);
     // // 添加题目解析提示提示
     // if($this->user_id == $question_info['published_uid'] AND !$question_info['solution_id'])
     // {
     // 	TPL::assign('show_add_solution_hint', true);
     // }
     // 获取上一道题目和下一道题目的信息
     // $question_info_next = $this->model('question')->get_next_question_info($question_info['question_id']);
     // $question_info_previous = $this->model('question')->get_previous_question_info($question_info['question_id']);
     // TPL::assign('question_info_next', $question_info_next);
     // TPL::assign('question_info_previous', $question_info_previous);
     TPL::import_js('js/app/question.js');
     TPL::import_js('js/bootstrap-growl.min.js');
     TPL::import_js('js/quiz.js');
     TPL::import_css('css/quiz.css');
     TPL::import_js('js/sweetalert.min.js');
     TPL::import_css('css/sweetalert.css');
     TPL::import_js('js/jquery-qrcode.min.js');
     TPL::import_js('js/share.js');
     TPL::output('question/index');
 }
コード例 #15
0
ファイル: main.php プロジェクト: Vizards/HeavenSpree
 public function article_action()
 {
     if ($_GET['notification_id']) {
         $this->model('notify')->read_notification($_GET['notification_id'], $this->user_id);
     }
     if (!($article_info = $this->model('article')->get_article_info_by_id($_GET['id']))) {
         H::redirect_msg(AWS_APP::lang()->_t('文章不存在或已被删除'), '/home/explore/');
     }
     $this->crumb($article_info['title'], '/article/' . $article_info['id']);
     if ($article_info['has_attach']) {
         $article_info['attachs'] = $this->model('publish')->get_attach('article', $article_info['id'], 'min');
         $article_info['attachs_ids'] = FORMAT::parse_attachs($article_info['message'], true);
     }
     $article_info['user_info'] = $this->model('account')->get_user_info_by_uid($article_info['uid'], true);
     $article_info['message'] = FORMAT::parse_attachs(nl2br(FORMAT::parse_markdown($article_info['message'])));
     if ($this->user_id) {
         $article_info['vote_info'] = $this->model('article')->get_article_vote_by_id('article', $article_info['id'], null, $this->user_id);
     }
     $article_info['vote_users'] = $this->model('article')->get_article_vote_users_by_id('article', $article_info['id'], null, 10);
     TPL::assign('article_info', $article_info);
     TPL::assign('article_topics', $this->model('topic')->get_topics_by_item_id($article_info['id'], 'article'));
     if ($_GET['item_id']) {
         $comments[] = $this->model('article')->get_comment_by_id($_GET['item_id']);
     } else {
         $comments = $this->model('article')->get_comments($article_info['id'], $_GET['page'], 100);
     }
     if ($comments and $this->user_id) {
         foreach ($comments as $key => $val) {
             $comments[$key]['vote_info'] = $this->model('article')->get_article_vote_by_id('comment', $val['id'], 1, $this->user_id);
         }
     }
     $this->model('article')->update_views($article_info['id']);
     TPL::assign('comments', $comments);
     TPL::assign('comments_count', $article_info['comments']);
     TPL::assign('human_valid', human_valid('answer_valid_hour'));
     TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/m/article/id-' . $article_info['id']), 'total_rows' => $article_info['comments'], 'per_page' => 100))->create_links());
     TPL::output('m/article');
 }
コード例 #16
0
 public function index_action()
 {
     if (!($article_info = $this->model('article')->get_article_info_by_id($_GET['id']))) {
         H::redirect_msg(AWS_APP::lang()->_t('文章不存在或已被删除'), '/');
     }
     if ($article_info['has_attach']) {
         $article_info['attachs'] = $this->model('publish')->get_attach('article', $article_info['id'], 'min');
         $article_info['attachs_ids'] = FORMAT::parse_attachs($article_info['message'], true);
     }
     $article_info['user_info'] = $this->model('account')->get_user_info_by_uid($article_info['uid'], true);
     $article_info['message'] = FORMAT::parse_attachs(nl2br(FORMAT::parse_bbcode($article_info['message'])));
     if ($this->user_id) {
         $article_info['vote_info'] = $this->model('article')->get_article_vote_by_id('article', $article_info['id'], null, $this->user_id);
     }
     //赞了该文章的用户信息
     $article_info['vote_users'] = $this->model('article')->get_article_vote_users_by_id('article', $article_info['id'], 1, 10);
     //文章话题
     $article_topics = $this->model('topic')->get_topics_by_item_id($article_info['id'], 'article');
     $comments = $this->model('article')->get_comments($article_info['id'], $_GET['page'], 100);
     if ($comments and $this->user_id) {
         foreach ($comments as $key => $val) {
             $comments[$key]['vote_info'] = $this->model('article')->get_article_vote_by_id('comment', $val['id'], 1, $this->user_id);
             $comments[$key]['message'] = $this->model('question')->parse_at_user($val['message']);
         }
     }
     $article_info['user_follow_check'] = 0;
     if ($this->user_id and $this->model('follow')->user_follow_check($this->user_id, $article_info['uid'])) {
         $article_info['user_follow_check'] = 1;
     }
     $this->model('article')->update_views($article_info['id']);
     //作者信息
     if ($article_info['user_info']) {
         $article_info['user_info'] = $this->model('myapi')->get_clean_user_info($article_info['user_info']);
     }
     //点赞者信息
     if (!empty($article_info['vote_users'])) {
         foreach ($article_info['vote_users'] as $key => $value) {
             $article_info['vote_users'][$key] = $this->model('myapi')->get_clean_user_info($value);
         }
     }
     $topics_key = array('topic_id', 'topic_title');
     if ($article_topics) {
         foreach ($article_topics as $kk => $vv) {
             foreach ($vv as $k => $v) {
                 if (!in_array($k, $topics_key)) {
                     unset($article_topics[$kk][$k]);
                 }
             }
         }
     }
     //评论里评论者信息
     if (!empty($comments)) {
         foreach ($comments as $key => $value) {
             if (!empty($value['user_info'])) {
                 $comments[$key]['user_info'] = $this->model('myapi')->get_clean_user_info($value['user_info']);
             }
             if (!empty($value['at_user_info'])) {
                 $comments[$key]['at_user_info'] = $this->model('myapi')->get_clean_user_info($value['at_user_info']);
             }
         }
     }
     H::ajax_json_output(AWS_APP::RSM(array('article_info' => $article_info, 'article_topics' => $article_topics, 'comments' => $comments), 1, null));
 }
コード例 #17
0
ファイル: main.php プロジェクト: egogg/naokr-website
 public function index_action()
 {
     if ($_GET['notification_id']) {
         $this->model('notify')->read_notification($_GET['notification_id'], $this->user_id);
     }
     if (is_mobile()) {
         HTTP::redirect('/m/question/' . $_GET['id']);
     }
     if ($_GET['column'] == 'log' and !$this->user_id) {
         HTTP::redirect('/question/' . $_GET['id']);
     }
     if (!($question_info = $this->model('question')->get_question_info_by_id($_GET['id']))) {
         H::redirect_msg(AWS_APP::lang()->_t('问题不存在或已被删除'), '/question/');
     }
     if (!$_GET['sort'] or $_GET['sort'] != 'ASC') {
         $_GET['sort'] = 'DESC';
     } else {
         $_GET['sort'] = 'ASC';
     }
     if (get_setting('unfold_question_comments') == 'Y') {
         $_GET['comment_unfold'] = 'all';
     }
     $question_info['redirect'] = $this->model('question')->get_redirect($question_info['question_id']);
     if ($question_info['redirect']['target_id']) {
         $target_question = $this->model('question')->get_question_info_by_id($question_info['redirect']['target_id']);
     }
     if (is_digits($_GET['rf']) and $_GET['rf']) {
         if ($from_question = $this->model('question')->get_question_info_by_id($_GET['rf'])) {
             $redirect_message[] = AWS_APP::lang()->_t('从问题 %s 跳转而来', '<a href="' . get_js_url('/question/' . $_GET['rf'] . '?rf=false') . '">' . $from_question['question_content'] . '</a>');
         }
     }
     if ($question_info['redirect'] and !$_GET['rf']) {
         if ($target_question) {
             HTTP::redirect('/question/' . $question_info['redirect']['target_id'] . '?rf=' . $question_info['question_id']);
         } else {
             $redirect_message[] = AWS_APP::lang()->_t('重定向目标问题已被删除, 将不再重定向问题');
         }
     } else {
         if ($question_info['redirect']) {
             if ($target_question) {
                 $message = AWS_APP::lang()->_t('此问题将跳转至') . ' <a href="' . get_js_url('/question/' . $question_info['redirect']['target_id'] . '?rf=' . $question_info['question_id']) . '">' . $target_question['question_content'] . '</a>';
                 if ($this->user_id and ($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'] or !$this->question_info['lock'] and $this->user_info['permission']['redirect_question'])) {
                     $message .= '&nbsp; (<a href="javascript:;" onclick="AWS.ajax_request(G_BASE_URL + \'/question/ajax/redirect/\', \'item_id=' . $question_info['question_id'] . '\');">' . AWS_APP::lang()->_t('撤消重定向') . '</a>)';
                 }
                 $redirect_message[] = $message;
             } else {
                 $redirect_message[] = AWS_APP::lang()->_t('重定向目标问题已被删除, 将不再重定向问题');
             }
         }
     }
     if ($question_info['has_attach']) {
         $question_info['attachs'] = $this->model('publish')->get_attach('question', $question_info['question_id'], 'min');
         $question_info['attachs_ids'] = FORMAT::parse_attachs($question_info['question_detail'], true);
     }
     if ($question_info['category_id'] and get_setting('category_enable') == 'Y') {
         $question_info['category_info'] = $this->model('system')->get_category_info($question_info['category_id']);
     }
     $question_info['user_info'] = $this->model('account')->get_user_info_by_uid($question_info['published_uid'], true);
     if ($_GET['column'] != 'log') {
         $this->model('question')->calc_popular_value($question_info['question_id']);
         $this->model('question')->update_views($question_info['question_id']);
         if (is_digits($_GET['uid'])) {
             $answer_list_where[] = 'uid = ' . intval($_GET['uid']);
             $answer_count_where = 'uid = ' . intval($_GET['uid']);
         } else {
             if ($_GET['uid'] == 'focus' and $this->user_id) {
                 if ($friends = $this->model('follow')->get_user_friends($this->user_id, false)) {
                     foreach ($friends as $key => $val) {
                         $follow_uids[] = $val['uid'];
                     }
                 } else {
                     $follow_uids[] = 0;
                 }
                 $answer_list_where[] = 'uid IN(' . implode($follow_uids, ',') . ')';
                 $answer_count_where = 'uid IN(' . implode($follow_uids, ',') . ')';
                 $answer_order_by = 'add_time ASC';
             } else {
                 if ($_GET['sort_key'] == 'add_time') {
                     $answer_order_by = $_GET['sort_key'] . " " . $_GET['sort'];
                 } else {
                     $answer_order_by = "agree_count " . $_GET['sort'] . ", against_count ASC, add_time ASC";
                 }
             }
         }
         if ($answer_count_where) {
             $answer_count = $this->model('answer')->get_answer_count_by_question_id($question_info['question_id'], $answer_count_where);
         } else {
             $answer_count = $question_info['answer_count'];
         }
         if (isset($_GET['answer_id']) and (!$this->user_id or $_GET['single'])) {
             $answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . intval($_GET['answer_id']));
         } else {
             if (!$this->user_id and !$this->user_info['permission']['answer_show']) {
                 if ($question_info['best_answer']) {
                     $answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . intval($question_info['best_answer']));
                 } else {
                     $answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, null, 'agree_count DESC');
                 }
             } else {
                 if ($answer_list_where) {
                     $answer_list_where = implode(' AND ', $answer_list_where);
                 }
                 $answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], calc_page_limit($_GET['page'], 100), $answer_list_where, $answer_order_by);
             }
         }
         // 最佳回复预留
         $answers[0] = '';
         if (!is_array($answer_list)) {
             $answer_list = array();
         }
         $answer_ids = array();
         $answer_uids = array();
         foreach ($answer_list as $answer) {
             $answer_ids[] = $answer['answer_id'];
             $answer_uids[] = $answer['uid'];
             if ($answer['has_attach']) {
                 $has_attach_answer_ids[] = $answer['answer_id'];
             }
         }
         if (!in_array($question_info['best_answer'], $answer_ids) and intval($_GET['page']) < 2) {
             $answer_list = array_merge($this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . $question_info['best_answer']), $answer_list);
         }
         if ($answer_ids) {
             $answer_agree_users = $this->model('answer')->get_vote_user_by_answer_ids($answer_ids);
             $answer_vote_status = $this->model('answer')->get_answer_vote_status($answer_ids, $this->user_id);
             $answer_users_rated_thanks = $this->model('answer')->users_rated('thanks', $answer_ids, $this->user_id);
             $answer_users_rated_uninterested = $this->model('answer')->users_rated('uninterested', $answer_ids, $this->user_id);
             $answer_attachs = $this->model('publish')->get_attachs('answer', $has_attach_answer_ids, 'min');
         }
         foreach ($answer_list as $answer) {
             if ($answer['has_attach']) {
                 $answer['attachs'] = $answer_attachs[$answer['answer_id']];
                 $answer['insert_attach_ids'] = FORMAT::parse_attachs($answer['answer_content'], true);
             }
             $answer['user_rated_thanks'] = $answer_users_rated_thanks[$answer['answer_id']];
             $answer['user_rated_uninterested'] = $answer_users_rated_uninterested[$answer['answer_id']];
             $answer['answer_content'] = $this->model('question')->parse_at_user(FORMAT::parse_attachs(nl2br(FORMAT::parse_bbcode($answer['answer_content']))));
             $answer['agree_users'] = $answer_agree_users[$answer['answer_id']];
             $answer['agree_status'] = $answer_vote_status[$answer['answer_id']];
             if ($question_info['best_answer'] == $answer['answer_id'] and intval($_GET['page']) < 2) {
                 $answers[0] = $answer;
             } else {
                 $answers[] = $answer;
             }
         }
         if (!$answers[0]) {
             unset($answers[0]);
         }
         if (get_setting('answer_unique') == 'Y') {
             if ($this->model('answer')->has_answer_by_uid($question_info['question_id'], $this->user_id)) {
                 TPL::assign('user_answered', 1);
             } else {
                 TPL::assign('user_answered', 0);
             }
         }
         TPL::assign('answers', $answers);
         TPL::assign('answer_count', $answer_count);
     }
     if ($this->user_id) {
         TPL::assign('question_thanks', $this->model('question')->get_question_thanks($question_info['question_id'], $this->user_id));
         TPL::assign('invite_users', $this->model('question')->get_invite_users($question_info['question_id']));
         TPL::assign('user_follow_check', $this->model('follow')->user_follow_check($this->user_id, $question_info['published_uid']));
         if ($this->user_info['draft_count'] > 0) {
             TPL::assign('draft_content', $this->model('draft')->get_data($question_info['question_id'], 'answer', $this->user_id));
         }
     }
     $question_info['question_detail'] = FORMAT::parse_attachs(nl2br(FORMAT::parse_bbcode($question_info['question_detail'])));
     TPL::assign('question_info', $question_info);
     TPL::assign('question_focus', $this->model('question')->has_focus_question($question_info['question_id'], $this->user_id));
     $question_topics = $this->model('topic')->get_topics_by_item_id($question_info['question_id'], 'question');
     if (sizeof($question_topics) == 0 and $this->user_id) {
         $related_topics = $this->model('question')->get_related_topics($question_info['question_content']);
         TPL::assign('related_topics', $related_topics);
     }
     TPL::assign('question_topics', $question_topics);
     TPL::assign('question_related_list', $this->model('question')->get_related_question_list($question_info['question_id'], $question_info['question_content']));
     TPL::assign('question_related_links', $this->model('related')->get_related_links('question', $question_info['question_id']));
     if ($this->user_id) {
         if ($question_topics) {
             foreach ($question_topics as $key => $val) {
                 $question_topic_ids[] = $val['topic_id'];
             }
         }
         if ($helpful_users = $this->model('topic')->get_helpful_users_by_topic_ids($question_topic_ids, 17)) {
             foreach ($helpful_users as $key => $val) {
                 if ($val['user_info']['uid'] == $this->user_id) {
                     unset($helpful_users[$key]);
                 } else {
                     $helpful_users[$key]['has_invite'] = $this->model('question')->has_question_invite($question_info['question_id'], $val['user_info']['uid'], $this->user_id);
                     $helpful_users[$key]['experience'] = end($helpful_users[$key]['experience']);
                 }
             }
             TPL::assign('helpful_users', $helpful_users);
         }
     }
     $this->crumb($question_info['question_content'], '/question/' . $question_info['question_id']);
     if ($_GET['column'] == 'log') {
         $this->crumb(AWS_APP::lang()->_t('日志'), '/question/id-' . $question_info['question_id'] . '__column-log');
     } else {
         TPL::assign('human_valid', human_valid('answer_valid_hour'));
         if ($this->user_id) {
             TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/question/id-' . $question_info['question_id'] . '__sort_key-' . $_GET['sort_key'] . '__sort-' . $_GET['sort'] . '__uid-' . $_GET['uid']), 'total_rows' => $answer_count, 'per_page' => 100))->create_links());
         }
     }
     TPL::set_meta('keywords', implode(',', $this->model('system')->analysis_keyword($question_info['question_content'])));
     TPL::set_meta('description', $question_info['question_content'] . ' - ' . cjk_substr(str_replace("\r\n", ' ', strip_tags($question_info['question_detail'])), 0, 128, 'UTF-8', '...'));
     if (get_setting('advanced_editor_enable') == 'Y') {
         import_editor_static_files();
     }
     if (get_setting('upload_enable') == 'Y') {
         // fileupload
         TPL::import_js('js/fileupload.js');
     }
     TPL::assign('attach_access_key', md5($this->user_id . time()));
     TPL::assign('redirect_message', $redirect_message);
     $recommend_posts = $this->model('posts')->get_recommend_posts_by_topic_ids($question_topic_ids);
     if ($recommend_posts) {
         foreach ($recommend_posts as $key => $value) {
             if ($value['question_id'] and $value['question_id'] == $question_info['question_id']) {
                 unset($recommend_posts[$key]);
                 break;
             }
         }
         TPL::assign('recommend_posts', $recommend_posts);
     }
     // 答题选项
     if (intval($question_info['quiz_id']) > 0) {
         $question_quiz = $this->model('quiz')->get_question_quiz_info_by_id($question_info['quiz_id']);
         TPL::import_js('js/quiz.js');
         TPL::import_css('css/quiz.css');
         TPL::import_js('js/app/question.js');
         TPL::assign('question_quiz', $question_quiz);
     }
     TPL::output('question/index');
 }
コード例 #18
0
 public function save_answer_action()
 {
     //Mobile 默认关注
     if (!isset($_POST['auto_focus'])) {
         $_POST['auto_focus'] = 1;
     }
     if ($this->user_info['integral'] < 0 and get_setting('integral_system_enabled') == 'Y') {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('你的剩余积分已经不足以进行此操作')));
     }
     if (!($question_info = $this->model('question')->get_question_info_by_id($_POST['question_id']))) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('问题不存在')));
     }
     if ($question_info['lock'] and !($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'])) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('已经锁定的问题不能回复')));
     }
     $answer_content = trim($_POST['answer_content'], "\r\n\t");
     if (!$answer_content) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('请输入回复内容')));
     }
     // 判断是否是问题发起者
     if (get_setting('answer_self_question') == 'N' and $question_info['published_uid'] == $this->user_id) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('不能回复自己发布的问题,你可以修改问题内容')));
     }
     // 判断是否已回复过问题
     if (get_setting('answer_unique') == 'Y' && $this->model('answer')->has_answer_by_uid($_POST['question_id'], $this->user_id)) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('一个问题只能回复一次,你可以编辑回复过的回复')));
     }
     if (strlen($answer_content) < get_setting('answer_length_lower')) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('回复内容字数不得少于 %s 字节', get_setting('answer_length_lower'))));
     }
     if (!$this->user_info['permission']['publish_url'] && FORMAT::outside_url_exists($answer_content)) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('你所在的用户组不允许发布站外链接')));
     }
     $this->model('draft')->delete_draft($question_info['question_id'], 'answer', $this->user_id);
     if ($this->publish_approval_valid($answer_content)) {
         $this->model('publish')->publish_approval('answer', array('question_id' => $question_info['question_id'], 'answer_content' => $answer_content, 'anonymous' => $_POST['anonymous'], 'attach_access_key' => $_POST['attach_access_key'], 'auto_focus' => $_POST['auto_focus']), $this->user_id, $_POST['attach_access_key']);
         H::ajax_json_output(AWS_APP::RSM(null, '0', AWS_APP::lang()->_t('发布成功, 请等待管理员审核...')));
     } else {
         $answer_id = $this->model('publish')->publish_answer($question_info['question_id'], $answer_content, $this->user_id, $_POST['anonymous'], $_POST['attach_access_key'], $_POST['auto_focus']);
         $this->model('answer')->set_answer_publish_source($answer_id, 'mobile');
         $answer_info = $this->model('answer')->get_answer_by_id($answer_id);
         if ($answer_info['has_attach']) {
             $answer_info['attachs'] = $this->model('publish')->get_attach('answer', $answer_id, 'min');
             $answer_info['insert_attach_ids'] = FORMAT::parse_attachs($answer_info['answer_content'], true);
         }
         //$answer_info['user_info'] = $this->user_info;
         $answer_info['answer_content'] = $this->model('question')->parse_at_user(FORMAT::parse_attachs(nl2br(FORMAT::parse_bbcode($answer_info['answer_content']))));
         H::ajax_json_output(AWS_APP::RSM(array('answer_id' => $answer_id, 'answer_info' => $answer_info), 1, null));
     }
 }