function generateHTML()
 {
     $user = UserDao::getUserByUsername(SessionUtil::getUsername());
     $changePasswordRows = "";
     if (Config::login_type == LOGIN_TYPE_DB) {
         $changePasswordRows = "\n\t\t\t\n\t\t\t<tr>\n\t\t\t\t\n\t\t\t\t<td class=\"centeredcellbold\">Change Password</td>\n\t\t\t\t<td class=\"centeredcellbold\">Current Password</td>\n\t\t\t\t<td class=\"centeredcellbold\">New Password</td>\n\t\t\t\t<td class=\"centeredcellbold\">Confirm Password</td>\n\t\t\n\t\t\t</tr>\n\t\t\t\n\t\t\t<tr>\n\t\t\t\t\n\t\t\t\t\t<form action=\"./index.php?pageid=savepassword\" method=\"POST\"><td class=\"centeredcellbold\"><input type=\"submit\" value=\"Save Password\"></td>\n\t\t\t\t\t<td class=\"centeredcell\"><input type=\"password\" name=\"curpass\"></td>\n\t\t\t\t\t<td class=\"centeredcell\"><input type=\"password\" name=\"newpass\"></th>\n\t\t\t\t\t<td class=\"centeredcell\"><input type=\"password\" name=\"confpass\"></td></form>\n\t\t\t\n\t\t\t\t</tr>";
     }
     return "<center><h3>My Account</h3>" . $this->context->getErrorHTML() . "</center>\n\t\t\t\n\t\t\t<table class=\"myaccount\">\n\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\n\t\t\t\t\t<td colspan=4 class=\"header\">Edit User Information</td>\n\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t\t\n\t\t\t\t<tr>\n\t\t\n\t\t\t\t\t<td class=\"centeredcellbold\">Username</td>\n\t\t\t\t\t<td colspan=3 class=\"centeredcell\">" . $user->username . "</td>\n\t\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t\n\t\t\t\t<tr>\n\t\t\n\t\t\t\t\t<td class=\"centeredcellbold\">Name</th>\n\t\t\t\t\t<td colspan=3 class=\"centeredcell\">" . $user->name . "</td>\n\t\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t\n\t\t\t\t" . $changePasswordRows . "\n\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\t\n\t\t\t\t\t<form action=\"./index.php?pageid=saveemail\" method=\"POST\">\n\t\t\t\t\t<td colspan=1 class=\"centeredcellbold\">Email</th><td colspan=3 class=\"centeredcell\"><input type=\"text\" name=\"email\" size=30 value=\"" . $user->email . "\"><input type=\"submit\" value=\"Save Email\"></td></form>\n\t\t\t\t\t\t\n\t\t\t\t</tr>\n\t\t\n\t\t\t\t<tr>\n\t\t\t\t\n\t\t\t\t\t<td colspan=1 class=\"centeredcellbold\">Warnings</th>\n\t\t\t\t\t<td class=\"centeredcellbold\" colspan=3><a href=\"./index.php?pageid=viewMyWarnings\">" . WarningDao::getWarningCountForUserByType($user->id, RES_WARNING_ACTIVE) . "(" . WarningDao::getWarningCountForUser($user->id) . ")</a></td>\n\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t\t\t\n\t\t\t</table>";
 }
 public static function getWarningsForUserByType($userId, $type)
 {
     $userId = Database::makeStringSafe($userId);
     $type = Database::makeStringSafe($type);
     $result = Database::doQuery("SELECT * FROM " . Database::addPrefix(WarningDao::table_name) . " WHERE user_id = '" . $userId . "' and type = '" . $type . "'");
     $warnings = array();
     while ($row = mysql_fetch_assoc($result)) {
         $warnings[] = WarningDao::buildWarning($row);
     }
     return $warnings;
 }
 public function generateHTML()
 {
     $reservation = ReservationDao::getReservation($_GET['resid']);
     if ($reservation == null) {
         $this->context->addError("Reservation Doesn't Exist.");
         return $this->context->getErrorHTML();
     }
     $user = UserDao::getUserByID($reservation->userId);
     $equip = EquipmentDao::getEquipmentByID($reservation->equipId);
     return "\n\t\t\t<center><h3>Reseravation Info</h3></center>\n\t\t\t<table class=\"viewreservation\">\n\t\t\t\t<tr>\n\t\t\t\t\t\n\t\t\t\t\t<td colspan=4 class=\"header\">User Information</td>\n\t\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\n\t\t\t\t\t<td class=\"centeredcellbold\">Name</th>\n\t\t\t\t\t<td class=\"centeredcell\">" . $user . "</td>\n\t\t\t\t\t<td class=\"centeredcellbold\">Warnings</th>\n\t\t\t\t\t<td class=\"centeredcell\"><a href=\"./index.php?pageid=viewWarnings&userid=" . $user->id['user_id'] . "\">" . WarningDao::getWarningCountForUserByType($user->id, RES_WARNING_ACTIVE) . "(" . WarningDao::getWarningCountForUser($user->id) . ")</a></td>\n\t\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t\n\t\t\t\t\t<td colspan=4 class=\"header\">Equipment Information</td>\n\t\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t\n\t\t\t\t\t<td colspan=2 class=\"centeredcellbold\">Name</th>\n\t\t\t\t\t<td colspan=2 class=\"centeredcell\">" . $equip . "</td>\n\t\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t\n\t\t\t\t\t<td colspan=4 class=\"header\">Reservation Information</td>\n\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\n\t\t\t\t\t<td class=\"centeredcellbold\">Start Date</td>\n\t\t\t\t\t<td class=\"centeredcell\">" . $reservation->startDate . "</td>\n\t\t\t\t\t<td class=\"centeredcellbold\">End Date</td>\n\t\t\t\t\t<td class=\"centeredcell\">" . $reservation->endDate . "</td>\n\t\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan=4 class=\"centeredcellbold\">Current Status: " . $reservation->getColoredModStatusString() . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t\n\t\t\t\t\t<td colspan=4 class=\"centeredcellbold\">User Comment</td>\n\t\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t\n\t\t\t\t\t<td colspan=4 class=\"topaligncell\">&nbsp;" . $reservation->userComment . "</td>\n\t\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t\n\t\t\t\t\t<td colspan=4 class=\"centeredcellbold\">Admin Comment</td>\n\t\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t\n\t\t\t\t\t<td colspan=4 class=\"topaligncell\">&nbsp;" . $reservation->adminComment . "</td>\n\t\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t\t" . $this->getCheckinRow($reservation) . "\n\t\t\t\n\t\t\t</table>\n\t\t\n\t\t";
 }
 public function generateHTML()
 {
     $user = UserDao::getUserByUsername(SessionUtil::getUsername());
     $warnings = WarningDao::getAllWarningsForUser($user->id);
     $options = "";
     foreach ($warnings as $warning) {
         $options .= $warning->toOptionHTML();
     }
     $warningSelect = "You have no warnings. :)";
     if ($options != "") {
         $warningSelect = "<form action=\"./index.php\" method=\"GET\">" . "<input type=\"hidden\" name=\"pageid\" value=\"viewWarning\" />" . "<select name=\"warnid\">" . $options . "</select>" . "<input type=\"submit\" value=\"View\" />" . "</form>";
     }
     return "<center><h3>View My Warnings</h3></center>" . $warningSelect;
 }
 public function generateHTML()
 {
     $user = UserDao::getUserByUsername(SessionUtil::getUsername());
     if (WarningDao::getWarningCountForUserByType($user->id, RES_WARNING_ACTIVE) > RES_WARNING_MAX_ACTIVE) {
         $this->context->addError("You have too many Active Warnings (more than " . RES_WARNING_MAX_ACTIVE . ") on your account to place Reservations.");
         return $this->context->getErrorHTML() . $this->context->getMessagesHTML();
     }
     //TODO: do we need this?
     $allEquipment = EquipmentDao::getAllEquipment();
     $equipArray = array();
     //^^^^^^^^^^^^^^^^^^^^^^^^^^
     $page = "";
     $success = false;
     if (isset($_POST['equip_id']) && $_POST['equip_id'] != "") {
         if (count($this->context->getErrors()) == 0) {
             $page = "Successfully Created Reservation.";
             $success = true;
         } else {
             $_GET['equipid'] = $_POST['equip_id'];
         }
     }
     if (!$success && isset($_GET['equipid']) && $_GET['equipid'] != "") {
         $equip = EquipmentDao::getEquipmentByID($_GET['equipid']);
         if ($equip != null) {
             if (SessionUtil::getUserlevel() >= $equip->minUserLevel) {
                 $lengthOptions = "";
                 for ($i = 1; $i <= $equip->maxLength; $i++) {
                     if ($i > 1) {
                         $lengthOptions = $lengthOptions . "<option value=\"" . $i . "\">" . $i . " Days</option>";
                     } else {
                         $lengthOptions = $lengthOptions . "<option value=\"" . $i . "\">" . $i . " Day</option>";
                     }
                 }
                 $page = "\n\n\t\t<form name=\"reservation\" action=\"./index.php?pageid=placeReservation\" method=\"POST\" onsubmit=\"return checkDate();\">\n\t\t<input type=\"hidden\" name=\"action\" value=\"createReservation\">\n\t\t<input type=\"hidden\" name=\"equip_id\" value=\"" . $_GET['equipid'] . "\">\n\t\t<table class=\"reservation\">\n\t\t\n\t\t\t<tr>\n\t\t\t\n\t\t\t\t<td colspan=4 class=\"header\">Reserve the " . $equip->name . "</td>\n\t\t\t\n\t\t\t</tr>\n\t\t\n\t\t\t<tr>\n\t\t\t\n\t\t\t\t<td class=\"centeredcellbold\">Date (YYYY-MM-DD)</td>\n\t\t\t\t<td class=\"centeredcell\">\n\t\t\t\t\t<input type=\"text\" readonly name=\"start_date\" id=\"startdate\" class=\"date\" value=\"blah\"/>\n\t\t\t\t</td>\n\t\t\t\t<td class=\"centeredcellbold\">Length</td>\n\t\t\t\t<td class=\"centeredcell\"><select name=\"length\">" . $lengthOptions . "</select></td>\n\t\t\n\t\t\t</tr>\n\n\t\t\t<tr>\n\t\t\t\n\t\t\t\t<td colspan=1 class=\"centeredcellbold\">User Comment</th>\n\t\t\t\t<td class=\"centeredcell\" colspan=3><textarea rows=5 cols=45 name=\"user_comment\"></textarea></td>\n\t\t\t\n\t\t\t</tr>\n\t\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\n\t\t\t\t\t<td colspan=4 class=\"centeredcell\"><input type=\"submit\" value=\"Reserve\"></td>\n\t\t\n\t\t\t\t</tr>\n\t\t\t\t\n\t\t\t</table>\n\t\t\t</form></div>";
             } else {
                 $this->context->addError("Cannot reserve equipment (User Level).");
             }
         } else {
             $this->context->addError("No equipment with ID '" . $_GET['equipid'] . "'.");
         }
     } else {
         if (!$success) {
             $this->context->addError("No equipment selected.");
         }
     }
     return "<center><h3>Place Reservation</h3>" . $this->context->getErrorHTML() . "</center>" . $page;
 }
 public function handleForm(Context $context, $action)
 {
     if (UserDao::getUserByUsername(SessionUtil::getUsername())->userlevel == RES_USERLEVEL_ADMIN) {
         if ($action == "deleteWarning") {
             $warning = WarningDao::getWarningByID($_POST['warnId']);
             if ($warning != null) {
                 WarningDao::deleteWarning($warning->id);
                 $context->addMessage("Successfully deleted warning.");
             } else {
                 $context->addError("No such warning.");
             }
         } else {
             $context->addError("Incorrect Action.");
         }
     } else {
         $context->addError("Not Authorized.");
     }
 }
 public function generateHTML()
 {
     $myuser = UserDao::getUserByUsername(SessionUtil::getUsername());
     $user = UserDao::getUserByID($_GET['userid']);
     if ($myuser->userlevel < RES_USERLEVEL_ADMIN) {
         $this->context->addError("Not Authorized.");
         return $this->context->getErrorHTML();
     }
     $warnings = WarningDao::getAllWarningsForUser($user->id);
     $options = "";
     foreach ($warnings as $warning) {
         $options .= $warning->toOptionHTML();
     }
     $warningSelect = $user . " has no warnings.";
     if ($options != "") {
         $warningSelect = "<form action=\"./index.php\" method=\"GET\">" . "<input type=\"hidden\" name=\"pageid\" value=\"viewWarning\" />" . "<select name=\"warnid\">" . $options . "</select>" . "<input type=\"submit\" value=\"View\" />" . "</form>";
     }
     return "<center><h3>View Warnings For " . $user . "</h3></center>" . $warningSelect;
 }
 public function generateHTML()
 {
     $userid;
     if (isset($_GET['userid'])) {
         $userid = $_GET['userid'];
     } else {
         if (isset($_POST['userid'])) {
             $userid = $_POST['userid'];
         }
     }
     if (isset($userid)) {
         $user = UserDao::getUserByID($userid);
         $passwordRows = "";
         if (Config::login_type == LOGIN_TYPE_DB) {
             $passwordRows = $this->generatePasswordRows($user);
         }
         return $this->context->getErrorHTML() . $this->context->getMessagesHTML() . "<table class=\"userinfo\">\n\t\t\n\t\t\t<tr>\n\t\t\t\n\t\t\t\t<td colspan=4 class=\"header\">User Information</td>\n\t\t\t\n\t\t\t</tr>\n\t\t\n\t\t\t<tr>\n\t\n\t\t\t\t<td class=\"centeredcellbold\">Username</th>\n\t\t\t\t<td colspan=3 class=\"centeredcell\">" . $user->username . "</td>\n\t\t\t\t\n\t\t\t</tr>\n\t\t\n\t\t\t<tr>\n\t\t\t\t<form action=\"./index.php?pageid=editUser\" method=\"POST\">\n\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"saveName\">\n\t\t\t\t<input type=\"hidden\" name=\"userid\" value=\"" . $user->id . "\">\n\t\t\t\t<td class=\"centeredcellbold\">Name</td>\n\t\t\t\t<td colspan=3 class=\"centeredcell\"><input type=\"text\" name=\"name\" size=\"25\" value=\"" . $user->name . "\"><input type=\"submit\" value=\"Save Name\"></td>\n\t\t\t\t</form>\n\t\t\t\t\n\t\t\t</tr>\n\t\t\t\n\t\t\t" . $passwordRows . "\n\t\t\n\t\t\t<tr>\n\t\t\t\t\n\t\t\t\t<td colspan=1 class=\"centeredcellbold\">Email</td>\n\t\t\t\t<form action=\"./index.php?pageid=editUser\" method=\"POST\">\n\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"saveEmail\">\n\t\t\t\t<input type=\"hidden\" name=\"userid\" value=\"" . $user->id . "\">\n\t\t\t\t<td colspan=3 class=\"centeredcell\"><input type=\"text\" name=\"email\" size=30 value=\"" . $user->email . "\"><input type=\"submit\" value=\"Save Email\"></td>\n\t\t\t\t</form>\n\t\t\t\t\t\n\t\t\t</tr>\n\t\t\n\t\t\t<tr>\n\t\t\t\t\n\t\t\t\t<td colspan=1 class=\"centeredcellbold\">Userlevel</td>\n\t\t\t\t<form action=\"./index.php?pageid=editUser\" method=\"POST\">\n\t\t\t\t<td colspan=3 class=\"centeredcell\">\n\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"saveUserLevel\">\n\t\t\t\t<input type=\"hidden\" name=\"userid\" value=\"" . $user->id . "\">\n\t\t\t\t" . $this->generateUserLevelDropdown("level", $user->userlevel) . "<input type=\"submit\" value=\"Save Level\"></td>\n\t\t\t\t</form>\n\t\t\t\t\t\n\t\t\t</tr>\n\t\n\t\t\t<tr>\n\t\t\t\n\t\t\t\t<td colspan=1 class=\"centeredcellbold\">Warnings</td>\n\t\t\t\t<td class=\"centeredcell\" colspan=2><a href=\"./index.php?pageid=viewWarnings&userid=" . $user->id['user_id'] . "\">" . WarningDao::getWarningCountForUserByType($user->id, RES_WARNING_ACTIVE) . "(" . WarningDao::getWarningCountForUser($user->id) . ")</a></td>\n\t\t\t\t<td class=\"centeredcell\" colspan=1><a href=\"./index.php?pageid=warnUser&userid=" . $user->id . "\">Warn User</a></td>\n\t\t\t\n\t\t\t</tr>\n\t\t\t\n\t\t\t<tr>\n\t\t\t\n\t\t\t\t<td colspan=4 class=\"centeredcellbold\">User Notes</th>\n\t\t\t\n\t\t\t</tr>\n\t\t\t\n\t\t\t<tr>\n\t\t\t\n\t\t\t\t<td colspan=4 class=\"centeredcellbold\">\n\t\t\t\t<br><form action=\"./index.php?pageid=editUser\" method=\"POST\">\n\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"saveNotes\">\n\t\t\t\t<input type=\"hidden\" name=\"userid\" value=\"" . $user->id . "\">\n\t\t\t\t<textarea cols=60 rows=8 name=\"notes\">" . $user->notes . "</textarea>\n\t\t\t\t<br><input type=\"submit\" value=\"Save Notes\"></form></th>\n\t\t\t\n\t\t\t</tr>\n\t\t\t\t\n\t\t</table>";
     } else {
         $this->context->addError("No User Selected");
         return $this->context->getErrorHTML() . $this->context->getMessagesHTML();
     }
 }
 public function handleForm(Context $context, $action)
 {
     if (UserDao::getUserByUsername(SessionUtil::getUsername())->userlevel == RES_USERLEVEL_ADMIN) {
         if ($action == "createWarning") {
             if (isset($_POST['userId']) && $_POST['userId'] != "" && (isset($_POST['reason']) && $_POST['reason'] != "") && (isset($_POST['type']) && $_POST['type'] != "")) {
                 $user = UserDao::getUserByID($_POST['userId']);
                 if ($user != null) {
                     $warning = WarningDao::warnUser($_POST['userId'], $_POST['reason'], $_POST['type']);
                     EmailUtil::sendWarningNoticeToUser($warning);
                     $context->addMessage("Successfully warned " . $user);
                 } else {
                     $context->addError("No such user.");
                 }
             } else {
                 $context->addError("Required field left blank.");
             }
         } else {
             $context->addError("Incorrect Action.");
         }
     } else {
         $context->addError("Not Authorized.");
     }
 }
 public function generateHTML()
 {
     $myuser = UserDao::getUserByUsername(SessionUtil::getUsername());
     $warning = WarningDao::getWarningByID($_GET['warnid']);
     $user = UserDao::getUserByID($warning->userId);
     if ($user->id != $myuser->id && $myuser->userlevel < RES_USERLEVEL_ADMIN) {
         $this->context->addError("Not Authorized.");
         return $this->context->getErrorHTML();
     }
     $warnings = WarningDao::getAllWarningsForUser($user->id);
     $options = "";
     foreach ($warnings as $warning) {
         $options .= $warning->toOptionHTML();
     }
     $warningSelect = $user . " has no warnings.";
     if ($options != "") {
         $warningSelect = "<form action=\"./index.php\" method=\"GET\">" . "<input type=\"hidden\" name=\"pageid\" value=\"viewWarning\" />" . "<select>" . $options . "</select>" . "<input type=\"submit\" value=\"View\" />" . "</form>";
     }
     $adminRow = "";
     if ($myuser->userlevel >= RES_USERLEVEL_ADMIN) {
         $adminRow = "<tr><form action=\"./index.php?pageid=adminWarning\" method=\"POST\">" . "<td colspan=2 class=\"centeredcellbold\">" . "<input type=\"hidden\" name=\"action\" value=\"deleteWarning\" />" . "<input type=\"hidden\" name=\"warnId\" value=\"" . $warning->id . "\" />" . "<input type=\"submit\" value=\"Delete\" /></td></form></tr>";
     }
     return "<center><h3>View Warning For " . $user . "</h3></center><table class=\"warning\">\n\t\t\t\n\t\t\t<tr>\n\t\t\t\n\t\t\t\t<td class=\"header\">Type</td>\n\t\t\t\t<td class=\"header\">Time</td>\n\t\t\t\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\n\t\t\t\t<td class=\"centeredcell\">" . $warning->getTypeString() . "</td>\n\t\t\t\t<td class=\"centeredcell\">" . $warning->datetime . "</td>\n\t\t\t\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\n\t\t\t\t<td colspan=2 class=\"header\">Warning Reason</td>\n\t\t\t\n\t\t\t</tr>\n\t\t\t\n\t\t\t<tr>\n\t\t\t\n\t\t\t\t<td colspan=2 class=\"centeredcell\"><textarea cols=\"55\" rows=\"7\" readonly>" . $warning->reason . "</textarea></td>\n\t\t\t\n\t\t\t</tr>\n\t\t\t" . $adminRow . "\n\t\t\n\t\t</table>";
 }