require("$_SERVER[DOCUMENT_ROOT]/lib/header.inc.php"); $currHeader->setPageTitle("Goon Wishlist - What we're looking for."); $currBanner->addContent("Goon Wishlist - Its what we're looking for."); $currNavbar->setCustomLinksTitle("Goon Wishlist"); $currNavbar->addCustomLink("/wishlist.php?action=add", "Add an item!"); $currNavbar->addCustomLink("/wishlist.php?action=viewList&user=$_SESSION[userid]", "View/Edit My Wishlist"); // if the person wants to be added, lets give them a form. if ($_REQUEST["action"] == "add") { $currHeader->setPageTitle("Add a Wishlist Entry - Goon Wishlist"); $currBanner->addContent("Add a Wishlist Entry"); ?>
You can add a wishlist entry from here.
} // to actually do an add command elseif ($_REQUEST["action"] == "doAdd") { $currHeader->setPageTitle("Add a Wishlist Entry - Goon Wishlist"); $currBanner->addContent("Add a Wishlist Entry"); if (auth(1, false)){ // escape out any html in the description $description = htmlspecialchars($_POST["description"]); $query = "INSERT INTO wishlist(owner, dateAdded, dateEdited, priority, status, name, description) VALUES($_SESSION[userid], NOW(), NOW(), $_POST[priority], 1, '$_POST[name]', '$description')"; $result = mysql_query($query); if ($result) print("Entry added successfully!
"); if (!$result) print("We could not add that entry. Here is the exact error: " . mysql_error() . "
"); } else { print("Sorry, you do not have permission to do that. Perhaps you need to be logged in.
"); } } // edit elseif ($_REQUEST["action"] == "edit") { $currHeader->setPageTitle("Edit a Wishlist Entry - Goon Wishlist"); $currBanner->addContent("Edit a Wishlist Entry"); // get the post we want to edit $query = "SELECT name, description, priority FROM wishlist WHERE id = $_REQUEST[id]"; $oldRow = mysql_fetch_array(mysql_query($query)); ?> } // do edit elseif ($_REQUEST["action"] == "doEdit") { $currHeader->setPageTitle("Edit a Wishlist Entry - Goon Wishlist"); $currBanner->addContent("Edit a Wishlist Entry"); // find out if the person in question is allowed to do this // get the users name $query = "SELECT level, owner FROM users, wishlist WHERE users.id = wishlist.owner AND wishlist.id = $_REQUEST[id]"; $row = mysql_fetch_array(mysql_query($query)); // if this is true, they are allowed to edit if ($_SESSION["userid"] == $row["owner"] || $_SESSION["level"] >= 4) { // escape out any html in the description $description = htmlspecialchars($_POST["description"]); $query = "UPDATE wishlist SET dateEdited = NOW(), priority = $_POST[priority], name = '$_POST[name]', description = '$description' WHERE id = $_POST[id]"; $result = mysql_query($query); if ($result) print("Entry updated successfully!
"); if (!$result) print("We could not update that entry. Here is the exact error: " . mysql_error() . "
"); } else { print("Sorry, you do not have permission to do that. Perhaps you need to be logged in.
"); } } // quick status change elseif ($_REQUEST["action"] == "changeStatus") { $currHeader->setPageTitle("Change Status - Goon Wishlist"); $currBanner->addContent("Change Status "); // find out if the person in question is allowed to do this // get the users name $query = "SELECT level, owner FROM users, wishlist WHERE users.id = wishlist.owner AND wishlist.id = $_REQUEST[id]"; $row = mysql_fetch_array(mysql_query($query)); // if this is true, they are allowed to edit if ($_SESSION["userid"] == $row["owner"] || $_SESSION["level"] >= 4) { $query = "UPDATE wishlist SET status = $_REQUEST[status], dateEdited = NOW() WHERE id = $_REQUEST[id]"; $result = mysql_query($query); if ($result) print("Status change successful!
"); else print("Status change failed. " . mysql_error() . "
"); } else { print("Sorry, you do not have permission to do that. Perhaps you need to be logged in.
"); } } // if we're viewing an entry for a specific user elseif ($_REQUEST["action"] == "viewList") { // get the users name $query = "SELECT name, level FROM users WHERE id = $_REQUEST[user]"; $row = mysql_fetch_array(mysql_query($query)); $currHeader->setPageTitle("Wishlist for $row[name]"); $currBanner->addContent("$row[name]'s Wishlist"); $userLevel = $row["level"]; if ($_REQUEST["status"] > 0) $status = $_REQUEST["status"]; else $status = 1; // status = 1 if we don't have it, 2 if we got it, 3 if we stopped wanting it. // orders are in order from lowest up. So 1 is what you want the most (for priority) $query = "SELECT wishlist.id, wishlist.name, wishlist.dateEdited, wishlist.description, wishlist.owner, wishlist.priority, wishlist_priority.name AS priorityname FROM wishlist, wishlist_priority WHERE wishlist.priority = wishlist_priority.id AND wishlist.owner = $_REQUEST[user] AND wishlist.status = $status ORDER BY wishlist_priority.orderIndex ASC, wishlist.name ASC"; $result = mysql_query($query); $quantity = mysql_num_rows($result); if ($status == 1) $statusTitle = "Stuff I want right now"; else { $query = "SELECT count(id) FROM wishlist WHERE owner = $_REQUEST[user] AND status = 1"; $row = mysql_fetch_row(mysql_query($query)); print("Show stuff I want now ($row[0]) "); } if ($status == 2) $statusTitle = "Stuff I got"; else { $query = "SELECT count(id) FROM wishlist WHERE owner = $_REQUEST[user] AND status = 2"; $row = mysql_fetch_row(mysql_query($query)); print("Show stuff I already got ($row[0]) "); } if ($status == 3) $statusTitle = "Stuff I stopped wanting"; else { $query = "SELECT count(id) FROM wishlist WHERE owner = $_REQUEST[user] AND status = 3"; $row = mysql_fetch_row(mysql_query($query)); print("Show stuff I stopped wanting ($row[0]) "); } print("$description
"); print("| Item Name | Date Last Modified | Priority | Description | |
|---|---|---|---|---|
| $row[name] | $row[dateEdited] | $row[priority] | $row[description] | "); if (($_SESSION["userid"] == $row["owner"]) || ($_SESSION["level"] > $userLevel)) print("[Edit] | "); print("
The Wishlist is just that, a wish list. Its what the people on here are looking to get. In this case, most likely Liz and I. If you're looking to buy us a present, this is a good place to start. :)
Use the options in the menu to the right if you wish to add an entry or edit your wishlist. You need to be logged in for this to work, simply because Anonymous Cowards aren't allowed to create wishlist entries. :)
The following users have items on their wishlist: