Пример #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 instance dashboard
  * @param str $username
  * @param str $network
  */
 private function loadPublicInstanceDashboard($username, $network)
 {
     $instance_dao = DAOFactory::getDAO('InstanceDAO');
     $instance = $instance_dao->getByUsernameOnNetwork($username, $network);
     if (isset($instance) && $instance->is_public) {
         $this->setPageTitle($instance->network_username . "'s Public Profile");
         $this->addToView('instance', $instance);
         //user
         $user_dao = DAOFactory::getDAO('UserDAO');
         $user = $user_dao->getDetails($instance->network_user_id, $instance->network);
         $this->addToView('user_details', $user);
         //posts
         $recent_posts = $this->post_dao->getAllPosts($instance->network_user_id, $instance->network, 5, true);
         $this->addToView('recent_posts', $recent_posts);
         $most_replied_to_alltime = $this->post_dao->getMostRepliedToPosts($instance->network_user_id, $network, 5);
         $this->addToView('most_replied_to_alltime', $most_replied_to_alltime);
         $most_retweeted_alltime = $this->post_dao->getMostRetweetedPosts($instance->network_user_id, $network, 5);
         $this->addToView('most_retweeted_alltime', $most_retweeted_alltime);
         $most_replied_to_1wk = $this->post_dao->getMostRepliedToPostsInLastWeek($instance->network_username, $instance->network, 5);
         $this->addToView('most_replied_to_1wk', $most_replied_to_1wk);
         $most_retweeted_1wk = $this->post_dao->getMostRetweetedPostsInLastWeek($instance->network_username, $instance->network, 5);
         $this->addToView('most_retweeted_1wk', $most_retweeted_1wk);
         $conversations = $this->post_dao->getPostsAuthorHasRepliedTo($instance->network_user_id, 5);
         $this->addToView('conversations', $conversations);
         //follows
         $follow_dao = DAOFactory::getDAO('FollowDAO');
         $least_likely_followers = $follow_dao->getLeastLikelyFollowers($instance->network_user_id, 'twitter', 16);
         $this->addToView('least_likely_followers', $least_likely_followers);
         //follower count history
         $follower_count_dao = DAOFactory::getDAO('FollowerCountDAO');
         $follower_count_history_by_day = $follower_count_dao->getHistory($instance->network_user_id, 'twitter', 'DAY');
         $this->addToView('follower_count_history_by_day', $follower_count_history_by_day);
         $first_follower_count = $follower_count_history_by_day['history'][0]['count'];
         $last_follower_count = $follower_count_history_by_day['history'][sizeof($follower_count_history_by_day['history']) - 1]['count'];
         $this->addToView('follower_count_by_day_trend', ($last_follower_count - $first_follower_count) / sizeof($follower_count_history_by_day['history']));
         $follower_count_history_by_week = $follower_count_dao->getHistory($instance->network_user_id, 'twitter', 'WEEK');
         $this->addToView('follower_count_history_by_week', $follower_count_history_by_week);
         $first_follower_count = $follower_count_history_by_week['history'][0]['count'];
         $last_follower_count = $follower_count_history_by_week['history'][sizeof($follower_count_history_by_week['history']) - 1]['count'];
         $this->addToView('follower_count_by_week_trend', ($last_follower_count - $first_follower_count) / sizeof($follower_count_history_by_week['history']));
         $post_dao = DAOFactory::getDAO('PostDAO');
         list($all_time_clients_usage, $latest_clients_usage) = $post_dao->getClientsUsedByUserOnNetwork($instance->network_user_id, $instance->network);
         // Only show the top 10 most used clients, since forever
         $all_time_clients_usage = array_merge(array_slice($all_time_clients_usage, 0, 10), array('Others' => array_sum(array_slice($all_time_clients_usage, 10))));
         $this->addToView('all_time_clients_usage', $all_time_clients_usage);
         // Only show the two most used clients for the last 25 posts
         $latest_clients_usage = array_slice($latest_clients_usage, 0, 2);
         $this->addToView('latest_clients_usage', $latest_clients_usage);
     } else {
         $this->addErrorMessage($username . " on " . ucwords($network) . " isn't set up on this ThinkUp installation.");
     }
 }
 public function control()
 {
     /*
      * Check if the view is cached and, if it is, return the cached version before any of the application login
      * is executed.
      */
     if ($this->view_mgr->isViewCached()) {
         if ($this->view_mgr->is_cached('json.tpl', $this->getCacheKeyString())) {
             // set the json data to keep the ThinkUpController happy.
             $this->setJsonData(array());
             return $this->generateView();
         }
     }
     /*
      * Check if the API is disabled and, if it is, throw the appropriate exception.
      *
      * Docs: http://thinkupapp.com/docs/userguide/api/errors/apidisabled.html
      */
     $is_api_disabled = Config::getInstance()->getValue('is_api_disabled');
     if ($is_api_disabled) {
         throw new APIDisabledException();
     }
     // fetch the correct PostDAO and UserDAO from the DAOFactory
     $this->post_dao = DAOFactory::getDAO('PostDAO');
     $this->user_dao = DAOFactory::getDAO('UserDAO');
     /*
      * Use the information gathered from the query string to retrieve a
      * User object. This will be the standard object with which to get
      * User information from in API calls.
      */
     if ($this->user_id != null) {
         $this->user = $this->user_dao->getDetails($this->user_id, $this->network);
     } else {
         if ($this->username != null) {
             $this->user = $this->user_dao->getUserByName($this->username, $this->network);
         } else {
             $this->user = null;
         }
     }
     //Privacy checks
     if (substr($this->type, 0, 4) == 'user') {
         //user-related API call
         if (is_null($this->user)) {
             // Check why the User object is null. Could be missing required fields or not found.
             if (is_null($this->user_id) && is_null($this->username)) {
                 $m = 'A request of type ' . $this->type . ' requires a user_id or username to be specified.';
                 throw new RequiredArgumentMissingException($m);
             } else {
                 throw new UserNotFoundException();
             }
         } elseif ($this->user->is_protected) {
             //user is protected on originating network
             throw new UserNotFoundException();
         } else {
             $instance_dao = DAOFactory::getDAO('InstanceDAO');
             $instance = $instance_dao->getByUsernameOnNetwork($this->user->username, $this->user->network);
             if (isset($instance)) {
                 if (!$instance->is_public) {
                     //user is protected on ThinkUp
                     throw new UserNotFoundException();
                 }
             }
         }
     } else {
         //post-related API call
         if ($this->network == "facebook") {
             //assume all Facebook posts are private
             throw new PostNotFoundException();
         }
     }
     /*
      * This switch statement is the main part of this function. It decides
      * what type of posts will be fetched depending on the "type" GET
      * variable and use the PostDAO to fetch the appropriate posts from
      * the database.
      *
      * If a required field is missing it will create an error field to
      * output in JSON.
      */
     switch ($this->type) {
         /*
          * Gets a post.
          *
          * Required arguments: post_id
          *
          * Optional arguments: network, include_entities, include_replies, trim_user
          *
          * Docs: http://thinkupapp.com/docs/userguide/api/posts/post.html
          */
         case 'post':
             if (is_null($this->post_id)) {
                 $m = 'A request of type ' . $this->type . ' requires a post_id to be specified.';
                 throw new RequiredArgumentMissingException($m);
             } else {
                 $data = $this->post_dao->getPost($this->post_id, $this->network, $this->is_public);
             }
             break;
             /*
              * Gets all retweets to a post.
              *
              * Required arguments: post_id
              *
              * Optional arguments: network, order_by, unit, count, page, include_entities, include_replies,
              * trim_user
              *
              * Docs: http://thinkupapp.com/docs/userguide/api/posts/post_retweets.html
              */
         /*
          * Gets all retweets to a post.
          *
          * Required arguments: post_id
          *
          * Optional arguments: network, order_by, unit, count, page, include_entities, include_replies,
          * trim_user
          *
          * Docs: http://thinkupapp.com/docs/userguide/api/posts/post_retweets.html
          */
         case 'post_retweets':
             if (is_null($this->post_id)) {
                 $m = 'A request of type ' . $this->type . ' requires a post_id to be specified.';
                 throw new RequiredArgumentMissingException($m);
             } else {
                 $data = $this->post_dao->getRetweetsOfPost($this->post_id, $this->network, $this->order_by, $this->unit, $this->is_public, $this->count, $this->page);
             }
             break;
             /**
              * Gets replies to a post.
              *
              * Required arguments: post_id
              *
              * Optional arguments: network, order_by, unit, count, page, include_entities, include_replies,
              * trim_user
              *
              * Ordering can only be done by either location or follower count.
              *
              * Docs: http://thinkupapp.com/docs/userguide/api/posts/post_replies.html
              */
         /**
          * Gets replies to a post.
          *
          * Required arguments: post_id
          *
          * Optional arguments: network, order_by, unit, count, page, include_entities, include_replies,
          * trim_user
          *
          * Ordering can only be done by either location or follower count.
          *
          * Docs: http://thinkupapp.com/docs/userguide/api/posts/post_replies.html
          */
         case 'post_replies':
             if (is_null($this->post_id)) {
                 $m = 'A request of type ' . $this->type . ' requires a post_id to be specified.';
                 throw new RequiredArgumentMissingException($m);
             } else {
                 $data = $this->post_dao->getRepliesToPost($this->post_id, $this->network, $this->order_by, $this->unit, $this->is_public, $this->count, $this->page);
             }
             break;
             /*
              * Gets replies to a post within a date range.
              *
              * Required arguments: post_id, from and until
              *
              * Optional arguments: network, order_by, unit, count, page, include_entities, include_replies,
              * trim_user
              *
              * Ordering can only be done by either location or follower count.
              *
              * Docs: http://thinkupapp.com/docs/userguide/api/posts/post_replies.html
              */
         /*
          * Gets replies to a post within a date range.
          *
          * Required arguments: post_id, from and until
          *
          * Optional arguments: network, order_by, unit, count, page, include_entities, include_replies,
          * trim_user
          *
          * Ordering can only be done by either location or follower count.
          *
          * Docs: http://thinkupapp.com/docs/userguide/api/posts/post_replies.html
          */
         case 'post_replies_in_range':
             if (is_null($this->post_id) || is_null($this->from) || is_null($this->until)) {
                 $m = 'A request of type ' . $this->type . ' requires a post_id to be specified.';
                 throw new RequiredArgumentMissingException($m);
             } else {
                 $data = $this->post_dao->getRepliesToPostInRange($this->post_id, $this->network, $this->from, $this->until, $this->order_by, $this->unit, $this->is_public, $this->count, $this->page);
             }
             break;
             /*
              * Get posts related to a post (replies to it, retweets of it).
              *
              * Required arguments: post_id
              *
              * Optional arguments: network, count, page, geo_encoded_only, include_original_post, include_entities,
              * include_replies, trim_user
              *
              * Docs: http://thinkupapp.com/docs/userguide/api/posts/related_posts.html
              */
         /*
          * Get posts related to a post (replies to it, retweets of it).
          *
          * Required arguments: post_id
          *
          * Optional arguments: network, count, page, geo_encoded_only, include_original_post, include_entities,
          * include_replies, trim_user
          *
          * Docs: http://thinkupapp.com/docs/userguide/api/posts/related_posts.html
          */
         case 'related_posts':
             if (is_null($this->post_id)) {
                 $m = 'A request of type ' . $this->type . ' requires a post_id to be specified.';
                 throw new RequiredArgumentMissingException($m);
             } else {
                 $data = $this->post_dao->getRelatedPosts($this->post_id, $this->network, $this->is_public, $this->count, $this->page, $geo_encoded_only = false, $include_original_post = false);
             }
             break;
             /*
              * Gets the user's most replied to posts.
              *
              * Required arguments: user_id or username
              *
              * Optional arguments: network, count, page, include_entities, include_replies, trim_user
              *
              * Docs: http://thinkupapp.com/docs/userguide/api/posts/user_posts_most_replied_to.html
              */
         /*
          * Gets the user's most replied to posts.
          *
          * Required arguments: user_id or username
          *
          * Optional arguments: network, count, page, include_entities, include_replies, trim_user
          *
          * Docs: http://thinkupapp.com/docs/userguide/api/posts/user_posts_most_replied_to.html
          */
         case 'user_posts_most_replied_to':
             $data = $this->post_dao->getMostRepliedToPosts($this->user->user_id, $this->network, $this->count, $this->page, $this->is_public);
             break;
             /*
              * Gets the user's most retweeted posts.
              *
              * Required arguments: user_id or username
              *
              * Optional arguments: network, count, page, include_entities, include_replies, trim_user
              *
              * Docs: http://thinkupapp.com/docs/userguide/api/posts/user_posts_most_retweeted.html
              */
         /*
          * Gets the user's most retweeted posts.
          *
          * Required arguments: user_id or username
          *
          * Optional arguments: network, count, page, include_entities, include_replies, trim_user
          *
          * Docs: http://thinkupapp.com/docs/userguide/api/posts/user_posts_most_retweeted.html
          */
         case 'user_posts_most_retweeted':
             $data = $this->post_dao->getMostRetweetedPosts($this->user->user_id, $this->network, $this->count, $this->page, $this->is_public);
             break;
             /*
              * Gets posts a user has made.
              *
              * Required arguments: user_id or username
              *
              * Optional arguments: network, count, page, order_by, direction, include_entities, include_replies,
              * trim_user
              *
              * Docs: http://thinkupapp.com/docs/userguide/api/posts/user_posts.html
              */
         /*
          * Gets posts a user has made.
          *
          * Required arguments: user_id or username
          *
          * Optional arguments: network, count, page, order_by, direction, include_entities, include_replies,
          * trim_user
          *
          * Docs: http://thinkupapp.com/docs/userguide/api/posts/user_posts.html
          */
         case 'user_posts':
             $data = $this->post_dao->getAllPosts($this->user->user_id, $this->network, $this->count, $this->page, true, $this->order_by, $this->direction, $this->is_public);
             break;
             /*
              * Gets posts a user has made.
              *
              * Required arguments: user_id or username, from and until
              *
              * Optional arguments: network, order_by, direction, include_entities, include_replies,
              * trim_user
              *
              * Docs: http://thinkupapp.com/docs/userguide/api/posts/user_posts_in_range.html
              */
         /*
          * Gets posts a user has made.
          *
          * Required arguments: user_id or username, from and until
          *
          * Optional arguments: network, order_by, direction, include_entities, include_replies,
          * trim_user
          *
          * Docs: http://thinkupapp.com/docs/userguide/api/posts/user_posts_in_range.html
          */
         case 'user_posts_in_range':
             if (is_null($this->from) || is_null($this->until)) {
                 $m = 'A request of type ' . $this->type . ' requires valid from and until parameters to be ';
                 $m .= 'specified.';
                 throw new RequiredArgumentMissingException($m);
             } else {
                 $data = $this->post_dao->getPostsByUserInRange($this->user->user_id, $this->network, $this->from, $this->until, $this->order_by, $this->direction, $iterator = false, $this->is_public);
             }
             break;
             /*
              * Gets posts a user is mentioned in.
              *
              * Required arguments: user_id or username
              *
              * Optional arguments: network, count, page, include_rts, include_entities, include_replies, trim_user
              *
              * Docs: http://thinkupapp.com/docs/userguide/api/posts/user_mentions.html
              */
         /*
          * Gets posts a user is mentioned in.
          *
          * Required arguments: user_id or username
          *
          * Optional arguments: network, count, page, include_rts, include_entities, include_replies, trim_user
          *
          * Docs: http://thinkupapp.com/docs/userguide/api/posts/user_mentions.html
          */
         case 'user_mentions':
             $data = $this->post_dao->getAllMentions($this->user->username, $this->count, $this->network, $this->page, $this->is_public, $this->include_rts, $this->order_by, $this->direction);
             break;
             /*
              * Gets posts a user is mentioned in.within a date range
              *
              * Required arguments: user_id or username, from and until
              *
              * Optional arguments: network, count, page, include_rts, include_entities, include_replies, trim_user
              */
         /*
          * Gets posts a user is mentioned in.within a date range
          *
          * Required arguments: user_id or username, from and until
          *
          * Optional arguments: network, count, page, include_rts, include_entities, include_replies, trim_user
          */
         case 'user_mentions_in_range':
             if (is_null($this->from) || is_null($this->until)) {
                 $m = 'A request of type ' . $this->type . ' requires valid from and until parameters to be ';
                 $m .= 'specified.';
                 throw new RequiredArgumentMissingException($m);
             } else {
                 $data = $this->post_dao->getAllMentionsInRange($this->user->username, $this->count, $this->network, $this->from, $this->until, $this->page, $this->is_public, $this->include_rts, $this->order_by, $this->direction);
             }
             break;
             /*
              * Gets question posts a user has made.
              *
              * Required arguments: user_id or username
              *
              * Optional arguments: network, count, page, order_by, direction, include_entities, include_replies,
              * trim_user
              *
              * Docs: http://thinkupapp.com/docs/userguide/api/posts/user_questions.html
              */
         /*
          * Gets question posts a user has made.
          *
          * Required arguments: user_id or username
          *
          * Optional arguments: network, count, page, order_by, direction, include_entities, include_replies,
          * trim_user
          *
          * Docs: http://thinkupapp.com/docs/userguide/api/posts/user_questions.html
          */
         case 'user_questions':
             $data = $this->post_dao->getAllQuestionPosts($this->user->user_id, $this->network, $this->count, $this->page, $this->order_by, $this->direction, $this->is_public);
             break;
             /*
              * Gets question posts a user has made within a date range
              *
              * Required arguments: user_id or username, from and until
              *
              * Optional arguments: network, count, page, order_by, direction, include_entities, include_replies,
              * trim_user
              *
              * Docs: http://thinkupapp.com/docs/userguide/api/posts/user_questions.html
              */
         /*
          * Gets question posts a user has made within a date range
          *
          * Required arguments: user_id or username, from and until
          *
          * Optional arguments: network, count, page, order_by, direction, include_entities, include_replies,
          * trim_user
          *
          * Docs: http://thinkupapp.com/docs/userguide/api/posts/user_questions.html
          */
         case 'user_questions_in_range':
             $data = $this->post_dao->getAllQuestionPostsInRange($this->user->user_id, $this->network, $this->count, $this->from, $this->until, $this->page, $this->order_by, $this->direction, $this->is_public);
             break;
             /*
              * Gets replies to a user.
              *
              * Required arguments: user_id or username
              *
              * Optional arguments: network, count, page, order_by, direction, include_entities, include_replies,
              * trim_user
              *
              * http://thinkupapp.com/docs/userguide/api/posts/user_replies.html
              */
         /*
          * Gets replies to a user.
          *
          * Required arguments: user_id or username
          *
          * Optional arguments: network, count, page, order_by, direction, include_entities, include_replies,
          * trim_user
          *
          * http://thinkupapp.com/docs/userguide/api/posts/user_replies.html
          */
         case 'user_replies':
             $data = $this->post_dao->getAllReplies($this->user->user_id, $this->network, $this->count, $this->page, $this->order_by, $this->direction, $this->is_public);
             break;
             /*
              * Gets replies to a user within a date range.
              *
              * Required arguments: user_id or username, from and until
              *
              * Optional arguments: network, count, page, order_by, direction, include_entities, include_replies,
              * trim_user
              *
              * http://thinkupapp.com/docs/userguide/api/posts/user_replies.html
              */
         /*
          * Gets replies to a user within a date range.
          *
          * Required arguments: user_id or username, from and until
          *
          * Optional arguments: network, count, page, order_by, direction, include_entities, include_replies,
          * trim_user
          *
          * http://thinkupapp.com/docs/userguide/api/posts/user_replies.html
          */
         case 'user_replies_in_range':
             $data = $this->post_dao->getAllRepliesInRange($this->user->user_id, $this->network, $this->count, $this->from, $this->until, $this->page, $this->order_by, $this->direction, $this->is_public);
             break;
             /*
              * Generate an error because the API call type was not recognized.
              *
              * Docs: http://thinkupapp.com/docs/userguide/api/errors/apicalltypenotrecognised.html
              */
         /*
          * Generate an error because the API call type was not recognized.
          *
          * Docs: http://thinkupapp.com/docs/userguide/api/errors/apicalltypenotrecognised.html
          */
         default:
             throw new APICallTypeNotRecognizedException($this->type);
             break;
     }
     if (is_null($data)) {
         throw new PostNotFoundException();
     }
     switch ($this->network) {
         case 'twitter':
             if (is_array($data)) {
                 foreach ($data as $key => $post) {
                     $data[$key] = $this->convertPostToTweet($post);
                 }
             } else {
                 $data = $this->convertPostToTweet($data);
             }
             break;
         case 'facebook':
             // TODO: write a function here to convert to Facebook API style
             break;
         default:
             break;
     }
     // if no posts were found, $data is null. Set it to an empty array.
     if (is_null($data)) {
         $data = array();
     }
     $this->setJsonData($data);
     return $this->generateView();
 }
