/** * 保存分享的评论 * @param array $_POST 提交的数据 * @return int 评论编号 */ public function saveComment($_POST) { global $_FANWE; $share_id = intval($_POST['share_id']); $data = array(); $data['content'] = htmlspecialchars(trim($_POST['content'])); $data['uid'] = $_FANWE['uid']; $data['parent_id'] = intval($_POST['parent_id']); $data['share_id'] = $share_id; $data['create_time'] = TIME_UTC; $comment_id = FDB::insert('share_comment', $data, true); $is_relay = isset($_POST['is_relay']) ? intval($_POST['is_relay']) : 0; //转发分享 if ($is_relay == 1) { $share = ShareService::getShareById($share_id); if ($share['base_id'] > 0) { $share_user = FS('User')->getUserCache($share['uid']); $_POST['content'] = trim($_POST['content']) . '//@' . $share_user['user_name'] . ':' . $share['content']; } //添加评论消息提示 $result = FDB::query("INSERT INTO " . FDB::table('user_notice') . "(uid, type, num, create_time) VALUES('{$share['uid']}',3,1,'" . TIME_UTC . "')", 'SILENT'); if (!$result) { FDB::query("UPDATE " . FDB::table('user_notice') . " SET num = num + 1, create_time='" . TIME_UTC . "' WHERE uid='{$share['uid']}' AND type=3"); } ShareService::saveRelay($_POST); } //分享评论数量加1 FDB::query('UPDATE ' . FDB::table('share') . ' SET comment_count = comment_count + 1 WHERE share_id = ' . $share_id); //清除分享评论列表缓存 ShareService::updateShareCache($share_id, 'comments'); return $comment_id; }