Exemplo n.º 1
0
 private function showConnectedProfiles()
 {
     $output = '<div class="clearfix networks">';
     $facebookLoginUrl = SessionManager::getInstance()->getFacebook()->getLoginUrl(array('redirect_uri' => APP_URL . '/' . Content::l() . '/login/facebookcallback/' . Content::l() . '/settings/', 'scope' => 'publish_stream'));
     $linkedInLoginUrl = APP_URL . '/' . Content::l() . '/login/linkedin/' . Content::l() . '/settings/';
     $twitterLoginUrl = APP_URL . '/' . Content::l() . '/login/twitter/' . Content::l() . '/settings/';
     // Facebook
     $output .= '<div class="clearfix">';
     if ($this->userDetails['facebook_access_token']) {
         $output .= '<a href="' . $facebookLoginUrl . '" id="loginFacebook" class="ir loggedIn">Facebook</a>' . '<a href="/' . Content::l() . '/ajax/disconnect/?network=Facebook" class="disconnect">' . str_replace('SOCIAL_NETWORK_NAME', 'Facebook', Content::c()->settings->disconnect) . '</a>';
     } else {
         $output .= '<a href="' . $facebookLoginUrl . '" id="loginFacebook" class="ir">Facebook</a>' . '<a href="' . $facebookLoginUrl . '" class="connect">' . str_replace('SOCIAL_NETWORK_NAME', 'Facebook', Content::c()->settings->connect) . '</a>';
     }
     // LinkedIn
     $output .= '</div><div class="clearfix">';
     if ($this->userDetails['linkedin_access_token']) {
         $output .= '<a href="' . $linkedInLoginUrl . '" id="loginLinkedIn" class="ir loggedIn">LinkedIn</a>' . '<a href="/' . Content::l() . '/ajax/disconnect/?network=LinkedIn" class="disconnect">' . str_replace('SOCIAL_NETWORK_NAME', 'LinkedIn', Content::c()->settings->disconnect) . '</a>';
     } else {
         $output .= '<a href="' . $linkedInLoginUrl . '" id="loginLinkedIn" class="ir">LinkedIn</a>' . '<a href="' . $linkedInLoginUrl . '" class="connect">' . str_replace('SOCIAL_NETWORK_NAME', 'LinkedIn', Content::c()->settings->connect) . '</a>';
     }
     // Twitter
     $output .= '</div><div class="clearfix">';
     if ($this->userDetails['twitter_access_token']) {
         $output .= '<a href="' . $twitterLoginUrl . '" id="loginTwitter" class="ir loggedIn">Twitter</a>' . '<a href="/' . Content::l() . '/ajax/disconnect/?network=Twitter" class="disconnect">' . str_replace('SOCIAL_NETWORK_NAME', 'Twitter', Content::c()->settings->disconnect) . '</a>';
     } else {
         $output .= '<a href="' . $twitterLoginUrl . '" id="loginTwitter" class="ir">Twitter</a>' . '<a href="' . $twitterLoginUrl . '" class="connect">' . str_replace('SOCIAL_NETWORK_NAME', 'Twitter', Content::c()->settings->connect) . '</a>';
     }
     $output .= '</div></div>';
     return $output;
 }
