forceAuth(); // Connect to the database $conn = new PDO('mysql:host=localhost;dbname=slatecrate', $config['DB_USERNAME'], $config['DB_PASSWORD']); // Determine if the user has admin status $isAdmin = determineAdminStatus($conn, phpCAS::getUser()); /** * Submitted actions: these are called when classes.php is loaded as an action of HTML forms from classes.php, * addclasses.php, and editclasses.php. */ if (isset($_POST["edit"])) { // Update an edited class with new details $alertArray = executeEdit($conn, $_POST["className"], $_POST["inputCategory"], $_POST["edit"]); } else { if (isset($_POST["user"])) { // Create a newly added class with the new details $alertArray = executeAdd($conn, $_POST["className"], $_POST["inputCategory"], $_POST["user"]); } else { if (isset($_POST["delete"])) { // Complete the deletion of a class $alertArray = executeDelete($conn, $_POST["delete"]); } } } /** * Uses the responses of executeEdit, executeAdd, and executeDelete to generate appropriate alerts as necessary. */ if (isset($alertArray)) { $alertType = $alertArray[0]; $alertMessage = $alertArray[1]; } else { $alertMessage = "";
forceAuth(); // Establish a connection to the database for this page. $conn = new PDO('mysql:host=localhost;dbname=slatecrate', $config['DB_USERNAME'], $config['DB_PASSWORD']); $isAdmin = determineAdminStatus($conn, phpCAS::getUser()); $categoryTitle = determineClassFilter($conn, isset($_GET["class"]) ? $_GET["class"] : ""); $pageHeader = "Links for " . (isset($_GET["class"]) ? $categoryTitle : "all classes"); //up or downvote if (isset($_POST["upvote"])) { executeVote($conn, $_POST["upvote"], 1); } else { if (isset($_POST["downvote"])) { executeVote($conn, $_POST["downvote"], -1); } else { if (isset($_POST["user"])) { // add class if we need to $alertArray = executeAdd($conn, $_POST["URL"], $_POST["classForAdd"], $_POST["linkName"]); } else { if (isset($_POST["delete"])) { $alertArray = executeDelete($conn, $_POST["delete"]); } else { if (isset($_POST["edit"])) { $alertArray = executeEdit($conn, $_POST["URL"], $_POST["classForAdd"], $_POST["linkName"], $_POST["edit"]); } } } } } if (isset($alertArray)) { $alertType = $alertArray[0]; $alertMessage = $alertArray[1]; } else {