From e0b1e84d7fe3f48504f4fda0e6c65e07406da0f6 Mon Sep 17 00:00:00 2001
From: Graham Cole <chckens@sucs.org>
Date: Sat, 19 Jan 2008 22:19:13 +0000
Subject: [PATCH] basically kill off the bananas component, apart from for
 non-members

---
 components/bananas.php | 38 ++++++++++++++++++++++++--------------
 templates/bananas.tpl  | 11 -----------
 2 files changed, 24 insertions(+), 25 deletions(-)

diff --git a/components/bananas.php b/components/bananas.php
index a2ce042..5eb09fe 100644
--- a/components/bananas.php
+++ b/components/bananas.php
@@ -1,32 +1,42 @@
 <?php
 
-/* as far as bananas are concerned, year ends after the beach party */
-$yearstart = date("Y")."-06-30";
+include_once("../lib/members.php");
 
-/* Banana viewing component. Looking a little obsolete since most of this is now in the members component */
+$members = new Members;
+
+/* Banana viewing component. Mostly 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";
+	// User wasn't looking for anything in particular, so bump them to the Members page
+	header("HTTP/1.1 301 Moved Permanently");
+	header("Location: https://$preferred_hostname$baseurl/Community/Members/");
 }
 
-if (isset($who))
-	$smarty->assign('who', "$who");
-
-// banana admin bits
-
+/* redirect requests for members' bananas to Members component. Only serve banana info for non-members (e.g. LIS ;-)) */
 
-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");
+if (count($members->memberView($who)) > 0) {
+	// this is actually a real member, so serve a redirect and let Members handle it
+	header("HTTP/1.1 301 Moved Permanently");
+	header("Location: https://$preferred_hostname$baseurl/Community/Members/$who");
+} else {
+	// banana admin bits 
+	if ($mode == "detail") {
+		if ($session->loggedin) {
+			include("../lib/banana-admin.php");
+		}
 	}
+	// attempt to find some bananas for this name in the database
+	$smarty->assign("awards",$DB->GetAll("SELECT *, date_trunc('second', whn) FROM awards WHERE username=? ORDER BY whn DESC", array($who)));
 }
 
-$users = $DB->GetAll("SELECT username, sum(score) AS sum FROM awards WHERE whn > ? GROUP BY username ORDER BY sum(score) DESC, username", array($yearstart));
+
+if (isset($who))
+	$smarty->assign('who', "$who");
+
 
 $smarty->assign('mode', "$mode");
 $smarty->assign('users', $users);
diff --git a/templates/bananas.tpl b/templates/bananas.tpl
index e86cdd1..fc2ed1e 100644
--- a/templates/bananas.tpl
+++ b/templates/bananas.tpl
@@ -31,14 +31,3 @@
 	</div>
 {/if}
 
-<h3>Banana Summary</h3>
-<table border="0" cellpadding="5">
-
-{foreach name=users from=$users key=key2 item=user}
-<tr>
-	<td><a href="/Community/Bananas/{$user.username}">{$user.username}</a></td>
-	<td>{$user.sum}</td>
-	<td>{bananaprint score=$user.sum}</td>
-</tr>
-{/foreach}
-</table>
-- 
GitLab