Exemplo n.º 1
0
 /**
  * Main control method
  */
 public function authControl()
 {
     $this->setViewTemplate('post.index.tpl');
     if (isset($_REQUEST['t']) && is_numeric($_REQUEST['t']) && $this->post_dao->isPostInDB($_REQUEST['t'])) {
         $post_id = $_REQUEST['t'];
         $this->addToViewCacheKey($post_id);
         $post = $this->post_dao->getPost($post_id);
         $this->addToView('post', $post);
         $this->addToView('likely_orphans', $this->post_dao->getLikelyOrphansForParent($post->pub_date, $post->author_user_id, $post->author_username, 15));
         $this->addToView('all_tweets', $this->post_dao->getAllPosts($post->author_user_id, 15));
         $all_replies = $this->post_dao->getRepliesToPost($post_id);
         $this->addToView('replies', $all_replies);
         $all_replies_count = count($all_replies);
         $this->addToView('reply_count', $all_replies_count);
         $all_retweets = $this->post_dao->getRetweetsOfPost($post_id);
         $this->addToView('retweets', $all_retweets);
         $retweet_reach = $this->post_dao->getPostReachViaRetweets($post_id);
         $this->addToView('retweet_reach', $retweet_reach);
         $public_replies = $this->post_dao->getPublicRepliesToPost($post_id);
         $public_replies_count = count($public_replies);
         $this->addToView('public_reply_count', $public_replies_count);
         $private_replies_count = $all_replies_count - $public_replies_count;
         $this->addToView('private_reply_count', $private_replies_count);
     } else {
         $this->addToView('error', 'Post not found');
     }
     return $this->generateView();
 }
 /**
  * Load view with individual post and replies and retweets
  * @param int $post_id
  */
 private function loadSinglePostThread($post_id)
 {
     $post = $this->post_dao->getPost($post_id);
     $public_tweet_replies = $this->post_dao->getPublicRepliesToPost($post->post_id);
     $public_retweets = $this->post_dao->getRetweetsOfPost($post->post_id, true);
     $this->addToView('post', $post);
     $this->addToView('replies', $public_tweet_replies);
     $this->addToView('retweets', $public_retweets);
     $rtreach = 0;
     foreach ($public_retweets as $t) {
         $rtreach += $t->author->follower_count;
     }
     $this->addToView('rtreach', $rtreach);
 }
 /**
  * Load view with individual post and replies and retweets
  * @param int $post_id
  * @param str $network
  */
 private function loadSinglePostThread($post_id, $network)
 {
     $this->setPageTitle('Public Post Replies');
     $this->post_dao->isPostByPublicInstance($_GET['t'], $network);
     $post = $this->post_dao->getPost($post_id, $network);
     if (!isset($post)) {
         $this->addErrorMessage("Post " . $post_id . " on " . ucwords($network) . " is not in ThinkUp.");
     } else {
         $plugin_option_dao = DAOFactory::GetDAO('PluginOptionDAO');
         $options = $plugin_option_dao->getOptionsHash('geoencoder', true);
         if (isset($options['distance_unit']->option_value)) {
             $distance_unit = $options['distance_unit']->option_value;
         } else {
             $distance_unit = 'km';
         }
         $public_tweet_replies = $this->post_dao->getPublicRepliesToPost($post->post_id, $network, 'default', $distance_unit);
         $public_retweets = $this->post_dao->getRetweetsOfPost($post->post_id, $network, 'default', $distance_unit, true);
         $this->addToView('post', $post);
         $this->addToView('replies', $public_tweet_replies);
         $this->addToView('retweets', $public_retweets);
         $this->addToView('unit', $distance_unit);
         $rtreach = 0;
         foreach ($public_retweets as $t) {
             $rtreach += $t->author->follower_count;
         }
         $this->addToView('rtreach', $rtreach);
     }
 }
Exemplo n.º 4
0
 /**
  * Main control method
  */
 public function authControl()
 {
     $this->setViewTemplate('post.index.tpl');
     $network = isset($_GET['n']) ? $_GET['n'] : 'twitter';
     $_GET['n'] = $network;
     if ($this->shouldRefreshCache()) {
         if (isset($_GET['t']) && is_numeric($_GET['t']) && $this->post_dao->isPostInDB($_GET['t'], $network)) {
             $plugin_option_dao = DAOFactory::GetDAO('PluginOptionDAO');
             $options = $plugin_option_dao->getOptionsHash('geoencoder', true);
             if (isset($options['distance_unit']->option_value)) {
                 $distance_unit = $options['distance_unit']->option_value;
             } else {
                 $distance_unit = 'km';
             }
             $post_id = $_GET['t'];
             $post = $this->post_dao->getPost($post_id, $network);
             $this->addToView('post', $post);
             $this->addToView('unit', $distance_unit);
             // costly query
             //$this->addToView('likely_orphans', $this->post_dao->getLikelyOrphansForParent($post->pub_date,
             //$post->author_user_id,$post->author_username, 15) );
             //$this->addToView('all_tweets', $this->post_dao->getAllPosts($post->author_user_id, 15) );
             $all_replies = $this->post_dao->getRepliesToPost($post_id, $network, 'default', $distance_unit);
             $this->addToView('replies', $all_replies);
             $all_replies_by_location = $this->post_dao->getRepliesToPost($post_id, $network, 'location', $distance_unit);
             $this->addToView('replies_by_location', $all_replies_by_location);
             $all_replies_count = count($all_replies);
             $this->addToView('reply_count', $all_replies_count);
             $all_retweets = $this->post_dao->getRetweetsOfPost($post_id, $network, 'default', $distance_unit);
             $this->addToView('retweets', $all_retweets);
             $all_retweets_by_location = $this->post_dao->getRetweetsOfPost($post_id, $network, 'location', $distance_unit);
             $this->addToView('retweets_by_location', $all_retweets_by_location);
             $retweet_reach = $this->post_dao->getPostReachViaRetweets($post_id, $network);
             $this->addToView('retweet_reach', $retweet_reach);
             $public_replies = $this->post_dao->getPublicRepliesToPost($post_id, $network);
             $public_replies_count = count($public_replies);
             $this->addToView('public_reply_count', $public_replies_count);
             $private_replies_count = $all_replies_count - $public_replies_count;
             $this->addToView('private_reply_count', $private_replies_count);
         } else {
             $this->addErrorMessage('Post not found');
         }
     }
     return $this->generateView();
 }
