Exemple #1
0
 function parse()
 {
     if ($this->user->isLoggedIn()) {
         $result = $this->db->buildQuery("SELECT * FROM objects WHERE id IN (SELECT objectid FROM bids WHERE username =%s GROUP BY objectid)", $this->user->getName());
         $objects = parseObjects($result, $this->user->getName());
         foreach ($objects as &$object) {
             $categoryTree = array();
             $categories = array();
             $catIdResult = $this->db->buildQuery("SELECT category_id FROM object_in_category WHERE object_id =%s ", $object['id']);
             $catId = $this->db->fetchAssoc($catIdResult)['category_id'];
             getCategoryFromBottom($categories, $catId);
             foreach ($categories as $cat) {
                 $temp = array("name" => $cat['name'], "link" => baseurl("Rubriek/" . $cat['id']), "parent" => $cat['parent']);
                 $categoryTree[] = $temp;
             }
             $object['categoryTree'] = $categoryTree;
         }
         $this->website->assign("objects", $objects);
         $this->addToBreadcrumbs("Home", baseurl("/"));
         $this->addToBreadcrumbs("UCP", baseurl("Users/CP"));
         $this->addToBreadcrumbs("Mijn Biedingen");
         $this->render("Bids", "users/bids.tpl");
     } else {
         $this->website->assign("loginError", "U moet ingelogd zijn voordat u uw biedingen kunt bekijken.");
         $this->render("login", "users/login.tpl");
     }
 }
Exemple #2
0
 function parse($id, $p)
 {
     $categoryResult = $this->db->buildQuery("SELECT * FROM categories WHERE id=%i", $id);
     $category = $this->db->fetchAssoc($categoryResult);
     //Fetch number of objects in this category:
     $countResult = $this->db->buildQuery("SELECT COUNT(object_id) AS c FROM object_in_category WHERE category_id=%i", $id);
     $c = $this->db->fetchAssoc($countResult)['c'];
     $sql = "SELECT id,title,end_moment,start_bid,city FROM objects WHERE id IN (SELECT object_id FROM object_in_category WHERE category_id=%i) ORDER BY start_moment DESC";
     $result = null;
     $maxPerPage = 18;
     if ($c > $maxPerPage) {
         if ($p > 0) {
             $fo = $p * $maxPerPage;
         } else {
             $fo = 0;
         }
         $fe = $fo + $maxPerPage;
         $sql .= " OFFSET %i ROWS FETCH NEXT %i ROWS ONLY;";
         $result = $this->db->buildQuery($sql, $id, $fo, $fe);
         $this->website->assign("paginationNeeded", true);
         $this->website->assign("page", $p + 1);
         $this->website->assign("maxPages", $c / $maxPerPage - 1);
     } else {
         $result = $this->db->buildQuery($sql, $id);
     }
     $objects = parseObjects($result);
     $categoriesCrumbs = array();
     getCategoryFromBottom($categoriesCrumbs, $id);
     array_pop($categoriesCrumbs);
     $this->addToBreadcrumbs("Home", baseurl(""));
     foreach ($categoriesCrumbs as $cat) {
         $this->addToBreadcrumbs($cat['name'], baseurl("Rubriek/" . $cat['id']));
     }
     $this->addToBreadcrumbs($category['name']);
     $categories = getCategory($categoriesCrumbs);
     $this->website->assign("category", $category);
     $this->website->assign("categories", $categories);
     $this->website->assign("objects", $objects);
     $this->render("Categorie", 'lot/objects.tpl');
 }