Exemplo n.º 2
0
    private function previousIntroductions()
    {
        $output = '';
        $introductionsQ = $this->db->prepare('SELECT i.id, i.introducer_id, introducer.name as introducer_name, i.introducee1_id, in1.name as introducee1_name, i.introducee2_id, in2.name as introducee2_name, i.time, i.link_password
			FROM introduction i
			LEFT JOIN person introducer ON introducer.id = i.introducer_id
			LEFT JOIN person in1 ON in1.id = i.introducee1_id
			LEFT JOIN person in2 ON in2.id = i.introducee2_id
			WHERE (i.introducer_id = :id OR i.introducee1_id = :id OR i.introducee2_id = :id)
			ORDER BY time DESC');
        $introductionsQ->execute(array(':id' => $this->userId));
        $introductions = $introductionsQ->fetchAll(PDO::FETCH_ASSOC);
        if (!empty($introductions)) {
            $you = (string) Content::c()->home->you;
            $youCapital = (string) Content::c()->home->you_capital;
            $story = (string) Content::c()->home->story;
            $output .= '<div id="previousIntroductions"><h2>' . Content::c()->home->history . '</h2>';
            foreach ($introductions as $introd) {
                $url = APP_URL . '/' . Content::l() . '/A' . $introd['link_password'] . BaseConvert::base10ToBase62($introd['id']);
                if ($this->userId == $introd['introducer_id']) {
                    $output .= '<p><a href="' . $url . '">' . str_replace('INTRODUCEE1_NAME', '<strong>' . $introd['introducee1_name'] . '</strong>', str_replace('INTRODUCEE2_NAME', '<strong>' . $introd['introducee2_name'] . '</strong>', str_replace('INTRODUCER_NAME', $youCapital, $story))) . '</a></p>';
                } elseif ($this->userId == $introd['introducee1_id']) {
                    $output .= '<p><a href="' . $url . '">' . str_replace('INTRODUCEE1_NAME', $you, str_replace('INTRODUCEE2_NAME', '<strong>' . $introd['introducee2_name'] . '</strong>', str_replace('INTRODUCER_NAME', '<strong>' . $introd['introducer_name'] . '</strong>', $story))) . '</a></p>';
                } else {
                    $output .= '<p><a href="' . $url . '">' . str_replace('INTRODUCEE1_NAME', $you, str_replace('INTRODUCEE2_NAME', '<strong>' . $introd['introducee1_name'] . '</strong>', str_replace('INTRODUCER_NAME', '<strong>' . $introd['introducer_name'] . '</strong>', $story))) . '</a></p>';
                }
                $output .= $this->formatTime(strtotime($introd['time']));
            }
            $output .= '</div>';
        }
        return $output;
    }
Exemplo n.º 3
0
 public function __construct()
 {
     $top = new Top('', 'aboutPage');
     echo $top->getOutput();
     echo Content::c()->about->desc;
     $bottom = new Bottom('');
     echo $bottom->getOutput();
 }
Exemplo n.º 4
0
 public function __construct()
 {
     session_start();
     $this->db = Database::getInstance();
     if (empty($_SESSION['mergeOtherAccount']) || empty($_SESSION['mergeNetwork'])) {
         Debug::l('Error merging account: missing session vars');
         header('Location: ' . APP_URL . '/' . Content::l() . '/');
         exit;
     }
     $this->mergeNetwork = $_SESSION['mergeNetwork'];
     $mergeOtherAccount = $_SESSION['mergeOtherAccount'];
     // Get the website user
     $userId = SessionManager::getInstance()->getUserId();
     if (!isset($userId)) {
         // No user logged in
         Debug::l('No user logged in');
         header('Location: ' . APP_URL . '/' . Content::l() . '/');
         exit;
     }
     // Load user data
     $userDetailsQ = $this->db->prepare('SELECT f.id as facebook_id, f.access_token as facebook_access_token, l.id as linkedin_id, l.access_token as linkedin_access_token, t.id as twitter_id, t.access_token as twitter_access_token FROM person p LEFT JOIN facebook f ON p.id = f.person_id LEFT JOIN linkedin l ON p.id = l.person_id LEFT JOIN twitter t ON p.id = t.person_id WHERE p.id = :id');
     $userDetailsQ->execute(array(':id' => $userId));
     $userDetails = $userDetailsQ->fetch(PDO::FETCH_ASSOC);
     $profiles = $this->loadProfiles($userDetails, true);
     // Load data for other account
     $userDetailsQ->execute(array(':id' => $mergeOtherAccount));
     $otherAccount = $userDetailsQ->fetch(PDO::FETCH_ASSOC);
     array_merge($profiles, $this->loadProfiles($otherAccount, false));
     $top = new Top('', 'mergeAccountsPage');
     echo $top->getOutput();
     echo '<h1>' . str_replace('SOCIAL_NETWORK_NAME', $this->mergeNetwork, Content::c()->merge_accounts->notice) . '</h1>' . '<p class="question">' . (count($profiles) == 2 ? Content::c()->merge_accounts->question_two_profiles : Content::c()->merge_accounts->question_more_profiles) . '</p>';
     foreach ($profiles as $profile) {
         echo $profile;
     }
     echo '<form action="/' . Content::l() . '/logout/" method="post" class="no">' . '<input type="submit" class="button" value="' . Content::c()->merge_accounts->n . '" />' . '</form>' . '<form action="/' . Content::l() . '/ajax/merge-accounts/" method="post" class="yes">' . '<input type="submit" class="button" value="' . Content::c()->merge_accounts->y . '" />' . '</form>' . '<p class="note">' . Content::c()->merge_accounts->note . '</p>';
     $bottom = new Bottom('');
     echo $bottom->getOutput();
 }
Exemplo n.º 5
0
 public function __construct($content = '', $page = '')
 {
     $this->output = "<!doctype html>\n" . '<!--[if lt IE 7]><html class="no-js ie6" lang="' . Content::l() . '"><![endif]-->' . '<!--[if IE 7]><html class="no-js ie7" lang="' . Content::l() . '"><![endif]-->' . '<!--[if IE 8]><html class="no-js ie8" lang="' . Content::l() . '"><![endif]-->' . '<!--[if gt IE 8]><!--><html class="no-js" lang="' . Content::l() . '"><!--<![endif]-->' . '<head>' . '<meta charset="utf-8" />' . '<title>' . Content::c()->title . '</title>' . '<meta name="description" content="' . Content::c()->tagline . '" />' . '<meta name="author" content="Keegan Street" />' . '<meta property="og:image" content="' . APP_URL . '/images/facebook-share-image.png" />' . '<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />' . '<link rel="stylesheet" href="/css/style.css" /><!-- Style source: /css/style.scss -->' . $content . '<script src="/js/modernizr.js"></script>' . '<script>' . 'var introduceme = (function (module) {' . 'module.mobile = Modernizr.mq("only all and (max-width: 640px)");' . 'module.content = module.content || {};' . 'module.content.errorAjaxTitle = "' . htmlentities(Content::c()->errors->ajax->title, ENT_QUOTES, 'UTF-8') . '";' . 'module.content.errorAjaxRefresh = "' . htmlentities(Content::c()->errors->ajax->refresh, ENT_QUOTES, 'UTF-8') . '";' . 'return module;' . '}(introduceme || {}));' . '</script>' . '<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>' . '<script>window.jQuery || document.write("<script src=\'/js/jquery-1.6.min.js\'>\\x3C/script>")</script>' . '</head>' . '<body class="lang-' . Content::l() . ' ' . $page . '">' . '<div id="fb-root"></div>' . '<div class="header"><header>' . '<a href="/' . Content::l() . '/" class="home"><h1 class="ir">Introd.uce.me</h1></a>' . '<h2 class="ir">' . Content::c()->tagline . '</h2>' . '</header></div>' . '<div id="main" class="clearfix">';
 }
Exemplo n.º 6
0
 public function __construct($script = '')
 {
     $this->userId = SessionManager::getInstance()->getUserId();
     $this->output = '</div>' . '<div class="footer"><footer>' . '<a href="/' . Content::l() . '/" class="home">' . Content::c()->home->home . '</a>' . '<a href="/' . Content::l() . '/about/" class="about">' . Content::c()->about->about . '</a>' . '<a href="http://introduceme.uservoice.com/forums/99481-general" class="feedback">' . Content::c()->feedback . '</a>' . (!empty($this->userId) ? '<a href="/' . Content::l() . '/settings/" class="settings">' . Content::c()->settings->title . '</a>' . '<a href="/' . Content::l() . '/logout/" class="logout">' . Content::c()->logout . '</a>' : '') . '</footer></div>' . '<script src="/js/plugins.js"></script>' . '<script src="/js/introduceme.js"></script>' . $script . '<script>' . 'var _gaq = [["_setAccount", "UA-20937143-1"],["_trackPageview"]];' . '(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1;g.src="//www.google-analytics.com/ga.js";s.parentNode.insertBefore(g,s);}(document,"script"));' . '</script>' . '</body>' . '</html>';
 }
Exemplo n.º 7
0
 public function __construct()
 {
     session_start();
     header('Content-type: text/json');
     // Get the website user
     $userId = SessionManager::getInstance()->getUserId();
     $json['result'] = 'true';
     // Make sure a user is logged in
     if (!isset($userId)) {
         $json['result'] = 'false';
         $json['title'] = (string) Content::c()->errors->session->title;
         $json['message'] = (string) Content::c()->errors->session->no_session;
         echo json_encode($json);
         exit;
     }
     // Validate input
     if (empty($_POST['introducee1Name']) || empty($_POST['introducee1FacebookId']) && empty($_POST['introducee1LinkedInId']) && empty($_POST['introducee1TwitterId']) || empty($_POST['introducee2Name']) || empty($_POST['introducee2FacebookId']) && empty($_POST['introducee2LinkedInId']) && empty($_POST['introducee2TwitterId'])) {
         $json['result'] = 'false';
         $json['title'] = (string) Content::c()->errors->input->title;
         $json['message'] = (string) Content::c()->errors->input->introduction_not_created;
         echo json_encode($json);
         exit;
     }
     // Make sure the introducees are unique
     if (!empty($_POST['introducee1FacebookId']) && !empty($_POST['introducee2FacebookId']) && $_POST['introducee1FacebookId'] == $_POST['introducee2FacebookId'] || !empty($_POST['introducee1LinkedInId']) && !empty($_POST['introducee2LinkedInId']) && $_POST['introducee1LinkedInId'] == $_POST['introducee2LinkedInId'] || !empty($_POST['introducee1TwitterId']) && !empty($_POST['introducee2TwitterId']) && $_POST['introducee1TwitterId'] == $_POST['introducee2TwitterId']) {
         $json['result'] = 'false';
         $json['title'] = (string) Content::c()->errors->input->title;
         $json['message'] = (string) Content::c()->errors->input->introduce_to_self;
         echo json_encode($json);
         exit;
     }
     // Connect to the database
     $db = Database::getInstance();
     $introducee1 = new Person(array('name' => $_POST['introducee1Name'], 'facebookId' => !empty($_POST['introducee1FacebookId']) ? $_POST['introducee1FacebookId'] : '', 'linkedInId' => !empty($_POST['introducee1LinkedInId']) ? $_POST['introducee1LinkedInId'] : null, 'twitterId' => !empty($_POST['introducee1TwitterId']) ? $_POST['introducee1TwitterId'] : null));
     $introducee2 = new Person(array('name' => $_POST['introducee2Name'], 'facebookId' => !empty($_POST['introducee2FacebookId']) ? $_POST['introducee2FacebookId'] : '', 'linkedInId' => !empty($_POST['introducee2LinkedInId']) ? $_POST['introducee2LinkedInId'] : null, 'twitterId' => !empty($_POST['introducee2TwitterId']) ? $_POST['introducee2TwitterId'] : null));
     // See if the introducees are already in our database, that would be nice!
     if (!empty($_POST['introducee1FacebookId'])) {
         $introducee1->getDataFromFacebookId($_POST['introducee1FacebookId']);
     } elseif (!empty($_POST['introducee1LinkedInId'])) {
         $introducee1->getDataFromLinkedInId($_POST['introducee1LinkedInId']);
     } elseif (!empty($_POST['introducee1TwitterId'])) {
         $introducee1->getDataFromTwitterId($_POST['introducee1TwitterId']);
     }
     if (!empty($_POST['introducee2FacebookId'])) {
         $introducee2->getDataFromFacebookId($_POST['introducee2FacebookId']);
     } elseif (!empty($_POST['introducee2LinkedInId'])) {
         $introducee2->getDataFromLinkedInId($_POST['introducee2LinkedInId']);
     } elseif (!empty($_POST['introducee2TwitterId'])) {
         $introducee2->getDataFromTwitterId($_POST['introducee2TwitterId']);
     }
     // Make sure the introducees are still unique
     if ($introducee1->getFacebookId() != null && $introducee1->getFacebookId() == $introducee2->getFacebookId() || $introducee1->getLinkedInId() != null && $introducee1->getLinkedInId() == $introducee2->getLinkedInId() || $introducee1->getTwitterId() != null && $introducee1->getTwitterId() == $introducee2->getTwitterId()) {
         $json['result'] = 'false';
         $json['title'] = (string) Content::c()->errors->input->title;
         $json['message'] = (string) Content::c()->errors->input->introduce_to_self;
         echo json_encode($json);
         exit;
     }
     // If the introducees aren't in the database yet, add them
     $introducee1->addToDatabase();
     $introducee2->addToDatabase();
     // If the introducees are on LinkedIn, add their public profile URL and picture to the DB
     if ($introducee1->getLinkedInId() != null || $introducee2->getLinkedInId() != null) {
         // Connect to LinkedIn API
         $sth = $db->prepare('SELECT id, access_token FROM linkedin WHERE person_id = :person_id');
         $sth->execute(array(':person_id' => $userId));
         $userDetails = $sth->fetch(PDO::FETCH_ASSOC);
         if (!empty($userDetails['access_token'])) {
             $linkedInAccessToken = $userDetails['access_token'];
             // Create LinkedIn object
             $API_CONFIG = array('appKey' => LI_API_KEY, 'appSecret' => LI_SECRET, 'callbackUrl' => '');
             $OBJ_linkedin = new LinkedIn($API_CONFIG);
             $OBJ_linkedin->setTokenAccess(unserialize($linkedInAccessToken));
             // Which introducees are on LinkedIn?
             $profilesToRequest = array();
             if ($introducee1->getLinkedInId() != null) {
                 $profilesToRequest[] = 'id=' . $introducee1->getLinkedInId();
             }
             if ($introducee2->getLinkedInId() != null) {
                 $profilesToRequest[] = 'id=' . $introducee2->getLinkedInId();
             }
             try {
                 $linkedInProfiles = $OBJ_linkedin->profileNew('::(' . implode(',', $profilesToRequest) . '):(id,public-profile-url,picture-url)');
             } catch (ErrorException $e) {
             }
             if ($linkedInProfiles['success'] === TRUE) {
                 $linkedInProfiles['linkedin'] = new SimpleXMLElement($linkedInProfiles['linkedin']);
                 if ($linkedInProfiles['linkedin']->getName() == 'people') {
                     foreach ($linkedInProfiles['linkedin']->person as $person) {
                         $id = (string) $person->id;
                         $url = (string) $person->{'public-profile-url'};
                         $pic = (string) $person->{'picture-url'};
                         if ($id && ($url || $pic)) {
                             $update = $db->prepare('REPLACE INTO temp_linkedin SET linkedin_id = :linkedin_id, time=NOW(), profile_url = :profile_url, picture_url = :picture_url');
                             $update->execute(array(':linkedin_id' => $id, ':profile_url' => $url, ':picture_url' => $pic));
                         }
                     }
                 }
             }
         }
     }
     // If the introducees are on Twitter, add their screen name and picture to the DB
     if ($introducee1->getTwitterId() != null || $introducee2->getTwitterId() != null) {
         // Which introducees are on Twitter?
         $profilesToRequest = array();
         if ($introducee1->getTwitterId() != null) {
             $profilesToRequest[] = $introducee1->getTwitterId();
         }
         if ($introducee2->getTwitterId() != null) {
             $profilesToRequest[] = $introducee2->getTwitterId();
         }
         // Connect to Twitter API
         $sth = $db->prepare('SELECT id, access_token FROM twitter WHERE person_id = :person_id');
         $sth->execute(array(':person_id' => $userId));
         $userDetails = $sth->fetch(PDO::FETCH_ASSOC);
         if (!empty($userDetails['access_token'])) {
             $twitterAccessToken = unserialize($userDetails['access_token']);
             try {
                 $twitter = new TwitterOAuth(TW_CONSUMER, TW_SECRET, $twitterAccessToken['oauth_token'], $twitterAccessToken['oauth_token_secret']);
                 $twitter->format = 'json';
                 $twitterProfiles = $twitter->get('users/lookup', array('user_id' => implode(',', $profilesToRequest)));
                 foreach ($twitterProfiles as $friend) {
                     $id = (string) $friend->id;
                     $screenName = (string) $friend->screen_name;
                     $pic = (string) $friend->profile_image_url;
                     $protected = (string) $friend->protected;
                     if ($id && ($screenName || $pic || $protected)) {
                         $update = $db->prepare('REPLACE INTO temp_twitter SET twitter_id = :twitter_id, time=NOW(), screen_name = :screen_name, picture_url = :picture_url, protected = :protected');
                         $update->execute(array(':twitter_id' => $id, ':screen_name' => $screenName, ':picture_url' => $pic, ':protected' => $protected));
                     }
                 }
             } catch (ErrorException $e) {
                 // Could not post to Twitter. Bad access token?
                 Debug::l('Error posting to Twitter ' . $e);
             }
         }
     }
     $linkPassword = BaseConvert::generatePassword();
     // Add the introduction to the database
     $insert = $db->prepare('INSERT INTO introduction (introducer_id, introducee1_id, introducee2_id, time, link_password) VALUES (:introducer_id, :introducee1_id, :introducee2_id, NOW(), :link_password)');
     $insert->execute(array(':introducer_id' => $userId, ':introducee1_id' => $introducee1->getId(), ':introducee2_id' => $introducee2->getId(), ':link_password' => $linkPassword));
     $introId = $db->lastInsertId();
     // Add the links for each introducee
     $linkPassword1 = BaseConvert::generatePassword();
     $linkPassword2 = BaseConvert::generatePassword();
     $insert = $db->prepare('INSERT INTO link (introduction_id, person_id, link_password) VALUES (:introduction_id, :person_id, :link_password)');
     $insert->execute(array(':introduction_id' => $introId, ':person_id' => $introducee1->getId(), ':link_password' => $linkPassword1));
     $insert->execute(array(':introduction_id' => $introId, ':person_id' => $introducee2->getId(), ':link_password' => $linkPassword2));
     // If there is a message, add it to the database
     if (!empty($_POST["message"])) {
         $message = htmlentities(trim($_POST['message']), ENT_QUOTES, 'UTF-8');
         if (!empty($message)) {
             $insert = $db->prepare('INSERT INTO message (body, time, introduction_id, writer_id) VALUES (:body, NOW(), :introduction_id, :writer_id)');
             $insert->execute(array(':body' => $message, ':introduction_id' => $introId, ':writer_id' => $userId));
         }
     }
     // Return the success message, which will tell the Javascript to redirect the user to the send-introduction page
     $json['result'] = 'true';
     $json['link'] = APP_URL . '/' . Content::l() . '/send-introduction/';
     $json['time'] = Debug::getInstance()->getTimeElapsed();
     echo json_encode($json);
 }
 private function displayIntroduction()
 {
     $output = '';
     $introTime = strtotime($this->introduction['time']);
     $ui = new ViewIntroduction();
     $output .= $ui->top();
     $script = '<script>' . '$(document).ready(function() {' . '_gaq.push(["_trackPageview", "/view-introduction/logged-in"]);' . '});' . 'var introduceme = (function (module) {' . 'module.content = module.content || {};' . 'module.content.youWrote = "' . str_replace('PERSON', Content::c()->view->you, Content::c()->view->wrote) . '";' . 'module.userType = "' . ($this->userId == $this->introduction['introducer_id'] ? 'introducer' : 'introducee') . '";' . 'return module;' . '}(introduceme || {}));' . 'Modernizr.load({' . 'test: introduceme.mobile,' . 'nope: "http://www.linkedin.com/js/public-profile/widget-os.js"' . '});' . '</script>';
     if ($this->userId == $this->introduction['introducer_id']) {
         // The user is the introducer
         $introducee1 = new Person(array());
         $introducee1->getDataFromId($this->introduction['introducee1_id']);
         $introducee2 = new Person(array());
         $introducee2->getDataFromId($this->introduction['introducee2_id']);
         $output .= '<div class="col1">' . '<h1>' . str_replace('INTRODUCEE1', $introducee1->getName(), str_replace('INTRODUCEE2', $introducee2->getName(), Content::c()->view->title_introducer)) . '</h1>' . $ui->introductionTime($introTime);
         // If this introduction was sent in the last 10x60 seconds display a confirmation message
         if ($introTime + 10 * 60 > time()) {
             $output .= $ui->confirmation($introducee1, $introducee2, $this->introduction['introducee1_notified'], $this->introduction['introducee2_notified']);
         }
         // If we don't have the user's email, show a form requesting it
         if (empty($this->userDetails['email'])) {
             $output .= $ui->emailForm($introducee1, $introducee2);
         }
         $output .= '<div class="profileTextLinks"><ul>' . $ui->socialProfileText($introducee1) . $ui->socialProfileText($introducee2) . '</ul></div>';
         // Show a message input form
         $output .= $ui->messageBox($introducee1, $introducee2, $this->id);
         // Show messages
         $messagesQ = $this->db->prepare('SELECT body, time, writer_id FROM message WHERE introduction_id = :introduction_id ORDER BY time DESC');
         $messagesQ->execute(array(':introduction_id' => $this->id));
         $messages = $messagesQ->fetchAll(PDO::FETCH_ASSOC);
         $len = count($messages);
         $output .= '<div class="displayingMessages" ' . ($len == 0 ? 'style="display:none;"' : '') . '>' . str_replace('PERSON1', $introducee1->getName(), str_replace('PERSON2', $introducee2->getName(), Content::c()->view->displaying_messages)) . '</div>' . '<div id="messages">';
         if ($len > 0) {
             for ($i = 0; $i < $len; $i++) {
                 $writer = '';
                 if ($messages[$i]['writer_id'] == $this->userId) {
                     $writer = Content::c()->view->you;
                 } elseif ($messages[$i]['writer_id'] == $introducee1->getId()) {
                     $writer = $introducee1->getName();
                 } elseif ($messages[$i]['writer_id'] == $introducee2->getId()) {
                     $writer = $introducee2->getName();
                 }
                 $output .= $ui->message($writer, strtotime($messages[$i]['time']), $messages[$i]['body']);
             }
             $output .= '</div>';
             // #messages DIV
         }
         $output .= '</div><div class="col2">' . $ui->socialProfile($introducee1) . $ui->socialProfile($introducee2) . '</div>';
         // .col2
         $bottom = new Bottom($script);
         $output .= $bottom->getOutput();
         return $output;
     } elseif ($this->userId == $this->introduction['introducee1_id']) {
         // The user is introducee 1
         $introducee = new Person(array());
         $introducee->getDataFromId($this->introduction['introducee2_id']);
         // Mark the introduction as read for introducee1
         if ($this->introduction['introducee1_read'] == 0) {
             $sth = $this->db->prepare('UPDATE introduction SET introducee1_read = 1 WHERE id = :introduction_id');
             $sth->execute(array(':introduction_id' => $this->id));
         }
     } else {
         // The user is introducee 2
         $introducee = new Person(array());
         $introducee->getDataFromId($this->introduction['introducee1_id']);
         // Mark the introduction as read for introducee2
         if ($this->introduction['introducee2_read'] == 0) {
             $sth = $this->db->prepare('UPDATE introduction SET introducee2_read = 1 WHERE id = :introduction_id');
             $sth->execute(array(':introduction_id' => $this->id));
         }
     }
     $introducer = new Person(array());
     $introducer->getDataFromId($this->introduction['introducer_id']);
     $output .= '<div class="col1">' . '<h1>' . str_replace('INTRODUCER', $introducer->getName(), str_replace('INTRODUCEE', $introducee->getName(), Content::c()->view->title_introducee)) . '</h1>' . $ui->introductionTime($introTime);
     // If we don't have the user's email, show a form requesting it
     if (empty($this->userDetails['email'])) {
         $output .= $ui->emailForm($introducer, $introducee);
     }
     $output .= '<div class="profileTextLinks"><ul>' . $ui->socialProfileText($introducee) . '</ul></div>';
     // Show a message input form
     $output .= $ui->messageBox($introducer, $introducee, $this->id);
     // Show messages
     $messagesQ = $this->db->prepare('SELECT body, time, writer_id FROM message WHERE introduction_id = :introduction_id ORDER BY time DESC');
     $messagesQ->execute(array(':introduction_id' => $this->id));
     $messages = $messagesQ->fetchAll(PDO::FETCH_ASSOC);
     $len = count($messages);
     if ($len > 0) {
         $output .= '<div class="displayingMessages">' . str_replace('PERSON1', $introducer->getName(), str_replace('PERSON2', $introducee->getName(), Content::c()->view->displaying_messages)) . '</div>' . '<div id="messages">';
         for ($i = 0; $i < $len; $i++) {
             $writer = '';
             if ($messages[$i]['writer_id'] == $this->userId) {
                 $writer = Content::c()->view->you;
             } elseif ($messages[$i]['writer_id'] == $introducer->getId()) {
                 $writer = $introducer->getName();
             } elseif ($messages[$i]['writer_id'] == $introducee->getId()) {
                 $writer = $introducee->getName();
             }
             $output .= $ui->message($writer, strtotime($messages[$i]['time']), $messages[$i]['body']);
         }
         $output .= '</div>';
         // #messages DIV
     }
     $output .= '</div><div class="col2">' . $ui->socialProfile($introducee) . '</div>';
     // .col2
     $bottom = new Bottom($script);
     $output .= $bottom->getOutput();
     return $output;
 }
Exemplo n.º 9
0
 private function printAccessTokenError($e)
 {
     Debug::l('Error loading ' . $this->network . ' friends ' . $e);
     $json['result'] = 'false';
     $json['redirect'] = 'true';
     $json['title'] = (string) Content::c()->errors->auth->title;
     $json['message'] = str_replace('SOCIAL_NETWORK_NAME', $this->network, Content::c()->errors->auth->invalid_access_token);
     echo json_encode($json);
     exit;
 }
Exemplo n.º 10
0
 private function finishPublishToFacebook()
 {
     // See if we can get a picture of the other introducee
     if ($this->other->getLinkedInId() != null) {
         $picture = $this->other->getLinkedInPicture();
     }
     if (!isset($picture) && $this->other->getTwitterId() != null) {
         $picture = $this->other->getTwitterPicture();
     }
     if (!isset($picture) && $this->other->getFacebookId() != null) {
         // Shorten the picture URL with BITLY so we can publish it on Facebook
         $results = bitly_v3_shorten('https://graph.facebook.com/' . $this->other->getFacebookId() . '/picture?type=normal', 'j.mp');
         if (!empty($results['url'])) {
             $picture = $results['url'];
         }
     }
     try {
         $params = array('description' => ' ', 'caption' => str_replace('INTRODUCEE_NAME', $this->other->getName(), str_replace('INTRODUCER_NAME', $this->userName, Content::c()->introduce->notification)), 'link' => $this->introductionUrl, 'name' => $this->other->getName(), 'access_token' => $this->userDetails['facebook_access_token']);
         if (!empty($picture)) {
             $params['picture'] = $picture;
         }
         $statusUpdate = SessionManager::getInstance()->getFacebook()->api('/' . $this->introducee->getFacebookId() . '/feed', 'POST', $params);
     } catch (FacebookApiException $e) {
         // Could not post to Facebook.
         Debug::l('Error posting to Facebook ' . $e);
         return false;
     }
     return true;
 }
Exemplo n.º 11
0
 public function message($name, $time, $body)
 {
     $output = '<div class="message"><h2>' . str_replace('PERSON', $name, Content::c()->view->wrote) . '</h2>' . $this->formatTime($time) . '<p>' . $body . '</p></div>';
     return $output;
 }