/** * Insert reaction in DB (eiter from a Facebook post or Tweet) * @param string $type * @param object $mention * @param integer $id * @param string $answer * * @return Reaction */ public function insertReaction($type, $mention, $id, $answer = null) { $reaction = new Reaction(); $reaction->publishment_id = $id; if ($answer != null) { $reaction->user_id = Auth::user()->id; } if ($type == 'twitter') { if ($mention['user']['id_str'] != Configuration::twitterId()) { $reaction->user_id = $mention['user']['id_str']; } $reaction->screen_name = $mention['user']['screen_name']; $reaction->tweet_id = $mention['id_str']; $reaction->tweet_reply_id = $mention['in_reply_to_status_id_str']; $reaction->message = $mention['text']; $reaction->post_date = changeDateFormat($mention['created_at']); } else { $reaction->fb_post_id = $mention->id; if ($answer == null) { $reaction->screen_name = $mention->from->name; $reaction->message = $mention->message; $reaction->post_date = changeFbDateFormat($mention->created_time); } else { $reaction->message = $answer; $reaction->post_date = Carbon::now(); } } $reaction->save(); return $reaction; }
<?php include_once '../php/connection.php'; include_once '../php/accept_reject_invite.php'; include_once '../php/database.php'; include_once '../php/function.php'; $election_id = $_SESSION['election_index']; //fetching the election details $election_name = $election_start_date = $election_end_date = $election_time_from = $election_time_to = $string_election = ""; $result_tag1 = $result_tag2 = ""; $election_start_date = changeDateFormat($election_details['election_start_date']); $adela = $election_details['election_time_from']; $election_time_from = explode(":", $adela)[0] - 1 . ":" . explode(":", $adela)[1] . ":" . explode(":", $adela)[2]; ?> <!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/html"> <head> <style type="text/css"> #displayedPhoto{ width: 150px; height: 150px; margin-left: 40px; /*border-radius: 50%;*/ border:3px solid #d9534f; } h4 { margin-top: 5px; margin-bottom: 5px; display:inline-block;
/** * Insert publishment in DB * * @param string $type * @param array $publication * @param string $content */ private function insertPublishment($type, $publication, $content) { if ($this->publishment->double($content)->exists()) { $publishment = $this->publishment->double($content)->first(); } else { $publishment = new Publishment(); } $publishment->user_id = Auth::user()->id; $publishment->content = $content; if ($type == self::TYPE_TWITTER) { $publishment->tweet_id = $publication['id_str']; $publishment->post_date = changeDateFormat($publication['created_at']); } else { if ($type == self::TYPE_FACEBOOK) { $publishment->fb_post_id = $publication->id; $publishment->post_date = Carbon::now(); } } $publishment->save(); }
/** * Gets all direct (private) messages on Twitter * @return void */ public function collectDirectMessages() { $sinceId = latestDirect(); $directs = $this->twitterContent->fetchDirectMessages($sinceId); foreach ($directs as $key => $direct) { $date = changeDateFormat($direct['created_at']); $message = new Message(); if ($this->contact->where('twitter_id', $direct['sender']['id_str'])->exists()) { $contact = $this->contact->where('twitter_id', $direct['sender']['id_str'])->first(); if (count($contact->cases)) { $case = $contact->cases()->where('origin', 'Twitter direct')->orderBy('id', 'DESC')->first(); } else { $case = $this->case->createCase('twitter_direct', $direct, $contact); } $message->case_id = $case->id; $this->case->openCase($case); } else { $contact = $this->contact->createContact('twitter_direct', $direct); $case = $this->case->createCase('twitter_direct', $direct, $contact); $message->case_id = $case->id; } $message->contact_id = $contact->id; $message->direct_id = $direct['id_str']; $message->message = filterUrl($direct['text']); $message->post_date = $date; $message->save(); $this->media->handleMedia($message->id, $direct, 'twitter'); $this->updateCase($case->id, 'twitter', $direct['id_str']); } }