public function actionGetUserById() { $objValidator = new helpers\Validation(); $objServerInfo = new helpers\ServerInfo(); $params = array('user_token', 'user_id'); try { $isRequestValid = $objValidator->validateRequest($params); if ($isRequestValid) { $objUserAuthMdl = new \models\Users(); $userToken = $this->_request->getPost('user_token', null); $userDetails = $objUserAuthMdl->getUserFromToken($userToken); if (!$userDetails) { $this->_request->sendErrorResponse(403, 403, 'User token invalid'); } else { $userId = $this->_request->getPost('user_id', null); $userRow = \R::load('users', $userId); if ($userRow->id) { $data = $userRow->export(); $userOwnedDogs = $objUserAuthMdl->getUserOwnedDogs($userId); $profilepic = $objServerInfo->getScheme() . "://" . $objServerInfo->getHost() . APPLICATION_BASE . 'images/' . $data['id'] . "_pp.jpg"; $picFilePath = APPLICATION_DIR . "/images/{$data['id']}_pp.jpg"; $data['profilepic'] = @is_file($picFilePath) ? $profilepic : null; $data['owneddogs'] = $userOwnedDogs; $data['expertData'] = $objUserAuthMdl->getUserProfiles($userRow); $this->_request->sendSuccessResponse('Success', $data); } else { $this->_request->sendErrorResponse(404, 404, 'Profile not found'); } } } else { $this->_request->sendErrorResponse(403, 403, 'Request cannot be validated'); } } catch (\Exception $e) { $this->_request->sendErrorResponse(404, 404, $e->getMessage()); } }