Exemplo n.º 1
0
 function makeSearchQuerySimple()
 {
     // Ha nem egy adott kategoriara vonatkozik a kereses, akkor az
     // osszes szoba joheto kategoriaban keresunk:
     if (empty($this->str)) {
         return "";
     }
     // ures -> eredmeny az osszes ad
     $word = quoteSQL($this->str);
     return "(" . implode(" OR ", $this->getSimpleCustomFieldConditions($word)) . ")";
 }
Exemplo n.º 2
0
 function makeSearchQuerySimple()
 {
     // Ha nem egy adott kategoriara vonatkozik a kereses, akkor az
     // osszes szoba joheto kategoriaban keresunk:
     if (!$this->str) {
         return "";
     }
     // ures -> eredmeny az osszes ad
     $word = quoteSQL($this->str);
     G::load($categories, "SELECT id FROM @category WHERE allowAd=1 AND directItemNum>0");
     $condOut = array();
     foreach ($categories as $cat) {
         $condIn = $this->getSimpleCustomFieldConditions($word, $cat->id);
         if (count($condIn)) {
             $condOut[] = "(cid='{$cat->id}' AND (" . implode(" OR ", $condIn) . "))";
         }
     }
     if (count($condOut)) {
         return "(" . implode(" OR ", $condOut) . ")";
     } else {
         return "";
     }
 }
Exemplo n.º 3
0
 function tranformEnumValuesForClass($field, $className, $file, $line)
 {
     $values = split(", *", $field->values);
     $cidCond = $className == "user" ? "" : "cid={$field->cid} AND ";
     G::load($objs, "SELECT id, {$field->columnIndex} FROM @{$className} WHERE {$cidCond} {$field->columnIndex}!=''");
     foreach ($objs as $obj) {
         $numValues = split(", *", $obj->{$field->columnIndex});
         $obj->{$field->columnIndex} = array();
         for ($i = 0; $i < count($numValues); $i++) {
             if (isset($values[$numValues[$i]])) {
                 $obj->{$field->columnIndex}[] = $values[$numValues[$i]];
             } elseif (in_array($numValues[$i], $values)) {
                 $obj->{$field->columnIndex}[] = $numValues[$i];
             }
         }
         $newValue = quoteSQL(join(",", array_map(create_function('$v', 'return str_replace(",", ",,", $v);'), $obj->{$field->columnIndex})));
         $query = "UPDATE @{$className} SET {$field->columnIndex}='{$newValue}' WHERE id={$obj->id}";
         if ($file) {
             executeQueryForUpdate($query, $file, $line);
         } else {
             executeQuery($query);
         }
     }
 }
Exemplo n.º 4
0
 function deletePictureOrMedia($isPicture = TRUE)
 {
     global $gorumrecognised, $gorumuser, $gorumroll;
     hasAdminRights($isAdm);
     $parts = explode("_", $gorumroll->rollid);
     $this->id = $parts[0];
     $className = $this->get_class();
     $attr = quoteSQL("{$parts['1']}_{$parts['2']}");
     CustomField::addCustomColumns($className);
     load($this);
     if ($isAdm || $className == "item" && $gorumrecognised && $gorumuser->id == $this->ownerId) {
         executeQuery("UPDATE @{$className} SET `attr`='' WHERE id=#id#", $attr, $this->id);
     } else {
         die;
     }
     return $isPicture ? "{$this->id}_{$parts['2']}." . $this->{$attr} : "{$this->id}_" . $this->{$attr};
 }
Exemplo n.º 5
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];
 }
Exemplo n.º 6
0
 function propagateField($attr, $value, $intoSubcatsOnly = FALSE)
 {
     global $lll;
     load($this);
     if ($intoSubcatsOnly) {
         $query = "SELECT * FROM @category AS c WHERE wholeName LIKE '" . quoteSQL($this->wholeName) . "%' AND id!=#id#";
     } else {
         $query = "SELECT * FROM @category WHERE name='" . quoteSQL($this->name) . "' AND id!=#id#";
     }
     G::load($cats, array($query, $this->id));
     foreach ($cats as $cat) {
         if ($attr == "picture") {
             $value = $this->picture;
             @copy(CAT_PIC_DIR . "/{$this->id}" . "." . $this->picture, CAT_PIC_DIR . "/{$cat->id}" . "." . $this->picture);
         }
         executeQuery("UPDATE @category SET `attr`=#value# WHERE id=#id#", $attr, $value, $cat->id);
     }
     return count($cats);
 }
