Beispiel #1
0
 public function saveInput(array $input)
 {
     $errors = $this->validateInput($input);
     if (count($errors)) {
         fatalError($errors);
     }
     $parameters = [$input['auction_name'], $input['auction_description'], $input['starting_price'] * 100, $input['end_date_time'], $input['userrole_id'], $input['reserve_price'] * 100];
     Database::insert('INSERT INTO Auction (name,description,starting_price,end_date,userrole_id, reserve_price) VALUES (?,?,?,?,?,?)', $parameters);
     $auction_id = Database::lastID();
     return $auction_id;
 }
Beispiel #2
0
 public function saveInput(array $input)
 {
     $errors = $this->validateInput($input);
     if (count($errors)) {
         fatalError('Tried to save invalid item data');
     }
     if (!isset($input['auction_id'])) {
         fatalError('Auction Id Was Not Set on Item (System Error)');
     }
     $name = $input['item_name'];
     $description = $input['item_description'];
     $image = $this->saveImage($input['image'], '/items');
     $auction_id = $input['auction_id'];
     $categories = $input['item_category'];
     Database::insert('INSERT INTO Item (name, description,image_url,auction_id) VALUES (?,?,?,?)', [$name, $description, $image, $auction_id]);
     $item_id = Database::lastID();
     foreach ($categories as $category) {
         Database::insert('INSERT INTO ItemCategory (item_id, category_id) VALUES (?,?)', [$item_id, $category]);
     }
     return $item_id;
 }
Beispiel #3
0
 public function processSignup(Request $request, Session $session)
 {
     if ($session->userIsLoggedIn()) {
         return $this->redirectTo('/dashboard');
     }
     if (isset($request->post['email']) && isset($request->post['password']) && (isset($request->post['buyer_account']) || isset($request->post['seller_account'])) && ($request->post['buyer_account'] == 1 || $request->post['seller_account'] == 1)) {
         if (Database::checkExists($request->post['email'], 'email', 'User')) {
             return View::renderView('login', ['signup_errors' => 'Email already exists']);
         }
         Database::insert('INSERT INTO User (email,password) VALUES (?,?)', [$request->post['email'], password_hash($request->post['password'], PASSWORD_DEFAULT)]);
         $user_id = Database::lastID();
         if ($request->post['buyer_account'] == 1) {
             Database::insert('INSERT INTO UserRole (user_id, role_id) VALUES (?,?)', [$user_id, Role::buyer()]);
         }
         if ($request->post['seller_account'] == 1) {
             Database::insert('INSERT INTO UserRole (user_id, role_id) VALUES (?,?)', [$user_id, Role::seller()]);
         }
         $session->generateSession($user_id);
         return $this->redirectTo('/dashboard');
     }
     return View::renderView('login', ['signup_errors' => 'You must complete the signup form']);
 }