Index: gobbler/install.php
===================================================================
--- gobbler/install.php (revision 392)
+++ gobbler/install.php (working copy)
@@ -150,6 +150,26 @@
track VARCHAR(255) REFERENCES Track(name),
PRIMARY KEY(username, tag, artist, album, track))");
+ $mdb2->query("CREATE TABLE Events(
+ eventID INT UNSIGNED,
+ event VARCHAR(255),
+ location VARCHAR(255),
+ date DATE,
+ time TIME,
+ description TEXT,
+ PRIMARY KEY(eventID, event),
+ FULLTEXT(event, location, description))");
+
+ $mdb2->query("CREATE TABLE Event_Artist(
+ eventID INT UNSIGNED REFERENCES Events(eventID),
+ artist VARCHAR(255) REFERENCES Artist(name),
+ PRIMARY KEY(eventID, artist))");
+
+ $mdb2->query("CREATE TABLE Event_Users(
+ eventID INT UNSIGNED REFERENCES Events(eventID),
+ username VARCHAR(255) REFERENCES Users(username),
+ PRIMARY KEY(eventID, username))");
+
// Test user configuration
$res = $mdb2->query("INSERT INTO Users
(username, password, created)
Index: web/themes/librefm/librefm.css
===================================================================
--- web/themes/librefm/librefm.css (revision 392)
+++ web/themes/librefm/librefm.css (working copy)
@@ -14,7 +14,7 @@
#login a{ color: yellow !important; }
-#hd li{ display: inline; font-size: 21px; text-transform: lowercase; font-weight: bold; margin-right: 20px;}
+#hd li{ display: inline; font-size: 18px; text-transform: lowercase; font-weight: bold; margin-right: 12px;}
#banner { height: 345px; position: relative;}
Index: web/themes/librefm/templates/events.tpl
===================================================================
--- web/themes/librefm/templates/events.tpl (revision 0)
+++ web/themes/librefm/templates/events.tpl (revision 0)
@@ -0,0 +1,95 @@
+{include file='header.tpl'}
+{if ($add)}
+
Add a new event
+
+{else}
+Upcoming events
+
+
+{if ($logged_in)}
+
Add Event
+{/if}
+ {section name=i loop=$events}
+
{$events[i].event}
+
{$events[i].date}
+
{$events[i].description}
+ {/section}
+
Next >>
+
+{/if}
+
+{include file='footer.tpl'}
Index: web/themes/librefm/templates/menu.tpl
===================================================================
--- web/themes/librefm/templates/menu.tpl (revision 392)
+++ web/themes/librefm/templates/menu.tpl (working copy)
@@ -13,4 +13,5 @@
{/if}
Explore:
Artists
+ Events
Index: web/themes/librefm/templates/explore-events.tpl
===================================================================
--- web/themes/librefm/templates/explore-events.tpl (revision 0)
+++ web/themes/librefm/templates/explore-events.tpl (revision 0)
@@ -0,0 +1,16 @@
+{include file='header.tpl'}
+
+Explore upcoming events
+
+
+{if ($logged_in)}
+
Add Event
+{/if}
+ {section name=i loop=$events}
+
{$events[i].event}
+
{$events[i].date}
+
{$events[i].description}
+ {/section}
+
+
+{include file='footer.tpl'}
Index: web/explore.php
===================================================================
--- web/explore.php (revision 392)
+++ web/explore.php (working copy)
@@ -24,11 +24,22 @@
require_once("templating.php");
require_once("data/Server.php");
-$aTopArtists = Server::getTopArtists(20);
-if (!PEAR::isError ($aTopArtists)) {
- $smarty->assign("topartists", $aTopArtists);
+if ($_GET['mode'] == 'events') {
+ $aComingEvents = Server::getComingEvents(5);
+ if (!PEAR::isError ($aComingEvents)) {
+ $smarty->assign("events", $aComingEvents);
+ }
+ $smarty->display("explore-events.tpl");
}
-$smarty->assign("explore", true);
-$smarty->display("explore-artists.tpl");
+else {
+ $aTopArtists = Server::getTopArtists(20);
+ if (!PEAR::isError ($aTopArtists)) {
+ $smarty->assign("topartists", $aTopArtists);
+ }
+ $smarty->display("explore-artists.tpl");
+}
+//$smarty->assign("explore", true);
+
+
?>
Index: web/event.php
===================================================================
--- web/event.php (revision 0)
+++ web/event.php (revision 0)
@@ -0,0 +1,78 @@
+.
+
+*/
+
+
+require_once("database.php");
+require_once("templating.php");
+//require_once("data/Event.php");
+require_once("data/Server.php");
+
+if (isset($_POST['event'])) {
+ $errors = "";
+ $event = $_POST['event'];
+ $location = $_POST['location'];
+ $day = $_POST['day'];
+ $month = $_POST['month'];
+ $year = $_POST['year'];
+ $artist = $_POST['artist'];
+ $description = $_POST['description'];
+
+ //Basic validation
+ if(empty($location)) {
+ $errors .= "You must enter a location.
";
+ }
+ if(empty($day) || empty($month) || empty($year)) {
+ $errors .= "You must enter a date.
";
+ }
+
+ $date = date($year . '-' . $month . '-' . $day);
+
+ if(empty($errors)) {
+ $mdb2->query("INSERT INTO Events (event, location, date, time, description) Values("
+ . $mdb2->quote($event, "text") . ", "
+ . $mdb2->quote($location, "text") . ", "
+ . $mdb2->quote($date, "date") . ", 0,"
+// . $mdb2->quote($time, . ", "
+ . $mdb2->quote($description, "text") . ")");
+
+ }
+
+}
+
+if (isset($_GET['add'])) {
+ $smarty->assign("add", true);
+}
+
+else {
+ if (isset($_GET['p'])) {
+ $p = $_GET['p'];
+ }
+ else $p = 0;
+ $aComingEvents = Server::getComingEvents(5, $p);
+ if (!PEAR::isError ($aComingEvents)) {
+ $smarty->assign("p",$p);
+ $smarty->assign("events", $aComingEvents);
+ }
+}
+
+$smarty->display("events.tpl");
+
+?>
\ No newline at end of file
Index: web/data/Server.php
===================================================================
--- web/data/Server.php (revision 392)
+++ web/data/Server.php (working copy)
@@ -122,7 +122,34 @@
return $result;
}
+
+ /**
+ * Retrieves a list of upcoming events
+ *
+ * @param int $number The number of artists to return
+ * @return An array of artists or a PEAR_Error in case of failure
+ */
+ static function getComingEvents($number=5, $p=0) {
+ global $mdb2;
+ $res = $mdb2->query("SELECT eventID, event, location, date, time, description FROM Events
+ ORDER BY date DESC LIMIT " . $mdb2->quote($p*5, "integer") . "," . $mdb2->quote($number, "integer"));
+
+ if(PEAR::isError($res)) {
+ return $res;
+ }
+
+ $data = $res->fetchAll(MDB2_FETCHMODE_ASSOC);
+ foreach($data as $i) {
+ $row = sanitize($i);
+// $res = $mdb2->query("SELECT artist FROM Event_Artist WHERE eventID=" . $mdb2->quote($row["eventID"]) . ")");
+// $row["artisturl"] = Server::getArtistURL($row["artist"]);
+ $row["eventurl"] = Server::getEventURL($row["eventID"]);
+ $result[] = $row;
+ }
+ return $result;
+ }
+
/**
* The get*URL functions are implemented here rather than in their respective
* objects so that we can produce URLs without needing to build whole objects.
@@ -165,5 +192,14 @@
return $base_url . "/track.php?artist=" . urlencode(stripslashes($artist)) . "&album=" . urlencode(stripslashes($album)) . "&track=" . urlencode(stripslashes($track));
}
}
+
+ static function getEventURL($eventID) {
+ global $friendly_urls, $base_url;
+ if($friendly_urls) {
+ return $base_url . "/event/" . stripslashes($eventID);
+ } else {
+ return $base_url . "/event.php?id=" . stripslashes($eventID);
+ }
+ }
}