Exemple #3
0
 function parse()
 {
     $displayName = "Kavel";
     $objectResult = $this->db->buildQuery("SELECT * FROM objects WHERE id=%i", $this->argsIndexed[0]);
     if ($this->db->getHasRows($objectResult)) {
         $object = $this->db->fetchAssoc($objectResult);
         //See if they placed a bid, and if they're logged in
         if (isset($_POST['submit']) && isset($_POST['bid']) && $this->user->isLoggedIn()) {
             if ($_POST['bid'] >= $this->db->fetchIndex($this->db->executeFunction('dbo.fnMinimalNewBid', $object['id']))[0]) {
                 if ($object['seller'] != $this->user->getName()) {
                     if ($_POST['bid'] < 1000000) {
                         $insertArray = array("objectid" => $object['id'], "bidvalue" => $_POST['bid'], "username" => $this->user->getName(), "bidmoment" => date('Y-m-d H:i:s'));
                     } else {
                         $this->website->assign("bidError", "Je bod overschrijd de maximale gepermitteerde bedrag.");
                     }
                     $this->db->insert("bids", $insertArray);
                     $error = $this->db->getLastError();
                     if ($error) {
                         var_dump($error);
                     } else {
                         header("Location: " . $_SERVER['REQUEST_URI']);
                     }
                 }
             } else {
                 $this->website->assign("bidError", "Je bod is niet hoog genoeg.");
             }
         }
         //Fetch images:
         $imageResult = $this->db->buildQuery("SELECT filename FROM files WHERE objectid=%i", $this->argsIndexed[0]);
         if ($this->db->getHasRows($imageResult)) {
             if ($object['city'] == 'batch') {
                 $object['image'] = "http://iproject2.icasites.nl/pics/" . $this->db->fetchAssoc($imageResult)['filename'];
             } else {
                 $object['image'] = baseurl("upload/" . $this->db->fetchAssoc($imageResult)['filename']);
             }
         } else {
             $object['image'] = "https://placehold.it/465x465";
         }
         $object['timeRemaining'] = $object['end_moment']->getTimeStamp() - time();
         $object['description'] = nl2br(htmlentities(str_replace("&nbsp;", chr(1), str_replace('\\n', "\n", $object['description']))));
         $object['description'] = bb2html(str_replace(chr(1), "&nbsp;", $object['description']));
         //Fetch bids
         $bidsResult = $this->db->buildQuery("SELECT * FROM bids WHERE objectid=%i ORDER BY bidmoment DESC", $this->argsIndexed[0]);
         $object['bids'] = $this->db->fetchAllAssoc($bidsResult);
         //Get minimal new bid:
         $object['nextBid'] = $this->db->fetchIndex($this->db->executeFunction('dbo.fnMinimalNewBid', $object['id']))[0];
         //Fetch user
         $userResult = $this->db->buildQuery("SELECT * FROM users WHERE username=%s", $object['seller']);
         $object['user'] = $this->db->fetchAssoc($userResult);
         $object['user']['gravatarUrl'] = get_gravatar($object['user']['email'], 72);
         //Fetch the rating:
         $object['user']['rating'] = $this->db->fetchIndex($this->db->executeFunction('dbo.fnCalculateRating', $object['user']['username'], false))[0];
         //Fetch category this object is in
         $catId = $this->db->fetchAssoc($this->db->buildQuery("SELECT category_id FROM object_in_category WHERE object_id=%i", $object['id']))['category_id'];
         //Get related here.
         $relatedObjectsResult = $this->db->buildQuery("SELECT TOP 3 * FROM objects WHERE id IN (SELECT object_id FROM object_in_category WHERE category_id=%i AND NOT object_id=%i) AND end_moment > GETDATE() ORDER BY NEWID()", $catId, $object['id']);
         $object['related'] = parseObjects($relatedObjectsResult);
         $categories = array();
         getCategoryFromBottom($categories, $catId);
         $this->addToBreadcrumbs("Home", baseurl(""));
         foreach ($categories as $cat) {
             $this->addToBreadcrumbs($cat['name'], baseurl("Rubriek/" . $cat['id']));
         }
         $this->addToBreadcrumbs($object['title']);
         $this->website->assign("object", $object);
         $this->render($displayName, 'lot/lot.tpl');
     } else {
         $this->website->assign("error", "Dit object bestaat niet!");
         $this->render($displayName, 'error.tpl');
     }
 }
Exemple #4
0
function getCategoryFromBottom(&$array, $childId)
{
    global $db;
    $category = $db->fetchAssoc($db->buildQuery("SELECT id,name, parent FROM categories WHERE id=%i", $childId));
    if ($category['parent'] != null) {
        getCategoryFromBottom($array, $category['parent']);
    }
    if ($category['name'] == null) {
        return;
    }
    $array[] = $category;
}