예제 #1
0
 public static function testTweet($request, $context)
 {
     $data = array("emetteur" => $request["emetteur"], "parent" => $request["parent"], "post" => $request["post"], "nbVotes" => $request["nbVotes"]);
     $tweet = new tweet($data);
     $tweet->id = $tweet->save();
     if (is_null($tweet->id)) {
         return NULL;
     } else {
         return $tweet;
     }
 }
예제 #2
0
 public static function vote($request, $context)
 {
     //print_r($request);
     if (!empty($request['idtweet']) && $context->getSessionAttribute('is_logged') == 1) {
         $voteInfo['message'] = $request['idtweet'];
         $voteInfo['utilisateur'] = $_SESSION['id'];
         $vote = new vote($voteInfo);
         $vote->save();
         $tweetInfo['id'] = $request['idtweet'];
         $nbVotes = vote::getVote($request['idtweet']);
         //print_r($nbVotes);
         $tweetInfo['nbVotes'] = $nbVotes[0]['count'];
         $tweet = new tweet($tweetInfo);
         $tweet->save();
         context::redirect(history . back());
         return context::SUCCESS;
     }
     return context::ERROR;
 }