Example #1
5
 /**
  * Remove the like that was given
  */
 function testRemoveLikeTopic()
 {
     $liked_message = basicMessageInfo($this->id_topic, true, true);
     // Lets remove the like from the topic
     likePost(1, $liked_message, '-');
     // get the number of likes, better be none now
     $likescount = messageLikeCount($this->id_topic);
     $this->assertEqual($likescount, 0);
 }
Example #2
0
 if (!empty($users_id)) {
     $sql = "SELECT  `id` FROM  `likes` WHERE users_id =:users_id\tAND share_id =:share_id";
     $stmt = $conn->prepare($sql);
     $stmt->bindValue(':users_id', $users_id);
     $stmt->bindValue(':share_id', $share_id);
     try {
         $stmt->execute();
     } catch (PDOException $e) {
         echo $e->getMessage();
     }
     $result = $stmt->FetchAll(PDO::FETCH_ASSOC);
     if ($result) {
         $success = "0";
         $msg = "Post is already liked";
     } else {
         $res = likePost($users_id, $share_id);
         $success = "1";
         $msg = "post liked!";
         if (!empty($res)) {
             $like_id = $res;
         }
         // $sql1="SELECT P.url, U.name, CONCAT('$path',profile_pic) as profile_pic, U.apn_id,
         // CASE
         // 	WHEN DATEDIFF(NOW(),L.created_on) != 0 THEN CONCAT(DATEDIFF(NOW(),L.created_on) ,'d ago')
         // 	WHEN HOUR(TIMEDIFF(NOW(),L.created_on)) != 0 THEN CONCAT(HOUR(TIMEDIFF(NOW(),L.created_on)) ,'h ago')
         // 	WHEN MINUTE(TIMEDIFF(NOW(),L.created_on)) != 0 THEN CONCAT(MINUTE(TIMEDIFF(NOW(),L.created_on)) ,'m ago')
         // ELSE
         // 	CONCAT(SECOND(TIMEDIFF(NOW(),L.created_on)) ,'s ago')
         // END as time_since
         // 	FROM  `post` P
         // 	JOIN likes L ON P.id = L.share_id
                $getInsertFieldValue['user_owner_id_fk'] = $user_owner_id;
                $getInsertFieldValue['likeDate_f'] = $createdDate;
                $lastInserted_user_id = $rm->insert_record($getInsertFieldValue, 'likes_t');
                if (!empty($lastInserted_user_id)) {
                    $sqlLikeCountUpdate = "update news_feeds_t set like_count_f= like_count_f+1 where post_id={$POSTID}";
                    mysql_query($sqlLikeCountUpdate, $GLOBALS['link']);
                    $deviceId = $rm->idToValue('device_id_f', 'user_details_t', 'user_id', $user_owner_id);
                    //getting deviceId
                    if ($deviceId != '') {
                        $message = "You have received a like on your post.";
                        $rm->sendPushNotification($deviceId, $message);
                    }
                    $result = $rm->getParticularPost($POSTID, $USERID);
                    return $result;
                } else {
                    $result = $rm->likeUnSuccessful();
                    return $result;
                }
            }
            // end of else first
        } else {
            $result = $rm->ssl_error();
            return $result;
        }
    } else {
        $result = $rm->ssl_error();
        return $result;
    }
}
echo likePost();
Example #4
0
 /**
  * Unlikes a post that you previously liked ... no negatives though, hurts feelings :'(
  * It redirects back to the referrer afterward.
  * It is accessed via ?action=like,sa=unlikepost.
  */
 public function action_unlikepost()
 {
     global $user_info, $topic, $txt, $modSettings;
     $this->_id_liked = !empty($_REQUEST['msg']) ? (int) $_REQUEST['msg'] : 0;
     // We used to like these
     require_once SUBSDIR . '/Likes.subs.php';
     require_once SUBSDIR . '/Messages.subs.php';
     // Have to be able to access it to unlike it now
     if ($this->prepare_like() && canAccessMessage($this->_id_liked)) {
         $liked_message = basicMessageInfo($this->_id_liked, true, true);
         if ($liked_message) {
             $likeResult = likePost($user_info['id'], $liked_message, '-');
             if ($likeResult === true) {
                 // Oh noes, taking the like back, let them know so they can complain
                 if (!empty($modSettings['mentions_enabled'])) {
                     require_once CONTROLLERDIR . '/Mentions.controller.php';
                     $mentions = new Mentions_Controller();
                     $mentions->setData(array('id_member' => $liked_message['id_member'], 'type' => 'rlike', 'id_msg' => $this->_id_liked));
                     // Notifying that likes were removed ?
                     if (!empty($modSettings['mentions_dont_notify_rlike'])) {
                         $mentions->action_rlike();
                     } else {
                         $mentions->action_add();
                     }
                 }
             } elseif ($this->_api) {
                 $this->_likes_response = array('result' => false, 'data' => $likeResult);
             }
         } elseif ($this->_api) {
             loadLanguage('Errors');
             $this->_likes_response = array('result' => false, 'data' => $txt['like_unlike_error']);
         }
     }
     // Back we go
     if ($this->_api) {
         $this->likeResponse();
     } elseif (!isset($_REQUEST['profile'])) {
         redirectexit('topic=' . $topic . '.msg' . $this->_id_liked . '#msg' . $this->_id_liked);
     } else {
         redirectexit('action=profile;area=showlikes;sa=given;u=' . $user_info['id']);
     }
 }
    $liftid = $_GET['liftid'];
    $results = $db->update("UPDATE Lift SET L_Seats = L_Seats - 1 WHERE L_ID = " . $liftid . ";");
    foreach ($results as $result) {
        echo $result;
    }
}
function likePost()
{
    global $db;
    $userID = $_SESSION["U_ID"];
    $postID = $_GET['like'];
    $sql = "INSERT INTO Likes(`P_ID`, `U_ID`)VALUES('" . $postID . "','" . $userID . "');";
    $results = $db->insert($sql);
    return $results;
}
if (isset($_GET['function'])) {
    switch ($_GET['function']) {
        case 'updatelift':
            decrementAvailableSeats();
            break;
        case 'displaylift':
            getAvailableLifts();
            break;
        case 'searchdrivers':
            getDrivers();
            break;
        case 'likepost':
            likePost();
            break;
    }
}
Example #6
0
<?php

require_once 'include.php';
$act = $_REQUEST['act'];
if ($act === 'signup') {
    $msg = signup();
} elseif ($act === 'login') {
    $msg = login();
} elseif ($act === 'logout') {
    $msg = logout();
} elseif ($act === 'post') {
    $msg = post();
} elseif ($act === 'deletePost') {
    $msg = deletePost();
} elseif ($act === 'likePost') {
    $msg = likePost();
} elseif ($act === 'commentPost') {
    $msg = commentPost();
} elseif ($act === 'deleteComment') {
    $msg = deleteComment();
} elseif ($act === 'changeInfo') {
    $msg = changeInfo();
} elseif ($act === 'readNotify') {
    $msg = readNotify();
} elseif ($act === 'markAllRead') {
    $msg = markAllRead();
}
?>
 <!DOCTYPE HTML>
 <html>
 <head>