Example #1
0
 public function Index()
 {
     parent::GetAccountInfo();
     //get all commands
     $sql = "SELECT * FROM commands";
     if ($stmt = $this->database->prepare($sql)) {
         $stmt->execute();
         $row = $stmt->fetchAll(PDO::FETCH_ASSOC);
         $this->view->commands = $row;
         $stmt->closeCursor();
     }
     //get current state command id
     $command_id = null;
     $sql = "SELECT command_id FROM state LIMIT 1";
     if ($stmt = $this->database->prepare($sql)) {
         $stmt->execute();
         $row = $stmt->fetch(PDO::FETCH_ASSOC);
         $command_id = $row['command_id'];
         $stmt->closeCursor();
     }
     //get current command
     $sql = "SELECT * FROM commands WHERE id=:command_id";
     if ($stmt = $this->database->prepare($sql)) {
         $stmt->bindParam(':command_id', $command_id, PDO::PARAM_STR);
         $stmt->execute();
         $row = $stmt->fetch(PDO::FETCH_ASSOC);
         $this->view->current_command = $row;
         $stmt->closeCursor();
     }
 }
Example #2
0
 public function AddToWatchList_POST($event_id)
 {
     parent::GetAccountInfo();
     //Check if event is already on watchlist
     $sql = "SELECT * FROM watchlist WHERE event_id=:event_id AND user_id=:user_id LIMIT 1";
     if ($stmt = $this->database->prepare($sql)) {
         $stmt->bindParam(':event_id', $event_id, PDO::PARAM_STR);
         $stmt->bindParam(':user_id', $this->view->account->id, PDO::PARAM_STR);
         $stmt->execute();
         $row = $stmt->fetch(PDO::PARAM_STR);
         if ($row) {
             echo json_encode("exists");
             exit;
         }
     }
     //Add to watchlist
     $sql = "INSERT INTO watchlist (event_id, user_id, created, updated) VALUES (:event_id, :user_id, NOW(), NOW())";
     if ($stmt = $this->database->prepare($sql)) {
         $stmt->bindParam(':event_id', $event_id, PDO::PARAM_STR);
         $stmt->bindParam(':user_id', $this->view->account->id, PDO::PARAM_STR);
         $stmt->execute();
         $stmt->closeCursor();
         $this->notification = array();
         //Create notification
         $notification = array("user_id" => $this->view->account->id, "type" => NotificationType::AddedToWatchList, "title" => NotificationType::AddedToWatchList, "content" => 'You added an <a href=/event/detail/' . $event_id . '>event</a> to your WatchList');
         parent::AddNotification($notification);
         echo json_encode("success");
         exit;
     }
 }
Example #3
0
 public function DeleteCommand_POST()
 {
     //Get current user account info
     parent::GetAccountInfo();
     //Get posted fields
     $this->view->post = array('id' => $_POST['id']);
     //Insert record
     $sql = "DELETE FROM commands\n          WHERE id=:id";
     if ($stmt = $this->database->prepare($sql)) {
         $stmt->bindParam(':id', $this->view->post['id'], PDO::PARAM_STR);
         $stmt->execute();
         $stmt->closeCursor();
     }
 }
Example #4
0
 public function GetUnSeenCount_POST()
 {
     parent::GetAccountInfo();
     $sql = "SELECT id FROM notifications WHERE user_id=:user_id AND has_seen=0";
     if ($stmt = $this->database->prepare($sql)) {
         $stmt->bindParam(':user_id', $this->view->account->id, PDO::PARAM_STR);
         $stmt->execute();
         $row = $stmt->fetchAll(PDO::FETCH_ASSOC);
         echo json_encode(count($row));
         exit;
     }
 }
