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; }