Exemplo n.º 1
0
 function makeSearchQuery($fromInstall = FALSE)
 {
     $cond = $this->makeSearchQueryAdvanced($fromInstall);
     $userQueryPieces = ItemField::getUserQueryPieces($this->cid);
     $this->query = "SELECT n.*, c.wholeName AS cName, c.permaLink AS catPermaLink, c.immediateAppear AS immediateAppear {$userQueryPieces['as']}\n                    FROM @item AS n, @category AS c {$userQueryPieces['from']}\n                    WHERE {$userQueryPieces['where']} c.id=n.cid";
     // alapbol csak az aktiv itemek kozt keresunk, kiveve ha admin direct valami mast ad meg a search formben:
     if (!isset($this->status)) {
         $this->query .= " AND n.status='1'";
     }
     if ($cond) {
         $this->query .= " AND {$cond}";
     } else {
         $this->query .= " AND 0";
     }
     // ha nincs feltetel, semmit se mutatunk
 }
Exemplo n.º 2
0
 function getListSelect($retrieveSelectOnly = TRUE, $elementName = "")
 {
     global $item_typ, $gorumroll, $gorumuser, $lll;
     // hogy ne hivodjon meg ketszer foloslegesen a getCount miatt
     // Ha kulonbozo queryStringgel hivjuk, akkor viszont tobbszor is meghivodhat:
     $qs = $gorumroll->ctrl->makeQueryString();
     if (isset($this->select[$qs]) && $retrieveSelectOnly) {
         return $this->select[$qs];
     }
     CustomField::addCustomColumns("item");
     // Az adott user altal birtokolt itemek:
     if ($gorumroll->list == "item_my") {
         $owner = new User();
         $owner->name = $gorumroll->rollid;
         $userId = load($owner, array("name")) ? 0 : $owner->id;
         $search = new CustomList();
         $search->activateVariableFields();
         // az 2-es ID-ju custom list a 'My ads':
         loadSQL($search, "SELECT * FROM @search WHERE id=2");
         $search->setupCustomListAppearance($elementName);
         // mas hirdeteseibol csak az aktivakat lathatjuk:
         hasAdminRights($isAdm);
         if (!$isAdm && $userId != $gorumuser->id) {
             $search->query .= " AND status=1";
         }
         $this->select[$qs] = str_replace('#gorumuser#', $userId, $search->query);
         $lll["item_my_ttitle"] = sprintf($lll["item_my_ttitle"], $owner->showListVal("name"));
         $this->pageTitle = $this->pageDescription = strip_tags($lll["item_my_ttitle"]);
     } elseif ($gorumroll->list == "item_search" || $gorumroll->list == "export") {
         // normal search eseten, az 1-es ID-ju customlistet kell lekernunk:
         $clId = $gorumroll->rollid ? $gorumroll->rollid : 1;
         $search = new CustomList();
         $search->activateVariableFields();
         if (!loadSQL($search, array("SELECT * FROM @search WHERE id=#id#", $clId))) {
             $search->setupCustomListAppearance($elementName);
         } else {
             Roll::setInfoText("listNotFound");
             LocationHistory::saveInfoText();
             LocationHistory::rollBack(new AppController("/"));
         }
         if ($clId == 1) {
             loadSQL($search = new Search(), array("SELECT * FROM @search WHERE uid=#uid# AND name=''", $gorumuser->id));
             $this->activateVariableFields();
             if ($specialSortAttrs = $this->getSpecialSortAttrs($search->cid ? 0 : 1, $search->cid)) {
                 $search->query = str_replace("n.*", "n.* {$specialSortAttrs}", $search->query);
             }
         } else {
             $this->pageTitle = $search->listTitle;
             $this->pageDescription = $search->listDescription;
             $search->applyCategoryFilterToSearchQuery();
         }
         $this->select[$qs] = array($search->query, $gorumuser->id);
     } elseif ($gorumroll->list == "item_favorities") {
         $this->activateVariableFields();
         $this->select[$qs] = array("SELECT n.*, c.wholeName AS cName, " . "c.immediateAppear AS immediateAppear, c.permaLink AS catPermaLink " . "FROM @item AS n, @category AS c " . "WHERE c.id=n.cid AND FIND_IN_SET(n.id, #favorities#)!=0", $gorumuser->favorities);
     } else {
         list($recursive, $wholeName) = G::getAttr($gorumroll->rollid, "appcategory", "recursive", "wholeName");
         $userQueryPieces = ItemField::getUserQueryPieces($gorumroll->rollid);
         $cidCond = $recursive ? "wholeName LIKE '" . quoteSQL($wholeName) . "%'" : "cid='" . quoteSQL($gorumroll->rollid) . "'";
         $this->select[$qs] = "SELECT n.* " . $this->getSpecialSortAttrs(0, $gorumroll->rollid) . ", c.wholeName AS cName, c.permaLink AS catPermaLink, " . "c.immediateAppear AS immediateAppear {$userQueryPieces['as']} FROM @item AS n, @category AS c {$userQueryPieces['from']} " . "WHERE {$userQueryPieces['where']} {$cidCond} AND c.id=n.cid AND n.status='1'";
     }
     return $this->select[$qs];
 }