コード例 #1
0
ファイル: main.php プロジェクト: egogg/wecenter-dev
 public function read_action()
 {
     if (!($dialog = $this->model('message')->get_dialog_by_id($_GET['id']))) {
         H::redirect_msg(AWS_APP::lang()->_t('指定的站内信不存在'), '/inbox/');
     }
     if ($dialog['recipient_uid'] != $this->user_id and $dialog['sender_uid'] != $this->user_id) {
         H::redirect_msg(AWS_APP::lang()->_t('指定的站内信不存在'), '/inbox/');
     }
     $this->model('message')->set_message_read($_GET['id'], $this->user_id);
     if ($list = $this->model('message')->get_message_by_dialog_id($_GET['id'])) {
         if ($dialog['sender_uid'] != $this->user_id) {
             $recipient_user = $this->model('account')->get_user_info_by_uid($dialog['sender_uid']);
         } else {
             $recipient_user = $this->model('account')->get_user_info_by_uid($dialog['recipient_uid']);
         }
         foreach ($list as $key => $val) {
             if ($dialog['sender_uid'] == $this->user_id and $val['sender_remove']) {
                 unset($list[$key]);
             } else {
                 if ($dialog['sender_uid'] != $this->user_id and $val['recipient_remove']) {
                     unset($list[$key]);
                 } else {
                     $list[$key]['message'] = FORMAT::parse_links($val['message']);
                     $list[$key]['user_name'] = $recipient_user['user_name'];
                     $list[$key]['url_token'] = $recipient_user['url_token'];
                     $list[$key]['profile_update_time'] = $recipient_user['profile_update_time'];
                 }
             }
         }
     }
     $this->crumb(AWS_APP::lang()->_t('私信对话') . ': ' . $recipient_user['user_name'], '/inbox/read/' . intval($_GET['id']));
     TPL::assign('list', $list);
     TPL::assign('recipient_user', $recipient_user);
     TPL::output('inbox/read');
 }
コード例 #2
0
ファイル: main.php プロジェクト: Vizards/HeavenSpree
 public function inbox_action()
 {
     if ($_GET['dialog_id']) {
         if (!($dialog = $this->model('message')->get_dialog_by_id($_GET['dialog_id']))) {
             H::redirect_msg(AWS_APP::lang()->_t('指定的站内信不存在'), '/m/inbox/');
         }
         if ($dialog['recipient_uid'] != $this->user_id and $dialog['sender_uid'] != $this->user_id) {
             H::redirect_msg(AWS_APP::lang()->_t('指定的站内信不存在'), '/m/inbox/');
         }
         $this->model('message')->set_message_read($_GET['dialog_id'], $this->user_id);
         if ($list = $this->model('message')->get_message_by_dialog_id($_GET['dialog_id'])) {
             if ($dialog['sender_uid'] != $this->user_id) {
                 $recipient_user = $this->model('account')->get_user_info_by_uid($dialog['sender_uid']);
             } else {
                 $recipient_user = $this->model('account')->get_user_info_by_uid($dialog['recipient_uid']);
             }
             foreach ($list as $key => $value) {
                 $value['message'] = FORMAT::parse_links($value['message']);
                 $value['user_name'] = $recipient_user['user_name'];
                 $value['url_token'] = $recipient_user['url_token'];
                 $list_data[] = $value;
             }
         }
         $this->crumb(AWS_APP::lang()->_t('私信对话') . ': ' . $recipient_user['user_name'], '/m/inbox/dialog_id-' . intval($_GET['dialog_id']));
         TPL::assign('body_class', 'active');
         TPL::assign('list', $list_data);
         TPL::assign('recipient_user', $recipient_user);
         TPL::output('m/inbox_read');
     } else {
         $this->crumb(AWS_APP::lang()->_t('私信'), '/m/inbox/');
         TPL::output('m/inbox');
     }
 }
コード例 #3
0
ファイル: ajax.php プロジェクト: tenstone/wecenter
 public function get_question_comments_action()
 {
     $comments = $this->model('question')->get_question_comments($_GET['question_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'];
     }
     TPL::assign('question', $this->model('question')->get_question_info_by_id($_GET['question_id']));
     TPL::assign('comments', $comments);
     TPL::output("question/ajax/comments");
 }
コード例 #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
 public function read_action()
 {
     if (!($dialog = $this->model('message')->get_dialog_by_id($_GET['id']))) {
         H::redirect_msg(AWS_APP::lang()->_t('指定的站内信不存在'), '/inbox/');
     }
     if ($dialog['recipient_uid'] != $this->user_id and $dialog['sender_uid'] != $this->user_id) {
         H::redirect_msg(AWS_APP::lang()->_t('指定的站内信不存在'), '/inbox/');
     }
     $this->model('message')->set_message_read($_GET['id'], $this->user_id);
     if ($list = $this->model('message')->get_message_by_dialog_id($_GET['id'])) {
         if ($dialog['sender_uid'] != $this->user_id) {
             $recipient_user = $this->model('account')->get_user_info_by_uid($dialog['sender_uid']);
         } else {
             $recipient_user = $this->model('account')->get_user_info_by_uid($dialog['recipient_uid']);
         }
         foreach ($list as $key => $val) {
             if ($dialog['sender_uid'] == $this->user_id and $val['sender_remove']) {
                 unset($list[$key]);
             } else {
                 if ($dialog['sender_uid'] != $this->user_id and $val['recipient_remove']) {
                     unset($list[$key]);
                 } else {
                     $list[$key]['message'] = FORMAT::parse_links($val['message']);
                     $list[$key]['user_name'] = $recipient_user['user_name'];
                     $list[$key]['url_token'] = $recipient_user['url_token'];
                 }
             }
         }
     }
     $user_key = array('uid', 'user_name', 'name', 'avatar_file', 'namecard_pic', 'signature');
     if (!empty($recipient_user)) {
         foreach ($recipient_user as $k => $v) {
             if (!in_array($k, $user_key)) {
                 unset($recipient_user[$k]);
             }
         }
     }
     $recipient_user['avatar_file'] = get_avatar_url($recipient_user['uid'], 'max');
     H::ajax_json_output(AWS_APP::RSM(array('recipient_user' => $recipient_user, 'rows' => $list), 1, null));
 }
コード例 #6
0
ファイル: Markdown.php プロジェクト: Vizards/HeavenSpree
 protected function doParseLink($text)
 {
     return $this->hashPart(FORMAT::parse_links($text));
 }
コード例 #7
0
 public function get_answer_comments_action()
 {
     $comments = $this->model('answer')->get_answer_comments($_GET['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'];
         $comments[$key]['avatar_file'] = $user_infos[$val['uid']]['avatar_file'];
         $comments[$key]['time'] = date_friendly($val['time']);
     }
     //$answer_info = $this->model('answer')->get_answer_by_id($_GET['answer_id']);
     echo json_encode($array = array("value" => $comments));
     /*TPL::assign('question', $this->model('question')->get_question_info_by_id($answer_info['question_id']));
     
     		TPL::assign('comments', $comments);
     
     		if (is_mobile())
     		{
     		TPL::output("m/ajax/question_comments");
     		}
     		else
     		{
     		TPL::output("question/ajax/comments");
     		}*/
 }