public static function renderHeader($withMenu = true) { include '../resources/header.html'; if ($withMenu) { $userManager = new UserManager(); $loggedInUser = $userManager->getLoggedInUser(); $auctionManager = new AuctionManager(); $categories = $auctionManager->getAllCategories(); $searchTerm = isset($_GET['searchTerm']) ? $_GET['searchTerm'] : ""; $categoryID = isset($_GET['categoryID']) ? $_GET['categoryID'] : AuctionManager::DEFAULT_ALL_CATEGORIES; echo ' <nav class="navbar navbar-bidbucket" role="navigation"> <div class="container-fluid"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="/auction/homepage"><img src="/assets/img/logo2.png" height="25" alt="logo"></a> <span class="navbar-brand"><a href="/auction/profile?id=' . $loggedInUser->userID . '">Hello ' . $loggedInUser->firstName . '!</a></span> </div> <div class="collapse navbar-collapse" id="myNavbar"> <form class="navbar-form navbar-left" role="form" action="/auction/homepage" method="get"> <div class="form-group"> <input type="text" class="form-control" id="searchbox" name="searchTerm" placeholder="Search" value="' . $searchTerm . '"> <select class="form-control" id="categoryDrop" name="categoryID" > <option value="' . AuctionManager::DEFAULT_ALL_CATEGORIES . '">ALL</option>'; foreach ($categories as $category) { $selected = $categoryID == $category->id ? "selected" : ""; echo '<option ' . $selected . ' value="' . $category->id . '">' . $category->name . '</option>'; } echo ' </select> </div> <button type="submit" class="btn btn-default">Submit</button> </form> <ul class="nav navbar-nav navbar-right"> <li><a href="/auction/settings"><span class="glyphicon glyphicon-user"></span> My Bucket</a></li> '; if ($loggedInUser->roleID == 2) { echo '<li><a href="/auction/upload"><span class="glyphicon glyphicon-list-alt"></span> Start Auction</a></li>'; } echo ' <li><a href="/auction/logout"><span class="glyphicon glyphicon-log-out"></span> Log out</a></li> </ul> </div> </div> </nav> '; } }
/** * Remove all roles, permissions and assignments in your database. * * Used for testing. * * @param boolean Must set to true or throws error. * @return boolean */ function reset($Ensure = false) { if ($Ensure !== true) { throw new \Exception("You must pass true to this function, otherwise it won't work."); return; } $res = true; $res = $res and $this->Roles->resetAssignments(true); $res = $res and $this->Roles->reset(true); $res = $res and $this->Permissions->reset(true); $res = $res and $this->Users->resetAssignments(true); return $res; }
<?php /** * Created by PhpStorm. * User: Claz * Date: 17/03/2016 * Time: 15:58 */ include_once '../bootstrap.php'; use Models\UserManager; use Views\SettingsView; use Views\HomepageView; use Models\LoginManager; // login protected page LoginManager::startSessionAndRedirectIfNotLoggedIn(); $change = isset($_REQUEST['notification']) ? 'y' : 'n'; $userManager = new UserManager(); $user = $userManager->getLoggedInUser()->userID; $notificationChange = $userManager->notificationSettings($change, $user); if ($notificationChange) { $SettingsView = new SettingsView(false); $SettingsView->render(); echo "<script type='text/javascript'>alert('Notifications updated')</script>"; exit; } else { $SettingsView = new SettingsView(true); $SettingsView->render(); //echo "<script type='text/javascript'>alert('submitted unsuccessfully!')</script>"; }
public function render() { Header::renderHeader(); $SettingsManager = new SettingsManager(); $userManager = new UserManager(); $loggedInUser = $userManager->getLoggedInUser(); $updateFailedBlock = ''; if ($this->updateFailed) { $updateFailedBlock .= '<h6 id="update_fail"><i class="glyphicon glyphicon-alert"></i> Some of your information is incorrect.</h6></span>'; } echo '<div id="settings" class="container"> <div class="well well-small"> <h2>Settings</h2> <ul class="nav nav-tabs"> <li class="active"><a data-toggle="tab" href="#uPassword">Update Password</a></li> <li><a data-toggle="tab" href="#uEmail">Update Email</a></li> <li><a data-toggle="tab" href="#emailNotifications">Email Notifications</a></li> </ul> <div class="tab-content"> <div id="uPassword" class="tab-pane fade in active"> <h3>Update Password</h3> <p>Update your password here</p> <form class="form-horizontal" action="/auction/settingsPasswordForm" method="post" role="form"> <div class="form-group"> <label class="control-label col-sm-2" for="pwd"><span class="glyphicon glyphicon-lock form-control-feedback"></span></label> <div class="col-sm-10"> <input type="password" name="oldPassword" class="form-control" required="required" id="oldpwd" placeholder="Enter old password"> </div> </div> <div class="form-group"> <label class="control-label col-sm-2" for="pwd"><span class="glyphicon glyphicon-lock form-control-feedback"></span></label> <div class="col-sm-10"> <input type="password" name="newPassword" class="form-control" required="required" id="UserPassword" placeholder="Enter new password"> </div> </div> <div class="form-group"> <label class="control-label col-sm-2" for="pwd"><span class="glyphicon glyphicon-lock form-control-feedback"></span></label> <div class="col-sm-10"> <input type="password" name="password_check" class="form-control" required="required" id="UserPasswordCheck" onkeyup="checkPass(); return false;" placeholder="Confirm new password"> <span id="confirmMessage" class="confirmMessage"></span> </div> </div> ' . $updateFailedBlock . ' <div class="form-group"> <div class="col-sm-12"> <button type="submit" class="btn btn-primary btn-large btn-block">Submit</button> </div> </div> </form> </div> <div id="uEmail" class="tab-pane fade"> <h3>Update Email</h3> <p>Update your email here</p> <form class="form-horizontal" action="/auction/settingsEmailForm" method="post" role="form"> <div class="form-group"> <label class="control-label col-sm-2" for="email"><span class="glyphicon glyphicon-envelope form-control-feedback"></label> <div class="col-sm-10"> <input type="email" class="form-control" name="OldEmail" id="OldEmail" required="required" placeholder="Enter old email"> </div> </div> <div class="form-group"> <label class="control-label col-sm-2" for="pwd"><span class="glyphicon glyphicon-envelope form-control-feedback"></label> <div class="col-sm-10"> <input type="email" class="form-control" name="NewEmail" id="NewEmail" required="required" placeholder="Enter new email"> </div> <span id="confirmEmailMessage" class="confirmEmailMessage"></span> </div> <?php echo $updateFailedBlock; ?> <div class="form-group"> <div class="col-sm-12"> <button type="submit" class="btn btn-primary btn-large btn-block">Submit</button> </div> </div> </form> </div> <div id="emailNotifications" class="tab-pane fade"> <h3>Email Notifications</h3> <form class="form-horizontal" action="/auction/settingsNotificationsForm" method="post" role="form"> <label for="emailNotifications"><p>Check this to receive notifications on your items, uncheck to turn off</p></label> <input type="checkbox" name="notification" value="Y" ' . ($loggedInUser->notifications ? 'checked="checked"' : "") . '"> <button type="submit" class="btn btn-primary btn-large btn-block">Submit</button> </form> </div> </div> </div> </div>'; }
<?php /** * Created by PhpStorm. * User: BlackLinden * Date: 14/03/2016 * Time: 17:43 */ use Models\AuctionAwarderManager; use Models\AuctionManager; use Models\EmailManager; use Models\UserManager; require __DIR__ . '/../bootstrap.php'; $auctionManager = new AuctionManager(); $auctionAwarderManager = new AuctionAwarderManager(); $userManager = new UserManager(); $emailManager = new EmailManager(); $auctionIds = $auctionAwarderManager->getAuctionIdsToAward(); echo count($auctionIds) . " auctions to award\n"; foreach ($auctionIds as $auctionID) { echo "Awarding {$auctionID}...\n"; $auctionDetail = $auctionManager->getAuctionDetail($auctionID); $seller = $userManager->getUser($auctionDetail->sellerID); // There have been bids echo "There have been " . $auctionDetail->numberOfBids . " bids\n"; if ($auctionDetail->numberOfBids > 0) { $highestBidder = $userManager->getUser($auctionDetail->highestBidderID); $losingBuyers = $auctionAwarderManager->getLosingBuyers($auctionID, $auctionDetail->highestBidderID); foreach ($losingBuyers as $losingBuyer) { $emailManager->sendEmailUnsuccessfullBid($losingBuyer, $auctionDetail); }
<?php include_once '../bootstrap.php'; use Models\Logger; use Models\LoginManager; use Models\AuctionManager; use Views\HomepageView; use Models\UserManager; use Models\AuctionSellerManager; use Views\SellerHomepageView; // login protected page LoginManager::startSessionAndRedirectIfNotLoggedIn(); $userManager = new UserManager(); $loggedInUser = $userManager->getLoggedInUser(); $userRole = $loggedInUser->roleID; Logger::log($userRole); if (isset($_REQUEST["searchTerm"])) { $searchTerm = $_REQUEST["searchTerm"]; } else { $searchTerm = AuctionManager::DEFAULT_SEARCH_TERM; } if (isset($_REQUEST["categoryID"])) { $categoryID = $_REQUEST["categoryID"]; } else { $categoryID = AuctionManager::DEFAULT_ALL_CATEGORIES; } if ($userRole == UserManager::USER_ROLE_BUYER || $userRole == UserManager::USER_ROLE_ADMIN) { $auctionManager = new AuctionManager(); } elseif ($userRole == UserManager::USER_ROLE_SELLER || $userRole == UserManager::USER_ROLE_ADMIN) { $auctionManager = new AuctionSellerManager(); }
* Created by PhpStorm. * User: Claz * Date: 05/02/2016 * Time: 11:58 */ include_once '../bootstrap.php'; use Models\LoginManager; use Models\UserManager; use Views\RegisterView; LoginManager::startSession(); //minimum to create the view and render $username = $_REQUEST['username']; $first_name = $_REQUEST['first_name']; $last_name = $_REQUEST['last_name']; $email = $_REQUEST['email']; $email_check = $_REQUEST['email_check']; $role_id = $_REQUEST['role_id']; $description = $_REQUEST['description']; $password = $_REQUEST['password']; $password_check = $_REQUEST['password_check']; $registerManager = new UserManager(); $isRegisterSuccess = $registerManager->registerUser($username, $first_name, $last_name, $email, $email_check, $role_id, $description, $password, $password_check); $loginManager = new LoginManager(); $login = $loginManager->isValid($username, $password); if ($isRegisterSuccess) { header("Location: /auction/homepage"); exit; } else { $registerView = new RegisterView(true); $registerView->render(); }
public function render() { Header::renderHeader(true); $userManager = new UserManager(); $isCurrentUserHighestBidder = $userManager->getLoggedInUser()->userID == $this->auctionDetail->highestBidderID; $step = round($this->auctionDetail->maxBid * 0.05, 2); $minValue = $this->auctionDetail->maxBid + $step; if (count($this->auctionDetail->imageIDs) > 0) { $url = "/auction/image?id=" . $this->auctionDetail->imageIDs[0]; } else { $url = "/assets/img/logo.png"; } $loggedInUser = $userManager->getLoggedInUser(); /** * Search - needs to be abstracted */ echo ' <div class="container"> <div class="media"> <div class="media-left"> <a href="#"> <img id="item_image" class="media-object" class="img-responsive" src="' . $url . '"> </a> </div> <div class="media-body"> <h1 class="media-heading">' . $this->auctionDetail->itemName . '</h1> <div class="panel panel-default"> <div class="panel-body">'; if ($this->auctionDetail->isAuctionExpired) { echo ' <span><b>Item expired!</b></span><br><br>'; } if (!$this->auctionDetail->isAuctionStarted) { echo ' <span><b>Item is not on auction yet!</b></span><br><br>'; } echo ' <p><b>Auction start time</b>: ' . DateTimeUtils::formatDate($this->auctionDetail->startDate) . '</p> <p><b>Expiration time</b> : ' . DateTimeUtils::formatDate($this->auctionDetail->endDate) . '</p>'; if (!$this->auctionDetail->isAuctionExpired && $this->auctionDetail->isAuctionStarted) { echo ' <span id="bid_price">£ ' . $this->auctionDetail->maxBid . '</span> <a href="/auction/bidHistory?id=' . $this->auctionDetail->auctionId . '"><span id="bid_number"> ' . $this->auctionDetail->numberOfBids . ' bids</span></a> <div><i>' . ($isCurrentUserHighestBidder ? "You are the current highest bidder!" : "") . '</i></div> '; //if the user is a buyer, they can bid on or watch an item if ($loggedInUser->roleID == 1) { echo ' <form method="post"> <input type="hidden" value="' . $this->auctionDetail->auctionId . '" name="id"> <input type="hidden" value="' . $this->auctionDetail->itemName . '" name="itemName"> <div class="form-group"> <input type="number" min="' . $minValue . '" class="form-control" placeholder="Enter your max. bid" name="newBid" value="' . $this->auctionDetail->maxBid . '"> </div> <button type="submit" class="btn btn-default" id="submitBid">Submit</button> <span>'; if (!$this->auctionDetail->isWatching) { echo '<a href="/auction/auction?id=' . $this->auctionDetail->auctionId . '&isWatching=1"><br><i class="glyphicon glyphicon-eye-open"></i>' . ' ' . ' Start watching </a>'; } else { echo '<a href="/auction/auction?id=' . $this->auctionDetail->auctionId . '&isWatching=0"><br><i class="glyphicon glyphicon-eye-close"></i> Unwatch </a>'; } echo ' </span> </form> '; } } echo ' </div> </div> </div>'; echo '<div class="panel panel-default"> <div class="panel-heading"> <a href="/auction/profile?id=' . $this->auctionDetail->sellerID . '"><h3 class="panel-title">' . $this->auctionDetail->sellerName . '</h3></a> <div class="star-rating"> <div>'; for ($x = 1; $x < 6; $x++) { if ($x > round($this->auctionDetail->sellerRating)) { echo '<i class="glyphicon glyphicon-star-empty"></i>'; } else { echo '<i class="glyphicon glyphicon-star"></i>'; } } echo '(' . $this->auctionDetail->numberOfRatings . ')'; echo ' </div> </div> </div> <div class="panel-body"> <a href="/auction/feedback?id=' . $this->auctionDetail->sellerID . '">View detailed feedback</a> </div> </div> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title">Item description</h3> </div> <div class="panel-body"> ' . $this->auctionDetail->itemDescription . ' </div> </div> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title">Item condition</h3> </div> <div class="panel-body"> ' . $this->auctionDetail->itemCondition . ' </div> <a href="/auction/homepage">Back to search results</a> </div> </div> '; }
/** * @param $title * @param $description * @param $item_condition * @param $start_price * @param $reserve_price * @param $start_date * @param $start_time * @param $end_date * @param $end_time * @param $categories * @return mixed */ public function createNewItem($title, $description, $item_condition, $start_price, $reserve_price, $start_date, $start_time, $end_date, $end_time, $categories) { $connection = ConnectionManager::getConnection(); Logger::log('uploadItem'); $userManager = new UserManager(); $seller_id = $userManager->getLoggedInUser()->userID; $title = $connection->escape_string($title); $description = $connection->escape_string($description); $item_condition = $connection->escape_string($item_condition); $start_price = $connection->escape_string($start_price); $reserve_price = $connection->escape_string($reserve_price); $start_date = $connection->escape_string($start_date); $start_time = $connection->escape_string($start_time); $end_date = $connection->escape_string($end_date); $end_time = $connection->escape_string($end_time); // sets views to zero so increment works $start_date = $start_date . ' ' . $start_time; $end_date = $end_date . ' ' . $end_time; $auction_id = -1; $sql = "INSERT INTO auction (description, views, start_price, end_date, start_date, seller_id, reserve_price, item_condition, title)\n VALUES ('{$description}', 0, '{$start_price}', '{$end_date}', '{$start_date}', '{$seller_id}', '{$reserve_price}', '{$item_condition}', '{$title}')"; if ($connection->query($sql) === TRUE) { Logger::log('insert to auction table'); // gets the id of the query $auction_id = $connection->insert_id; Logger::log($auction_id); foreach ($categories as $category) { $category = (int) $category; $sqlCategory = "INSERT INTO auction_category (auction_id, category_id) VALUES ({$auction_id}, {$category})"; if ($connection->query($sqlCategory) === TRUE) { Logger::log('insert to auction_category table'); } else { Logger::log('insert to auction_category failed ' . $sqlCategory); } } } else { Logger::log('not connected to database'); } return $auction_id; }
/** * Created by PhpStorm. * User: Claz * Date: 04/03/2016 * Time: 12:39 */ include_once '../bootstrap.php'; use Models\AuctionSellerManager; use Models\LoginManager; use Views\AuctionReportView; use Models\EmailManager; use Models\UserManager; LoginManager::startSessionAndRedirectIfNotLoggedIn(); $auctionSellerManager = new AuctionSellerManager(); $userManager = new UserManager(); // get the auction id $auctionId = (int) $_REQUEST['id']; if ($auctionId) { // make methods in the auction report $auctionReport = $auctionSellerManager->getAuctionDetail($auctionId); $auctionReportView = new AuctionReportView($auctionReport); $auctionReportView->render(); if (isset($_POST['report'])) { $emailManager = new EmailManager(); $userDetails = $userManager->getLoggedInUser(); $email = $userDetails->email; $firstName = $userDetails->firstName; $emailManager->reportEmail($email, $auctionId, $firstName); } } else {
<?php /** * Created by PhpStorm. * User: Claz * Date: 17/03/2016 * Time: 23:31 */ use Models\AuctionManager; use Models\EmailManager; use Models\UserManager; require __DIR__ . '/../bootstrap.php'; $auctionManager = new AuctionManager(); $userManager = new UserManager(); $emailManager = new EmailManager(); $sellers = $userManager->getSellers(); //printf("Sellers "); //var_dump($sellers); foreach ($sellers as $sellerID) { printf("First for each"); $auctionIDs = array(); $auctionIDs = $userManager->getAuctionIDs($sellerID); //var_dump($auctionIDs); if (!empty($auctionIDs)) { //printf("Has some auctions"); $receiveNotifications = $userManager->receiveNotifications($sellerID); var_dump($receiveNotifications); if ($receiveNotifications) { //printf("Receives notifications"); $emailManager->autoReportEmail($auctionIDs, $sellerID); }
/** * Created by PhpStorm. * User: BlackLinden * Date: 08/02/2016 * Time: 11:33 */ include_once '../bootstrap.php'; use Models\AuctionManager; use Models\Bid; use Models\BidManager; use Models\LoginManager; use Models\UserManager; use Views\AuctionDetailView; LoginManager::startSessionAndRedirectIfNotLoggedIn(); $auctionManager = new AuctionManager(); $userManager = new UserManager(); $currentUser = $userManager->getLoggedInUser()->userID; // get the auction id $auctionId = (int) $_REQUEST['id']; if ($auctionId) { if ($_SERVER['REQUEST_METHOD'] === 'POST') { $id = $_POST['id']; $amount = $_POST['newBid']; $itemName = $_REQUEST['itemName']; $bidManager = new BidManager(); $bid = new Bid($amount, new DateTime(), $id, $currentUser, $itemName); $bidManager->updateBid($bid); $auctionDetail = $auctionManager->getAuctionDetail($auctionId); $auctionDetailView = new AuctionDetailView($auctionDetail); $auctionDetailView->render(); } elseif ($_SERVER['REQUEST_METHOD'] === 'GET') {