public function buy(Flux_ItemShop $fromShop) { if (!$this->hasFunds()) { return false; } $successful = array(); foreach ($this->cart as $cartItem) { $successful[] = array('item' => $cartItem, 'name' => $cartItem->shop_item_name, 'cost' => $cartItem->shop_item_cost, 'quantity' => $cartItem->shop_item_qty, 'success' => $fromShop->buy($cartItem->shop_item_id)); } $this->clear(); return $successful; }
<?php if (!defined('FLUX_ROOT')) { exit; } $this->loginRequired(); $shopItemID = $params->get('id'); if (!$shopItemID) { $this->deny(); } require_once 'Flux/ItemShop.php'; $shop = new Flux_ItemShop($server); $shop->deleteShopItemImage($shopItemID); $session->setMessageData('Shop item image has been deleted.'); $this->redirect($this->referer);
$tempTable = new Flux_TemporaryTable($server->connection, $tableName, $fromTables); $shopTable = Flux::config('FluxTables.ItemShopTable'); $col = "id AS item_id, name_japanese AS item_name, type"; $sql = "SELECT {$col} FROM {$tableName} WHERE items.id = ?"; $sth = $server->connection->getStatement($sql); $sth->execute(array($itemID)); $item = $sth->fetch(); $stackable = false; if ($item && Flux::isStackableItemType($item->type)) { $stackable = true; } if ($item && count($_POST)) { $maxCost = (int) Flux::config('ItemShopMaxCost'); $maxQty = (int) Flux::config('ItemShopMaxQuantity'); $category = $params->get('category'); $shop = new Flux_ItemShop($server); $cost = (int) $params->get('cost'); $quantity = (int) $params->get('qty'); $info = trim(htmlspecialchars($params->get('info'))); $image = $files->get('image'); $useExisting = (int) $params->get('use_existing'); if (!$cost) { $errorMessage = 'You must input a credit cost greater than zero.'; } elseif ($cost > $maxCost) { $errorMessage = "The credit cost must not exceed {$maxCost}."; } elseif (!$quantity) { $errorMessage = 'You must input a quantity greater than zero.'; } elseif ($quantity > 1 && !$stackable) { $errorMessage = 'This item is not stackable. Quantity must be 1.'; } elseif ($quantity > $maxQty) { $errorMessage = "The item quantity must not exceed {$maxQty}.";
<?php if (!defined('FLUX_ROOT')) { exit; } $this->loginRequired(); $title = 'Modificar Item da Loja'; require_once 'Flux/TemporaryTable.php'; require_once 'Flux/ItemShop.php'; $stackable = false; $shopItemID = $params->get('id'); $shop = new Flux_ItemShop($server); $categories = Flux::config('ShopCategories')->toArray(); $item = $shop->getItem($shopItemID); if ($item) { $fromTables = array("{$server->charMapDatabase}.item_db", "{$server->charMapDatabase}.item_db2"); $tableName = "{$server->charMapDatabase}.items"; $tempTable = new Flux_TemporaryTable($server->connection, $tableName, $fromTables); $shopTable = Flux::config('FluxTables.ItemShopTable'); $col = "id AS item_id, name_japanese AS item_name, type"; $sql = "SELECT {$col} FROM {$tableName} WHERE items.id = ?"; $sth = $server->connection->getStatement($sql); $sth->execute(array($item->shop_item_nameid)); $originalItem = $sth->fetch(); if ($originalItem && Flux::isStackableItemType($originalItem->type)) { $stackable = true; } if (count($_POST)) { $maxCost = (int) Flux::config('ItemShopMaxCost'); $maxQty = (int) Flux::config('ItemShopMaxQuantity'); $category = $params->get('category');
<?php if (!defined('FLUX_ROOT')) { exit; } $this->loginRequired('Please log-in to add items to your cart.'); require_once 'Flux/ItemShop.php'; $id = $params->get('id'); $shop = new Flux_ItemShop($server); $item = $shop->getItem($id); if ($item) { $server->cart->add($item); $session->setMessageData("{$item->shop_item_name} has been added to your cart."); } else { $session->setMessageData("Couldn't add item to your cart."); } $action = $params->get('cart') ? 'cart' : 'index'; $this->redirect($this->url('purchase', $action));
<?php if (!defined('FLUX_ROOT')) { exit; } $this->loginRequired(); if (!$auth->allowedToDeleteShopItem) { $this->deny(); } require_once 'Flux/ItemShop.php'; $shop = new Flux_ItemShop($server); $shopItemID = $params->get('id'); $deleted = $shopItemID ? $shop->delete($shopItemID) : false; if ($deleted) { $session->setMessageData('Item successfully deleted from the item shop.'); $this->redirect($this->url('purchase')); }
<?php if (!defined('FLUX_ROOT')) { exit; } $title = 'Loja de Itens'; require_once 'Flux/ItemShop.php'; $category = $params->get('category'); $categories = Flux::config("ShopCategories")->toArray(); $categoryName = Flux::config("ShopCategories.{$category}"); $categoryCount = array(); $shop = new Flux_ItemShop($server); $items = $shop->getItems($category); $sql = sprintf("SELECT COUNT(id) AS total FROM %s.%s WHERE category = ?", $server->charMapDatabase, Flux::config('FluxTables.ItemShopTable')); $sql2 = sprintf("SELECT COUNT(id) AS total FROM %s.%s", $server->charMapDatabase, Flux::config('FluxTables.ItemShopTable')); $sth = $server->connection->getStatement($sql); $sth2 = $server->connection->getStatement($sql2); $sth2->execute(); $total = $sth2->fetch()->total; foreach ($categories as $catID => $catName) { $sth->execute(array($catID)); $categoryCount[$catID] = $sth->fetch()->total; }
<?php if (!defined('FLUX_ROOT')) { exit; } $title = 'Item Shop'; require_once 'Flux/ItemShop.php'; $category = $params->get('category'); $categories = Flux::config("ShopCategories")->toArray(); $categoryName = Flux::config("ShopCategories.{$category}"); $categoryCount = array(); $shop = new Flux_ItemShop($server); $sql = sprintf("SELECT COUNT(id) AS total FROM %s.%s WHERE category = ?", $server->charMapDatabase, Flux::config('FluxTables.ItemShopTable')); $sql2 = sprintf("SELECT COUNT(id) AS total FROM %s.%s", $server->charMapDatabase, Flux::config('FluxTables.ItemShopTable')); $sth = $server->connection->getStatement($sql); $sth2 = $server->connection->getStatement($sql2); $sth2->execute(); $total = $sth2->fetch()->total; foreach ($categories as $catID => $catName) { $sth->execute(array($catID)); $categoryCount[$catID] = $sth->fetch()->total; } $categoryTotal = isset($category) ? $categoryCount[$category] : $total; $perPage = Flux::config("ItemShopItemPerPage"); $paginator = $this->getPaginator($categoryTotal, array('perPage' => $perPage)); $items = $shop->getItems($paginator, $category);