Пример #4
0
require_once 'config.webapp.inc.php';
ini_set("include_path", ini_get("include_path") . PATH_SEPARATOR . $INCLUDE_PATH);
require_once "init.php";
$ud = new UserDAO($db);
$fd = new FollowDAO($db);
$id = new InstanceDAO($db);
$pd = new PostDAO($db);
$s = new SmartyThinkTank();
if (isset($_REQUEST['u']) && $ud->isUserInDBByName($_REQUEST['u']) && isset($_REQUEST['i'])) {
    $user = $ud->getUserByName($_REQUEST['u']);
    $i = $id->getByUsername($_REQUEST['i']);
    if (isset($i)) {
        $cfg = new Config($i->network_username, $i->network_user_id);
        if (!$s->is_cached('user.index.tpl', $i->network_username . "-" . $user->user_name)) {
            $s->assign('profile', $user);
            $s->assign('user_statuses', $pd->getAllPosts($user->user_id, 20));
            $s->assign('sources', $pd->getStatusSources($user->user_id));
            $s->assign('cfg', $cfg);
            $s->assign('instance', $i);
            $s->assign('i', $i);
            // HATE TO DO THIS BUT SOME TEMPLATES LOOKING FOR $i AND NOT $instance
            $exchanges = $pd->getExchangesBetweenUsers($cfg->twitter_user_id, $user->user_id);
            $s->assign('exchanges', $exchanges);
            $s->assign('total_exchanges', count($exchanges));
            $mutual_friends = $fd->getMutualFriends($user->user_id, $i->network_user_id);
            $s->assign('mutual_friends', $mutual_friends);
            $s->assign('total_mutual_friends', count($mutual_friends));
        }
        $db->closeConnection($conn);
        $s->display('user.index.tpl', $i->network_username . "-" . $user->user_name);
    }
Пример #5
0
if (!$s->is_cached('inline.view.tpl', $i->network_username . "-" . $_SESSION['user'] . "-" . $_REQUEST['d'])) {
    $cfg = new Config($i->network_username, $i->network_user_id);
    $s->assign('cfg', $cfg);
    $s->assign('i', $i);
    $u = new Utils();
    // instantiate data access objects
    $ud = new UserDAO($db);
    $pd = new PostDAO($db);
    $fd = new FollowDAO($db);
    $ld = new LinkDAO($db);
    $s->assign('display', $_REQUEST['d']);
    // pass data to smarty
    switch ($_REQUEST['d']) {
        case "tweets-all":
            $s->assign('header', 'All Posts');
            $s->assign('all_tweets', $pd->getAllPosts($i->network_user_id, 15));
            break;
        case "tweets-mostreplies":
            $s->assign('header', 'Most Replied-To Posts');
            $s->assign('most_replied_to_tweets', $pd->getMostRepliedToPosts($i->network_user_id, 15));
            break;
        case "tweets-mostretweeted":
            $s->assign('header', 'Most Forwarded');
            $s->assign('most_retweeted', $pd->getMostRetweetedPosts($i->network_user_id, 15));
            break;
        case "tweets-convo":
            $s->assign('header', 'Conversations');
            $s->assign('author_replies', $pd->getPostsAuthorHasRepliedTo($i->network_user_id, 15));
            break;
        case "mentions-all":
            $s->assign('header', 'All Mentions');
 function fetchInstanceUserMentions($lurl, $fa)
 {
     $status_message = "";
     // Get owner's mentions
     if ($this->api->available_api_calls_for_crawler > 0) {
         $got_newest_mentions = false;
         $continue_fetching = true;
         while ($this->api->available && $this->api->available_api_calls_for_crawler > 0 && $continue_fetching) {
             # Get the most recent mentions
             $mentions = str_replace("[id]", $this->owner_object->username, $this->api->cURL_source['mentions']);
             $args = array();
             $args['count'] = 200;
             if ($got_newest_mentions) {
                 $this->last_page_fetched_mentions++;
                 $args['page'] = $this->last_page_fetched_mentions;
             }
             list($cURL_status, $twitter_data) = $this->api->apiRequest($mentions, $this->logger, $args);
             if ($cURL_status > 200) {
                 $continue_fetching = false;
             } else {
                 try {
                     $count = 0;
                     $tweets = $this->api->parseXML($twitter_data);
                     if (count($tweets) == 0 && $got_newest_mentions) {
                         # you're paged back and no new tweets
                         $this->last_page_fetched_mentions = 1;
                         $continue_fetching = false;
                         $this->instance->is_archive_loaded_mentions = true;
                         $status_message = 'Paged back but not finding new mentions; moving on.';
                         $this->logger->logStatus($status_message, get_class($this));
                         $status_message = "";
                     }
                     $pd = new PostDAO($this->db, $this->logger);
                     if (!isset($recentTweets)) {
                         $recentTweets = $pd->getAllPosts($this->owner_object->user_id, 15);
                     }
                     $count = 0;
                     foreach ($tweets as $tweet) {
                         // Figure out if the mention is a retweet
                         if (RetweetDetector::isRetweet($tweet['post_text'], $this->owner_object->username)) {
                             $this->logger->logStatus("Retweet found, " . substr($tweet['post_text'], 0, 50) . "... ", get_class($this));
                             $originalTweetId = RetweetDetector::detectOriginalTweet($tweet['post_text'], $recentTweets);
                             if ($originalTweetId != false) {
                                 $tweet['in_retweet_of_post_id'] = $originalTweetId;
                                 $this->logger->logStatus("Retweet original status ID found: " . $originalTweetId, get_class($this));
                             }
                         }
                         if ($pd->addPost($tweet, $this->owner_object, $this->logger) > 0) {
                             $count++;
                             //expand and insert links contained in tweet
                             $this->processTweetURLs($tweet, $lurl, $fa);
                             if ($tweet['user_id'] != $this->owner_object->user_id) {
                                 //don't update owner info from reply
                                 $u = new User($tweet, 'mentions');
                                 $this->ud->updateUser($u);
                             }
                         }
                     }
                     $status_message .= count($tweets) . " mentions found and {$count} saved";
                     $this->logger->logStatus($status_message, get_class($this));
                     $status_message = "";
                     $got_newest_mentions = true;
                     $this->logger->logStatus($status_message, get_class($this));
                     $status_message = "";
                     if ($got_newest_mentions && $this->instance->is_archive_loaded_replies) {
                         $continue_fetching = false;
                         $status_message .= 'Retrieved newest mentions; Reply archive loaded; Stopping reply fetch.';
                         $this->logger->logStatus($status_message, get_class($this));
                         $status_message = "";
                     }
                 } catch (Exception $e) {
                     $status_message = 'Could not parse mentions XML for $this->owner_object->username';
                     $this->logger->logStatus($status_message, get_class($this));
                     $status_message = "";
                 }
             }
         }
     } else {
         $status_message = 'Crawler API call limit exceeded.';
     }
     $this->logger->logStatus($status_message, get_class($this));
     $status_message = "";
 }