}
     break;
 case 'fetchDynamicDialog':
     require_once PATH_CORE . "/classes/template.class.php";
     $tObj = new template();
     $tObj->registerTemplates(MODULE_ACTIVE, $_GET['t']);
     $code = $tObj->templates[$_GET['d']];
     break;
 case 'fetchChallenges':
     if (isset($_GET['sort'])) {
         $sort = $_GET['sort'];
     } else {
         $sort = 'default';
     }
     require_once PATH_CORE . "/classes/challenges.class.php";
     $chObj = new challenges();
     $code = $chObj->fetchChallenges($sort, $currentPage, true);
     break;
 case 'fetchLeaders':
     if (isset($_GET['view'])) {
         $view = $_GET['view'];
     } else {
         $view = 'alltime';
     }
     if (isset($_GET['filter'])) {
         $filter = $_GET['filter'];
     } else {
         $filter = 'inside';
     }
     require_once PATH_FACEBOOK . '/classes/pages.class.php';
     $pagesObj = new pages($app, 0, false);
    function fetchChallengeList($currentPage = 1)
    {
        require_once PATH_CORE . '/classes/challenges.class.php';
        $challenges = new challenges($this->db);
        $code .= '<div id="ajaxFeed" class="panel_1">
					<h2>' . $this->templateObj->templates['ChallengesTitle'] . '</h2>';
        // do I need to keep this id?
        $code .= $challenges->fetchChallenges('pointValue', $currentPage, false);
        $code .= '</div><!--end "ajaxFeed" "panel_1"-->';
        return $code;
    }
 function fetchChallenges()
 {
     require_once PATH_CORE . '/classes/challenges.class.php';
     $challengesObj = new challenges($this->db);
     $code .= '<h2>Challenges</h2>' . $challengesObj->fetchChallengesForPublisher('pointValue', 1, false);
     $code .= '<input type="hidden" name="pubType" value="challenge">';
     return $code;
 }
    function fetchChallenges($mode = 'random', $limit = 3)
    {
        if (!ENABLE_ACTION_CHALLENGES) {
            return '';
        }
        $modes = array('featured', 'popular', 'automatic', 'latest');
        $titles = array('Featured Challenges', 'Popular Challenges', 'Site Challenges', 'Latest Challenges');
        if ($mode == 'random') {
            $x = rand(0, 3);
            $mode = $modes[$x];
            $title = $titles[$x];
        }
        require_once PATH_CORE . '/classes/challenges.class.php';
        $challenges = new challenges($this->db);
        switch ($mode) {
            case 'featured':
                $code .= $challenges->fetchChallengePanelList('pointValue', $limit, "WHERE status='enabled' AND isFeatured=1", true);
                break;
            case 'popular':
                $code .= $challenges->fetchChallengePanelList('completions', $limit, "WHERE status='enabled' AND type='submission'", true);
                break;
            case 'automatic':
                $code .= $challenges->fetchChallengePanelList('pointValue', $limit, "WHERE status='enabled' AND type='automatic'", true);
                break;
            case 'latest':
                $code .= $challenges->fetchChallengePanelList('dateStart', $limit, "WHERE status='enabled' ", true);
                break;
        }
        $inTeam = false;
        $code = '<div class="list_challenges">' . $code . '</div>';
        $code = '<div class="panelBar clearfix">
	            <h2>' . $title . '</h2>
	            <div class="bar_link">' . $this->buildLink('challenges', 'See all', true, $inTeam) . '</div>
	        </div>' . $code;
        $code = '<div class="panel_2 clearfix">' . $code . '</div>';
        return $code;
    }