Exemplo n.º 7
0
 function applyCategoryFilterToSearchQuery()
 {
     global $gorumcategory;
     if ($this->recursive && $gorumcategory) {
         $wholeName = G::getAttr($gorumcategory, "appcategory", "wholeName");
         $this->query .= " AND c.wholeName LIKE '" . quoteSQL($wholeName) . "%'";
     } elseif ($this->categorySpecific && $gorumcategory) {
         $this->query .= " AND n.cid='" . quoteSQL($gorumcategory) . "'";
     }
 }
Exemplo n.º 8
0
 function propagateField($attr, $value, $intoSubcatsOnly = FALSE, $default = FALSE, $stack = FALSE)
 {
     global $lll;
     load($this);
     if ($intoSubcatsOnly) {
         $wholeName = G::getAttr($this->cid, "appcategory", "wholeName");
         $query = "SELECT f.* FROM @itemfield AS f, @category AS c WHERE c.id=f.cid AND c.wholeName LIKE '" . quoteSQL($wholeName) . "%' AND\n                 ((f.name!='' AND f.name=#name# AND f.type=#type#) OR (f.name='' AND userField!=0 AND userField=#uf#)) \n                 AND cid!=#cid#";
     } else {
         $query = "SELECT * FROM @itemfield WHERE \n                 ((name!='' AND name=#name# AND type=#type#) OR (name='' AND userField!=0 AND userField=#uf#)) \n                 AND cid!=#cid#";
     }
     // ha egy masik kategoriaban letezik olyan field aminek neve es tipusa megegyezik az eppen letrehozottal,
     // vagy ami ugyanarra a userFieldre mutat, azt atallitjuk common-ra:
     G::load($fields, array($query, $this->name, $this->type, $this->userField, $this->cid));
     // a 'values' es a 'default' fieldek propagalasa specialis, mert ezekben egy tomb erkezhet:
     if ($default !== FALSE) {
         $values = JavaScript::jsonDecode($value);
         $defaults = JavaScript::jsonDecode($default);
         $stack = JavaScript::jsonDecode($stack);
         $value = dbEncodeEnumValue($values);
         $default = dbEncodeEnumValue($defaults);
     }
     foreach ($fields as $field) {
         if ($default === FALSE) {
             if (strstr($attr, "default_")) {
                 $attr = "default";
             }
             executeQuery("UPDATE @customfield SET `attr`=#value# WHERE id=#id#", $attr, $value, $field->id);
         } else {
             executeQuery("UPDATE @customfield SET `attr`=#value#, `default`=#default# WHERE id=#id#", $attr, $value, "default", $default, $field->id);
             $field->handleEnumValueChange($stack, $field->values, $values);
         }
         if ($attr == "mainPicture" && $value != "0") {
             $field->mainPicture = $value;
             $field->handleMainPictureChange();
         } elseif ($attr == "seo" && $value != "0") {
             $field->seo = $value;
             $field->handleSeoChange();
         }
     }
     return count($fields);
 }
Exemplo n.º 9
0
 function getTitleDescriptionCondition($columnIndex)
 {
     if ($this->{$columnIndex} === '') {
         return "";
     }
     $word = quoteSQL($this->{$columnIndex});
     G::load($categories, "SELECT id FROM @category WHERE allowAd=1 AND directItemNum>0");
     $condOut = array();
     $tag = $columnIndex == "title" ? customfield_title : customfield_description;
     // az osszes kategoria title ill. description szerepkoru attributumaban keresunk:
     foreach ($categories as $cat) {
         if (!loadSQL($v = new CustomField(), "SELECT columnIndex, type, subType FROM @customfield WHERE cid='{$cat->id}' AND seo={$tag}")) {
             if ($v->subType == customfield_alnum || $v->type == customfield_textarea) {
                 $cond = "n.{$v->columnIndex} LIKE '%{$word}%'";
             } else {
                 $cond = "n.{$v->columnIndex}='{$word}'";
             }
             $condOut[] = "(cid='{$cat->id}' AND {$cond})";
         }
     }
     if (count($condOut)) {
         return "(" . implode(" OR ", $condOut) . ")";
     } else {
         return "";
     }
 }