示例#1
0
                $replyObj->saveReply($replyID, $newsID, $userID, $replyStatement, $replyContent, $replyType);
                $result = $replyObj->getArray();
            }
            echo json_encode($result);
        } else {
            if (is_del()) {
                $newsID = _get("newsID", 0);
                $replyID = _get("replyID", 0);
                $subReplyID = _get("subReplyID", 0);
                if ($replyID == 0) {
                    throw new Exception("no such replyID", -1);
                }
                $auth = Auth::getInstance();
                $replyObj = new Reply($replyID);
                $userID = $replyObj->getReplyUserID($subReplyID);
                if ($userID != $auth->getUserID()) {
                    throw new Exception("unauthorized deletion", -1);
                }
                $replyObj->removeReply($subReplyID);
                if ($subReplyID > 0) {
                    echo $replyObj->getJson();
                } else {
                    echo json_encode(array("errCode" => 0, "errMessage" => "deletion succeeded", "replyID" => $replyID));
                }
            }
        }
    }
} catch (Exception $e) {
    $result = array("errCode" => $e->getCode(), "errMessage" => $e->getMessage());
    echo json_encode($result);
}