public function postFriendshipRequest($userID, $friendID) { parent::post(); $statement = $this->dbConnector->prepareStatement(self::PREPARED_STATEMENT_INSERT_FRIEND_REQUEST); $statement->bindParam(":userID", $userID); $statement->bindParam(":friendID", $friendID); if ($statement->execute()) { $error = false; $friendShip = $this->getFriendship($userID, $friendID, $error); if (!$error) { $this->gcmController->sendGCMToUser($friendID, 'friend-request', $friendShip, $error); $this->setSuccessfulPostObjectResponse($friendShip); } else { $this->setServerErrorResponse($error); } } else { $errorArray = $statement->errorInfo(); $this->setServerErrorResponse($errorArray[2]); } }
public function post() { parent::post(); $error = ""; if (!$this->isDataValid($this->postDataMandatoryJSONKeys, $error)) { $this->setBadRequestResponse(ErrorRespond::INVALID_DATA, $error); } else { $hashedPassword = self::hashPassword($this->data[self::KEY_PASSWORD]); $this->preparedStatementInsert->bindParam(':email', $this->data[self::KEY_EMAIL]); $this->preparedStatementInsert->bindParam(':nickName', $this->data[self::KEY_NICK_NAME]); $this->preparedStatementInsert->bindParam(':firstName', $this->data[self::KEY_FIRST_NAME]); $this->preparedStatementInsert->bindParam(':lastName', $this->data[self::KEY_LAST_NAME]); $this->preparedStatementInsert->bindParam(':password', $hashedPassword); if ($this->preparedStatementInsert->execute()) { $error = false; $user = $this->getUser($this->dbConnector->lastInsertID(), $error); $this->setSuccessfulPostObjectResponse($user); } else { $errorArray = $this->preparedStatementInsert->errorInfo(); $this->setServerErrorResponse($errorArray[2]); } } }
public function post($senderID, $receiverID) { parent::post(); if (!$this->isDataValid($this->postDataMandatoryJSONKeys, $error)) { $this->setBadRequestResponse(ErrorRespond::INVALID_DATA, $error); } else { $statement = $this->dbConnector->prepareStatement(self::PREPARED_STATEMENT_INSERT); if ($statement->execute(array(":sender" => $senderID, ":receiver" => $receiverID, ":message" => stripslashes($this->data[self::KEY_MESSAGE]), ":date" => $this->data[self::KEY_DATE]))) { $error = false; $message = $this->selectMessage($this->dbConnector->lastInsertID(), $error); if (!$error) { $msg = $message; unset($msg[self::KEY_MESSAGE]); $this->gcmController->sendGCMToUser($receiverID, "new-message", $msg, $error); $this->setSuccessfulPostObjectResponse($message); } else { $this->setServerErrorResponse($error); } } else { $errorArray = $this->{$statement}->errorInfo(); $this->setServerErrorResponse($errorArray[2]); } } }
public function post($userID) { parent::post(); if (!$this->isDataValid($this->postDataMandatoryJSONKeys, $error)) { $this->setBadRequestResponse(ErrorRespond::INVALID_DATA, $error); } else { $statement = $this->dbConnector->prepareStatement(self::PREPARED_STATEMENT_INSERT_SIGN); if ($statement->execute(array(":userID" => $userID, ":name" => $this->data[self::KEY_NAME], ":date" => $this->data[self::KEY_DATE], ":sign" => stripslashes($this->data[self::KEY_SIGN])))) { $error = false; $signID = $this->dbConnector->lastInsertID(); foreach ($this->data[self::KEY_TAGS] as $tag) { $tagID = $this->insertOrSelectTag($tag[self::KEY_TAG], $error); if (!$error) { $this->insertSignHasTag($signID, $tagID, $error); if ($error) { $this->setServerErrorResponse($error); } } else { $this->setServerErrorResponse($error); } } $sign = $this->selectSign($signID, $error); if (!$error) { $this->setSuccessfulPostObjectResponse($sign); } else { $this->setServerErrorResponse($error); } } else { $errorArray = $this->{$statement}->errorInfo(); $this->setServerErrorResponse($errorArray[2]); } } }