function vault_tab_get($guild_id, $slot) { $item = VaultItem::fetchOneItem($guild_id, $slot); if ($item) { return new VaultTab($item->data); } else { return null; } }
function search($search, $limit = 10, $page = 0) { global $roster; include_once $this->data['inc_dir'] . 'vault_item.php'; // Get all the vault page names first $sql = "SELECT `guild_id`, `item_slot`, `item_name`, `item_texture` FROM `" . $roster->db->table('addons_vault_items') . "` WHERE `item_parent` = 'vault';"; $result = $roster->db->query($sql); $x = $roster->db->num_rows($result); $tab_name = array(); while ($x > 0) { $row = $roster->db->fetch($result); $tab_name[$row['guild_id']][$row['item_slot']] = array('name' => $row['item_name'], 'icon' => $row['item_texture']); $x--; } $roster->db->free_result($result); // Search the items $first = $page * $limit; $sql = "SELECT *, SUM(item_quantity) AS total_quantity" . " FROM `" . $roster->db->table('addons_vault_items') . "`" . " WHERE (`item_parent` LIKE 'Tab%') AND (`item_name` LIKE '%{$search}%' OR `item_tooltip` LIKE '%{$search}%')" . ($this->minlvl != '' ? " AND `level` >= '{$this->minlvl}'" : '') . ($this->maxlvl != '' ? " AND `level` <= '{$this->maxlvl}'" : '') . $this->quality_sql . " GROUP BY `item_name`" . ($limit > 0 ? " LIMIT {$first}," . $limit : '') . ';'; // calculating the search time $this->start_search = format_microtime(); $result = $roster->db->query($sql); $this->stop_search = format_microtime(); $this->time_search = $this->stop_search - $this->start_search; $nrows = $roster->db->num_rows($result); $x = $limit > $nrows ? $nrows : ($limit > 0 ? $limit : $nrows); if ($nrows > 0 && $limit > 0) { while ($x > 0) { $row = $roster->db->fetch($result); $row['item_quantity'] = $row['total_quantity']; // Totals quantity, found on all pages $icon = new VaultItem($row, false); $item['html'] = '<td class="SearchRowCell">' . $icon->out(true) . '</td>' . '<td class="SearchRowCell">' . $icon->requires_level . '</td>' . '<td class="SearchRowCell"><span style="color:#' . $icon->color . '">[' . $icon->name . ']</span></td>' . '<td class="SearchRowCellRight"><a href="' . makelink('guild-vault&a=g:' . $row['guild_id']) . '">' . '<span class="item-sm">' . '<img src="' . $roster->config['interface_url'] . 'Interface/Icons/' . $tab_name[$row['guild_id']][$row['item_parent']]['icon'] . '.' . $roster->config['img_suffix'] . '" alt="" />' . '<span class="mask none"></span></span> ' . $tab_name[$row['guild_id']][$row['item_parent']]['name'] . '</a></td>'; $this->add_result($item); unset($item); $x--; } } else { $this->result_count = $nrows; } $roster->db->free_result($result); }