private function updateEventDateVenue($user_id, $password, $event_id, $startDate, $endDate) { $response = array(); $response["success"] = 0; if ($this->isValidated($startDate, $endDate)) { //dates are not in pass and are in the future $try = new TryUserLogin($user_id, $password); if ($try->isExists()) { //The account exist $tryUpdateDateEvent = new TryUpdateDateEventModel($event_id, $startDate, $endDate); $result = $tryUpdateDateEvent->update(); if ($result) { $response["success"] = 1; $response["message"] = "Event date updated successfully"; } else { $response["error_message"] = "Invalid event request on unexisting event"; } } else { $response["error_message"] = "No user found"; } } else { $response["error_message"] = $this->__message; } $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; }
private function updateEvent($user_id, $user_password, $event_id, $desc) { $response = array(); $response["success"] = 0; $jsonView = new JsonViewer(); $tryLogin = new TryUserLogin($user_id, $user_password); if ($tryLogin->isExists()) { //update the events $database = new Database(); $sql = "UPDATE " . EventTable::TableName . " set " . EventTable::Description . "=:desc WHERE " . EventTable::Id . "=:id"; $smt = $database->prepare($sql); $smt->bindValue(":id", $event_id); $smt->bindValue(":desc", $desc); $status = $smt->execute(); if ($status) { $response["success"] = 1; $response["message"] = "Description updated"; } else { $response["error_message"] = "No event with such information found"; } } else { $response["error_message"] = "Invalid user login details"; } $jsonView->setContent($response); return $jsonView; }
private function updateEvent($user_id, $user_password, $event_id, $searchablekeywords) { $response = array(); $response["success"] = 0; $jsonView = new JsonViewer(); $tryLogin = new TryUserLogin($user_id, $user_password); if ($tryLogin->isExists()) { //update the events $database = new Database(); $sql = "UPDATE " . EventTable::TableName . " set " . EventTable::SeachableKeywords . "=:search_keys WHERE " . EventTable::Id . "=:id"; $smt = $database->prepare($sql); $smt->bindValue(":id", $event_id); $smt->bindValue(":search_keys", $searchablekeywords); $status = $smt->execute(); if ($status) { $response["success"] = 1; $response["message"] = "update searchable keys"; } else { $response["error_message"] = "Invalid event details provided"; } } else { $response["error_message"] = "Invalid login details"; } $jsonView->setContent($response); return $jsonView; }
private function uploadEventImage($email, $password, $eventId, $imagebase64) { $response = array(); $response["success"] = 0; //upload the $tryLogin = new TryUserLogin($email, $password); if ($tryLogin->isExists()) { //check if the event exist $event = TryFetchUserEvent::FetchById($eventId); if ($event != null) { print_r($event); $tryUploadEventPicture = new TryUploadEventPicture($eventId, $imagebase64); $result = $tryUploadEventPicture->update(); if ($result) { $response["success"] = 1; $response["message"] = "upload successful"; } else { $response["error_message"] = "There is no image or file to upload"; } } else { $response["error_message"] = "There is no event found with the given {$eventId} id"; } } else { $response["error_message"] = "User did not exist , have to login first to be able to upload event image"; } $json = new JsonViewer(); $json->setContent($response); return $json; }
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 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 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 update($eventid, $title, $venue, $privacy, $email, $password) { $response = array(); $response["success"] = 0; //check if the user is valid $tryLoginUser = new TryUserLogin($email, $password); if ($tryLoginUser->isExists()) { //get the current event if exist $event = TryFetchUserEvent::FetchById($eventid); if ($event != null) { //set the event properties to the new added informations $eventObject = $this->parserEventJson(json_encode($event)); if ($eventObject != null) { $eventObject->setTitle($title); $eventObject->setId($eventid); $eventObject->setVenue($venue); $eventObject->setType($privacy); //validate to match such the date send is current if ($this->validateEvent($eventObject)) { //update the vent $tryUpdateEvent = new TryUpdateUserEvent($eventObject); $status = $tryUpdateEvent->update(); if ($status) { $response["success"] = 1; $response["message"] = "Event Updated"; } else { $response["message"] = "There was error when trying to update event"; } } else { $response["error_message"] = $this->__message; } } } else { $response["error_message"] = "Know event with the given information"; } //exist } else { $response["error_message"] = "Unknown user request..."; } $jsonView = new JsonViewer(); $jsonView->setContent($response); return $jsonView; }
private function getProfileImageUrl($email, $password) { $response = array(); $response["success"] = 0; $tryLogin = new TryUserLogin($email, $password); if ($tryLogin->isExists()) { $tryFetchUserPhoto = new TryFetchUserProfilePhoto(); $url = $tryFetchUserPhoto->fetch($email); $response["success"] = 1; if ($url == null) { $url = DEFAULT_IMAGE_PROFILE_URL; } $response["img_src"] = $url; } else { $response["error_message"] = "user authentication fails"; } $json = new JsonViewer(); $json->setContent($response); return $json; }
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; }