public function sendOtp() { $this->autoRender = false; $json = $this->request->input(); $userOtp = DTO\ClsUserDto::Deserialize($json); $userToEmailid = $userOtp->emailId; if (empty($userToEmailid)) { $this->response->body(\App\DTO\ClsErrorDto::prepareError(118)); //$this->response->send(); return; } $otp = rand(1000, 999999); $subject = OTP_EMAIL_SUBJECT; $message = sprintf(OTP_EMAIL_BODY, $otp); //Update the OTP in database $result = $this->getTableObj()->updateOtp($userOtp->userId, $otp); $emailClient = new \Cake\Mailer\Email('default'); $emailClient->addBcc('*****@*****.**', 'Anand Kulkarni'); $emailClient->subject($subject); $emailClient->to($userToEmailid); $emailClient->send($message); if ($result) { $this->response->body(\App\DTO\ClsErrorDto::prepareSuccessMessage("verification email was sent to email : " . $userToEmailid)); //$this->response->send(); return; } else { $this->response->body(\App\DTO\ClsErrorDto::prepareError(115)); //$this->response->send(); return; } }
private function updateUserInfo($userDto) { if (is_null($userDto->userId) or is_null($userDto->emailId) or is_null($userDto->userName)) { $this->response->body(DTO\ClsErrorDto::prepareError(114)); \Cake\Log\Log::error("User information is empty"); return FAIL; } if ($this->getTableObj()->update($userDto)) { $this->response->body(DTO\ClsErrorDto::prepareSuccessMessage("User updated successfully for userid " . $userDto->userId)); $syncController = new SyncController(); $downloadUserDto = new DownloadDto\UserDto($userDto->userId, $userDto->userName, $userDto->photoUrl); $syncController->userEntry($userDto->userId, json_encode($downloadUserDto), INSERT); } else { $this->response->body(DTO\ClsErrorDto::prepareError(108)); } }
public function submit($senderUserId, DTO\ClsAnswerDto $answer) { $check = $this->getTablObj()->isAnswerNew($answer); if ($check) { $result = $this->getTablObj()->update($answer); } else { $result = $this->getTablObj()->Insert($answer->userId, $answer->destId, $answer->optionId); if ($result) { $json = json_encode(new DTO\ClsAnswerDto($answer->userId, $answer->destId, $answer->optionId, $result, date('Y-m-d H:i:s'))); $syncController = new \App\Controller\SyncController(); $syncController->answerEntry($senderUserId, $answer->userId, $json, INSERT); \Cake\Log\Log::debug("Sync Entry for Answer"); } } if ($result) { \Cake\Log\Log::debug('answer submited'); $this->response->body(DTO\ClsErrorDto::prepareSuccessMessage("Answer Saved")); $this->response->send(); } else { \Cake\Log\Log::error('answer not submited'); $this->response->body(DTO\ClsErrorDto::prepareError(120)); $this->response->send(); } }
public function uploadProfileImage($data) { $binary = base64_decode($data['upload']); $filename = $data['imageName']; $ext = $this->getExtension($filename); \Cake\Log\Log::info("image extension : " . $ext); if (!in_array($ext, $this->extension)) { $this->response->body(DTO\ClsErrorDto::prepareError(105)); $this->response->send(); return FAIL; } $dir = new Folder(PROFILE_IMAGE_DIR, true); $imagePath = PROFILE_IMAGE_DIR . $filename; $file = fopen($imagePath, 'wb'); fwrite($file, $binary); fclose($file); if (file_exists($imagePath)) { $awsDir = AWS_USER_PROFILE_IMAGES_DIR . $data['userId']; $imageUrl = $this->awsImageUpload($awsDir, $filename, $imagePath); $userDto = new DTO\ClsUserDto($data['userId'], $userName = null, $password = null, $data['emailId'], $imageUrl); if ($this->updateProfile($userDto)) { $this->response->body(DTO\ClsErrorDto::prepareSuccessMessage($imageUrl)); $this->response->send(); \Cake\Log\Log::debug('profile image upload successful imagename : ' . $filename); return SUCCESS; } else { $this->response->body(DTO\ClsErrorDto::prepareError(113)); $this->response->send(); } } $this->response->body(DTO\ClsErrorDto::prepareError(111)); $this->response->send(); return FAIL; }
private function updateLike($senderUserId, $count, DTO\ClsCommentAndLikeDto $likeDto) { $result = $this->getTableObj()->updateLike($count, $likeDto->userId, $likeDto->destId); if ($result) { $json = json_encode(new DTO\ClsLikeDto($likeDto->userId, $likeDto->destId, $result)); $syncController = new \App\Controller\SyncController(); $syncController->likeEntry($senderUserId, $likeDto->userId, $json, UPDATE); \Cake\Log\Log::debug('Like succefully stored'); $this->response->body(DTO\ClsErrorDto::prepareSuccessMessage("Like Saved")); $this->response->send(); } else { \Cake\Log\Log::error('Like not saved'); $this->response->body(\App\DTO\ClsErrorDto::prepareError(109)); $this->response->send(); } }