Exemplo n.º 5
0
    $page = $_REQUEST['page'];
} else {
    $page = 1;
}
if ($page > 1) {
    $s->assign('prev_page', $page - 1);
}
$s->assign('cfg', $cfg);
$i = $id->getInstanceFreshestOne();
$s->assign('crawler_last_run', $i->crawler_last_run);
$s->assign('i', $_i);
// show tweet with public replies
if (isset($_REQUEST['t']) && $pd->isPostByPublicInstance($_REQUEST['t'])) {
    if (!$s->is_cached('public.tpl', $_REQUEST['t'])) {
        $post = $pd->getPost($_REQUEST['t']);
        $public_tweet_replies = $pd->getPublicRepliesToPost($post->post_id);
        $public_retweets = $pd->getRetweetsOfPost($post->post_id, true);
        $s->assign('post', $post);
        $s->assign('replies', $public_tweet_replies);
        $s->assign('retweets', $public_retweets);
        $rtreach = 0;
        foreach ($public_retweets as $t) {
            $rtreach += $t->author->follower_count;
        }
        $s->assign('rtreach', $rtreach);
        $s->assign('site_root', $THINKTANK_CFG['site_root_path']);
    }
    $s->display('public.tpl', $_REQUEST['t']);
} elseif (isset($_REQUEST['v'])) {
    $view = $_REQUEST['v'];
    switch ($view) {
Exemplo n.º 6
0
     //$id = new InstanceDAO($db);
     //$i = $id->getByUsername($post->author_username);
     // instead, lets pull the instance object out of the session variable
     $i = unserialize($_SESSION['instance']);
     if (isset($i)) {
         $s->assign('likely_orphans', $pd->getLikelyOrphansForParent($post->pub_date, $i->network_user_id, $post->author_username, 15));
         $s->assign('all_tweets', $pd->getAllPosts($i->network_user_id, 15));
     }
     $cfg = new Config($i->network_username, $i->network_user_id);
     // instantiate data access objects
     $ud = new UserDAO($db);
     $all_replies = $pd->getRepliesToPost($post_id);
     $all_replies_count = count($all_replies);
     $all_retweets = $pd->getRetweetsOfPost($post_id);
     $retweet_reach = $pd->getPostReachViaRetweets($post_id);
     $public_replies = $pd->getPublicRepliesToPost($post_id);
     $public_replies_count = count($public_replies);
     $private_replies_count = $all_replies_count - $public_replies_count;
     $post = $pd->getPost($post_id);
     $s->assign('post', $post);
     $s->assign('replies', $all_replies);
     $s->assign('retweets', $all_retweets);
     $s->assign('retweet_reach', $retweet_reach);
     $s->assign('public_reply_count', $public_replies_count);
     $s->assign('private_reply_count', $private_replies_count);
     $s->assign('reply_count', $all_replies_count);
     $s->assign('cfg', $cfg);
     $s->assign('instance', $i);
     $s->assign('i', $i);
 }
 # clean up
Exemplo n.º 7
0
     $u = new Utils();
     // BUG: THIS ISN'T GOING TO WORK WHEN LOOKING AT POSTS OF OTHER USERS BECAUSE THEY DON'T HAVE INSTANCES
     $id = new InstanceDAO($db);
     $i = $id->getByUsername($post->author_username);
     if (isset($i)) {
         $s->assign('likely_orphans', $pd->getLikelyOrphansForParent($post->pub_date, $i->network_user_id, $post->author_username, 15));
         $s->assign('all_tweets', $pd->getAllPosts($i->network_user_id, 15));
     }
     $cfg = new Config($i->network_username, $i->network_user_id);
     // instantiate data access objects
     $ud = new UserDAO($db);
     $all_replies = $pd->getRepliesToPost($status_id);
     $all_replies_count = count($all_replies);
     $all_retweets = $pd->getRetweetsOfPost($status_id);
     $retweet_reach = $pd->getPostReachViaRetweets($status_id);
     $public_replies = $pd->getPublicRepliesToPost($status_id);
     $public_replies_count = count($public_replies);
     $private_replies_count = $all_replies_count - $public_replies_count;
     $post = $pd->getPost($status_id);
     $s->assign('post', $post);
     $s->assign('replies', $all_replies);
     $s->assign('retweets', $all_retweets);
     $s->assign('retweet_reach', $retweet_reach);
     $s->assign('public_reply_count', $public_replies_count);
     $s->assign('private_reply_count', $private_replies_count);
     $s->assign('reply_count', $all_replies_count);
     $s->assign('cfg', $cfg);
     $s->assign('instance', $i);
     $s->assign('i', $i);
 }
 # clean up