/** * 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(); }
chdir(".."); require_once "common/init.php"; $pd = new PostDAO($db); if (isset($_REQUEST['t']) && is_numeric($_REQUEST['t']) && $pd->isPostInDB($_REQUEST['t'])) { $post_id = $_REQUEST['t']; $s = new SmartyThinkTank(); if (!$s->is_cached('status.index.tpl', $post_id)) { $post = $pd->getPost($post_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); // 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);