private function getUserByEventId($event_id) { $response = array(); $response["success"] = 0; if ($event_id != null) { $event = TryFetchUserEvent::FetchById($event_id); if ($event != null) { //there is an event found $json_event = json_encode($event); $php_event = json_decode($json_event); $user_id = $php_event->CreatorId; if ($user_id != null) { $tryfetchUser = new TryFetchUser(); $user = $tryfetchUser->fetch($user_id); if ($user != null) { $response["success"] = 1; $response["user"] = $user; } } } else { $response["error_message"] = "No event found "; } } else { $response["error_message"] = "Event id must be provided"; } $jsonView = new JsonViewer(); $jsonView->setContent($response); return $jsonView; }
private function removeEvent($user_id, $password, $event_id) { $response = array(); $response["success"] = 0; $tryUser = new TryFetchUser(); $user = $tryUser->fetch($user_id); if ($user != null) { //convert to php object $json_user = json_encode($user); $php_user = json_decode($json_user); $email = $php_user->Email; $trylogin = new TryUserLogin($email, $password); if ($trylogin->isExists()) { //now check if the event $tryRemove = new TryRemoveEvent(); if ($tryRemove->remove($event_id)) { $response["success"] = 1; $response["message"] = "Event successfully removed"; } else { $response["error_message"] = "Invalid event details provided {$event_id} "; } } else { $response["error_message"] = "No such information found with the login information"; } } else { $response["error_message"] = "Invalid user login information provided"; } $jsonView = new JsonViewer(); $jsonView->setContent($response); return $jsonView; }
public function Update($email, $password, $fullname, $long, $lat) { $jsonView = new JsonViewer(); $response = array(); $response["success"] = 0; $tryLogin = new TryUserLogin($email, $password); //if exists if ($tryLogin->isExists()) { //fetch user $tryFectUser = new TryFetchUser(); $user = $tryFectUser->fetch($email); if ($user != null) { $user = json_encode($user); $user_php = json_decode($user); //update the user information $tryUpdate = new TryUpdateUser($user_php->ID, $fullname, $long, $lat); $returnVal = $tryUpdate->update(); if ($returnVal) { $response["success"] = 1; $response["message"] = "user information updated"; } else { $response["error_message"] = "Could not update records contact administrator"; } } else { $response["message"] = "user information could not be update"; } } else { $response["error_message"] = "Valid email or password information passed for update"; } $jsonView->setContent($response); return $jsonView; }
private function createNewEvent($email, $password, $title, $venue, $privacy, $fees, $currency_country = "") { $response = array(); $response["success"] = 0; //verify if the user exists $trycheck = new TryUserLogin($email, $password); if ($trycheck->isExists()) { $tryfetch = new TryFetchUser(); $user = $tryfetch->fetch($email); if ($user != null) { $user_json = json_encode($user); $user_php = json_decode($user_json); $event = new Event($user_php->ID, $title, $venue, $privacy); $event->setCreateDate(Validator::Now()); $event->setDuration(""); $event->setStartDate(""); $event->setDescription(""); $event->setFees($fees); $event->setCurrencyCountry($currency_country); // $event->setSearchableKeywords($searchable); //validate the events if ($this->validate($event)) { $response = $this->commit($event); } else { $response["error_message"] = $this->__message; } } } else { $response["success"] = 0; $response["error_message"] = "relogin into your account , user session expired"; } $jsonView = new JsonViewer(); $jsonView->setContent($response); return $jsonView; }
private function upLoad($email, $password, $imagebase64) { $response = array(); $response["success"] = 0; $jsonView = new JsonViewer(); $tryLogin = new TryUserLogin($email, $password); if ($tryLogin->isExists()) { $tryUser = new TryFetchUser(); $user = $tryUser->fetch($email); if ($user != null) { //the user exists $jsonuser = json_encode($user); $phpuser = json_decode($jsonuser); $tryuploadImage = new TryUploadUserProfilePhoto($phpuser->ID, $imagebase64); $path = $tryuploadImage->update(); if ($path != null) { $response["success"] = 1; $response["src_img"] = $path; } else { $response["error_message"] = "Could not upload file not file given"; } } } else { $response["error_message"] = "Session expired , please relogin with your devices"; } $jsonView->setContent($response); return $jsonView; }
private function getUser($email) { $tryfetch = new TryFetchUser(new UserTable()); $user = $tryfetch->fetch($email); if ($user != null) { $user = json_encode($user); $user = json_decode($user); } return $user; }
private function getUpdateEvent($user_id, $event_id) { $response = array(); $response["success"] = 0; $jsonView = new JsonViewer(); $events = TryFetchUserEvent::FetchById($event_id); if ($events != null) { $tryuser = new TryFetchUser(new UserTable()); $user = $tryuser->fetch($user_id); if ($user != null) { $response = $this->addNewAttendance($events, $user_id, $event_id); } else { $response["error_message"] = "User no found [{$user_id}]"; } } else { $response["error_message"] = "No event find with the given event id [{$event_id}]"; } $jsonView->setContent($response); return $jsonView; }
private function getUserInfo($username, $password) { $jsonViewer = new JsonViewer(); $response = array(); $response["success"] = 0; $userlogin = new TryUserLogin($username, $password); if ($userlogin->isExists()) { $tryUser = new TryFetchUser(new UserTable()); $user = $tryUser->fetch($username); $response["success"] = 1; $response["user"] = $user; } else { //check if the user email exist $error = "Invalid username[{$username}] or password"; $response["message_error"] = $error; } //set the view content to return to the users phone $jsonViewer->setContent($response); return $jsonViewer; }
private function getUserEvents($email, $password, $noevents) { $response = array(); $response["success"] = 0; $tryLogin = new TryUserLogin($email, $password); if ($tryLogin->isExists()) { $tryfetch = new TryFetchUser(new UserTable()); $user = $tryfetch->fetch($email); if ($user != null) { $response["success"] = 1; $user_json = json_encode($user); $php_user = json_decode($user_json); $tryfetchEvents = new TryFetchUserEvent($noevents); $events = $tryfetchEvents->fetch($php_user->ID); $response["events"] = $events; } else { $response["error_message"] = "Invalid user request"; } $json = new JsonViewer(); $json->setContent($response); return $json; } }
public function Index() { $email = HttpResquestHandler::getParam("email"); $password = HttpResquestHandler::getParam("password"); $response = array(); $response["success"] = 0; $tryuser = new TryFetchUser(); $userdb = $tryuser->fetch($email); if ($userdb != null) { $user = new User(json_encode($userdb)); $tryLogin = new TryUserLogin($user->getId(), $password); if ($tryLogin->isExists()) { $response["success"] = 1; } else { $response["error_message"] = "Login details is not current or you have not yet verify your account."; } } else { $response["error_message"] = "Invalid Username or Password"; } $jsonView = new JsonViewer(); $jsonView->setContent($response); return $jsonView; }
private function tryCreate(User $user) { $tryFetchUser = new TryFetchUser(); $response = array(); $response["success"] = 0; if ($tryFetchUser->fetch($user->getEmail()) == null) { $user->setVerificationCode(Validator::UniqueKey(4)); $tryCreate = new TryCreateUser($user); $abool = $tryCreate->create(); if ($abool) { $response["success"] = 1; $user = $tryFetchUser->fetch($user->getEmail()); $response["user"] = $user; $this->sendWelcomeMessage(json_encode($user)); } else { $response["error_message"] = "report this problem please!"; } } else { $email = $user->getEmail(); $response["error_message"] = "The [{$email}] account already exists "; } return $response; }
public function Index() { $jsonView = new JsonViewer(); $response = array(); $response["success"] = 0; $email = HttpResquestHandler::getParam("email"); $tryReset = new TryResetPassword($email); $code = $tryReset->update(); if ($code != null) { $response["success"] = 1; $tryFetchUser = new TryFetchUser(); $user = $tryFetchUser->fetch($email); $phpuser = new User(json_encode($user)); $status = $this->sendUserResetCode($phpuser); if ($status) { $response["message"] = "The verification as be sent to the email address {$email}"; } } else { //this should not happen die("Debugging Error in update reset code"); } $jsonView->setContent($response); return $jsonView; }
private function createLoginDetailsFrom($email, $vcode, $newpassword) { $response = array(); $response["success"] = 0; $tryFetchUser = new TryFetchUser(); $dbuser = $tryFetchUser->fetch($email); if ($dbuser != null) { $php_user = new User(json_encode($dbuser)); if (trim($php_user->getVerificationCode()) == trim($vcode)) { //create the new user login details //check if the user login details account already exists or created $tryCreateLogin = new TryCreateLoginDetail($php_user->getId(), $newpassword); if (!$tryCreateLogin->isExists()) { if ($this->validate($newpassword)) { if ($tryCreateLogin->create()) { $response["success"] = 1; } else { //This should never happen $response["error_message"] = "Error occur during login details creations"; } } else { $response["error_message"] = "Password characters must be more than 3"; } } else { $response["error_message"] = "This account has already be verified"; } } else { $response["error_message"] = "Invalid verification code provided"; } } else { $response["error_message"] = "No account found with the given details"; } $jsonView = new JsonViewer(); $jsonView->setContent($response); return $jsonView; }