Example #5
0
 public function Run()
 {
     parent::GetAccountInfo();
     $sampleKeywords = array('cosy', 'rustic', 'modern', 'old', 'quiet', 'refurbished', 'farm', 'peaceful', 'zen', 'rural', 'original', 'big', 'small');
     $count = 10;
     $sampleEvents = array();
     //locations
     $locations = array('43 Main Street, Toronto, Canada, CA12 EFJ', '21 Some Road, Toronto, Canada, CA12 7ET', '828 Big Close, Toronto, Canada, CA12 5JD', '18 Small Lane, Toronto, Canada, CA12 9DJ', '98 Barvas Walk, Toronto, Canada, CA12 3DF', '23 Stronsey Drive, Toronto, Canada, CA12 9DN', '39 Kincorth Avenue, Toronto, Canada, CA12 2JF', '4339 Union Street, Toronto, Canada, CA12 2ED', '323 Tarrensay Square, Toronto, Canada, CA12 6FN', '849 MadeUp Road, Toronto, Canada, CA12 8FJ');
     //names
     $names = array('Event Sample Name #1', 'Event Sample Name #2', 'Event Sample Name #3', 'Event Sample Name #4', 'Event Sample Name #5', 'Event Sample Name #6', 'Event Sample Name #7', 'Event Sample Name #8', 'Event Sample Name #9', 'Event Sample Name #10');
     //descriptions
     $descriptions = array("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.", "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.", "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.", "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.", "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.", "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.", "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.", "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.", "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.", "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.");
     $dates = array(array('date' => '2015-10-10', 'start_time' => '09:00:00', 'end_time' => '11:00:00'), array('date' => '2015-10-10', 'start_time' => '09:00:00', 'end_time' => '11:00:00'), array('date' => '2015-10-12', 'start_time' => '09:00:00', 'end_time' => '11:00:00'), array('date' => '2015-10-13', 'start_time' => '09:00:00', 'end_time' => '11:00:00'), array('date' => '2015-10-14', 'start_time' => '09:00:00', 'end_time' => '11:00:00'), array('date' => '2015-10-15', 'start_time' => '09:00:00', 'end_time' => '11:00:00'), array('date' => '2015-10-16', 'start_time' => '09:00:00', 'end_time' => '11:00:00'), array('date' => '2015-10-18', 'start_time' => '09:00:00', 'end_time' => '11:00:00'), array('date' => '2015-10-18', 'start_time' => '09:00:00', 'end_time' => '11:00:00'), array('date' => '2015-10-18', 'start_time' => '09:00:00', 'end_time' => '11:00:00'));
     //Generate sample events
     for ($i = 0; $i < $count; $i++) {
         array_push($sampleEvents, $this->CreateSampleEvent($locations[$i], $names[$i], $descriptions[$i]));
     }
     //echo '<pre>'; print_r($sampleEvents); exit();
     $count = 0;
     $event_id = null;
     $insertedImageId = null;
     //Create events
     foreach ($sampleEvents as $event) {
         $sql = "INSERT INTO events (user_id,\n              location,\n              currency,\n              price,\n              bedrooms,\n              bathrooms,\n              type,\n              name,\n              description,\n              privacy,\n              created,\n              updated) VALUES (:user_id,\n                :location,\n                'CAD',\n                :price,\n                :bedrooms,\n                :bathrooms,\n                :type,\n                :name,\n                :description,\n                :privacy,\n                NOW(),\n                NOW()\n            )";
         if ($stmt = $this->database->prepare($sql)) {
             $stmt->bindParam(':user_id', $event['user_id'], PDO::PARAM_STR);
             $stmt->bindParam(':location', $event['location'], PDO::PARAM_STR);
             $stmt->bindParam(':price', $event['price'], PDO::PARAM_STR);
             $stmt->bindParam(':bedrooms', $event['bedrooms'], PDO::PARAM_STR);
             $stmt->bindParam(':bathrooms', $event['bathrooms'], PDO::PARAM_STR);
             $stmt->bindParam(':type', $event['type'], PDO::PARAM_STR);
             $stmt->bindParam(':name', $event['name'], PDO::PARAM_STR);
             $stmt->bindParam(':description', $event['description'], PDO::PARAM_STR);
             $stmt->bindParam(':privacy', $event['privacy'], PDO::PARAM_STR);
             $stmt->execute();
             $event_id = $this->database->lastInsertId();
         }
         $sql = "INSERT INTO event_dates (event_id, date, start_time, end_time) VALUES (:event_id, :date, :start_time, :end_time)";
         if ($stmt = $this->database->prepare($sql)) {
             $stmt->bindParam(':event_id', $event_id, PDO::PARAM_STR);
             $stmt->bindParam(':date', $dates[rand(0, count($dates) - 1)]['date'], PDO::PARAM_STR);
             $stmt->bindParam(':start_time', $dates[rand(0, count($dates) - 1)]['start_time'], PDO::PARAM_STR);
             $stmt->bindParam(':end_time', $dates[rand(0, count($dates) - 1)]['end_time'], PDO::PARAM_STR);
             $stmt->execute();
         }
         $sql = "INSERT INTO event_dates (event_id, date, start_time, end_time) VALUES (:event_id, :date, :start_time, :end_time)";
         if ($stmt = $this->database->prepare($sql)) {
             $stmt->bindParam(':event_id', $event_id, PDO::PARAM_STR);
             $stmt->bindParam(':date', $dates[rand(0, count($dates) - 1)]['date'], PDO::PARAM_STR);
             $stmt->bindParam(':start_time', $dates[rand(0, count($dates) - 1)]['start_time'], PDO::PARAM_STR);
             $stmt->bindParam(':end_time', $dates[rand(0, count($dates) - 1)]['end_time'], PDO::PARAM_STR);
             $stmt->execute();
         }
         //
         //INSERT EVENT_KEYWORDS
         //
         $sql = "INSERT INTO event_keywords (event_id, tag) VALUES (:event_id, :tag)";
         if ($stmt = $this->database->prepare($sql)) {
             $stmt->bindParam(':event_id', $event_id, PDO::PARAM_STR);
             $stmt->bindParam(':tag', $sampleKeywords[rand(0, count($sampleKeywords) - 1)], PDO::PARAM_STR);
             $stmt->execute();
         }
         if ($stmt = $this->database->prepare($sql)) {
             $stmt->bindParam(':event_id', $event_id, PDO::PARAM_STR);
             $stmt->bindParam(':tag', $sampleKeywords[rand(0, count($sampleKeywords) - 1)], PDO::PARAM_STR);
             $stmt->execute();
         }
         if ($stmt = $this->database->prepare($sql)) {
             $stmt->bindParam(':event_id', $event_id, PDO::PARAM_STR);
             $stmt->bindParam(':tag', $sampleKeywords[rand(0, count($sampleKeywords) - 1)], PDO::PARAM_STR);
             $stmt->execute();
         }
         //
         //INSERT IMAGES AND EVENT_IMAGES
         //
         for ($i = 0; $i < 3; $i++) {
             $image = rand(1, 3) . '.jpg';
             $sql = "INSERT INTO event_images (event_id, href, created, updated) VALUES (:event_id, :href, NOW(), NOW())";
             if ($stmt = $this->database->prepare($sql)) {
                 $href = '/public/app_data/event_images/' . $image;
                 $stmt->bindParam(':event_id', $event_id, PDO::PARAM_STR);
                 $stmt->bindParam(':href', $href, PDO::PARAM_STR);
                 $stmt->execute();
             }
         }
         $count++;
     }
 }