/** * getTombstoneOrBlank: Same as above, but return blank text instead of "a work." The number of functions * related to tombstones is a bit silly; it would be better to build this functionality into getTombstone() via * another parameter and then just refactor. So...FIXME. * * @wid The work id * @return Tombstone, or blank text */ function getTombstoneOrBlank($wid) { global $dbh; return workHasTombstone($wid) ? getTombstone($wid, true) : ""; }
But this functionality isn't active for the trial game. </div> <div id="challenges"> <h3>Challenges Pending Your Approval</h3> <h4>Tombstones</h4> <!-- Hey, let's have some tables --> <table style="border:1px solid black;width:90%;"> <tr><td class="header">Collector</td><td class="header">Work</td><td class="header">Tombstone</td><td class="header">Approve?</td></tr> <?php $stmt = $dbh->prepare("SELECT * FROM tombstones WHERE approved = 2"); $stmt->execute(); while ($row = $stmt->fetch()) { echo "<form id=\"" . $row['id'] . "-ts\"><input type=\"hidden\" name=\"mode\" value=\"ts\"/><input type=\"hidden\" name=\"tombstoneId\" value=\"" . $row['id'] . "\"/><input type=\"hidden\" name=\"player\" value=\"" . $row['uid_creator'] . "\"/><input type=\"hidden\" name=\"work\" value=\"" . $row['wid'] . "\"/><tr>\n"; echo "<td style=\"vertical-align:top;\">" . getUsername($row['uid_creator']) . "</td><td style=\"vertical-align:top;\"><a href=\"javascript:alert('" . $row['wid'] . "');\"><img src=\"../img.php?img=" . $row['wid'] . "\\&mode=thumb\" style=\"width:75px;\"/></a></td>"; echo "<td style=\"vertical-align:top;\">" . getTombstone($row['wid'], false) . "</td><td>"; echo "<button format=\"" . $row['id'] . "-ts\" class=\"challengeApprover\" formact=\"approve\">Yes</button>"; echo "<button format=\"" . $row['id'] . "-ts\" class=\"challengeApprover\" formact=\"reject\"> No </button></td></tr></form>\n"; } ?> </table> <h4>Descriptions</h4> <table style="border:1px solid black;width:90%;"> <tr><td class="header">Collector</td><td class="header">Work</td><td class="header">Description</td><td style="min-width:130px;" class="header">Approve?</td></tr> <?php $stmt = $dbh->prepare("SELECT * FROM work_descriptions WHERE approved = 2"); $stmt->execute(); while ($row = $stmt->fetch()) { echo "<form id=\"" . $row['id'] . "-d\"><input type=\"hidden\" name=\"mode\" value=\"d\"/><input type=\"hidden\" name=\"tombstoneId\" value=\"" . $row['id'] . "\"/><input type=\"hidden\" name=\"player\" value=\"" . $row['uid'] . "\"/><input type=\"hidden\" name=\"work\" value=\"" . $row['work'] . "\"/>\n"; echo "<tr><td style=\"vertical-align:top;\">" . getUsername($row['uid']) . "</td><td><img src=\"../img.php?img=" . $row['work'] . "\" style=\"width:75px;\"/></td>";
</script> </head> <body style="background-color:#fff"> <form id="descForm" action="descriptionProcessor.php" method="post"> <h2>Edit Description</h2> Here, you can add some information about this work. <p/> <!-- Display the work image. If it already has a tombstone (artist name/birth-death dates), show that as well. --> <img src="img.php?img=<?php echo $workId; ?> " style="width:300;margin-left:auto;margin-right:auto;display:block;"/> <center> <?php if (workHasTombstone($workId)) { echo getTombstone($workId); } ?> </center> <!-- Work ID is passed as a hidden field. For the "mode" field, we must be updating the description if the work already has one, so set the value accordingly. --> <input type="hidden" name="work" value="<?php echo $workId; ?> "/> <input type="hidden" name="mode" value="<?php echo workHasDescription($workId) ? "update" : "new"; ?> "/> <p/> <!-- textarea for the description. Contains the existing description if there is one. -->
$stmt = $dbh->prepare("UPDATE tombstones SET approved = ? WHERE id = ?"); $stmt->bindParam(1, $approvalAction); $stmt->bindParam(2, $challengeId); $stmt->execute(); if ($action === "approve") { adjustPoints($player, 10); createNotification($player, $E_ACHIEVEMENT, "Your tombstone for " . getTombstone($work, true) . " was approved by the game administrator! You receive " . $CURRENCY_SYMBOL . "10."); } else { createNotification($player, $E_ACHIEVEMENT, "Your tombstone for " . getTombstone($work, true) . " was rejected by the game administrator! You can create a new tombstone to try again."); $stmt = $dbh->prepare("DELETE FROM tombstones WHERE id = ?"); $stmt->bindParam(1, $challengeId); $stmt->execute(); } } else { if ($mode === "d") { $approvalAction = $action === "approve" ? 1 : 0; $stmt = $dbh->prepare("UPDATE work_descriptions SET approved = ? WHERE id = ?"); $stmt->bindParam(1, $approvalAction); $stmt->bindParam(2, $challengeId); $stmt->execute(); if ($action === "approve") { adjustPoints($player, 10); createNotification($player, $E_ACHIEVEMENT, "Your description for " . (workHasTombstone($work) ? getTombstone($work, true) : "a work") . " was approved! You receive " . $CURRENCY_SYMBOL . "10."); } else { createNotification($player, $E_ACHIEVEMENT, "Your description for " . (workHasTombstone($work) ? getTombstone($work, true) : "a work") . " was rejected! You can modify the description and try again."); } } } ?>
$collectionQuery = $dbh->prepare("SELECT work,w1.id AS url FROM " . $userTable . " LEFT OUTER JOIN works AS w1 ON w1.id = " . $userTable . ".work"); $collectionQuery->execute(); $userName = $row['cn']; while ($item = $collectionQuery->fetch()) { if ($ind % 3 == 0) { // 3 x n grid echo "</div><div style=\"display:table-row;\">"; } // Link the work image to workview.php (shadowbox). echo "<div class=\"collCell\"><a href=\"workview.php?wid=" . $item['url'] . "\" rel=\"shadowbox\">"; // Include the sentiment div, which contains the heart icon players can click to "love" a work. // (Handled in sentiment.js) echo "<div class=\"imgMouseOver\" name=\"" . $item['url'] . "\" style=\"background:url('img.php?img=" . $item['url'] . "');background-size:contain;background-repeat:no-repeat;\"/><div class=\"sentiment\" name=\"" . $item['url'] . "\" style=\"background-color: rgba(0,0,0,0.5);position:relative;float:left;width:20px;height:20px;padding:5px;overflow: none;z-index:-200;\"></div></div></a>"; echo "<div class=\"collCellCaption\">"; // Show tombstone, if there is one. if (workHasTombstone($item['url'])) { echo getTombstone($item['url'], false); } echo "</div></div>\n"; $ind++; } } echo "</div>\n"; ?> </div> </body> <?php include 'jewel.php'; ?> </html>
$approver = $_GET['uuid']; $action = $_GET['action']; $player = $_GET['player']; $work = $_GET['work']; // APPROVED column in these tables: 0 = rejected; 1 = accepted; 2 = pending. // These values really need to be global variables. Magic numbers abound. FIXME $approvalAction = $action === "approve" ? 1 : 0; $stmt = $dbh->prepare("UPDATE tombstones SET approved = ? WHERE id = ?"); $stmt->bindParam(1, $approvalAction); $stmt->bindParam(2, $challengeId); $stmt->execute(); if ($action === "approve") { // Award the player who submitted the tombstone 10 FCGs and notify them. adjustPoints($player, 10); createNotification($player, $E_ACHIEVEMENT, "Your tombstone for " . getTombstone($work, true) . " was approved by " . getUserName($approver) . "! You receive " . $CURRENCY_SYMBOL . "10."); } else { // ...or tell them they got it wrong. createNotification($player, $E_ACHIEVEMENT, "Your tombstone for " . getTombstone($work, true) . " was rejected by " . getUserName($approver) . "! You can create a new tombstone to try again."); // Delete the tombstone attempt. There's a mismatch here between the way we use // approval flags (0/1) and the fact that we just drop rejected attempts from the // table altogether, but fixing the problem will require rewriting some utility // functions in functions.php. $stmt = $dbh->prepare("DELETE FROM tombstones WHERE id = ?"); $stmt->bindParam(1, $challengeId); $stmt->execute(); } // Finally, award the approver 10 points. adjustPoints($approver, 10); ?>
echo "<li>" . $row['description'] . "</li>\n"; } echo "</ol>\n"; // ...and get rid of it. $drop = $dbh->prepare("DROP TABLE " . $provTable); $drop->execute(); ?> </div> </div> <div id="image"> <h3> <?php // Image div. Print out the tombstone if the user has supplied one. if (workHasTombstone($workid)) { echo getTombstone($workid); } ?> </h3> <div> <center> <?php // And include the full-size image. echo "<img src=\"img.php?img=" . $workid . "\" alt=\"[image]\" />\n"; ?> </center> </div> </div> <div id="description"> <h3>Description</h3>