Esempio n. 1
0
 function create()
 {
     global $lll, $noahVersion, $gorumroll;
     $exportExtensions = array(customlist_xml => "xml", customlist_csv => "csv");
     hasAdminRights($isAdm);
     if (!$isAdm) {
         return;
     }
     include GORUM_DIR . "/gorum_view.php";
     $list = new CustomList();
     $list->activateVariableFields();
     if (loadSQL($list, array("SELECT * FROM @search WHERE id=#id#", $gorumroll->rollid)) || !$list->exportFormat) {
         return;
     }
     $ext = $exportExtensions[$list->exportFormat];
     $date = date("Y-m-d-H-i-s");
     $fileName = LOG_DIR . "/export_{$date}.{$ext}";
     G::load($unsortedColumns, "SELECT * FROM @itemfield WHERE FIND_IN_SET(id, '{$list->exportFields}')!=0");
     // Hogy a $columns arary sorrendje ugyanaz legyen, mint $list->exportFields-ben:
     $columns = array();
     $length = count($unsortedColumns);
     foreach (explode(",", $list->exportFields) as $id) {
         for ($i = 0; $i < $length; $i++) {
             if ($unsortedColumns[$i]->id == $id) {
                 $columns[] = $unsortedColumns[$i];
                 break;
             }
         }
     }
     $ad = new Item();
     $ad->loadHtmlList($ads);
     array_walk($columns, create_function('$v', '
     if( $v->userField ) 
     { 
         list( $v->userColumnIndex, $v->type, $v->name, $v->allowHtml) = G::getAttr($v->userField, "userfield", "columnIndex", "type", "name", "allowHtml");            
     }
     else $v->userColumnIndex = "";
     $v->name = preg_replace(array("/$[\\d.-]/", "/[^\\w:]/"), "_", $v->name);'));
     $owner = new User();
     $owner->activateVariableFields();
     $fgName = "create_{$ext}";
     $this->{$fgName}($fileName, $list, $ads, $columns);
     $this->nextAction =& new AppController("customlist/list");
     Roll::setInfoText("exportSavedAs", $fileName);
 }
Esempio n. 2
0
 function handleEnumValueChange($stack = FALSE, $oldValue = FALSE, $newValue = FALSE)
 {
     if ($stack === FALSE) {
         if (!isset($_POST["optionValueModificationStack"]) || !count($stack = JavaScript::jsonDecode($_POST["optionValueModificationStack"]))) {
             return;
         }
         // ha nem vol modositas, vagy torles
     }
     if ($oldValue !== FALSE) {
         // ha propagate van, nem csak azokat a modositasokat kell figyelembe venni, amik az adott modifyban tortentek,
         // hanem a korabbiakat is. Ezt a 'values' regi es uj ertekenek osszehasonlitasaval erjuk el. Ha talalunk olyat,
         // ami nincs benne az uj 'values'-ban, azt hozzaadjuk $stack-hoz egy 'delete' action-nel:
         $oldValueArr = splitByCommas($oldValue, FALSE);
         // without HTML encoding
         $modified = array_unique(array_map(create_function('$v', 'return $v[0]=="modify" ? $v[1] : "";'), $stack));
         foreach ($oldValueArr as $val) {
             if (!in_array($val, $newValue) && !in_array($val, $modified)) {
                 $stack[] = array("delete", $val);
             }
         }
     }
     if (!$stack) {
         return;
     }
     // ha az old es new values osszehasonlitasa utan se derul ki, hogy lett volna torles v. modositas
     CustomField::addCustomColumns($this->getManagedTable());
     $affectedValues = array_map(create_function('$v', 'return quoteSQL(str_replace(",", ",,", $v[1]));'), $stack);
     $regexp = array();
     $columnIndex = G::getAttr($this->id, "itemfield", "columnIndex");
     foreach ($affectedValues as $v) {
         $regexp[] = "{$columnIndex} LIKE '%{$v}%'";
     }
     $whereCond = " WHERE (" . implode(" OR ", $regexp) . ")";
     if ($this->cid) {
         $whereCond .= " AND (cid={$this->cid} OR cid=0)";
     }
     $query = "SELECT id, {$columnIndex} FROM @" . $this->getManagedTable() . $whereCond;
     G::load($objs, $query);
     $customLists = new CustomList();
     $customLists->activateVariableFields();
     $query = "SELECT * FROM @search {$whereCond}";
     if (!loadObjectsSql($customLists, $query, $customLists)) {
         $objs = array_merge($objs, $customLists);
     }
     foreach ($objs as $obj) {
         $vals = splitByCommas($obj->{$columnIndex}, FALSE);
         $map = array_flip($vals);
         foreach ($stack as $action) {
             if (isset($map[$action[1]])) {
                 // modositjuk, ha modify, uresre allitjuk, ha delete:
                 $vals[$map[$action[1]]] = $action[0] == 'modify' ? $action[2] : "";
             }
         }
         $obj->{$columnIndex} = array_filter($vals);
         // removes the empty values
         if (is_a($obj, "search")) {
             $obj->modify(TRUE);
         } else {
             modify($obj);
         }
     }
 }
Esempio n. 3
0
 function deleteColumn($field)
 {
     if ($field->isCommon) {
         $cidCond = "";
     } else {
         $cidCond = " AND cid=#cid#";
     }
     // ha nem common a custom field, amit torlunk, csak azoknak a custom listeknek az oszlopaibol kell torolni,
     // amik a field categoriajara specifikusak:
     $query = array("SELECT id, `columns`, cache FROM @search WHERE FIND_IN_SET(#id#, `columns`)!=0 {$cidCond}", "columns", $field->id, "columns", $field->cid);
     loadObjectsSql($lists = new CustomList(), $query, $lists);
     foreach ($lists as $l) {
         $f = preg_replace("{(,)?\\b{$this->id}\\b(?(1)|(,|\$))}", "", $l->columns);
         executeQuery(array("UPDATE @search SET `columns`=#f# WHERE id=#id#", "columns", $f, $l->id));
         if ($l->cache) {
             CacheManager::resetCache($l->id, TRUE, FALSE);
         }
     }
     $query = array("SELECT *, '' AS str FROM @search WHERE query LIKE '%{$field->columnIndex}%' {$cidCond}", $field->cid);
     $lists = new CustomList();
     $lists->cid = $field->cid;
     $lists->activateVariableFields();
     loadObjectsSql($lists, $query, $lists);
     foreach ($lists as $l) {
         unset($l->{$field->columnIndex});
         $l->makeSearchQuery(TRUE);
         modify($l);
         if ($l->cache) {
             CacheManager::resetCache($l->id, TRUE, FALSE);
         }
     }
 }
Esempio n. 4
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];
 }