/** * @param $JSON * INFO : API-11 | Status:Completed | Tested : Yes. | Tested in Live : Yes. */ function doGetFullMessagesListOfParticularConversation($JSON) { # JSON info's Reading. $appUserFacebookID = $JSON->app_user_facebook_id; $otherUserFacebookID = $JSON->other_user_facebook_id; $conversationThreadID = getConversationThreadID($appUserFacebookID, $otherUserFacebookID); # Extra JSON User info's Reading $language = $JSON->lang; # value can be only 'en' or 'ar' $os = $JSON->os; # value can be only 'a' or 'i'. # Other details $currentAppUsingUsersID = getUserIDFromFacebookID($appUserFacebookID); # Current app Using User's ID. # 1 $query = "SELECT * FROM " . TABLE_CONVERSATION_THREADS_INFO . " WHERE id=" . $conversationThreadID; $db = new DBCon(); $result = $db->executeQuery($query); if (mysql_num_rows($result) > 0) { # Reading all messages exchanged between one conversation , Message's info details Reading. $conversationThreadInfo = mysql_fetch_assoc($result); $userOneID = $conversationThreadInfo['user_one_id']; $userTwoID = $conversationThreadInfo['user_two_id']; $otherUserID = $userOneID == $currentAppUsingUsersID ? $userTwoID : $userOneID; # 6 # Current App using Users User Info Read. $query = "SELECT facebook_id,profile_picture_url,full_name,flag_online FROM " . TABLE_USER_INFO . " WHERE id={user-id}"; $query = str_replace("{user-id}", $currentAppUsingUsersID, $query); $resultAppUserInfo = $db->executeQuery($query); $appUserInfo = mysql_fetch_assoc($resultAppUserInfo); $appUserFacebookID = $appUserInfo['facebook_id']; # 2 $appUserProfilePictureURL = $appUserInfo['profile_picture_url']; # 3 $appUserFullName = $appUserInfo['full_name']; # 4 $appUserFlagOnline = $appUserInfo['flag_online']; # 5 # Other Chat users User Info Read. $query = "SELECT facebook_id,profile_picture_url,full_name,flag_online FROM " . TABLE_USER_INFO . " WHERE id={user-id}"; $query = str_replace("{user-id}", $otherUserID, $query); $resultOtherUserInfo = $db->executeQuery($query); $otherUserInfo = mysql_fetch_assoc($resultOtherUserInfo); $otherUserFacebookID = $otherUserInfo['facebook_id']; # 7 $otherUserProfilePictureURL = $otherUserInfo['profile_picture_url']; # 8 $otheUserFullName = $otherUserInfo['full_name']; # 9 $otheUserFlagOnline = $otherUserInfo['flag_online']; # 10 $fullConversationInfo = getFullConversation($conversationThreadID, $currentAppUsingUsersID); # Response JSON Creation. $responseJSON = array("key" => REQUEST_GET_FULL_MESSAGES, "response" => RESPONSE_SUCCESS, "message" => "Info Read.", "app_user_id" => $currentAppUsingUsersID, "app_user_facebook_id" => $appUserFacebookID, "app_user_profile_picture" => $appUserProfilePictureURL, "app_user_full_name" => $appUserFullName, "app_user_flag_online" => $appUserFlagOnline, "other_user_id" => $otherUserID, "other_user_facebook_id" => $otherUserFacebookID, "other_user_profile_picture" => $otherUserProfilePictureURL, "other_user_full_name" => $otheUserFullName, "other_user_flag_online" => $otheUserFlagOnline, "conversation_info" => $fullConversationInfo); } else { # Current App using Users User Info Read. $query = "SELECT facebook_id,profile_picture_url,full_name,flag_online FROM " . TABLE_USER_INFO . " WHERE id={user-id}"; $query = str_replace("{user-id}", $currentAppUsingUsersID, $query); $resultAppUserInfo = $db->executeQuery($query); $appUserInfo = mysql_fetch_assoc($resultAppUserInfo); $appUserFacebookID = $appUserInfo['facebook_id']; # 2 $appUserProfilePictureURL = $appUserInfo['profile_picture_url']; # 3 $appUserFullName = $appUserInfo['full_name']; # 4 $appUserFlagOnline = $appUserInfo['flag_online']; # 5 # Other Chat users User Info Read. $query = "SELECT facebook_id,profile_picture_url,full_name,flag_online FROM " . TABLE_USER_INFO . " WHERE id={user-id}"; $query = str_replace("{user-id}", getUserIDFromFacebookID($otherUserFacebookID), $query); $resultOtherUserInfo = $db->executeQuery($query); $otherUserInfo = mysql_fetch_assoc($resultOtherUserInfo); $otherUserFacebookID = $otherUserInfo['facebook_id']; # 7 $otherUserProfilePictureURL = $otherUserInfo['profile_picture_url']; # 8 $otheUserFullName = $otherUserInfo['full_name']; # 9 $otheUserFlagOnline = $otherUserInfo['flag_online']; # 10 # Response JSON Creation. $responseJSON = array("key" => REQUEST_GET_FULL_MESSAGES, "response" => RESPONSE_SUCCESS, "message" => "Messages Empty.", "app_user_id" => $currentAppUsingUsersID, "app_user_facebook_id" => $appUserFacebookID, "app_user_profile_picture" => $appUserProfilePictureURL, "app_user_full_name" => $appUserFullName, "app_user_flag_online" => $appUserFlagOnline, "other_user_id" => getUserIDFromFacebookID($otherUserFacebookID), "other_user_facebook_id" => $otherUserFacebookID, "other_user_profile_picture" => $otherUserProfilePictureURL, "other_user_full_name" => $otheUserFullName, "other_user_flag_online" => $otheUserFlagOnline, "conversation_info" => []); } sendResponseToAppAndExitAPI($responseJSON); # Giving JSON Response to Mobile app. }
/** * @param $JSON * INFO : API-11 | Status:Completed | Tested : Yes. | Tested in Live : Yes. */ function doGetFullMessagesListOfParticularConversation($JSON) { # JSON info's Reading. $appUserFacebookID = $JSON->app_user_facebook_id; $otherUserFacebookID = $JSON->other_user_facebook_id; $selected_given_food_id = $JSON->selected_given_food_id; $conversationThreadID = getConversationThreadID($appUserFacebookID, $otherUserFacebookID, $selected_given_food_id); # Extra JSON User info's Reading $language = $JSON->lang; # value can be only 'en' or 'ar' $os = $JSON->os; # value can be only 'a' or 'i'. # Other details $currentAppUsingUsersID = getUserIDFromFacebookID($appUserFacebookID); # Current app Using User's ID. # 1 $query = "SELECT * FROM " . TABLE_CONVERSATION_THREADS_INFO . " WHERE id=" . $conversationThreadID; $db = new DBCon(); $result = $db->executeQuery($query); if (mysql_num_rows($result) > 0) { # Reading all messages exchanged between one conversation , Message's info details Reading. $conversationThreadInfo = mysql_fetch_assoc($result); $userOneID = $conversationThreadInfo['user_one_id']; $userTwoID = $conversationThreadInfo['user_two_id']; $selectedGivenFoodID = $conversationThreadInfo['selected_given_food_id']; $otherUserID = $userOneID == $currentAppUsingUsersID ? $userTwoID : $userOneID; # 6 # Current App using Users User Info Read. $query = "SELECT facebook_id,profile_picture_url,full_name,flag_online FROM " . TABLE_USER_INFO . " WHERE id={user-id}"; $query = str_replace("{user-id}", $currentAppUsingUsersID, $query); $resultAppUserInfo = $db->executeQuery($query); $appUserInfo = mysql_fetch_assoc($resultAppUserInfo); $appUserFacebookID = $appUserInfo['facebook_id']; # 2 $appUserProfilePictureURL = $appUserInfo['profile_picture_url']; # 3 $appUserFullName = $appUserInfo['full_name']; # 4 $appUserFlagOnline = $appUserInfo['flag_online']; # 5 # Other Chat users User Info Read. $query = "SELECT facebook_id,profile_picture_url,full_name,flag_online FROM " . TABLE_USER_INFO . " WHERE id={user-id}"; $query = str_replace("{user-id}", $otherUserID, $query); $resultOtherUserInfo = $db->executeQuery($query); $otherUserInfo = mysql_fetch_assoc($resultOtherUserInfo); $otherUserFacebookID = $otherUserInfo['facebook_id']; # 7 $otherUserProfilePictureURL = $otherUserInfo['profile_picture_url']; # 8 $otheUserFullName = $otherUserInfo['full_name']; # 9 $otheUserFlagOnline = $otherUserInfo['flag_online']; # 10 $fullConversationInfo = getFullConversation($conversationThreadID, $currentAppUsingUsersID); /*------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ $query = "SELECT GV.id AS given_food_id,GV.owner_user_id,GV.title,GV.image_file,GV.`description`,GV.`sharing_for_id`,SF.display_text AS sharing_for_name,\n GV.`category_id`,GC.display_text AS give_category_name,GV.`expiration_date`,\n GV.`expiration_time`,GV.expiration_timestamp,GV.`latitude`,GV.`longitude`,GV.`city`,GV.`country`,GV.flag_taken\n FROM given_foods_info AS GV,sharing_for_list AS SF,give_categories_list AS GC,users_info AS UI\n WHERE\n GV.id={given-food-id}\n AND\n SF.id=GV.`sharing_for_id`\n AND\n GC.id=GV.category_id"; $query = str_replace("{given-food-id}", $selectedGivenFoodID, $query); $resultFoodInfo = $db->executeQuery($query); if (mysql_num_rows($resultFoodInfo) > 0) { if ($info = mysql_fetch_assoc($resultFoodInfo)) { # Reading all messages exchanged between one conversation , Message's info details Reading. $givenFoodID = $info['given_food_id']; $ownerUserID = $info['owner_user_id']; $title = $info['title']; $imageFile = $info['image_file']; $description = $info['description']; $sharingFoodID = $info['sharing_for_id']; $sharingFoodName = $info['sharing_for_name']; $categoryID = $info['category_id']; $categoryName = $info['give_category_name']; $expirationDate = $info['expiration_date']; $expirationTime = $info['expiration_time']; $expirationTimestamp = $info['expiration_timestamp']; $latitude = $info['latitude']; $longitude = $info['longitude']; $city = $info['city']; $country = $info['country']; $flagTaken = $info['flag_taken']; # Formatting of Values $imageFileFullPath = DIR_GIVE_FOOD_IMAGES_ABSOLUTE_PATH . "/" . $imageFile; # Creation of Take List. $foodInfo = array("given_food_id" => $givenFoodID, "owner_user_id" => $ownerUserID, "title" => $title, "image_file" => $imageFileFullPath, "description" => $description, "sharing_food_id" => $sharingFoodID, "sharing_food_name" => $sharingFoodName, "category_id" => $categoryID, "category_name" => $categoryName, "expiration_date" => $expirationDate, "expiration_time" => $expirationTime, "expiration_timestamp" => $expirationTimestamp, "latitude" => $latitude, "longitude" => $longitude, "city" => $city, "country" => $country, "flag_taken" => $flagTaken); } # Response JSON Creation. $responseJSON = array("key" => REQUEST_GET_FULL_MESSAGES, "response" => RESPONSE_SUCCESS, "message" => "Info Read.", "app_user_id" => $currentAppUsingUsersID, "app_user_facebook_id" => $appUserFacebookID, "app_user_profile_picture" => $appUserProfilePictureURL, "app_user_full_name" => $appUserFullName, "app_user_flag_online" => $appUserFlagOnline, "other_user_id" => $otherUserID, "other_user_facebook_id" => $otherUserFacebookID, "other_user_profile_picture" => $otherUserProfilePictureURL, "other_user_full_name" => $otheUserFullName, "other_user_flag_online" => $otheUserFlagOnline, "conversation_info" => $fullConversationInfo, "food_info" => $foodInfo); } else { $responseJSON = array("key" => REQUEST_GET_CONVERSATION_THREADS_LIST, "response" => RESPONSE_FAILED, "message" => "Read Food info Failed."); } /*------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ } else { # Current App using Users User Info Read. $query = "SELECT facebook_id,profile_picture_url,full_name,flag_online FROM " . TABLE_USER_INFO . " WHERE id={user-id}"; $query = str_replace("{user-id}", $currentAppUsingUsersID, $query); $resultAppUserInfo = $db->executeQuery($query); $appUserInfo = mysql_fetch_assoc($resultAppUserInfo); $appUserFacebookID = $appUserInfo['facebook_id']; # 2 $appUserProfilePictureURL = $appUserInfo['profile_picture_url']; # 3 $appUserFullName = $appUserInfo['full_name']; # 4 $appUserFlagOnline = $appUserInfo['flag_online']; # 5 # Other Chat users User Info Read. $query = "SELECT facebook_id,profile_picture_url,full_name,flag_online FROM " . TABLE_USER_INFO . " WHERE id={user-id}"; $query = str_replace("{user-id}", getUserIDFromFacebookID($otherUserFacebookID), $query); $resultOtherUserInfo = $db->executeQuery($query); $otherUserInfo = mysql_fetch_assoc($resultOtherUserInfo); $otherUserFacebookID = $otherUserInfo['facebook_id']; # 7 $otherUserProfilePictureURL = $otherUserInfo['profile_picture_url']; # 8 $otheUserFullName = $otherUserInfo['full_name']; # 9 $otheUserFlagOnline = $otherUserInfo['flag_online']; # 10 # Response JSON Creation. $responseJSON = array("key" => REQUEST_GET_FULL_MESSAGES, "response" => RESPONSE_SUCCESS, "message" => "Messages Empty.", "app_user_id" => $currentAppUsingUsersID, "app_user_facebook_id" => $appUserFacebookID, "app_user_profile_picture" => $appUserProfilePictureURL, "app_user_full_name" => $appUserFullName, "app_user_flag_online" => $appUserFlagOnline, "other_user_id" => getUserIDFromFacebookID($otherUserFacebookID), "other_user_facebook_id" => $otherUserFacebookID, "other_user_profile_picture" => $otherUserProfilePictureURL, "other_user_full_name" => $otheUserFullName, "other_user_flag_online" => $otheUserFlagOnline, "conversation_info" => []); } sendResponseToAppAndExitAPI($responseJSON); # Giving JSON Response to Mobile app. }