public function modify_question_action() { 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('问题已锁定, 不能编辑'))); } if (!$this->user_info['permission']['is_administortar'] and !$this->user_info['permission']['is_moderator'] and !$this->user_info['permission']['edit_question']) { if ($question_info['published_uid'] != $this->user_id) { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('你没有权限编辑这个问题'))); } } if (!$_POST['category_id'] and get_setting('category_enable') == 'Y') { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请选择分类'))); } if (cjk_strlen($_POST['question_content']) < 5) { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('问题标题字数不得少于 5 个字'))); } if (get_setting('question_title_limit') > 0 and cjk_strlen($_POST['question_content']) > get_setting('question_title_limit')) { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('问题标题字数不得大于') . ' ' . get_setting('question_title_limit') . ' ' . AWS_APP::lang()->_t('字节'))); } if (!$this->user_info['permission']['publish_url'] and FORMAT::outside_url_exists($_POST['question_detail'])) { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('你所在的用户组不允许发布站外链接'))); } if (!$this->model('publish')->insert_attach_is_self_upload($_POST['question_detail'], $_POST['attach_ids'])) { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('只允许插入当前页面上传的附件'))); } if (human_valid('question_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(1, 'question', $this->user_id); if ($_POST['do_delete'] and !$this->user_info['permission']['is_administortar'] and !$this->user_info['permission']['is_moderator']) { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('对不起, 你没有删除问题的权限'))); } if ($_POST['do_delete']) { if ($this->user_id != $question_info['published_uid']) { $this->model('account')->send_delete_message($question_info['published_uid'], $question_info['question_content'], $question_info['question_detail']); } $this->model('question')->remove_question($question_info['question_id']); H::ajax_json_output(AWS_APP::RSM(array('url' => get_js_url('/home/explore/')), 1, null)); } $IS_MODIFY_VERIFIED = TRUE; if (!$this->user_info['permission']['is_administortar'] and !$this->user_info['permission']['is_moderator'] and $question_info['published_uid'] != $this->user_id) { $IS_MODIFY_VERIFIED = FALSE; } $this->model('question')->update_question($question_info['question_id'], $_POST['question_content'], $_POST['question_detail'], $this->user_id, $IS_MODIFY_VERIFIED, $_POST['modify_reason'], $question_info['anonymous'], $_POST['category_id']); if ($this->user_id != $question_info['published_uid']) { $this->model('question')->add_focus_question($question_info['question_id'], $this->user_id); $this->model('notify')->send($this->user_id, $question_info['published_uid'], notify_class::TYPE_MOD_QUESTION, notify_class::CATEGORY_QUESTION, $question_info['question_id'], array('from_uid' => $this->user_id, 'question_id' => $question_info['question_id'])); $this->model('email')->action_email('QUESTION_MOD', $question_info['published_uid'], get_js_url('/question/' . $question_info['question_id']), array('user_name' => $this->user_info['user_name'], 'question_title' => $question_info['question_content'])); } if ($_POST['category_id'] and $_POST['category_id'] != $question_info['category_id']) { $category_info = $this->model('system')->get_category_info($_POST['category_id']); ACTION_LOG::save_action($this->user_id, $question_info['question_id'], ACTION_LOG::CATEGORY_QUESTION, ACTION_LOG::MOD_QUESTION_CATEGORY, $category_info['title'], $category_info['id']); } if ($_POST['attach_access_key'] and $IS_MODIFY_VERIFIED) { if ($this->model('publish')->update_attach('question', $question_info['question_id'], $_POST['attach_access_key'])) { ACTION_LOG::save_action($this->user_id, $question_info['question_id'], ACTION_LOG::CATEGORY_QUESTION, ACTION_LOG::MOD_QUESTION_ATTACH); } } H::ajax_json_output(AWS_APP::RSM(array('url' => get_js_url('/question/' . $question_info['question_id'] . '?column=log&rf=false')), 1, null)); }
public function remove_related_topic_action() { if (!($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'])) { if (!$this->user_info['permission']['edit_topic']) { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('你没有权限进行此操作'))); } else { if ($this->model('topic')->has_lock_topic($_GET['topic_id'])) { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('锁定的话题不能编辑'))); } } } $this->model('topic')->remove_related_topic($_GET['topic_id'], $_GET['related_id']); ACTION_LOG::save_action($this->user_id, $_GET['topic_id'], ACTION_LOG::CATEGORY_TOPIC, ACTION_LOG::DELETE_RELATED_TOPIC, '', $_GET['related_id']); H::ajax_json_output(AWS_APP::RSM(null, 1, null)); }
public function redirect($uid, $item_id, $target_id = NULL) { if ($item_id == $target_id) { return false; } if (!$target_id) { if ($this->delete('redirect', 'item_id = ' . intval($item_id))) { return ACTION_LOG::save_action($uid, $item_id, ACTION_LOG::CATEGORY_QUESTION, ACTION_LOG::DEL_REDIRECT_QUESTION); } } else { if ($question = $this->get_question_info_by_id($item_id)) { if (!$this->fetch_row('redirect', 'item_id = ' . intval($item_id) . ' AND target_id = ' . intval($target_id))) { $redirect_id = $this->insert('redirect', array('item_id' => intval($item_id), 'target_id' => intval($target_id), 'time' => time(), 'uid' => intval($uid))); ACTION_LOG::save_action($uid, $item_id, ACTION_LOG::CATEGORY_QUESTION, ACTION_LOG::REDIRECT_QUESTION, $question['question_content'], $target_id); return $redirect_id; } } } }
public function article_vote($type, $item_id, $rating, $uid, $reputation_factor, $item_uid) { $this->delete('article_vote', "`type` = '" . $this->quote($type) . "' AND item_id = " . intval($item_id) . ' AND uid = ' . intval($uid)); if ($rating) { if ($article_vote = $this->fetch_row('article_vote', "`type` = '" . $this->quote($type) . "' AND item_id = " . intval($item_id) . " AND rating = " . intval($rating) . ' AND uid = ' . intval($uid))) { $this->update('article_vote', array('rating' => intval($rating), 'time' => time(), 'reputation_factor' => $reputation_factor), 'id = ' . intval($article_vote['id'])); } else { $this->insert('article_vote', array('type' => $type, 'item_id' => intval($item_id), 'rating' => intval($rating), 'time' => time(), 'uid' => intval($uid), 'item_uid' => intval($item_uid), 'reputation_factor' => $reputation_factor)); } } switch ($type) { case 'article': $this->update('article', array('votes' => $this->count('article_vote', "`type` = '" . $this->quote($type) . "' AND item_id = " . intval($item_id) . " AND rating = 1")), 'id = ' . intval($item_id)); switch ($rating) { case 1: ACTION_LOG::save_action($uid, $item_id, ACTION_LOG::CATEGORY_QUESTION, ACTION_LOG::ADD_AGREE_ARTICLE); break; case -1: ACTION_LOG::delete_action_history('associate_type = ' . ACTION_LOG::CATEGORY_QUESTION . ' AND associate_action = ' . ACTION_LOG::ADD_AGREE_ARTICLE . ' AND uid = ' . intval($uid) . ' AND associate_id = ' . intval($item_id)); break; } break; case 'comment': $this->update('article_comments', array('votes' => $this->count('article_vote', "`type` = '" . $this->quote($type) . "' AND item_id = " . intval($item_id) . " AND rating = 1")), 'id = ' . intval($item_id)); break; } $this->model('account')->sum_user_agree_count($item_uid); return true; }
public function publish_article($title, $message, $uid, $topics = null, $category_id = null, $attach_access_key = null, $create_topic = true) { if ($article_id = $this->insert('article', array('uid' => intval($uid), 'title' => htmlspecialchars($title), 'message' => htmlspecialchars($message), 'category_id' => intval($category_id), 'add_time' => time()))) { set_human_valid('question_valid_hour'); if (is_array($topics)) { foreach ($topics as $key => $topic_title) { $topic_id = $this->model('topic')->save_topic($topic_title, $uid, $create_topic); $this->model('topic')->save_topic_relation($uid, $topic_id, $article_id, 'article'); } } if ($attach_access_key) { $this->model('publish')->update_attach('article', $article_id, $attach_access_key); } $this->model('search_fulltext')->push_index('article', $title, $article_id); // 记录日志 ACTION_LOG::save_action($uid, $article_id, ACTION_LOG::CATEGORY_QUESTION, ACTION_LOG::ADD_ARTICLE, htmlspecialchars($title), htmlspecialchars($message), 0); $this->model('posts')->set_posts_index($article_id, 'article'); } return $article_id; }
public function add_focus_question($question_id, $uid, $anonymous = 0, $save_action = true) { if (!$question_id or !$uid) { return false; } if (!$this->has_focus_question($question_id, $uid)) { if ($this->insert('question_focus', array('question_id' => intval($question_id), 'uid' => intval($uid), 'add_time' => time()))) { $this->update_focus_count($question_id); } // 璁板綍鏃ュ織 if ($save_action) { ACTION_LOG::save_action($uid, $question_id, ACTION_LOG::CATEGORY_QUESTION, ACTION_LOG::ADD_REQUESTION_FOCUS, '', '', 0, intval($anonymous)); } return 'add'; } else { // 鍑忓皯闂鍏虫敞鏁伴噺 if ($this->delete_focus_question($question_id, $uid)) { $this->update_focus_count($question_id); } return 'remove'; } }
public function publish_article_comment($article_id, $message, $uid, $at_uid = null) { if (!($article_info = $this->model('article')->get_article_info_by_id($article_id))) { return false; } $comment_id = $this->insert('article_comments', array('uid' => intval($uid), 'article_id' => intval($article_id), 'message' => htmlspecialchars($message), 'add_time' => time(), 'at_uid' => intval($at_uid))); $this->update('article', array('comments' => $this->count('article_comments', 'article_id = ' . intval($article_id))), 'id = ' . intval($article_id)); if ($at_uid and $at_uid != $uid) { $this->model('notify')->send($uid, $at_uid, notify_class::TYPE_ARTICLE_COMMENT_AT_ME, notify_class::CATEGORY_ARTICLE, $article_info['id'], array('from_uid' => $uid, 'article_id' => $article_info['id'], 'item_id' => $comment_id)); } if ($at_users = $this->model('question')->parse_at_user($message, false, true)) { foreach ($at_users as $user_id) { if ($user_id != $uid) { $this->model('notify')->send($uid, $user_id, notify_class::TYPE_ARTICLE_COMMENT_AT_ME, notify_class::CATEGORY_ARTICLE, $article_info['id'], array('from_uid' => $uid, 'article_id' => $article_info['id'], 'item_id' => $answer_id)); } } } set_human_valid('answer_valid_hour'); if ($article_info['uid'] != $uid) { $this->model('notify')->send($uid, $article_info['uid'], notify_class::TYPE_ARTICLE_NEW_COMMENT, notify_class::CATEGORY_ARTICLE, $article_info['id'], array('from_uid' => $uid, 'article_id' => $article_info['id'], 'item_id' => $comment_id)); } if ($weixin_user = $this->model('openid_weixin_weixin')->get_user_info_by_uid($article_info['uid']) and $article_info['uid'] != $uid) { $weixin_user_info = $this->model('account')->get_user_info_by_uid($weixin_user['uid']); if ($weixin_user_info['weixin_settings']['NEW_ARTICLE_COMMENT'] != 'N') { $this->model('weixin')->send_text_message($weixin_user['openid'], "您的文章 [" . $article_info['title'] . "] 收到了新的评论:\n\n" . strip_tags($message), $this->model('openid_weixin_weixin')->redirect_url('/article/' . $article_info['id'])); } } ACTION_LOG::save_action($uid, $article_info['id'], ACTION_LOG::CATEGORY_QUESTION, ACTION_LOG::ADD_COMMENT_ARTICLE, $message, $comment_id); $this->model('posts')->set_posts_index($article_info['id'], 'article'); return $comment_id; }
public function save_topic_relation($uid, $topic_id, $item_id, $type) { if (!$topic_id or !$item_id or !$type) { return false; } if (!($topic_info = $this->get_topic_by_id($topic_id))) { return false; } if ($flag = $this->check_topic_relation($topic_id, $item_id, $type)) { return $flag; } switch ($type) { case 'question': ACTION_LOG::save_action($uid, $item_id, ACTION_LOG::CATEGORY_QUESTION, ACTION_LOG::ADD_TOPIC, $topic_info['topic_title'], $topic_id); ACTION_LOG::save_action($uid, $topic_id, ACTION_LOG::CATEGORY_TOPIC, ACTION_LOG::ADD_TOPIC, $topic_info['topic_title'], $item_id); break; } $this->model('account')->save_recent_topics($uid, $topic_info['topic_title']); $insert_id = $this->insert('topic_relation', array('topic_id' => intval($topic_id), 'item_id' => intval($item_id), 'add_time' => time(), 'uid' => intval($uid), 'type' => $type)); $this->model('topic')->update_discuss_count($topic_id); return $insert_id; }
/** * * 回复投票 * @param int $answer_id //回复id * @param int $question_id //问题ID * @param int $vote_value //-1反对 1 赞同 * @param int $uid //用户ID * * @return boolean true|false */ public function change_answer_vote($answer_id, $vote_value = 1, $uid = 0, $reputation_factor = 0) { if (!$answer_id) { return false; } if (!in_array($vote_value, array(-1, 0, 1))) { return false; } $answer_info = $this->get_answer_by_id($answer_id); $question_id = $answer_info['question_id']; $answer_uid = $answer_info['uid']; if (!($vote_info = $this->get_answer_vote_status($answer_id, $uid))) { $this->insert('answer_vote', array('answer_id' => $answer_id, 'answer_uid' => $answer_uid, 'vote_uid' => $uid, 'add_time' => time(), 'vote_value' => $vote_value, 'reputation_factor' => $reputation_factor)); if ($vote_value == 1) { ACTION_LOG::save_action($uid, $question_id, ACTION_LOG::CATEGORY_QUESTION, ACTION_LOG::ADD_AGREE, '', intval($answer_id)); } } else { if ($vote_info['vote_value'] == $vote_value) { $this->delete_answer_vote($vote_info['voter_id']); ACTION_LOG::delete_action_history('associate_type = ' . ACTION_LOG::CATEGORY_QUESTION . ' AND associate_action = ' . ACTION_LOG::ADD_AGREE . ' AND uid = ' . intval($uid) . ' AND associate_id = ' . intval($question_id) . ' AND associate_attached = ' . intval($answer_id)); } else { $this->set_answer_vote_status($vote_info['voter_id'], $vote_value); if ($vote_value == 1) { ACTION_LOG::save_action($uid, $question_id, ACTION_LOG::CATEGORY_QUESTION, ACTION_LOG::ADD_AGREE, '', $answer_id); } } } if ($vote_value == 1 and $vote_info['vote_value'] != 1 and $answer_info['uid'] != $uid) { $this->model('notify')->send($uid, $answer_info['uid'], notify_class::TYPE_ANSWER_AGREE, notify_class::CATEGORY_QUESTION, $question_id, array('from_uid' => $uid, 'question_id' => $question_id, 'item_id' => $answer_id)); } $this->update_vote_count($answer_id, 'against'); $this->update_vote_count($answer_id, 'agree'); $this->update_question_vote_count($question_id); // 更新回复作者的被赞同数 $this->model('account')->sum_user_agree_count($answer_uid); return true; }
public function set_project_like($project_id, $uid) { if (!$project_id or !$uid) { return false; } if ($this->get_like_status_by_uid($project_id, $uid)) { return false; } $like_id = $this->insert('project_like', array('project_id' => intval($project_id), 'uid' => intval($uid), 'add_time' => time())); $this->update('project', array('like_count' => $this->count('project_like', 'project_id = ' . intval($project_id))), 'id = ' . intval($project_id)); // Modify by wecenter ACTION_LOG::save_action($uid, $project_id, ACTION_LOG::CATEGORY_QUESTION, ACTION_LOG::ADD_LIKE_PROJECT); return $like_id; }
public function add_product_order_action() { if (!($project_info = $this->model('project')->get_project_info_by_id($_POST['project_id']))) { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('项目不存在'))); } if ($project_info['approved'] != 1) { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('当前项目未通过审核'))); } if ($project_info['start_time'] > time()) { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('当前项目处于预热中,尚未开始'))); } if ($project_info['end_time'] < time()) { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('当前项目已经结束'))); } switch ($project_info['project_type']) { case 'DEFAULT': if (!($product_info = $this->model('project')->get_product_info_by_id($_POST['product_id']))) { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('指定商品不存在'))); } if ($_POST['is_donate'] != 1 and (!$_POST['shipping_name'] or !$_POST['shipping_address'] or !$_POST['shipping_province'] or !$_POST['shipping_city'] or !$_POST['shipping_mobile'] or !$_POST['shipping_zipcode'])) { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('请完善收货信息'))); } if (intval($product_info['amount']) == 0 and isset($_POST['amount']) and (!preg_match('/^\\d+(\\.\\d{1,2})?$/', $_POST['amount']) or intval($_POST['amount']) <= 0)) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请输入正确的金额'))); } if ($order_id = $this->model('project')->add_project_order($this->user_id, $product_info['id'], $_POST['shipping_name'], $_POST['shipping_province'], $_POST['shipping_city'], $_POST['shipping_address'], $_POST['shipping_zipcode'], $_POST['shipping_mobile'], $_POST['is_donate'], $_POST['note'], $_POST['amount'])) { // Modify by wecenter ACTION_LOG::save_action($this->user_id, $product_info['project_id'], ACTION_LOG::CATEGORY_QUESTION, ACTION_LOG::ADD_SUPPORT_PROJECT, '', $product_info['id']); if ($this->model('project')->get_like_status_by_uid($product_info['project_id'], $this->user_id)) { $this->model('project')->unset_project_like($product_info['project_id'], $this->user_id); } if (intval($product_info['amount']) == 0 and intval($_POST['amount']) == 0) { $this->model('payment')->set_order_payment_time($order_id); H::ajax_json_output(AWS_APP::RSM(array('url' => get_js_url('/project/sponsored/')), 1, null)); } else { /*if (is_mobile()) { $url = get_js_url('/m/add_project_order/' . $order_id); } else {*/ $url = get_js_url('/project/order/init_payment/' . $order_id); //} H::ajax_json_output(AWS_APP::RSM(array('url' => $url), 1, null)); } } else { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('订单生产失败,库存不足'))); } break; case 'EVENT': if (!$_POST['name'] or !$_POST['mobile'] or !$_POST['email'] or !$_POST['address']) { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('请完善报名信息'))); } if ($this->model('project')->get_single_project_order_by_uid($this->user_id, $project_info['id'])) { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('一个活动只允许报名一次, 你已经报名'))); } $this->model('project')->add_project_event($project_info['id'], $this->user_id, 0, $_POST['name'], $_POST['mobile'], $_POST['email'], $_POST['address']); H::ajax_json_output(AWS_APP::RSM(null, 1, null)); break; case 'STOCK': if (!$_POST['amount'] or !$_POST['name'] or !$_POST['mobile'] or !$_POST['email']) { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('请完善报名信息'))); } if ($this->model('project')->get_single_project_order_by_uid($this->user_id, $project_info['id'])) { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('一个活动只允许报名一次, 你已经报名'))); } $this->model('project')->add_project_event($project_info['id'], $this->user_id, $_POST['amount'], $_POST['name'], $_POST['mobile'], $_POST['email']); H::ajax_json_output(AWS_APP::RSM(null, 1, null)); break; } H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('项目类型错误'))); }