From 5aa4ef99adde24cb0bc709a7860ccca2e5e93c1b Mon Sep 17 00:00:00 2001 From: Shadez Date: Thu, 30 Dec 2010 15:05:12 +0800 Subject: [PATCH] [434] Properly handle some search filters --- includes/classes/class.items.php | 15 ++++++++++----- includes/classes/class.search.php | 14 +++++++++++--- includes/revision_nr.php | 4 ++-- sql/updates/armory_r434_armory_item_sources.sql | 4 ++++ 4 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 sql/updates/armory_r434_armory_item_sources.sql diff --git a/includes/classes/class.items.php b/includes/classes/class.items.php index 67dd1c7f7..1191968e6 100644 --- a/includes/classes/class.items.php +++ b/includes/classes/class.items.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release Candidate 1 - * @revision 433 + * @revision 434 * @copyright (c) 2009-2010 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -2582,13 +2582,18 @@ public function GenerateEnchantmentSpellData($spellID) { * @access public * @param string $key * @param string $row = 'type' + * @param string $type = null * @return int **/ - public function GetItemTypeInfo($key, $row = 'type') { - if($key == 'all' || ($row != 'type' && $row != 'subtype')) { - return false; + public function GetItemTypeInfo($key, $row = 'type', $type = null) { + if(($key == 'all' && $type == null) || (!in_array($row, array('type', 'subtype')))) { + return -1; + } + $info = $this->armory->aDB->selectCell("SELECT `%s` FROM `ARMORYDBPREFIX_item_sources` WHERE `key`='%s' LIMIT 1", $row, $key); + if(!$info) { + $info = $this->armory->aDB->selectCell("SELECT `%s` FROM `ARMORYDBPREFIX_item_sources` WHERE `key`='%s' LIMIT 1", $row, $type); } - return $this->armory->aDB->selectCell("SELECT `%s` FROM `ARMORYDBPREFIX_item_sources` WHERE `key`='%s' LIMIT 1", $row, $key); + return $info; } /** diff --git a/includes/classes/class.search.php b/includes/classes/class.search.php index 47802ae28..0b57bbf9d 100644 --- a/includes/classes/class.search.php +++ b/includes/classes/class.search.php @@ -3,7 +3,7 @@ /** * @package World of Warcraft Armory * @version Release Candidate 1 - * @revision 433 + * @revision 434 * @copyright (c) 2009-2010 Shadez * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -832,8 +832,16 @@ private function HandleItemFilters($item_ids = null, $data = null) { if($this->get_array['type'] != 'all') { $type_info = Items::GetItemTypeInfo($this->get_array['type'], 'type'); } - if((isset($this->get_array['subTp'])) && $this->get_array['subTp'] != 'all') { - $subType_info = Items::GetItemTypeInfo($this->get_array['subTp'], 'subtype'); + if((isset($this->get_array['subTp']))) { + if($this->get_array['subTp'] != 'all') { + $subType_info = Items::GetItemTypeInfo($this->get_array['subTp'], 'subtype'); + } + elseif($this->get_array['subTp'] == 'all' && in_array($this->get_array['type'], array('mounts', 'minipets', 'misc', 'reagents'))) { + $subType_info = Items::GetItemTypeInfo($this->get_array['subTp'], 'subtype', $this->get_array['type']); + } + } + elseif(in_array($this->get_array['type'], array('mounts', 'minipets', 'misc', 'reagents'))) { + $subType_info = Items::GetItemTypeInfo('all', 'subtype', $this->get_array['type']); } if($type_info != -1 && $subType_info != -1) { $sql .= sprintf(" (`item_template`.`class`='%d' AND `item_template`.`subclass`='%d') AND", $type_info, $subType_info); diff --git a/includes/revision_nr.php b/includes/revision_nr.php index a15bddee6..25daedf6f 100644 --- a/includes/revision_nr.php +++ b/includes/revision_nr.php @@ -1,5 +1,5 @@ \ No newline at end of file diff --git a/sql/updates/armory_r434_armory_item_sources.sql b/sql/updates/armory_r434_armory_item_sources.sql new file mode 100644 index 000000000..a2ab0acb5 --- /dev/null +++ b/sql/updates/armory_r434_armory_item_sources.sql @@ -0,0 +1,4 @@ +UPDATE `armory_db_version` SET `version` = 'armory_r434'; +UPDATE `armory_item_sources` SET `type` = '15', `subtype` = '4' WHERE `key` = 'misc' LIMIT 1 ; +INSERT IGNORE INTO `armory_item_sources` ( `key` , `parent` , `item` , `type` , `subtype` ) VALUES ('reagents', '0', '0', '15', '1'); +INSERT IGNORE INTO `armory_item_sources` ( `key` , `parent` , `item` , `type` , `subtype` ) VALUES ('recipes', '0', '0', '9', '0'); \ No newline at end of file