diff --git a/includes/profiler.class.php b/includes/profiler.class.php index 8ead60b5..fe128bac 100644 --- a/includes/profiler.class.php +++ b/includes/profiler.class.php @@ -375,6 +375,7 @@ class Profiler 'realm' => $realmId, 'realmGUID' => $charGuid, 'name' => $char['name'], + 'renameItr' => 0, 'race' => $char['race'], 'class' => $char['class'], 'level' => $char['level'], @@ -403,7 +404,10 @@ class Profiler // char is flagged for rename if ($char['at_login'] & 0x1) - $data['name'] = 'RENAME-'.$data['name']; + { + $ri = DB::Aowow()->selectCell('SELECT MAX(renameItr) FROM ?_profiler_profiles WHERE realm = ?d AND realmGUID = ?d AND name = ?', $realmId, $charGuid, $char['name']); + $data['renameItr'] = $ri ? ++$ri : 1; + } /********************/ /* talents + glyphs */ diff --git a/includes/types/profile.class.php b/includes/types/profile.class.php index 804836c6..20709889 100644 --- a/includes/types/profile.class.php +++ b/includes/types/profile.class.php @@ -64,12 +64,17 @@ class ProfileList extends BaseType $data[$this->id][$col] = $this->getField($col); if ($addInfo & PROFILEINFO_PROFILE) + { if ($_ = $this->getField('description')) $data[$this->id]['description'] = $_; - if ($addInfo & PROFILEINFO_PROFILE) if ($_ = $this->getField('icon')) $data[$this->id]['icon'] = $_; + } + + if ($addInfo & PROFILEINFO_CHARACTER) + if ($_ = $this->getField('renameItr')) + $data[$this->id]['renameItr'] = $_; if ($this->getField('cuFlags') & PROFILER_CU_PINNED) $data[$this->id]['pinned'] = 1; @@ -591,7 +596,19 @@ class RemoteProfileList extends ProfileList // char is pending rename if ($curTpl['at_login'] & 0x1) - $curTpl['name'] = 'RENAME-'.$curTpl['name']; + { + if (!isset($this->rnItr[$curTpl['name']])) + $this->rnItr[$curTpl['name']] = DB::Aowow()->selectCell('SELECT MAX(renameItr) FROM ?_profiler_profiles WHERE realm = ?d AND realmGUID IS NOT NULL AND name = ?', $r, $curTpl['name']) ?: 0; + + // already saved as "pending rename" + if ($rnItr = DB::Aowow()->selectCell('SELECT renameItr FROM ?_profiler_profiles WHERE realm = ?d AND realmGUID = ?d', $r, $g)) + $curTpl['renameItr'] = $rnItr; + // not yet recognized: get max itr + else + $curTpl['renameItr'] = ++$this->rnItr[$curTpl['name']]; + } + else + $curTpl['renameItr'] = 0; $curTpl['cuFlags'] = 0; } @@ -657,6 +674,7 @@ class RemoteProfileList extends ProfileList 'realm' => $this->getField('realm'), 'realmGUID' => $this->getField('guid'), 'name' => $this->getField('name'), + 'renameItr' => $this->getField('renameItr'), 'race' => $this->getField('race'), 'class' => $this->getField('class'), 'level' => $this->getField('level'), @@ -696,7 +714,7 @@ class RemoteProfileList extends ProfileList if ($baseData) { foreach (Util::createSqlBatchInsert($baseData) as $ins) - DB::Aowow()->query('INSERT IGNORE INTO ?_profiler_profiles (?#) VALUES '.$ins, array_keys(reset($baseData))); + DB::Aowow()->query('INSERT INTO ?_profiler_profiles (?#) VALUES '.$ins.' ON DUPLICATE KEY UPDATE name = VALUES(name), renameItr = VALUES(renameItr)', array_keys(reset($baseData))); // merge back local ids $localIds = DB::Aowow()->select( diff --git a/pages/profile.php b/pages/profile.php index 873658c1..46caffd6 100644 --- a/pages/profile.php +++ b/pages/profile.php @@ -24,8 +24,9 @@ class ProfilePage extends GenericPage ['path' => 'Profiler.css'] ); - private $isCustom = false; - private $profile = null; + private $isCustom = false; + private $profile = null; + private $rnItr = 0; public function __construct($pageCall, $pageParam) { @@ -71,27 +72,38 @@ class ProfilePage extends GenericPage // names MUST be ucFirst. Since we don't expect partial matches, search this way $this->profile = $params; + // pending rename + if (preg_match('/([^\-]+)-(\d+)/i', $this->subjectName, $m)) + { + $this->subjectName = $m[1]; + $this->rnItr = $m[2]; + } + // 3 possibilities // 1) already synced to aowow - if ($subject = DB::Aowow()->selectRow('SELECT id, realmGUID, cuFlags FROM ?_profiler_profiles WHERE realm = ?d AND realmGUID IS NOT NULL AND name = ?', $this->realmId, Util::ucFirst($this->subjectName))) + if ($subject = DB::Aowow()->selectRow('SELECT id, realmGUID, cuFlags FROM ?_profiler_profiles WHERE realm = ?d AND realmGUID IS NOT NULL AND name = ? AND renameItr = ?d', $this->realmId, Util::ucFirst($this->subjectName), $this->rnItr)) { + $this->subjectGUID = $subject['id']; + if ($subject['cuFlags'] & PROFILER_CU_NEEDS_RESYNC) { $this->handleIncompleteData($params, $subject['realmGUID']); return; } - $this->subjectGUID = $subject['id']; - $this->subject = new LocalProfileList(array(['id', $subject['id']])); + $this->subject = new LocalProfileList(array(['id', $subject['id']])); if ($this->subject->error) $this->notFound(); } // 2) not yet synced but exists on realm (and not a gm character) - else if ($char = DB::Characters($this->realmId)->selectRow('SELECT c.guid AS realmGUID, c.name, c.race, c.class, c.level, c.gender, g.guildid AS guildGUID, IFNULL(g.name, "") AS guildName, IFNULL(gm.rank, 0) AS guildRank FROM characters c LEFT JOIN guild_member gm ON gm.guid = c.guid LEFT JOIN guild g ON g.guildid = gm.guildid WHERE c.name = ? AND level <= ?d AND (extra_flags & ?d) = 0', Util::ucFirst($this->subjectName), MAX_LEVEL, Profiler::CHAR_GMFLAGS)) + else if (!$this->rnItr && ($char = DB::Characters($this->realmId)->selectRow('SELECT c.guid AS realmGUID, c.name, c.race, c.class, c.level, c.gender, g.guildid AS guildGUID, IFNULL(g.name, "") AS guildName, IFNULL(gm.rank, 0) AS guildRank FROM characters c LEFT JOIN guild_member gm ON gm.guid = c.guid LEFT JOIN guild g ON g.guildid = gm.guildid WHERE c.name = ? AND level <= ?d AND (extra_flags & ?d) = 0', Util::ucFirst($this->subjectName), MAX_LEVEL, Profiler::CHAR_GMFLAGS))) { $char['realm'] = $this->realmId; $char['cuFlags'] = PROFILER_CU_NEEDS_RESYNC; + if ($char['at_login'] & 0x1) + $char['renameItr'] = DB::Aowow()->selectCell('SELECT MAX(renameItr) FROM ?_profiler_profiles WHERE realm = ?d AND realmGUID IS NOT NULL AND name = ?', $realmId, $char['name']); + if ($char['guildGUID']) { // create empty guild if nessecary to satisfy foreign keys @@ -104,7 +116,8 @@ class ProfilePage extends GenericPage unset($char['guildName']); // create entry from realm with enough basic info to disply tooltips - DB::Aowow()->query('INSERT IGNORE INTO ?_profiler_profiles (?#) VALUES (?a)', array_keys($char), array_values($char)); + DB::Aowow()->query('REPLACE INTO ?_profiler_profiles (?#) VALUES (?a)', array_keys($char), array_values($char)); + $this->subjectGUID = DB::Aowow()->selectCell('SELECT id FROM ?_profiler_profiles WHERE realm = ?d AND realmGUID = ?d', $this->realmId, $char['realmGUID']); $this->handleIncompleteData($params, $char['realmGUID']); } @@ -224,7 +237,7 @@ class ProfilePage extends GenericPage { if ($this->mode == CACHE_TYPE_TOOLTIP) // enable tooltip display with basic data we just added { - $this->subject = new LocalProfileList(array(['name', Util::ucFirst($this->subjectName)]), ['sv' => $params[1]]); + $this->subject = new LocalProfileList(array(['id', $this->subjectGUID]), ['sv' => $params[1]]); if ($this->subject->error) $this->notFound(); diff --git a/setup/db_structure.sql b/setup/db_structure.sql index 5ab011f0..c201facc 100644 --- a/setup/db_structure.sql +++ b/setup/db_structure.sql @@ -1884,6 +1884,7 @@ CREATE TABLE `aowow_profiler_profiles` ( `icon` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `user` int(11) unsigned DEFAULT NULL, `name` varchar(50) COLLATE utf8mb4_bin NOT NULL, + `renameItr` tinyint(3) unsigned NOT NULL, `race` tinyint(3) unsigned NOT NULL, `class` tinyint(3) unsigned NOT NULL, `level` tinyint(3) unsigned NOT NULL, @@ -1914,6 +1915,7 @@ CREATE TABLE `aowow_profiler_profiles` ( UNIQUE KEY `realm_realmGUID` (`realm`,`realmGUID`), KEY `user` (`user`), KEY `guild` (`guild`), + KEY `name` (`name`), CONSTRAINT `FK_aowow_profiler_profiles_aowow_profiler_guild` FOREIGN KEY (`guild`) REFERENCES `aowow_profiler_guild` (`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -3117,7 +3119,7 @@ UNLOCK TABLES; LOCK TABLES `aowow_dbversion` WRITE; /*!40000 ALTER TABLE `aowow_dbversion` DISABLE KEYS */; -INSERT INTO `aowow_dbversion` VALUES (1531668312,0,NULL,NULL); +INSERT INTO `aowow_dbversion` VALUES (1543774779,0,NULL,NULL); /*!40000 ALTER TABLE `aowow_dbversion` ENABLE KEYS */; UNLOCK TABLES; diff --git a/setup/updates/1543774778_01.sql b/setup/updates/1543774778_01.sql new file mode 100644 index 00000000..65183783 --- /dev/null +++ b/setup/updates/1543774778_01.sql @@ -0,0 +1,8 @@ +-- clear synced chars to prevent conflicts +DELETE FROM `aowow_profiler_profiles` WHERE `realmGUID` IS NOT NULL; +-- clear queue +DELETE FROM `aowow_profiler_sync`; +-- update unique index +ALTER TABLE `aowow_profiler_profiles` + ADD COLUMN `renameItr` TINYINT UNSIGNED NOT NULL DEFAULT '0' AFTER `name`, + ADD INDEX `name` (`name`); diff --git a/static/js/global.js b/static/js/global.js index 6dee289a..ed9d7114 100644 --- a/static/js/global.js +++ b/static/js/global.js @@ -15769,6 +15769,12 @@ Listview.templates = { $WH.ae(d, $WH.ct(LANG.privateprofile)); } + // aowow custom + if (profile.renameItr) { + $WH.ae(s, $WH.ct(LANG.pr_note_pendingrename)); + } + // end aowow custom + $WH.ae(wrapper, d); $WH.ae(td, wrapper); }, @@ -17641,7 +17647,8 @@ function g_cleanCharacterName(name) { function g_getProfileUrl(profile) { if (profile.region) { // Armory character - return '?profile=' + profile.region + '.' + profile.realm + '.' + g_cleanCharacterName(profile.name); + // return '?profile=' + profile.region + '.' + profile.realm + '.' + g_cleanCharacterName(profile.name); // aowow custom + return '?profile=' + profile.region + '.' + profile.realm + '.' + g_cleanCharacterName(profile.name) + (profile.renameItr ? '-' + profile.renameItr : ''); } else { // Custom profile return '?profile=' + profile.id; diff --git a/static/js/locale_dede.js b/static/js/locale_dede.js index cb3e9a1d..47820d90 100644 --- a/static/js/locale_dede.js +++ b/static/js/locale_dede.js @@ -4618,6 +4618,8 @@ var LANG = { pr_note_gearscore: "Ausrüstungswertung", pr_note_weighted: "Gewogen", + pr_note_pendingrename: "Name freigegeben", + su_note_stats: "Werte", su_note_other: "Anderes", diff --git a/static/js/locale_enus.js b/static/js/locale_enus.js index b04e51b9..c6fea9b4 100644 --- a/static/js/locale_enus.js +++ b/static/js/locale_enus.js @@ -4665,6 +4665,8 @@ var LANG = { pr_note_gearscore: "Gear score", pr_note_weighted: "Weighted", + pr_note_pendingrename: "Pending Rename", + su_note_stats: "Stats", su_note_other: "Other", diff --git a/static/js/locale_eses.js b/static/js/locale_eses.js index d36e95aa..31338d61 100644 --- a/static/js/locale_eses.js +++ b/static/js/locale_eses.js @@ -4620,6 +4620,8 @@ var LANG = { pr_note_gearscore: "Puntuación de equipo", pr_note_weighted: "Valorado", + pr_note_pendingrename: "Pending Rename", + su_note_stats: "Estadisticas", su_note_other: "Otros", diff --git a/static/js/locale_frfr.js b/static/js/locale_frfr.js index 7b85aff4..48dd617e 100644 --- a/static/js/locale_frfr.js +++ b/static/js/locale_frfr.js @@ -4619,6 +4619,8 @@ var LANG = { pr_note_gearscore: "Score d'équipement", pr_note_weighted: "Valorisé", /* some relic text..? */ + pr_note_pendingrename: "Pending Rename", + su_note_stats: "Statistiques", su_note_other: "Autre", diff --git a/static/js/locale_ruru.js b/static/js/locale_ruru.js index e81d5edc..3081dcaf 100644 --- a/static/js/locale_ruru.js +++ b/static/js/locale_ruru.js @@ -4618,9 +4618,11 @@ var LANG = { pr_note_missing: "Отсутствует", pr_note_normal: "Обычный", pr_note_exotic: "Экзотический", - + pr_note_gearscore: "Очки экипировки", pr_note_weighted: "Взвешено", /* some relic text..? */ + pr_note_pendingrename: "Pending Rename", + su_note_stats: "Характеристики", su_note_other: "Другое", diff --git a/static/js/locale_zhcn.js b/static/js/locale_zhcn.js index dbf31a44..c453253c 100644 --- a/static/js/locale_zhcn.js +++ b/static/js/locale_zhcn.js @@ -4645,6 +4645,8 @@ var LANG = { pr_note_gearscore: "装备", pr_note_weighted: "Weighted", + pr_note_pendingrename: "Pending Rename", + su_note_stats: "任务基本属性", su_note_other: "其他",