Skip to content
Snippets Groups Projects
bananas.php 1.11 KiB
Newer Older
  • Learn to ignore specific revisions
  • <?php
    
    /* as far as bananas are concerned, year ends after the beach party */
    $yearstart = date("Y")."-06-30";
    
    /* Banana viewing component. Looking a little obsolete since most of this is now in the members component */
    
    $banana_index = array_search("Bananas", $pathlist);
    if ((sizeof($pathlist) > $banana_index + 1) && (trim($pathlist[$banana_index + 1]) != "")) {
    	$mode = "detail";
    	$who = $pathlist[$banana_index + 1];
    } else {
    	$mode = "summary";
    }
    
    if (isset($who))
    	$smarty->assign('who', "$who");
    
    // banana admin bits
    
    
    if ($mode == "detail") {
    	$smarty->assign("awards",$DB->GetAll("SELECT *, date_trunc('second', whn) FROM awards WHERE username=? AND whn > ? ORDER BY whn DESC", array($who, $yearstart)));
    	if ($session->loggedin) {
    		include("../lib/banana-admin.php");
    	}
    }
    
    $users = $DB->GetAll("SELECT username, sum(score) AS sum FROM awards WHERE whn > ? GROUP BY username ORDER BY sum(score) DESC, username", array($yearstart));
    
    $smarty->assign('mode', "$mode");
    $smarty->assign('users', $users);
    
    $result = $smarty->fetch('bananas.tpl');
    $smarty->assign('title', "Banana Awards");
    $smarty->assign('body', $result);
    
    
    
    ?>