/** * 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(); }
/** * 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(); }
// 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); // 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); }
$post = $pd->getPost($status_id); $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); }