diff --git a/includes/ajaxHandler/admin.class.php b/includes/ajaxHandler/admin.class.php index 7fe2e782..9d176dca 100644 --- a/includes/ajaxHandler/admin.class.php +++ b/includes/ajaxHandler/admin.class.php @@ -128,7 +128,7 @@ class AjaxAdmin extends AjaxHandler foreach ($this->_get['id'] as $id) { // must not be already approved - if ($_ = DB::Aowow()->selectRow('SELECT userIdOwner, date FROM ?_screenshots WHERE (status & ?d) = 0 AND id = ?d', CC_FLAG_APPROVED, $id)) + if ($_ = DB::Aowow()->selectRow('SELECT userIdOwner, date, type, typeId FROM ?_screenshots WHERE (status & ?d) = 0 AND id = ?d', CC_FLAG_APPROVED, $id)) { // should also error-log if (!file_exists(sprintf($path, 'pending', $id))) @@ -171,6 +171,9 @@ class AjaxAdmin extends AjaxHandler // set as approved in DB and gain rep (once!) DB::Aowow()->query('UPDATE ?_screenshots SET status = ?d, userIdApprove = ?d WHERE id = ?d', CC_FLAG_APPROVED, User::$id, $id); Util::gainSiteReputation($_['userIdOwner'], SITEREP_ACTION_UPLOAD, ['id' => $id, 'what' => 1, 'date' => $_['date']]); + // flag DB entry as having screenshots + if (Util::$typeClasses[$_['type']] && ($tbl = (new Util::$typeClasses[$_['type']])::$dataTable)) + DB::Aowow()->query('UPDATE '.$tbl.' SET cuFlags = cuFlags | ?d WHERE id = ?d', CUSTOM_HAS_SCREENSHOT, $_['typeId']); } } @@ -237,7 +240,16 @@ class AjaxAdmin extends AjaxHandler } // flag as deleted if not aready + $oldEntries = DB::Aowow()->selectCol('SELECT `type` AS ARRAY_KEY, GROUP_CONCAT(typeId) FROM ?_screenshots WHERE id IN (?a) GROUP BY `type`', $this->_get['id']); DB::Aowow()->query('UPDATE ?_screenshots SET status = ?d, userIdDelete = ?d WHERE id IN (?a)', CC_FLAG_DELETED, User::$id, $this->_get['id']); + // deflag db entry as having screenshots + foreach ($oldEntries as $type => $typeIds) + { + $typeIds = explode(',', $typeIds); + $toUnflag = DB::Aowow()->selectCol('SELECT typeId AS ARRAY_KEY, IF(BIT_OR(`status`) & ?d, 1, 0) AS hasMore FROM ?_screenshots WHERE `type` = ?d AND typeId IN (?a) GROUP BY typeId HAVING hasMore = 0', CC_FLAG_APPROVED, $type, $typeIds); + if ($toUnflag && Util::$typeClasses[$type] && ($tbl = (new Util::$typeClasses[$type])::$dataTable)) + DB::Aowow()->query('UPDATE '.$tbl.' SET cuFlags = cuFlags & ~?d WHERE id IN (?a)', CUSTOM_HAS_SCREENSHOT, array_keys($toUnflag)); + } return ''; } @@ -249,11 +261,24 @@ class AjaxAdmin extends AjaxHandler if (!$this->_get['id'] || !$this->_get['typeid']) return ''; - $type = DB::Aowow()->selectCell('SELECT type FROM ?_screenshots WHERE id = ?d', $this->_get['id']); - $typeId = (int)$this->_get['typeid']; + $id = $this->_get['id'][0]; + list($type, $oldTypeId) = array_values(DB::Aowow()->selectRow('SELECT type, typeId FROM ?_screenshots WHERE id = ?d', $id)); + $typeId = (int)$this->_get['typeid']; - if (!(new Util::$typeClasses[$type]([['id', $typeId]]))->error) - DB::Aowow()->query('UPDATE ?_screenshots SET typeId = ?d WHERE id = ?d', $typeId, $this->_get['id'][0]); + $tc = new Util::$typeClasses[$type]([['id', $typeId]]); + if (!$tc->error) + { + // move screenshot + DB::Aowow()->query('UPDATE ?_screenshots SET typeId = ?d WHERE id = ?d', $typeId, $id); + + // flag target as having screenshot + DB::Aowow()->query('UPDATE '.$tc::$dataTable.' SET cuFlags = cuFlags | ?d WHERE id = ?d', CUSTOM_HAS_SCREENSHOT, $typeId); + + // deflag source for having had screenshots (maybe) + $ssInfo = DB::Aowow()->selectRow('SELECT IF(BIT_OR(~status) & ?d, 1, 0) AS hasMore FROM ?_screenshots WHERE `status`& ?d AND `type` = ?d AND typeId = ?d', CC_FLAG_DELETED, CC_FLAG_APPROVED, $type, $oldTypeId); + if($ssInfo || !$ssInfo['hasMore']) + DB::Aowow()->query('UPDATE '.$tc::$dataTable.' SET cuFlags = cuFlags & ~?d WHERE id = ?d', CUSTOM_HAS_SCREENSHOT, $oldTypeId); + } return ''; } diff --git a/includes/ajaxHandler/comment.class.php b/includes/ajaxHandler/comment.class.php index 405cf0d4..2e43250a 100644 --- a/includes/ajaxHandler/comment.class.php +++ b/includes/ajaxHandler/comment.class.php @@ -92,8 +92,8 @@ class AjaxComment extends AjaxHandler // every comment starts with a rating of +1 and i guess the simplest thing to do is create a db-entry with the system as owner DB::Aowow()->query('INSERT INTO ?_comments_rates (commentId, userId, value) VALUES (?d, 0, 1)', $postIdx); - // flag target with hasComment (if filtrable) - if ($tbl = Util::getCCTableParent($this->_get['type'])) + // flag target with hasComment + if (Util::$typeClasses[$this->_get['type']] && ($tbl = (new Util::$typeClasses[$this->_get['type']])::$dataTable)) DB::Aowow()->query('UPDATE '.$tbl.' SET cuFlags = cuFlags | ?d WHERE id = ?d', CUSTOM_HAS_COMMENT, $this->_get['typeid']); } } @@ -143,7 +143,7 @@ class AjaxComment extends AjaxHandler User::isInGroup(U_GROUP_MODERATOR) ? DBSIMPLE_SKIP : User::$id ); - // deflag hasComment (if filtrable) + // deflag hasComment if ($ok) { $coInfo = DB::Aowow()->selectRow('SELECT IF(BIT_OR(~b.flags) & ?d, 1, 0) as hasMore, b.type, b.typeId FROM ?_comments a JOIN ?_comments b ON a.type = b.type AND a.typeId = b.typeId WHERE a.id = ?d', @@ -151,7 +151,7 @@ class AjaxComment extends AjaxHandler $this->_post['id'] ); - if (!$coInfo['hasMore'] && ($tbl = Util::getCCTableParent($coInfo['type']))) + if (!$coInfo['hasMore'] && Util::$typeClasses[$coInfo['type']] && ($tbl = (new Util::$typeClasses[$coInfo['type']])::$dataTable)) DB::Aowow()->query('UPDATE '.$tbl.' SET cuFlags = cuFlags & ~?d WHERE id = ?d', CUSTOM_HAS_COMMENT, $coInfo['typeId']); } } @@ -168,11 +168,11 @@ class AjaxComment extends AjaxHandler User::isInGroup(U_GROUP_MODERATOR) ? DBSIMPLE_SKIP : User::$id ); - // reflag hasComment (if filtrable) + // reflag hasComment if ($ok) { $coInfo = DB::Aowow()->selectRow('SELECT type, typeId FROM ?_comments WHERE id = ?d', $this->_post['id']); - if ($tbl = Util::getCCTableParent($coInfo['type'])) + if (Util::$typeClasses[$coInfo['type']] && ($tbl = (new Util::$typeClasses[$coInfo['type']])::$dataTable)) DB::Aowow()->query('UPDATE '.$tbl.' SET cuFlags = cuFlags | ?d WHERE id = ?d', CUSTOM_HAS_COMMENT, $coInfo['typeId']); } } diff --git a/includes/basetype.class.php b/includes/basetype.class.php index ab50fa65..b3decd1e 100644 --- a/includes/basetype.class.php +++ b/includes/basetype.class.php @@ -50,14 +50,14 @@ abstract class BaseType * results in * WHERE ((`id` = 45) OR (`name` NOT LIKE "test%") OR ((`flags` & 255) AND (`flags2` & 15)) OR ((`mask` & 3) = 0)) OR (`joinedTbl`.`field` IS NULL) LIMIT 5 */ - public function __construct($conditions = [], $miscData = null) + public function __construct(array $conditions = [], $miscData = null) { $where = []; $linking = ' AND '; $limit = CFG_SQL_LIMIT_DEFAULT; $className = get_class($this); - if (!$this->queryBase || $conditions === null) + if (!$this->queryBase || !$conditions) return; $prefixes = []; diff --git a/includes/types/achievement.class.php b/includes/types/achievement.class.php index c8803b3d..dfcb95c1 100644 --- a/includes/types/achievement.class.php +++ b/includes/types/achievement.class.php @@ -8,17 +8,18 @@ class AchievementList extends BaseType { use listviewHelper; - public static $type = TYPE_ACHIEVEMENT; - public static $brickFile = 'achievement'; + public static $type = TYPE_ACHIEVEMENT; + public static $brickFile = 'achievement'; + public static $dataTable = '?_achievement'; - public $criteria = []; + public $criteria = []; - protected $queryBase = 'SELECT `a`.*, `a`.`id` AS ARRAY_KEY FROM ?_achievement a'; - protected $queryOpts = array( - 'a' => [['si'], 'o' => 'orderInGroup ASC'], - 'si' => ['j' => ['?_icons si ON si.id = a.iconId', true], 's' => ', si.iconString'], - 'ac' => ['j' => ['?_achievementcriteria AS `ac` ON `ac`.`refAchievementId` = `a`.`id`', true], 'g' => '`a`.`id`'] - ); + protected $queryBase = 'SELECT `a`.*, `a`.`id` AS ARRAY_KEY FROM ?_achievement a'; + protected $queryOpts = array( + 'a' => [['si'], 'o' => 'orderInGroup ASC'], + 'si' => ['j' => ['?_icons si ON si.id = a.iconId', true], 's' => ', si.iconString'], + 'ac' => ['j' => ['?_achievementcriteria AS `ac` ON `ac`.`refAchievementId` = `a`.`id`', true], 'g' => '`a`.`id`'] + ); /* todo: evaluate TC custom-data-tables: a*_criteria_data should be merged on installation diff --git a/includes/types/charclass.class.php b/includes/types/charclass.class.php index f4be8771..a3d574f0 100644 --- a/includes/types/charclass.class.php +++ b/includes/types/charclass.class.php @@ -6,10 +6,11 @@ if (!defined('AOWOW_REVISION')) class CharClassList extends BaseType { - public static $type = TYPE_CLASS; - public static $brickFile = 'class'; + public static $type = TYPE_CLASS; + public static $brickFile = 'class'; + public static $dataTable = '?_classes'; - protected $queryBase = 'SELECT *, id AS ARRAY_KEY FROM ?_classes c'; + protected $queryBase = 'SELECT *, id AS ARRAY_KEY FROM ?_classes c'; public function __construct($conditions = []) { diff --git a/includes/types/charrace.class.php b/includes/types/charrace.class.php index 57d2ab62..9fcfd4c5 100644 --- a/includes/types/charrace.class.php +++ b/includes/types/charrace.class.php @@ -6,10 +6,11 @@ if (!defined('AOWOW_REVISION')) class CharRaceList extends BaseType { - public static $type = TYPE_RACE; - public static $brickFile = 'race'; + public static $type = TYPE_RACE; + public static $brickFile = 'race'; + public static $dataTable = '?_races'; - protected $queryBase = 'SELECT *, id AS ARRAY_KEY FROM ?_races r'; + protected $queryBase = 'SELECT *, id AS ARRAY_KEY FROM ?_races r'; public function getListviewData() { diff --git a/includes/types/creature.class.php b/includes/types/creature.class.php index 8349f3ec..738a0a76 100644 --- a/includes/types/creature.class.php +++ b/includes/types/creature.class.php @@ -8,11 +8,12 @@ class CreatureList extends BaseType { use spawnHelper; - public static $type = TYPE_NPC; - public static $brickFile = 'creature'; + public static $type = TYPE_NPC; + public static $brickFile = 'creature'; + public static $dataTable = '?_creature'; - protected $queryBase = 'SELECT ct.*, ct.id AS ARRAY_KEY FROM ?_creature ct'; - public $queryOpts = array( + protected $queryBase = 'SELECT ct.*, ct.id AS ARRAY_KEY FROM ?_creature ct'; + public $queryOpts = array( 'ct' => [['ft', 'qse', 'dct1', 'dct2', 'dct3'], 's' => ', IFNULL(dct1.id, IFNULL(dct2.id, IFNULL(dct3.id, 0))) AS parentId, IFNULL(dct1.name_loc0, IFNULL(dct2.name_loc0, IFNULL(dct3.name_loc0, ""))) AS parent_loc0, IFNULL(dct1.name_loc2, IFNULL(dct2.name_loc2, IFNULL(dct3.name_loc2, ""))) AS parent_loc2, IFNULL(dct1.name_loc3, IFNULL(dct2.name_loc3, IFNULL(dct3.name_loc3, ""))) AS parent_loc3, IFNULL(dct1.name_loc6, IFNULL(dct2.name_loc6, IFNULL(dct3.name_loc6, ""))) AS parent_loc6, IFNULL(dct1.name_loc8, IFNULL(dct2.name_loc8, IFNULL(dct3.name_loc8, ""))) AS parent_loc8, IF(dct1.difficultyEntry1 = ct.id, 1, IF(dct2.difficultyEntry2 = ct.id, 2, IF(dct3.difficultyEntry3 = ct.id, 3, 0))) AS difficultyMode'], 'dct1' => ['j' => ['?_creature dct1 ON ct.cuFlags & 0x02 AND dct1.difficultyEntry1 = ct.id', true]], 'dct2' => ['j' => ['?_creature dct2 ON ct.cuFlags & 0x02 AND dct2.difficultyEntry2 = ct.id', true]], diff --git a/includes/types/currency.class.php b/includes/types/currency.class.php index 39700278..346c082d 100644 --- a/includes/types/currency.class.php +++ b/includes/types/currency.class.php @@ -6,14 +6,15 @@ if (!defined('AOWOW_REVISION')) class CurrencyList extends BaseType { - public static $type = TYPE_CURRENCY; - public static $brickFile = 'currency'; + public static $type = TYPE_CURRENCY; + public static $brickFile = 'currency'; + public static $dataTable = '?_currencies'; - protected $queryBase = 'SELECT *, c.id AS ARRAY_KEY FROM ?_currencies c'; - protected $queryOpts = array( - 'c' => [['ic']], - 'ic' => ['j' => ['?_icons ic ON ic.id = c.iconId', true], 's' => ', ic.iconString'] - ); + protected $queryBase = 'SELECT *, c.id AS ARRAY_KEY FROM ?_currencies c'; + protected $queryOpts = array( + 'c' => [['ic']], + 'ic' => ['j' => ['?_icons ic ON ic.id = c.iconId', true], 's' => ', ic.iconString'] + ); public function getListviewData() { diff --git a/includes/types/emote.class.php b/includes/types/emote.class.php index 674c1e2d..6739bc65 100644 --- a/includes/types/emote.class.php +++ b/includes/types/emote.class.php @@ -6,10 +6,11 @@ if (!defined('AOWOW_REVISION')) class EmoteList extends BaseType { - public static $type = TYPE_EMOTE; - public static $brickFile = 'emote'; + public static $type = TYPE_EMOTE; + public static $brickFile = 'emote'; + public static $dataTable = '?_emotes'; - protected $queryBase = 'SELECT *, e.id AS ARRAY_KEY FROM ?_emotes e'; + protected $queryBase = 'SELECT *, e.id AS ARRAY_KEY FROM ?_emotes e'; public function __construct($conditions = []) { diff --git a/includes/types/enchantment.class.php b/includes/types/enchantment.class.php index 5219b0b3..7002e4e4 100644 --- a/includes/types/enchantment.class.php +++ b/includes/types/enchantment.class.php @@ -8,18 +8,19 @@ class EnchantmentList extends BaseType { use listviewHelper; - public static $type = TYPE_ENCHANTMENT; - public static $brickFile = 'enchantment'; + public static $type = TYPE_ENCHANTMENT; + public static $brickFile = 'enchantment'; + public static $dataTable = '?_itemenchantment'; - private $jsonStats = []; - private $relSpells = []; - private $triggerIds = []; + private $jsonStats = []; + private $relSpells = []; + private $triggerIds = []; - protected $queryBase = 'SELECT ie.*, ie.id AS ARRAY_KEY FROM ?_itemenchantment ie'; - protected $queryOpts = array( // 502 => TYPE_ENCHANTMENT - 'ie' => [['is']], - 'is' => ['j' => ['?_item_stats `is` ON `is`.`type` = 502 AND `is`.`typeId` = `ie`.`id`', true], 's' => ', `is`.*'], - ); + protected $queryBase = 'SELECT ie.*, ie.id AS ARRAY_KEY FROM ?_itemenchantment ie'; + protected $queryOpts = array( // 502 => TYPE_ENCHANTMENT + 'ie' => [['is']], + 'is' => ['j' => ['?_item_stats `is` ON `is`.`type` = 502 AND `is`.`typeId` = `ie`.`id`', true], 's' => ', `is`.*'], + ); public function __construct($conditions = []) { diff --git a/includes/types/faction.class.php b/includes/types/faction.class.php index 9c0ef6ba..f327e95c 100644 --- a/includes/types/faction.class.php +++ b/includes/types/faction.class.php @@ -6,15 +6,16 @@ if (!defined('AOWOW_REVISION')) class FactionList extends BaseType { - public static $type = TYPE_FACTION; - public static $brickFile = 'faction'; + public static $type = TYPE_FACTION; + public static $brickFile = 'faction'; + public static $dataTable = '?_factions'; - protected $queryBase = 'SELECT f.*, f.parentFactionId AS cat, f.id AS ARRAY_KEY FROM ?_factions f'; - protected $queryOpts = array( - 'f' => [['f2']], - 'f2' => ['j' => ['?_factions f2 ON f.parentFactionId = f2.id', true], 's' => ', IFNULL(f2.parentFactionId, 0) AS cat2'], - 'ft' => ['j' => '?_factiontemplate ft ON ft.factionId = f.id'] - ); + protected $queryBase = 'SELECT f.*, f.parentFactionId AS cat, f.id AS ARRAY_KEY FROM ?_factions f'; + protected $queryOpts = array( + 'f' => [['f2']], + 'f2' => ['j' => ['?_factions f2 ON f.parentFactionId = f2.id', true], 's' => ', IFNULL(f2.parentFactionId, 0) AS cat2'], + 'ft' => ['j' => '?_factiontemplate ft ON ft.factionId = f.id'] + ); public function __construct($conditions = []) { diff --git a/includes/types/gameobject.class.php b/includes/types/gameobject.class.php index f1a12331..e6cf6bb2 100644 --- a/includes/types/gameobject.class.php +++ b/includes/types/gameobject.class.php @@ -8,11 +8,12 @@ class GameObjectList extends BaseType { use listviewHelper, spawnHelper; - public static $type = TYPE_OBJECT; - public static $brickFile = 'object'; + public static $type = TYPE_OBJECT; + public static $brickFile = 'object'; + public static $dataTable = '?_objects'; - protected $queryBase = 'SELECT o.*, o.id AS ARRAY_KEY FROM ?_objects o'; - protected $queryOpts = array( + protected $queryBase = 'SELECT o.*, o.id AS ARRAY_KEY FROM ?_objects o'; + protected $queryOpts = array( 'o' => [['ft', 'qse']], 'ft' => ['j' => ['?_factiontemplate ft ON ft.id = o.faction', true], 's' => ', ft.factionId, ft.A, ft.H'], 'qse' => ['j' => ['?_quests_startend qse ON qse.type = 2 AND qse.typeId = o.id', true], 's' => ', IF(min(qse.method) = 1 OR max(qse.method) = 3, 1, 0) AS startsQuests, IF(min(qse.method) = 2 OR max(qse.method) = 3, 1, 0) AS endsQuests', 'g' => 'o.id'], diff --git a/includes/types/item.class.php b/includes/types/item.class.php index c029a822..c274de14 100644 --- a/includes/types/item.class.php +++ b/includes/types/item.class.php @@ -8,30 +8,31 @@ class ItemList extends BaseType { use ListviewHelper; - public static $type = TYPE_ITEM; - public static $brickFile = 'item'; + public static $type = TYPE_ITEM; + public static $brickFile = 'item'; + public static $dataTable = '?_items'; - public $json = []; - public $itemMods = []; - public $sources = []; + public $json = []; + public $itemMods = []; + public $sources = []; - public $rndEnchIds = []; - public $subItems = []; + public $rndEnchIds = []; + public $subItems = []; - private $sourceMore = null; - private $ssd = []; - private $vendors = []; - private $jsGlobals = []; // getExtendedCost creates some and has no access to template + private $sourceMore = null; + private $ssd = []; + private $vendors = []; + private $jsGlobals = []; // getExtendedCost creates some and has no access to template - protected $queryBase = 'SELECT i.*, i.block AS tplBlock, i.id AS ARRAY_KEY, i.id AS id FROM ?_items i'; - protected $queryOpts = array( // 3 => TYPE_ITEM - 'i' => [['is', 'src', 'ic'], 'o' => 'i.quality DESC, i.itemLevel DESC'], - 'ic' => ['j' => ['?_icons `ic` ON `ic`.`id` = -`i`.`displayId`', true], 's' => ', ic.iconString'], - 'is' => ['j' => ['?_item_stats `is` ON `is`.`type` = 3 AND `is`.`typeId` = `i`.`id`', true], 's' => ', `is`.*'], - 's' => ['j' => ['?_spell `s` ON `s`.`effect1CreateItemId` = `i`.`id`', true], 'g' => 'i.id'], - 'e' => ['j' => ['?_events `e` ON `e`.`id` = `i`.`eventId`', true], 's' => ', e.holidayId'], - 'src' => ['j' => ['?_source `src` ON `src`.`type` = 3 AND `src`.`typeId` = `i`.`id`', true], 's' => ', moreType, moreTypeId, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10, src11, src12, src13, src14, src15, src16, src17, src18, src19, src20, src21, src22, src23, src24'] - ); + protected $queryBase = 'SELECT i.*, i.block AS tplBlock, i.id AS ARRAY_KEY, i.id AS id FROM ?_items i'; + protected $queryOpts = array( // 3 => TYPE_ITEM + 'i' => [['is', 'src', 'ic'], 'o' => 'i.quality DESC, i.itemLevel DESC'], + 'ic' => ['j' => ['?_icons `ic` ON `ic`.`id` = -`i`.`displayId`', true], 's' => ', ic.iconString'], + 'is' => ['j' => ['?_item_stats `is` ON `is`.`type` = 3 AND `is`.`typeId` = `i`.`id`', true], 's' => ', `is`.*'], + 's' => ['j' => ['?_spell `s` ON `s`.`effect1CreateItemId` = `i`.`id`', true], 'g' => 'i.id'], + 'e' => ['j' => ['?_events `e` ON `e`.`id` = `i`.`eventId`', true], 's' => ', e.holidayId'], + 'src' => ['j' => ['?_source `src` ON `src`.`type` = 3 AND `src`.`typeId` = `i`.`id`', true], 's' => ', moreType, moreTypeId, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10, src11, src12, src13, src14, src15, src16, src17, src18, src19, src20, src21, src22, src23, src24'] + ); public function __construct($conditions = [], $miscData = null) { @@ -1792,7 +1793,7 @@ class ItemListFilter extends Filter public function __construct() { - $classes = new CharClassList(); + $classes = new CharClassList([true]); foreach ($classes->iterate() as $cId => $_tpl) { // preselect misc subclasses diff --git a/includes/types/itemset.class.php b/includes/types/itemset.class.php index 689eb5e6..0653f14f 100644 --- a/includes/types/itemset.class.php +++ b/includes/types/itemset.class.php @@ -8,14 +8,15 @@ class ItemsetList extends BaseType { use ListviewHelper; - public static $type = TYPE_ITEMSET; - public static $brickFile = 'itemset'; + public static $type = TYPE_ITEMSET; + public static $brickFile = 'itemset'; + public static $dataTable = '?_itemset'; - public $pieceToSet = []; // used to build g_items and search - private $classes = []; // used to build g_classes + public $pieceToSet = []; // used to build g_items and search + private $classes = []; // used to build g_classes - protected $queryBase = 'SELECT `set`.*, `set`.id AS ARRAY_KEY FROM ?_itemset `set`'; - protected $queryOpts = array( + protected $queryBase = 'SELECT `set`.*, `set`.id AS ARRAY_KEY FROM ?_itemset `set`'; + protected $queryOpts = array( 'set' => ['o' => 'maxlevel DESC'], 'e' => ['j' => ['?_events e ON e.id = `set`.eventId', true], 's' => ', e.holidayId'] ); diff --git a/includes/types/pet.class.php b/includes/types/pet.class.php index 47ab9f92..d3a6cb70 100644 --- a/includes/types/pet.class.php +++ b/includes/types/pet.class.php @@ -8,10 +8,11 @@ class PetList extends BaseType { use ListviewHelper; - public static $type = TYPE_PET; - public static $brickFile = 'pet'; + public static $type = TYPE_PET; + public static $brickFile = 'pet'; + public static $dataTable = '?_pet'; - protected $queryBase = 'SELECT *, id AS ARRAY_KEY FROM ?_pet p'; + protected $queryBase = 'SELECT *, id AS ARRAY_KEY FROM ?_pet p'; public function getListviewData() { diff --git a/includes/types/profile.class.php b/includes/types/profile.class.php index a6a6da11..0730331a 100644 --- a/includes/types/profile.class.php +++ b/includes/types/profile.class.php @@ -9,11 +9,12 @@ if (!defined('AOWOW_REVISION')) // class ArenaTeamList extends BaseType class ProfileList extends BaseType { - public static $type = 0; // profiles dont actually have one - public static $brickFile = 'profile'; + public static $type = 0; // profiles dont actually have one + public static $brickFile = 'profile'; + public static $dataTable = ''; // doesn't have community content - protected $queryBase = ''; // SELECT p.*, p.id AS ARRAY_KEY FROM ?_profiles p'; - protected $queryOpts = array( + protected $queryBase = ''; // SELECT p.*, p.id AS ARRAY_KEY FROM ?_profiles p'; + protected $queryOpts = array( 'p' => [['pa', 'pg']], 'pam' => [['?_profiles_arenateam_member pam ON pam.memberId = p.id', true], 's' => ', pam.status'], 'pa' => ['?_profiles_arenateam pa ON pa.id = pam.teamId', 's' => ', pa.mode, pa.name'], diff --git a/includes/types/quest.class.php b/includes/types/quest.class.php index 018659ab..266c1c8f 100644 --- a/includes/types/quest.class.php +++ b/includes/types/quest.class.php @@ -8,6 +8,7 @@ class QuestList extends BaseType { public static $type = TYPE_QUEST; public static $brickFile = 'quest'; + public static $dataTable = '?_quests'; public $requires = []; public $rewards = []; diff --git a/includes/types/skill.class.php b/includes/types/skill.class.php index 2b2d0865..4b467a9f 100644 --- a/includes/types/skill.class.php +++ b/includes/types/skill.class.php @@ -8,6 +8,7 @@ class SkillList extends BaseType { public static $type = TYPE_SKILL; public static $brickFile = 'skill'; + public static $dataTable = '?_skillline'; protected $queryBase = 'SELECT *, sl.id AS ARRAY_KEY FROM ?_skillline sl'; protected $queryOpts = array( diff --git a/includes/types/spell.class.php b/includes/types/spell.class.php index eb7b9825..9c19a12c 100644 --- a/includes/types/spell.class.php +++ b/includes/types/spell.class.php @@ -8,14 +8,15 @@ class SpellList extends BaseType { use listviewHelper; - public $ranks = []; - public $relItems = null; - public $sources = []; + public $ranks = []; + public $relItems = null; + public $sources = []; - public static $type = TYPE_SPELL; - public static $brickFile = 'spell'; + public static $type = TYPE_SPELL; + public static $brickFile = 'spell'; + public static $dataTable = '?_spell'; - public static $skillLines = array( + public static $skillLines = array( 6 => [ 43, 44, 45, 46, 54, 55, 95, 118, 136, 160, 162, 172, 173, 176, 226, 228, 229, 473], // Weapons 8 => [293, 413, 414, 415, 433], // Armor 9 => [129, 185, 356, 762], // sec. Professions @@ -23,20 +24,20 @@ class SpellList extends BaseType 11 => [164, 165, 171, 182, 186, 197, 202, 333, 393, 755, 773] // prim. Professions ); - public static $spellTypes = array( + public static $spellTypes = array( 6 => 1, 8 => 2, 10 => 4 ); - public static $effects = array( + public static $effects = array( 'heal' => [ 0, 3, 10, 67, 75, 136 ], // , Dummy, Heal, Heal Max Health, Heal Mechanical, Heal Percent 'damage' => [ 0, 2, 3, 9, 62 ], // , Dummy, School Damage, Health Leech, Power Burn 'itemCreate' => [24, 34, 59, 66, 157 ], // createItem, changeItem, randomItem, createManaGem, createItem2 'trigger' => [ 3, 32, 64, 101, 142, 148, 151, 152, 155, 160, 164], // dummy, trigger missile, trigger spell, feed pet, force cast, force cast with value, unk, trigger spell 2, unk, dualwield 2H, unk, remove aura 'teach' => [36, 57, /*133*/ ] // learn spell, learn pet spell, /*unlearn specialization*/ ); - public static $auras = array( + public static $auras = array( 'heal' => [ 4, 8, 62, 69, 97, 226 ], // Dummy, Periodic Heal, Periodic Health Funnel, School Absorb, Mana Shield, Periodic Dummy 'damage' => [ 3, 4, 15, 53, 89, 162, 226 ], // Periodic Damage, Dummy, Damage Shield, Periodic Health Leech, Periodic Damage Percent, Power Burn Mana, Periodic Dummy 'itemCreate' => [86 ], // Channel Death Item @@ -44,20 +45,20 @@ class SpellList extends BaseType 'teach' => [ ] ); - private $spellVars = []; - private $refSpells = []; - private $tools = []; - private $interactive = false; - private $charLevel = MAX_LEVEL; + private $spellVars = []; + private $refSpells = []; + private $tools = []; + private $interactive = false; + private $charLevel = MAX_LEVEL; - protected $queryBase = 'SELECT s.*, s.id AS ARRAY_KEY FROM ?_spell s'; - protected $queryOpts = array( - 's' => [['src', 'sr', 'si', 'si', 'sia']], // 6: TYPE_SPELL - 'si' => ['j' => ['?_icons si ON si.id = s.iconId', true], 's' => ', IFNULL (si.iconString, "inv_misc_questionmark") AS iconString'], - 'sia' => ['j' => ['?_icons sia ON sia.id = s.iconIdAlt', true], 's' => ', sia.iconString AS iconStringAlt'], - 'sr' => ['j' => ['?_spellrange sr ON sr.id = s.rangeId'], 's' => ', sr.rangeMinHostile, sr.rangeMinFriend, sr.rangeMaxHostile, sr.rangeMaxFriend, sr.name_loc0 AS rangeText_loc0, sr.name_loc2 AS rangeText_loc2, sr.name_loc3 AS rangeText_loc3, sr.name_loc6 AS rangeText_loc6, sr.name_loc8 AS rangeText_loc8'], - 'src' => ['j' => ['?_source src ON type = 6 AND typeId = s.id', true], 's' => ', src1, src2, src3, src4, src5, src6, src7, src8, src9, src10, src11, src12, src13, src14, src15, src16, src17, src18, src19, src20, src21, src22, src23, src24'] - ); + protected $queryBase = 'SELECT s.*, s.id AS ARRAY_KEY FROM ?_spell s'; + protected $queryOpts = array( + 's' => [['src', 'sr', 'si', 'si', 'sia']], // 6: TYPE_SPELL + 'si' => ['j' => ['?_icons si ON si.id = s.iconId', true], 's' => ', IFNULL (si.iconString, "inv_misc_questionmark") AS iconString'], + 'sia' => ['j' => ['?_icons sia ON sia.id = s.iconIdAlt', true], 's' => ', sia.iconString AS iconStringAlt'], + 'sr' => ['j' => ['?_spellrange sr ON sr.id = s.rangeId'], 's' => ', sr.rangeMinHostile, sr.rangeMinFriend, sr.rangeMaxHostile, sr.rangeMaxFriend, sr.name_loc0 AS rangeText_loc0, sr.name_loc2 AS rangeText_loc2, sr.name_loc3 AS rangeText_loc3, sr.name_loc6 AS rangeText_loc6, sr.name_loc8 AS rangeText_loc8'], + 'src' => ['j' => ['?_source src ON type = 6 AND typeId = s.id', true], 's' => ', src1, src2, src3, src4, src5, src6, src7, src8, src9, src10, src11, src12, src13, src14, src15, src16, src17, src18, src19, src20, src21, src22, src23, src24'] + ); public function __construct($conditions = []) { diff --git a/includes/types/title.class.php b/includes/types/title.class.php index ef979af3..00ac972a 100644 --- a/includes/types/title.class.php +++ b/includes/types/title.class.php @@ -8,16 +8,17 @@ class TitleList extends BaseType { use listviewHelper; - public static $type = TYPE_TITLE; - public static $brickFile = 'title'; + public static $type = TYPE_TITLE; + public static $brickFile = 'title'; + public static $dataTable = '?_titles'; - public $sources = []; + public $sources = []; - protected $queryBase = 'SELECT t.*, id AS ARRAY_KEY FROM ?_titles t'; - protected $queryOpts = array( - 't' => [['src']], // 11: TYPE_TITLE - 'src' => ['j' => ['?_source src ON type = 11 AND typeId = t.id', true], 's' => ', src13, moreType, moreTypeId'] - ); + protected $queryBase = 'SELECT t.*, id AS ARRAY_KEY FROM ?_titles t'; + protected $queryOpts = array( + 't' => [['src']], // 11: TYPE_TITLE + 'src' => ['j' => ['?_source src ON type = 11 AND typeId = t.id', true], 's' => ', src13, moreType, moreTypeId'] + ); public function __construct($conditions = []) { diff --git a/includes/types/user.class.php b/includes/types/user.class.php index e32442a7..2a23413c 100644 --- a/includes/types/user.class.php +++ b/includes/types/user.class.php @@ -6,16 +6,17 @@ if (!defined('AOWOW_REVISION')) class UserList extends BaseType { - public static $type = TYPE_USER; - public static $brickFile = 'user'; + public static $type = TYPE_USER; + public static $brickFile = 'user'; + public static $dataTable = ''; // doesn't have community content - public $sources = []; + public $sources = []; - protected $queryBase = 'SELECT *, a.id AS ARRAY_KEY FROM ?_account a'; - protected $queryOpts = array( - 'a' => [['r']], - 'r' => ['j' => ['?_account_reputation r ON r.userId = a.id', true], 's' => ', IFNULL(SUM(r.amount), 0) AS reputation', 'g' => 'a.id'] - ); + protected $queryBase = 'SELECT *, a.id AS ARRAY_KEY FROM ?_account a'; + protected $queryOpts = array( + 'a' => [['r']], + 'r' => ['j' => ['?_account_reputation r ON r.userId = a.id', true], 's' => ', IFNULL(SUM(r.amount), 0) AS reputation', 'g' => 'a.id'] + ); public function getListviewData() { } diff --git a/includes/types/worldevent.class.php b/includes/types/worldevent.class.php index ac98c68d..b124771c 100644 --- a/includes/types/worldevent.class.php +++ b/includes/types/worldevent.class.php @@ -6,14 +6,15 @@ if (!defined('AOWOW_REVISION')) class WorldEventList extends BaseType { - public static $type = TYPE_WORLDEVENT; - public static $brickFile = 'event'; + public static $type = TYPE_WORLDEVENT; + public static $brickFile = 'event'; + public static $dataTable = '?_events'; - protected $queryBase = 'SELECT e.*, h.*, e.description AS nameINT, e.id AS id, e.id AS ARRAY_KEY FROM ?_events e'; - protected $queryOpts = array( - 'e' => [['h']], - 'h' => ['j' => ['?_holidays h ON e.holidayId = h.id', true], 'o' => '-e.id ASC'] - ); + protected $queryBase = 'SELECT e.*, h.*, e.description AS nameINT, e.id AS id, e.id AS ARRAY_KEY FROM ?_events e'; + protected $queryOpts = array( + 'e' => [['h']], + 'h' => ['j' => ['?_holidays h ON e.holidayId = h.id', true], 'o' => '-e.id ASC'] + ); public function __construct($conditions = []) { diff --git a/includes/types/zone.class.php b/includes/types/zone.class.php index 52dea10f..e1e97d98 100644 --- a/includes/types/zone.class.php +++ b/includes/types/zone.class.php @@ -8,10 +8,11 @@ class ZoneList extends BaseType { use listviewHelper; - public static $type = TYPE_ZONE; - public static $brickFile = 'zone'; + public static $type = TYPE_ZONE; + public static $brickFile = 'zone'; + public static $dataTable = '?_zones'; - protected $queryBase = 'SELECT *, id AS ARRAY_KEY FROM ?_zones z'; + protected $queryBase = 'SELECT *, id AS ARRAY_KEY FROM ?_zones z'; public function __construct($conditions = [], $miscData = null) { diff --git a/includes/utilities.php b/includes/utilities.php index 6c374a63..6c1b74a1 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -1430,23 +1430,6 @@ class Util return DB::Aowow()->query('INSERT IGNORE INTO ?_account_reputation (?#) VALUES (?a)', array_keys($x), array_values($x)); } - // TYPE => tableName; when handling comments, screenshots or videos - public static function getCCTableParent($type) - { - // only filtrable types; others don't care about being flagged for having CommunityContent - switch ($type) - { - case TYPE_ACHIEVEMENT: return '?_achievement'; - case TYPE_SPELL: return '?_spell'; - case TYPE_OBJECT: return '?_objects'; - case TYPE_ITEM: return '?_items'; - case TYPE_ITEMSET: return '?_itemset'; - case TYPE_NPC: return '?_creature'; - case TYPE_QUEST: return '?_quests'; - default: return null; - } - } - public static function getServerConditions($srcType, $srcGroup = null, $srcEntry = null) { if (!$srcGroup && !$srcEntry) diff --git a/pages/classes.php b/pages/classes.php index 9b8a2448..28af9f69 100644 --- a/pages/classes.php +++ b/pages/classes.php @@ -25,7 +25,7 @@ class ClassesPage extends GenericPage protected function generateContent() { - $classes = new CharClassList(); + $classes = new CharClassList([true]); if (!$classes->error) $this->lvTabs[] = ['class', ['data' => array_values($classes->getListviewData())]]; } diff --git a/pages/emotes.php b/pages/emotes.php index 68a3a37a..fddbfea1 100644 --- a/pages/emotes.php +++ b/pages/emotes.php @@ -26,7 +26,7 @@ class EmotesPage extends GenericPage protected function generateContent() { $tabData = array( - 'data' => array_values((new EmoteList())->getListviewData()), + 'data' => array_values((new EmoteList([true]))->getListviewData()), 'name' => Util::ucFirst(Lang::game('emotes')) ); diff --git a/pages/quest.php b/pages/quest.php index 7cbfbd3d..c9941591 100644 --- a/pages/quest.php +++ b/pages/quest.php @@ -559,7 +559,7 @@ class QuestPage extends GenericPage $this->suggestedPl = $this->subject->getField('suggestedPlayers'); $this->unavailable = $_flags & QUEST_FLAG_UNAVAILABLE || $this->subject->getField('cuFlags') & CUSTOM_EXCLUDE_FOR_LISTVIEW; $this->redButtons = array( - BUTTON_WOWHEAD => true + BUTTON_WOWHEAD => true, BUTTON_LINKS => array( 'linkColor' => 'ffffff00', 'linkId' => 'quest:'.$this->typeId.':'.$_level; diff --git a/setup/updates/1487858459_01.sql b/setup/updates/1487858459_01.sql new file mode 100644 index 00000000..a4f4e559 --- /dev/null +++ b/setup/updates/1487858459_01.sql @@ -0,0 +1,107 @@ +-- TYPE_NPC:1 +UPDATE aowow_creature a +JOIN (SELECT typeId, BIT_OR(`status`) AS `ccFlags` FROM aowow_screenshots WHERE `type` = 1 GROUP BY typeId) b ON a.id = b.typeId +SET a.cuFlags = a.cuFlags | 0x02000000 +WHERE b.ccFlags & 0x8; + +-- TYPE_OBJECT:2 +UPDATE aowow_objects a +JOIN (SELECT typeId, BIT_OR(`status`) AS `ccFlags` FROM aowow_screenshots WHERE `type` = 2 GROUP BY typeId) b ON a.id = b.typeId +SET a.cuFlags = a.cuFlags | 0x02000000 +WHERE b.ccFlags & 0x8; + +-- TYPE_ITEM:3 +UPDATE aowow_items a +JOIN (SELECT typeId, BIT_OR(`status`) AS `ccFlags` FROM aowow_screenshots WHERE `type` = 3 GROUP BY typeId) b ON a.id = b.typeId +SET a.cuFlags = a.cuFlags | 0x02000000 +WHERE b.ccFlags & 0x8; + +-- TYPE_ITEMSET:4 +UPDATE aowow_itemset a +JOIN (SELECT typeId, BIT_OR(`status`) AS `ccFlags` FROM aowow_screenshots WHERE `type` = 4 GROUP BY typeId) b ON a.id = b.typeId +SET a.cuFlags = a.cuFlags | 0x02000000 +WHERE b.ccFlags & 0x8; + +-- TYPE_QUEST:5 +UPDATE aowow_quests a +JOIN (SELECT typeId, BIT_OR(`status`) AS `ccFlags` FROM aowow_screenshots WHERE `type` = 5 GROUP BY typeId) b ON a.id = b.typeId +SET a.cuFlags = a.cuFlags | 0x02000000 +WHERE b.ccFlags & 0x8; + +-- TYPE_SPELL:6 +UPDATE aowow_spell a +JOIN (SELECT typeId, BIT_OR(`status`) AS `ccFlags` FROM aowow_screenshots WHERE `type` = 6 GROUP BY typeId) b ON a.id = b.typeId +SET a.cuFlags = a.cuFlags | 0x02000000 +WHERE b.ccFlags & 0x8; + +-- TYPE_ZONE:7 +UPDATE aowow_zones a +JOIN (SELECT typeId, BIT_OR(`status`) AS `ccFlags` FROM aowow_screenshots WHERE `type` = 7 GROUP BY typeId) b ON a.id = b.typeId +SET a.cuFlags = a.cuFlags | 0x02000000 +WHERE b.ccFlags & 0x8; + +-- TYPE_FACTION:8 +UPDATE aowow_factions a +JOIN (SELECT typeId, BIT_OR(`status`) AS `ccFlags` FROM aowow_screenshots WHERE `type` = 8 GROUP BY typeId) b ON a.id = b.typeId +SET a.cuFlags = a.cuFlags | 0x02000000 +WHERE b.ccFlags & 0x8; + +-- TYPE_PET:9 +UPDATE aowow_pet a +JOIN (SELECT typeId, BIT_OR(`status`) AS `ccFlags` FROM aowow_screenshots WHERE `type` = 9 GROUP BY typeId) b ON a.id = b.typeId +SET a.cuFlags = a.cuFlags | 0x02000000 +WHERE b.ccFlags & 0x8; + +-- TYPE_ACHIEVEMENT:10 +UPDATE aowow_achievement a +JOIN (SELECT typeId, BIT_OR(`status`) AS `ccFlags` FROM aowow_screenshots WHERE `type` = 10 GROUP BY typeId) b ON a.id = b.typeId +SET a.cuFlags = a.cuFlags | 0x02000000 +WHERE b.ccFlags & 0x8; + +-- TYPE_TITLE:11 +UPDATE aowow_titles a +JOIN (SELECT typeId, BIT_OR(`status`) AS `ccFlags` FROM aowow_screenshots WHERE `type` = 11 GROUP BY typeId) b ON a.id = b.typeId +SET a.cuFlags = a.cuFlags | 0x02000000 +WHERE b.ccFlags & 0x8; + +-- TYPE_WORLDEVENT:12 +UPDATE aowow_events a +JOIN (SELECT typeId, BIT_OR(`status`) AS `ccFlags` FROM aowow_screenshots WHERE `type` = 12 GROUP BY typeId) b ON a.id = b.typeId +SET a.cuFlags = a.cuFlags | 0x02000000 +WHERE b.ccFlags & 0x8; + +-- TYPE_CLASS:13 +UPDATE aowow_classes a +JOIN (SELECT typeId, BIT_OR(`status`) AS `ccFlags` FROM aowow_screenshots WHERE `type` = 13 GROUP BY typeId) b ON a.id = b.typeId +SET a.cuFlags = a.cuFlags | 0x02000000 +WHERE b.ccFlags & 0x8; + +-- TYPE_RACE:14 +UPDATE aowow_races a +JOIN (SELECT typeId, BIT_OR(`status`) AS `ccFlags` FROM aowow_screenshots WHERE `type` = 14 GROUP BY typeId) b ON a.id = b.typeId +SET a.cuFlags = a.cuFlags | 0x02000000 +WHERE b.ccFlags & 0x8; + +-- TYPE_SKILL:15 +UPDATE aowow_skillline a +JOIN (SELECT typeId, BIT_OR(`status`) AS `ccFlags` FROM aowow_screenshots WHERE `type` = 15 GROUP BY typeId) b ON a.id = b.typeId +SET a.cuFlags = a.cuFlags | 0x02000000 +WHERE b.ccFlags & 0x8; + +-- TYPE_CURRENCY:17 +UPDATE aowow_currencies a +JOIN (SELECT typeId, BIT_OR(`status`) AS `ccFlags` FROM aowow_screenshots WHERE `type` = 17 GROUP BY typeId) b ON a.id = b.typeId +SET a.cuFlags = a.cuFlags | 0x02000000 +WHERE b.ccFlags & 0x8; + +-- TYPE_EMOTE:501 +UPDATE aowow_emotes a +JOIN (SELECT typeId, BIT_OR(`status`) AS `ccFlags` FROM aowow_screenshots WHERE `type` = 501 GROUP BY typeId) b ON a.id = b.typeId +SET a.cuFlags = a.cuFlags | 0x02000000 +WHERE b.ccFlags & 0x8; + +-- TYPE_ENCHANTMENT:502 +UPDATE aowow_itemenchantment a +JOIN (SELECT typeId, BIT_OR(`status`) AS `ccFlags` FROM aowow_screenshots WHERE `type` = 502 GROUP BY typeId) b ON a.id = b.typeId +SET a.cuFlags = a.cuFlags | 0x02000000 +WHERE b.ccFlags & 0x8;