コード例 #1
0
ファイル: putComment.php プロジェクト: egrivel/vacationblog
if (isPutMethod()) {
    $data = getPostData();
    $tripId = '';
    if (isset($data['tripId'])) {
        $tripId = $data['tripId'];
    }
    $commentId = '';
    if (isset($data['commentId']) && $data['commentId'] !== '') {
        $commentId = $data['commentId'];
    } else {
        $commentId = Comment::generateCommentId();
    }
    if ($tripId === '' || $commentId === '') {
        $response = errorResponse(RESPONSE_BAD_REQUEST, 'Need tripId and commentId');
    } else {
        if (!$auth->canPutComment($tripId, $commentId)) {
            $response = errorResponse(RESPONSE_UNAUTHORIZED);
        } else {
            $object = new Comment($tripId, $commentId);
            if (isset($data['userId'])) {
                $object->setUserId($data['userId']);
            }
            if (isset($data['referenceId'])) {
                $object->setReferenceId($data['referenceId']);
            }
            if (isset($data['commentText'])) {
                $object->setCommentText($data['commentText']);
            }
            if (isset($data['deleted'])) {
                $object->setDeleted($data['deleted']);
            }