コード例 #1
0
ファイル: PageAbout.php プロジェクト: chitrakojha/introduceme
 public function __construct()
 {
     $top = new Top('', 'aboutPage');
     echo $top->getOutput();
     echo Content::c()->about->desc;
     $bottom = new Bottom('');
     echo $bottom->getOutput();
 }
コード例 #2
0
 public function __construct()
 {
     session_start();
     // Connect to the database
     $this->db = Database::getInstance();
     // Get the website user
     $this->userId = SessionManager::getInstance()->getUserId();
     if (empty($this->userId)) {
         Debug::l('No user logged in');
         header('Location: ' . Content::getInstance()->getRootUrl());
         exit;
     }
     $userDetailsQ = $this->db->prepare('SELECT p.email, 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' => $this->userId));
     $this->userDetails = $userDetailsQ->fetch(PDO::FETCH_ASSOC);
     $top = new Top('', 'settingsPage');
     echo $top->getOutput();
     echo '<h1>' . Content::c()->settings->title . '</h1>' . '<h2>' . Content::c()->settings->profiles . '</h2>' . $this->showConnectedProfiles() . '<h2>' . Content::c()->settings->email . '</h2>' . '<form id="formEmail" class="clearfix">' . '<input type="email" name="email" id="email" value="' . $this->userDetails['email'] . '" placeholder="' . Content::c()->view->email_request->placeholder . '" />' . '<input id="submitEmail" class="button" type="submit" value="' . Content::c()->settings->submit . '" />' . '</form>' . '';
     $script = '<script>' . 'var introduceme = (function (module) {' . 'module.content = module.content || {};' . 'module.content.success = "' . Content::c()->settings->success . '";' . 'module.content.saved = "' . Content::c()->settings->saved . '";' . 'return module;' . '}(introduceme || {}));' . '</script>';
     $bottom = new Bottom($script);
     echo $bottom->getOutput();
 }
コード例 #3
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();
 }
コード例 #4
0
ファイル: PageIndex.php プロジェクト: chitrakojha/introduceme
 public function __construct()
 {
     session_start();
     // Connect to the database
     $this->db = Database::getInstance();
     // Get the website user
     $this->userId = SessionManager::getInstance()->getUserId();
     if (!empty($this->userId)) {
         $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' => $this->userId));
         $this->userDetails = $userDetailsQ->fetch(PDO::FETCH_ASSOC);
     }
     $this->facebookLoginUrl = SessionManager::getInstance()->getFacebook()->getLoginUrl(array('redirect_uri' => APP_URL . '/' . Content::l() . '/login/facebookcallback/', 'scope' => 'publish_stream, offline_access'));
     $top = new Top('', 'homePage');
     echo $top->getOutput();
     echo '<div id="preloaderFriends" style="display: none;">' . Content::c()->home->loading . '</div>' . '<div id="info">' . '<p>' . Content::c()->home->desc . '</p>' . '</div>' . '<div id="formLogin" class="clearfix">' . '<p>' . Content::c()->introduce->login . '</p>' . '<a href="' . $this->facebookLoginUrl . '" id="loginFacebook" class="ir' . (!empty($this->userDetails['facebook_access_token']) ? ' loggedIn' : '') . '">Facebook</a>' . '<a href="/' . Content::l() . '/login/linkedin/" id="loginLinkedIn" class="ir' . (!empty($this->userDetails['linkedin_access_token']) ? ' loggedIn' : '') . '">LinkedIn</a>' . '<a href="/' . Content::l() . '/login/twitter/" id="loginTwitter" class="ir' . (!empty($this->userDetails['twitter_access_token']) ? ' loggedIn' : '') . '">Twitter</a>' . '<p id="loginFirst">' . Content::c()->introduce->login_here_first . '</p>' . '</div>' . '<form id="formIntroduce" class="clearfix" novalidate="novalidate" autocomplete="off">' . '<div class="friendSelector introduceeInput1">' . '<label for="introducee1">' . Content::c()->introduce->introduce . '</label>' . '<input type="text" id="introducee1" placeholder="' . Content::c()->introduce->enter_name . '" />' . '<ul class="filteredFriends"></ul>' . '</div>' . '<div class="friendSelector introduceeInput2">' . '<label for="introducee2">' . Content::c()->introduce->with . '</label>' . '<input type="text" id="introducee2" placeholder="' . Content::c()->introduce->enter_name . '" />' . '<ul class="filteredFriends"></ul>' . '</div>' . '<label for="message">' . Content::c()->introduce->why . '</label>' . '<textarea id="message" placeholder="' . Content::c()->introduce->message . '"></textarea>' . '<input id="submitIntroduce" class="button" type="submit" value="' . Content::c()->introduce->submit . '" />' . '<a href="/' . Content::l() . '/about/" class="help">' . Content::c()->introduce->help . '</a>' . '</form>';
     if (!empty($this->userId)) {
         echo $this->previousIntroductions();
     }
     $script = '<script>' . 'var introduceme = (function (module) {' . 'module.content = module.content || {};' . 'module.content.loginFirst = "' . Content::c()->introduce->login_first . '";' . 'module.personId = ' . (!empty($this->userId) ? '"' . $this->userId . '"' : 'null') . ';' . 'module.facebookId = ' . (!empty($this->userDetails['facebook_access_token']) ? '"' . $this->userDetails['facebook_id'] . '"' : 'null') . ';' . 'module.linkedInId = ' . (!empty($this->userDetails['linkedin_access_token']) ? '"' . $this->userDetails['linkedin_id'] . '"' : 'null') . ';' . 'module.twitterId = ' . (!empty($this->userDetails['twitter_access_token']) ? '"' . $this->userDetails['twitter_id'] . '"' : 'null') . ';' . 'return module;' . '}(introduceme || {}));' . '</script>';
     $bottom = new Bottom($script);
     echo $bottom->getOutput();
 }
コード例 #5
0
 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;
 }
コード例 #6
0
 private function output($value)
 {
     $top = new Top('', 'sendIntroductionPage');
     echo $top->getOutput();
     echo '<div class="sendIntroduction">' . $value . '</div>';
     $bottom = new Bottom('');
     echo $bottom->getOutput();
 }