function cloneCategory($category, $sortId = 0) { $id = $category->id; unset($category->id); unset($category->creationtime); unset($category->wholeName); unset($category->permaLink); $category->sortId = $sortId; $category->subCatNum = $category->directSubCatNum = $category->itemNum = $category->directItemNum = 0; if (!$this->withPictures) { $category->picture = ""; } $category->create(FALSE, TRUE); // fromClone=TRUE if ($this->withPictures && $category->picture) { copy(CAT_PIC_DIR . "/{$id}.{$category->picture}", CAT_PIC_DIR . "/{$category->id}.{$category->picture}"); } // Cloning the custom fields: G::load($fields, array("SELECT * FROM @customfield WHERE cid=#cid#", $id)); foreach ($fields as $field) { unset($field->id); $field->cid = $category->id; create($field); } if ($this->recursive) { G::load($subCats, array("SELECT * FROM @category WHERE up=#id#", $id)); foreach ($subCats as $sc) { $sc->up = $category->id; $this->cloneCategory($sc, $sc->sortId); } } }
function create() { global $gorumroll; $class = strstr($gorumroll->list, "user") ? "user" : "item"; $this->valid(); if (Roll::isFormInvalid()) { return; } if (!preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$/i', $this->youremail) || !preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$/i', $this->friendsemail)) { return Roll::setFormInvalid("invalidEmail"); } G::load($n, Notification_adToAFriend, "notification"); if ($n->active) { $obj = new $class(); $obj->id = $gorumroll->rollid; $obj->getEmailParams($params); $params["message"] = $this->mess; $params["name"] = $this->yourname; $sp = new SendingParameters(); $sp->to = $this->friendsemail; $sp->from = $this->youremail; $sp->replyTo = $this->youremail; $sp->replyToName = $this->yourname; $n->send($sp, $params); } //TODO: respnum increase Roll::setInfoText("mail_fr_sent_{$class}"); }
function delete() { parent::delete(); G::load($relatedFields, array("SELECT * FROM @customfield WHERE userField=#id#", $this->id)); foreach ($relatedFields as $f) { $f->delete(); } }
function executeCronJobs() { global $now; G::load($cronjobs, "SELECT * FROM @cronjob WHERE active='1' AND NOW()-INTERVAL frequency HOUR > lastExecutionTime"); foreach ($cronjobs as $cronjob) { eval($cronjob->function); $cronjob->lastExecutionTime = $now; modify($cronjob); } }
function cloneToSubcats(&$fields) { G::load($children, array("SELECT id FROM @category WHERE up=#cid#", $this->cid)); foreach ($children as $child) { $this->cid = $child->id; $this->deleteAll(TRUE); foreach ($fields as $field) { $field->cloneToCategory($this->cid); } $this->cloneToSubcats($fields); } }
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); }
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 ""; } }
function prepareCustomMetaTags($customAdMeta) { $_S =& new AppSettings(); $this->prepareVariableSubstitutionRules($patterns, $replacements); G::load($cat, $this->cid, "appcategory"); $patterns[] = "/{\\s*category:\\s*title\\s*}/i"; $replacements[] = htmlspecialchars(strip_tags(nl2br($cat->name))); $patterns[] = "/{\\s*category:\\s*description\\s*}/i"; $replacements[] = htmlspecialchars(strip_tags(nl2br($cat->descriptionMeta))); $patterns[] = "/{\\s*category:\\s*keywords\\s*}/i"; $replacements[] = htmlspecialchars(strip_tags(nl2br($cat->keywords))); $patterns[] = "/{\\s*site:\\s*title\\s*}/i"; $replacements[] = htmlspecialchars(strip_tags(nl2br($_S->mainTitle))); $patterns[] = "/{\\s*site:\\s*title\\s*prefix\\s*}/i"; $replacements[] = htmlspecialchars(strip_tags(nl2br($_S->titlePrefix))); $patterns[] = "/{\\s*site:\\s*description\\s*}/i"; $replacements[] = htmlspecialchars(strip_tags(nl2br($_S->mainDescription))); $patterns[] = "/{\\s*site:\\s*keywords\\s*}/i"; $replacements[] = htmlspecialchars(strip_tags(nl2br($_S->mainKeywords))); return preg_replace($patterns, $replacements, $customAdMeta); }
function updateItemTable() { global $thumbnailSizes; executeQueryForUpdate("\n ALTER TABLE @item \n DROP title, DROP picture, DROP keepPrivate,\n CHANGE `active` `status` INT NOT NULL DEFAULT 1, \n CHANGE `expirationTime` `expirationTime` DATETIME NOT NULL, \n CHANGE `creationtime` `creationtime` DATETIME NOT NULL;", __FILE__, __LINE__); executeQueryForUpdate("UPDATE @item SET `expirationTime`=0, expEmailSent=0", __FILE__, __LINE__); G::load($cats, "SELECT * FROM @category WHERE expiration!=0"); foreach ($cats as $cat) { executeQueryForUpdate("UPDATE @item SET `expirationTime`= NOW() + INTERVAL {$cat->expiration} DAY WHERE cid={$cat->id};", __FILE__, __LINE__); } CustomField::addCustomColumns("item"); G::load($items, "SELECT * FROM @item WHERE col_1!=''"); $create_fg = array("", "ImageCreateFromGIF", "ImageCreateFromJPEG", "ImageCreateFromPNG"); $save_fg = array("", "ImageGIF", "ImageJPEG", "ImagePNG"); $extensions = array("", "gif", "jpg", "png"); $checkBits = array(0, IMG_GIF, IMG_JPG, IMG_PNG); $memoryLimit = byteStr2num(ini_get('memory_limit')); foreach ($items as $item) { $ext = strstr($item->col_1, "jpg") ? "jpg" : (strstr($item->col_1, "gif") ? "gif" : (strstr($item->col_1, "png") ? "png" : "")); if (!$ext) { continue; } executeQueryForUpdate("UPDATE @item SET col_1='{$ext}' WHERE id={$item->id}", __FILE__, __LINE__); $fname = AD_PIC_DIR . "/{$item->id}.{$ext}"; if (file_exists($fname)) { @unlink(AD_PIC_DIR . "/th_{$item->id}.{$ext}"); // a regi thumbnailt toroljuk copy($fname, AD_PIC_DIR . "/{$item->id}_1.{$ext}"); // uj nev a full image-nek // mas fg-eket kell hivni az image tipusnak megfeleloen: $size = getimagesize($fname); $width = $size[0]; $height = $size[1]; $type = $size[2]; // az image tipus, 1=>GIF, 2=>JPG, 3=>PNG $ext = $extensions[$type]; $supported = FALSE; if (defined("IMG_GIF") && function_exists("ImageTypes")) { $supported = isset($checkBits[$type]) && ImageTypes() & $checkBits[$type]; } // ha az adott image tipus supportalva van: if ($supported) { foreach ($thumbnailSizes as $thSize => $dimensions) { if (function_exists('memory_get_usage') && $memoryLimit && $memoryLimit != -1) { $channels = isset($size['channels']) ? $size['channels'] : 1; // png has no channels $memoryNeeded = Round(($size[0] * $size[1] * $size['bits'] * $channels / 8 + Pow(2, 16)) * 1.65); $usage = memory_get_usage(); //FP::log("Current usage: $usage, limit: $memoryLimit, new to allocate: $memoryNeeded, rest after allocate: ". ($memoryLimit-$usage-$memoryNeeded)); // skipping if ImageCreate would exceed the memory limit: if ($usage + $memoryNeeded > $memoryLimit) { continue; } } shrinkPicture($newWidth, $newHeight, $dimensions["width"], $dimensions["height"], $fname); $src_im = $create_fg[$type]($fname); $dst_im = ImageCreateTrueColor($newWidth, $newHeight); imagecopyresampled($dst_im, $src_im, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height); $th_foname = AD_PIC_DIR . "/th_{$thSize}_{$item->id}_1.{$ext}"; // pictures/ads/th_medium_2345_5.jpg $save_fg[$type]($dst_im, $th_foname); imagedestroy($src_im); } } @unlink($fname); // a full image-et a regi neven toroljuk } } global $gorumuser, $gorumrecognised; $gorumrecognised = TRUE; $gorumuser->isAdm = 1; $c = new AppCategory(); $c->recalculateAllItemNums(TRUE); }
function getNavBarPieces() { global $lll, $gorumroll, $gorumcategory; $cid = !empty($this->cid) ? $this->cid : $gorumcategory; if ($gorumroll->method == "sortfield_form" && $gorumroll->rollid !== 0 || !empty($this->cid)) { G::load($cat, $cid, "appcategory"); $navBarPieces = $cat->getNavBarPieces(); } else { $navBarPieces = ControlPanel::getNavBarPieces(TRUE); } $label = $cid ? "itemfield_ttitle_simple" : "itemfield_ttitle_global"; if ($gorumroll->method == "sortfield_form") { $navBarPieces[$lll[$label]] = ""; } else { $navBarPieces[$lll[$label]] = new AppController("field/sortfield_form/{$this->cid}"); } return $navBarPieces; }
function iterateLargeDatabaseTable($query, $operation) { $blockSize = 100; $offset = 0; G::load($objs, $query . " LIMIT {$offset}, {$blockSize}"); while (count($objs)) { foreach ($objs as $obj) { if (is_array($operation)) { call_user_func($operation, $obj); } else { $operation($obj); } } $offset += $blockSize; G::load($objs, $query . " LIMIT {$offset}, {$blockSize}"); } }
function authenticate($fromLogin = FALSE) { global $gorumuser, $gorumroll, $gorumauthlevel, $gorumrecognised; global $autoLogout, $autoLogoutTime, $cookiePath, $testauth, $now; global $dontSetLastClickTime, $includeGuestsInCurrentlyOnline; if (!empty($_COOKIE["sessionUserId"]) && !empty($_COOKIE["usrPassword"])) { if (!G::load($gorumuser, $_COOKIE["sessionUserId"], "user")) { if ($_COOKIE["usrPassword"] && $gorumuser->password == $_COOKIE["usrPassword"]) { $expired = $fromLogin ? FALSE : timeoutExpired(); if (!$expired) { $gorumauthlevel = Loginlib_LowLevel; $gorumrecognised = TRUE; if (!isset($dontSetLastClickTime)) { $gorumuser->lastClickTime = $now; executeQuery(array("UPDATE @user SET lastClickTime=#lct# WHERE id=#id#", $now->getDbFormat(), $gorumuser->id)); } } return; } } } if (!empty($_COOKIE["globalUserId"])) { if (!G::load($gorumuser, $_COOKIE["globalUserId"], "user")) { if ($gorumuser->id == $gorumuser->name || isset($_COOKIE["usrPassword"]) && $gorumuser->password == $_COOKIE["usrPassword"]) { if ($gorumuser->id == $gorumuser->name) { $gorumauthlevel = Loginlib_GuestLevel; $gorumrecognised = FALSE; if (isset($includeGuestsInCurrentlyOnline) && !isset($dontSetLastClickTime)) { executeQuery(array("UPDATE @user SET lastClickTime=#lct# WHERE id=#id#", $now->getDbFormat(), $gorumuser->id)); } } else { $gorumauthlevel = Loginlib_BasicLevel; $gorumrecognised = !empty($gorumuser->rememberPassword); // Ez a feltetel csak akkor aktualizalja a // lastClickTime-ot, ha a user recognised. Ez igy jo // is, csak az a problema, hogy akkor a // currentlyOnline sorban nem tudnak meg guest-kent // se szerepelni azok a juzerek, akik azonositottak, // de nem recognised-ok: if (($gorumrecognised || isset($includeGuestsInCurrentlyOnline)) && !isset($dontSetLastClickTime)) { executeQuery(array("UPDATE @user SET lastClickTime=#lct# WHERE id=#id#", $now->getDbFormat(), $gorumuser->id)); } } return; } } else { $gorumauthlevel = Loginlib_GuestLevel; //than create without name $gorumuser->init(array("id" => $gorumuser->id, "name" => $gorumuser->id)); // azert csinaljuk igy, hogy a valid ne hivodjon: executeQuery("INSERT INTO @user SET id=#id#, name=#name#", $gorumuser->id, $gorumuser->id); if (isset($includeGuestsInCurrentlyOnline)) { $gorumuser->lastClickTime = $now; executeQuery("UPDATE @user SET lastClickTime=#lc# WHERE id=#id#", $now->getDbFormat(), $gorumuser->id); } // azert hogy az isAdm es hasonlok is ki legyenek toltve: load($gorumuser); if (isset($_COOKIE["usrPassword"])) { setcookie("usrPassword", "", Loginlib_ExpirationDate, $cookiePath); } $gorumrecognised = FALSE; return; } } $gorumauthlevel = Loginlib_NewUser; $gorumrecognised = FALSE; generateRandomId($randomId); $gorumuser = new User(); $gorumuser->isAdm = FALSE; $gorumuser->isMod = FALSE; $gorumuser->id = $randomId; $gorumuser->name = $randomId; //: Note: The sideeffect of this function is that it tries to set //: the GlobalUserId cookie if the level of authentication //: has proved to be NewUser. setcookie("globalUserId", $randomId, Loginlib_ExpirationDate, $cookiePath); }
function init($queryString) { global $allowedMethods; $_S =& new AppSettings(); if (!count($queryPieces = AppController::getQueryPieces($queryString))) { $_GS =& new GlobalStat(); if ($_GS->defPageConf) { $this->Controller("checkconf", "show"); } elseif (!empty($_S->homeLocation) && $_S->homeLocation != "/") { $this->Controller($_S->homeLocation); } else { $this->Controller("appcategory", "showhtmllist", 0); } // default application home } elseif (is_numeric($queryPieces[0])) { // Pl: /123 /123/attr1/val1/attr2/val2 $this->Controller("item", "showdetails", array_shift($queryPieces), $queryPieces); } elseif ($queryPieces[0] == "list") { array_shift($queryPieces); if (is_numeric($queryPieces[0]) || $queryPieces[0] == '*') { // Pl: /list/23 /list/23/attr1/val1/attr2/val2 // ha nincs ilyen category id, de van olyan user, aminek ez a neve: if (G::load($obj, $queryPieces[0], "appcategory") && !loadSQL($obj = new User(), array("SELECT id FROM @user WHERE name=#name# LIMIT 1", $queryPieces[0]))) { $this->Controller("item_my", "showhtmllist", array_shift($queryPieces), $queryPieces); } else { $this->Controller("appcategory", "showhtmllist", array_shift($queryPieces), $queryPieces); } } else { // Egy user osszes iteme: Pl: /list/henry $this->Controller("item_my", "showhtmllist", urldecode(array_shift($queryPieces)), $queryPieces); } } elseif ($queryPieces[0] == "rss") { // Pl: /rss/category/10/latest/20/days/3 array_shift($queryPieces); if ($queryPieces[0] == "modify_form") { $this->Controller("rss", "modify_form", "1"); } else { $this->Controller("rss", "get", "0", $queryPieces); } } elseif (count($queryPieces) == 1) { if ($queryPieces[0] == "control_panel") { $this->Controller("controlpanel", "showhtmllist"); } elseif ($queryPieces[0] == "purchaseitem" && class_exists("purchaseitem")) { $this->Controller("purchaseitem", "showhtmllist"); } elseif (!$_S->permaLinksEnabled() || !$this->validPermaLink($queryPieces)) { $this->Controller("staticpage", "show", $queryPieces[0]); // Pl: /faqpage $template = "{$queryPieces['0']}.tpl.php"; if (!file_exists(GORUM_TEMPLATE_DIR . "/{$template}") && !file_exists(TEMPLATE_DIR . "/{$template}") && !file_exists(COMMON_TEMPLATES . "/{$template}")) { return Roll::setFormInvalid("nonExistentStaticPage", $queryPieces[0]); } } } elseif (is_numeric($queryPieces[1]) || $queryPieces[1] == '*') { // Pl: /item/123 /item/123/attr1/val1/attr2/val2 $this->Controller(array_shift($queryPieces), "showdetails", array_shift($queryPieces), $queryPieces); } elseif ($_S->permaLinksEnabled() && !$this->isExistingMethod($queryPieces[1])) { if (!$this->validPermaLink($queryPieces)) { trigger_error("Invalid query string: {$queryString}", E_USER_ERROR); return Roll::setFormInvalid("invalidInternalLink", $queryString); } } elseif (count($queryPieces) == 2) { // Pl: /user/create_form/ $this->Controller(array_shift($queryPieces), array_shift($queryPieces), 0); } elseif (count($queryPieces) >= 3) { if ($queryPieces[2] == "off") { $this->Controller(array_shift($queryPieces), array_shift($queryPieces), 0, $queryPieces); } else { $this->Controller(array_shift($queryPieces), array_shift($queryPieces), array_shift($queryPieces), $queryPieces); } } else { trigger_error("Invalid query string: {$queryString}", E_USER_ERROR); return Roll::setFormInvalid("invalidInternalLink", $queryString); } return TRUE; }
function setupCustomListAppearance($elementName) { global $lll, $item_typ, $jQueryLib, $curvyCorners, $gorumroll; // ha tobb item list is van egy oldalon, mindegyiknek teljesen kulonbozo typeinfo-ja lehet: include "item_typ.php"; // resetting $item_typ CustomField::addCustomColumns("item"); $lll["item_search_ttitle"] = htmlspecialchars($this->listTitle); $columns = $gorumroll->list == "export" ? $this->exportFields : $this->columns; G::load($columns, "SELECT * FROM @itemfield WHERE FIND_IN_SET(id, '{$columns}')!=0"); $item = new Item(); $item_typ["listOrder"] = array(); foreach (explode(",", $this->columns) as $id) { for ($i = 0; $i < count($columns); $i++) { if ($columns[$i]->id == $id) { $columns[$i]->showInList = 1; if (!$columns[$i]->customListPlacement) { $item_typ["listOrder"][] = $columns[$i]->columnIndex; } $item_typ["attributes"][$columns[$i]->columnIndex][] = "list"; if ($columns[$i]->customListPlacement) { $item_typ["attributes"][$columns[$i]->columnIndex][] = "customListPlacement"; } break; } } } $item->fields =& $columns; $item->cid = $this->cid; $item->activateVariableFields(); $item->fields = 0; CustomList::getSortingSql($this->primarySort, $this->primaryDir, $this->primaryPersistent, $this->secondarySort, $this->secondaryDir, $this->secondaryPersistent); if ($specialSortAttrs = $item->getSpecialSortAttrs($this->cid ? 0 : 1, $this->cid)) { $this->query = str_replace("n.*", "n.* {$specialSortAttrs}", $this->query); } if ($this->limit) { $item_typ["limit"] = $this->limit; } if ($this->listStyle != customlist_scrollable && $gorumroll->list != "export") { $_S =& new AppSettings(); if ($this->customAdListTemplate) { $item_typ["listTemplate"] = $this->customAdListTemplate; } elseif ($_S->customAdListTemplate) { $item_typ["listTemplate"] = $_S->customAdListTemplate; } } //var_dump($item_typ); if ($this->listStyle == customlist_scrollable && $gorumroll->list != "export") { // Neheny szajton, az orientattiont egyszeruen nem tudtam a typeInfoban atvinni a // item_scrollablepresentationbe - kenytelen voltan globalba tenni: global $scrollablePlacement, $orientation; if (!isset($item_typ["listTemplate"])) { $item_typ["listTemplate"] = "scrollable_widget.tpl.php"; } $item_typ["listPresentationClassName"] = "ItemScrollablePresentation"; $params = ""; $scrollablePlacement = $elementName; if ($elementName == "customListLeft" || $elementName == "customListRight") { $item_typ["scrollableOrientation"] = $orientation = "vertical"; $scrollableParams = "vertical: true"; } else { $scrollableParams = "vertical: false"; $item_typ["scrollableOrientation"] = $orientation = "horizontal"; } if ($this->loop) { $scrollableParams .= ", loop: true"; } include_once NOAH_APP . "/item_scrollablepresentation.php"; JavaScript::addInclude(GORUM_JS_DIR . $jQueryLib); JavaScript::addInclude(GORUM_JS_DIR . "/jquery/jquery.dimensions.js"); JavaScript::addInclude(GORUM_JS_DIR . "/jquery/jquery.center.js"); JavaScript::addInclude(GORUM_JS_DIR . "/jquery/jquery.scrollable.js"); JavaScript::addInclude(GORUM_JS_DIR . "/jquery/jquery.em.js"); JavaScript::addInclude(GORUM_JS_DIR . "/jquery/jquery.jscrollpane.js"); JavaScript::addInclude(JS_DIR . "/scrollable.js"); JavaScript::addCss(CSS_DIR . "/scrollable.css"); JavaScript::addCss(GORUM_JS_DIR . "/jquery/jscrollpane.css"); JavaScript::addOnload("\$.noah.globalScrollableOnLoad();", "scrollable"); JavaScript::addOnload("\$.noah.scrollableOnLoad(" . G::js($this->id, $elementName, $scrollableParams) . ");"); if ($this->autoScroll) { JavaScript::addOnload("\$.noah.autoscrollOnLoad(" . G::js($this->id, $elementName, $this->autoScroll) . ");"); } } }
function populateFullCategoryTree() { global $categoryTreeFormat, $categoryTreeMainClass, $categoryTreeMainTag, $categoryTreeActiveNodeClass, $categoryTreeParentNodeClass, $categoryTreeLeafNodeClass, $categoryTreeWithLinks; $attrs = "id, name, up, sortId, wholeName, itemNum, permaLink, subCatNum"; if ($categoryTreeFormat == "single_array") { $item = new Item(); $categories = $item->getSelectFromTree(FALSE, TRUE, $attrs); } else { $query = "SELECT {$attrs} FROM @category WHERE up=0 ORDER BY sortId ASC"; G::load($mainCats, $query); $cat = new AppCategory(); $categories =& $cat->getCategoryTree($mainCats, $attrs, FALSE); if ($categoryTreeFormat == "html") { $categories = $cat->getHtmlTree($categories, $categoryTreeMainTag, $categoryTreeMainClass, $categoryTreeActiveNodeClass, $categoryTreeWithLinks); } } View::assign("fullCategoryTree", $categories); }
function decreaseItemNum($mennyivel = 1) { $this->itemNum -= $mennyivel; modify($this); if ($this->up) { G::load($father, $this->up, "appcategory"); $father->decreaseItemNum($mennyivel); // rekurziv } }
function deleteFromOtherAttr($values) { if (is_array($values)) { $values = implode(",", $values); } $query = "SELECT id, {$this->otherAttr} FROM @{$this->otherTable} WHERE FIND_IN_SET(id, '{$values}')!=0"; G::load($otherObjects, $query); foreach ($otherObjects as $s) { $f = preg_replace("{(,)?\\b" . $this->thisObj->id . "\\b(?(1)|(,|\$))}", "", $s->{$this->otherAttr}); executeQuery("UPDATE @{$this->otherTable} SET {$this->otherAttr}='{$f}' WHERE id={$s->id}"); } }
function showDetailsLink($id, $name, $class, $objName = "") { if (empty($this->{$name})) { if ($this->{$id}) { if (G::load($obj, $this->{$id}, $class)) { return "Not exists"; } else { $this->{$name} = $obj->{$objName}; } } else { return "None"; } } $ctrl =& new AppController($class, "showdetails", $this->{$id}); return $ctrl->generAnchor($this->{$name}); }
function assignCurrentUserFields() { global $gorumuser, $gorumrecognised; if ($gorumrecognised) { $user = User::createObject(); $user->activateVariableFields(); G::load($user, $gorumuser->id, "user"); View::assign("loggedIn", 1); $userArr = array(); foreach ($user->getFields() as $field) { if (!isset($user->{$field->columnIndex}) || in_array($field->columnIndex, array("password", "passwordCopy", "newPassword", "rememberPassword", "remindPasswordLink"))) { continue; } elseif ($field->columnIndex == "name" || $field->columnIndex == "email") { $userArr[$field->columnIndex . "Link"] = $user->showListVal($field->columnIndex, "", TRUE); $userArr[$field->columnIndex] = $userArr[$field->name] = htmlspecialchars($user->{$field->columnIndex}); } elseif ($field->type == customfield_picture) { $userArr[$field->name] = $userArr[$field->columnIndex] = $user->{$field->columnIndex} ? $user->showListVal($field->columnIndex, "", FALSE) : ""; } elseif ($field->type != customfield_separator) { $userArr[$field->name] = $user->{$field->columnIndex} = $user->showListVal($field->columnIndex, "", TRUE); } } View::assign("isAdmin", $user->isAdm); View::assign("currentUser", $userArr); } else { View::assign("loggedIn", 0); View::assign("isAdmin", 0); View::assign("currentUser", 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); } } }
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 ""; } }