Example #1
0
/**
 * @param $JSON
 * INFO : API-11 | Status:Completed | Tested : Yes. | Tested in Live : Yes.
 */
function doGetAllCommentedPostsOfAnIndividualUser($JSON)
{
    # JSON info's Reading.
    $facebookID = $JSON->facebook_id;
    # Extra JSON User info's Reading
    $os = $JSON->os;
    # value can be only 'a' or 'i'
    $language = $JSON->lang;
    # value can be only 'en' or 'ar'
    # Current app Using User's ID.
    $currentAppUsingUsersID = getUserIDFromFacebookID($facebookID);
    # Query creation.
    $query = "SELECT ci.id AS comment_id,ci.comment,ci.`commented_user_id`,ci.post_id,ci.timestamp_commented,\n            pi.id AS post_id,pi.post,pi.timestamp_posted,\n            ui.id AS user_id,ui.full_name,ui.facebook_id,ui.profile_picture_url,ui.flag_online\n            FROM comments_info AS ci,posts_info AS pi,users_info AS ui\n            WHERE\n            pi.id=ci.post_id\n            AND\n            pi.posted_user_id=ui.id\n            AND\n            ci.flag_active=1\n            AND\n            ci.commented_user_id={commented-user-id}\n            ORDER BY ci.timestamp_commented DESC";
    $query = str_replace("{commented-user-id}", $currentAppUsingUsersID, $query);
    $db = new DBCon();
    $result = $db->executeQuery($query);
    if (mysql_num_rows($result) > 0) {
        while ($resultRowAsArray = mysql_fetch_assoc($result)) {
            # Reading of Database values.
            $commentID = $resultRowAsArray['comment_id'];
            $comment = $resultRowAsArray['comment'];
            $commentedUserID = $resultRowAsArray['commented_user_id'];
            $postID = $resultRowAsArray['post_id'];
            $timestampCommented = $resultRowAsArray['timestamp_commented'];
            $postID = $resultRowAsArray['post_id'];
            $post = $resultRowAsArray['post'];
            $timestampPosted = $resultRowAsArray['timestamp_posted'];
            $userID = $resultRowAsArray['user_id'];
            $fullName = $resultRowAsArray['full_name'];
            $facebookID = $resultRowAsArray['facebook_id'];
            $profilePictureURL = $resultRowAsArray['profile_picture_url'];
            $flagOnline = $resultRowAsArray['flag_online'];
            # Assigning wanted details to this Array.
            $postsInfo[] = array("comment_id" => $commentID, "comment" => $comment, "commented_user_id" => $commentedUserID, "post_id" => $postID, "timestamp_commented" => $timestampCommented, "post_id" => $postID, "post" => $post, "post_user_id" => $userID, "full_name" => $fullName, "facebook_id" => $facebookID, "profile_picture_url" => $profilePictureURL, "flag_online" => $flagOnline, "timestamp_posted" => $timestampPosted);
        }
        $responseJSON = array("key" => REQUEST_ALL_COMMENTED_POSTS_OF_MINE, "response" => RESPONSE_SUCCESS, "message" => "Post Info Read.", "posts_info" => $postsInfo);
    } else {
        $responseJSON = array("key" => REQUEST_ALL_COMMENTED_POSTS_OF_MINE, "response" => RESPONSE_FAILED, "message" => "Comments Infos Empty");
    }
    sendResponseToAppAndExitAPI($responseJSON);
    # Giving JSON Response to Mobile app.
}
Example #2
0
/**
 * @param $JSON
 * INFO : API-22 | Status:Completed Partially | Tested : Yes | Tested in Beta : Yes | Tested in Live : No.
 * TODO : 1.Send all details as Email to Sarrah's Email ID.
 * DONE : Fullname to Description. - and Test working fine or Not.
 */
function doAddDonate($JSON)
{
    # Default Settings.
    $fileIndexName = "donate_food_image";
    # index name used for File in Multipart Request.
    # Reading of POST Infos.
    $appUserFacebookID = $_POST['app_user_facebook_id'];
    $title = $_POST['title'];
    $description = $_POST['description'];
    $phoneNumber = $_POST['phone_number'];
    $latitude = $_POST['latitude'];
    $longitude = $_POST['longitude'];
    $city = $_POST['city'];
    $country = $_POST['country'];
    # Creation of other values.
    $ownerUserID = getUserIDFromFacebookID($appUserFacebookID);
    # Getting User ID from Facebook ID.
    $flagTaken = "0";
    # by Default Donated food is not Taken.
    $flagActive = "1";
    # by default Donated food is Active.
    $timestampSubmitted = time();
    $imageFile = "without-image.png";
    #$newFileName = getUniqueRandomeFileName($fileIndexName); ++++++ reverse here
    #$imageFile=  $newFileName = getUniqueRandomeFileName($fileIndexName);
    # Save Image file of Food an continue according to the Result.
    $statusFileSave = true;
    #saveFileInFoodImagesDIR($fileIndexName, $newFileName);  +++++++++ reverse here
    #$statusFileSave =saveFileInDonatedFoodImagesDIR($fileIndexName, $newFileName);
    # If Image file is not Saved in server , Send Failed response to app and Exit.
    if (!$statusFileSave) {
        $responseJSON = array("key" => REQUEST_ADD_DONATE, "response" => RESPONSE_FAILED, "message" => "Donate Food Image file save Failed.");
        sendResponseToAppAndExitAPI($responseJSON);
        # Giving JSON Response to Mobile app.
    } else {
        $query = "INSERT INTO " . TABLE_DONATED_FOODS_INFO . "\n                (owner_user_id,title,image_file,description,phone_number,latitude,longitude,city,country,flag_taken,flag_active,timestamp_submitted)\n                VALUES({$ownerUserID},'{$title}','{$imageFile}','{$description}','{$phoneNumber}','{$latitude}','{$longitude}','{$city}','{$country}',{$flagTaken},{$flagActive},'{$timestampSubmitted}')";
        $db = new DBCon();
        $result = $db->executeQuery($query);
        if ($result) {
            $responseJSON = array("key" => REQUEST_ADD_DONATE, "response" => RESPONSE_SUCCESS, "message" => "Success, 'Add Donate' Details Saved.");
        } else {
            $responseJSON = array("key" => REQUEST_ADD_DONATE, "response" => RESPONSE_FAILED, "message" => "Add Donate Failed - Insert Query Error.");
        }
        sendResponseToAppAndExitAPI($responseJSON);
        # Giving JSON Response to Mobile app.
    }
}