diff --git a/includes/defines.php b/includes/defines.php index 532f4e76..ef466fa2 100644 --- a/includes/defines.php +++ b/includes/defines.php @@ -140,6 +140,7 @@ define('U_GROUP_PENDING', 0x4000); // restricts usage o define('U_GROUP_STAFF', (U_GROUP_ADMIN|U_GROUP_EDITOR|U_GROUP_MOD|U_GROUP_BUREAU|U_GROUP_DEV|U_GROUP_BLOGGER|U_GROUP_LOCALIZER|U_GROUP_SALESAGENT)); define('U_GROUP_EMPLOYEE', (U_GROUP_ADMIN|U_GROUP_BUREAU|U_GROUP_DEV)); define('U_GROUP_GREEN_TEXT', (U_GROUP_MOD|U_GROUP_BUREAU|U_GROUP_DEV)); +define('U_GROUP_PREMIUMISH', (U_GROUP_PREMIUM|U_GROUP_EDITOR)); define('U_GROUP_MODERATOR', (U_GROUP_ADMIN|U_GROUP_MOD|U_GROUP_BUREAU)); define('U_GROUP_COMMENTS_MODERATOR', (U_GROUP_MODERATOR|U_GROUP_LOCALIZER)); define('U_GROUP_PREMIUM_PERMISSIONS', (U_GROUP_PREMIUM|U_GROUP_STAFF|U_GROUP_VIP)); diff --git a/index.php b/index.php index 567e95f2..75a50795 100644 --- a/index.php +++ b/index.php @@ -121,6 +121,7 @@ switch ($pageCall) case 'reputation': case 'privilege': case 'privileges': + case 'top-users': (new MorePage($pageCall, $pageParam))->display(); break; case 'latest-additions': diff --git a/localization/locale_dede.php b/localization/locale_dede.php index b99bd030..45436e31 100644 --- a/localization/locale_dede.php +++ b/localization/locale_dede.php @@ -148,6 +148,7 @@ $lang = array( 'aboutus' => "Was ist AoWoW?", 'searchplugins' => "Such-Plugins", 'privileges' => "Privilegien", + 'top-users' => "Hilfreichste Benutzer", 'help' => array( 'commenting-and-you' => "Wie man Kommentare schreibt", 'modelviewer' => "Modellviewer", 'screenshots-tips-tricks' => "Screenshots: Tipps & Tricks", 'stat-weighting' => "Gewichtung von Werten", 'talent-calculator' => "Talentrechner", 'item-comparison' => "Gegenstandsvergleich", diff --git a/localization/locale_enus.php b/localization/locale_enus.php index 0607e87c..9a795f9f 100644 --- a/localization/locale_enus.php +++ b/localization/locale_enus.php @@ -143,6 +143,7 @@ $lang = array( 'aboutus' => "What is AoWoW?", 'searchplugins' => "Search Plugins", 'privileges' => "Privileges", + 'top-users' => "Top Users", 'help' => array( 'commenting-and-you' => "Commenting and You", 'modelviewer' => "Model Viewer", 'screenshots-tips-tricks' => "Screenshots: Tips & Tricks", 'stat-weighting' => "Stat Weighting", 'talent-calculator' => "Talent Calculator", 'item-comparison' => "Item Comparison", diff --git a/localization/locale_eses.php b/localization/locale_eses.php index 750b62cc..871d749e 100644 --- a/localization/locale_eses.php +++ b/localization/locale_eses.php @@ -148,6 +148,7 @@ $lang = array( 'aboutus' => "[What is AoWoW?]", 'searchplugins' => "Extensiones de búsqueda", 'privileges' => "Privilegios", + 'top-users' => "Usuarios más populares", 'help' => array( 'commenting-and-you' => "Los comentarios y tú", 'modelviewer' => "Visualizador de modelos", 'screenshots-tips-tricks' => "Capturas de pantalla: Sugerencias y trucos", 'stat-weighting' => "Medición de atributos", 'talent-calculator' => "Calculadora de talentos", 'item-comparison' => "Comparación de objetos", diff --git a/localization/locale_frfr.php b/localization/locale_frfr.php index 2a9778c3..e3f0879f 100644 --- a/localization/locale_frfr.php +++ b/localization/locale_frfr.php @@ -148,6 +148,7 @@ $lang = array( 'aboutus' => "[What is AoWoW?]", 'searchplugins' => "Plug-ins de recherche", 'privileges' => "Privilèges", + 'top-users' => "Meilleurs Utilisateurs", 'help' => array( 'commenting-and-you' => "Le guide du commentaire", 'modelviewer' => "Visionneuse 3D", 'screenshots-tips-tricks' => "Captures d'écran : Trucs et astuces", 'stat-weighting' => "Échelles de valeurs", 'talent-calculator' => "Calculateur de talents", 'item-comparison' => "Comparaison d'objets", diff --git a/localization/locale_ruru.php b/localization/locale_ruru.php index ce748ce3..a778501c 100644 --- a/localization/locale_ruru.php +++ b/localization/locale_ruru.php @@ -148,6 +148,7 @@ $lang = array( 'aboutus' => "[What is AoWoW?]", 'searchplugins' => "Дополнения для браузеров", 'privileges' => "Привилегии", + 'top-users' => "Лучшие пользователи", 'help' => array( 'commenting-and-you' => "Комментарии и Вы", 'modelviewer' => "3D просмотр", 'screenshots-tips-tricks' => "Скриншоты: Секреты мастерства", 'stat-weighting' => "Значимость характеристик", 'talent-calculator' => "Расчёт талантов", 'item-comparison' => "Сравнение предметов", diff --git a/pages/genericPage.class.php b/pages/genericPage.class.php index 5c6101d2..30c11ac0 100644 --- a/pages/genericPage.class.php +++ b/pages/genericPage.class.php @@ -133,6 +133,7 @@ class GenericPage 'sound' => ['template' => 'sound', 'id' => 'sounds', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.types[19][2]' ], 'spell' => ['template' => 'spell', 'id' => 'spells', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_spells' ], 'title' => ['template' => 'title', 'id' => 'titles', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_titles' ], + 'topusers' => ['template' => 'topusers', 'id' => 'topusers', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.topusers' ], 'video' => ['template' => 'video', 'id' => 'videos', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_videos' ], 'zone' => ['template' => 'zone', 'id' => 'zones', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_zones' ] ); diff --git a/pages/more.php b/pages/more.php index 9d8f7351..90a9dcd7 100644 --- a/pages/more.php +++ b/pages/more.php @@ -40,10 +40,11 @@ class MorePage extends GenericPage 'faq' => [2, [2, 3]], 'aboutus' => [2, [2, 0]], 'searchplugins' => [2, [2, 8]], - 'help' => [2, [2, 13], ['commenting-and-you', 'modelviewer', 'screenshots-tips-tricks', 'stat-weighting', 'talent-calculator', 'item-comparison', 'profiler', 'markup-guide', 'markup-guide-ext']], + 'help' => [2, [2, 13], ['commenting-and-you', 'modelviewer', 'screenshots-tips-tricks', 'stat-weighting', 'talent-calculator', 'item-comparison', 'profiler', 'markup-guide']], 'reputation' => [1, [3, 10]], 'privilege' => [1, [3, 10], [1, 2, 4, 5, 9, 10, 11, 12, 13, 14, 15, 16, 17]], 'privileges' => [1, [3, 10, 0]], + 'top-users' => [1, [3, 11]] ); public function __construct($pageCall, $subPage) @@ -100,6 +101,9 @@ class MorePage extends GenericPage $this->tpl = 'privilege'; $this->privReqPoints = sprintf(Lang::privileges('reqPoints'), Lang::nf($this->req2priv[$this->page[1]])); return; + case 'top-users': + $this->handleTopUsersPage(); + return; default: return; } @@ -163,6 +167,73 @@ class MorePage extends GenericPage $val ); } + + private function handleTopUsersPage() + { + $tabs = array( + [0, 'top-users-alltime', '$LANG.alltime_stc' ], + [time() - MONTH, 'top-users-monthly', '$LANG.lastmonth_stc'], + [time() - WEEK, 'top-users-weekly', '$LANG.lastweek_stc' ] + ); + + $nullFields = array( + 'uploads' => 0, + 'posts' => 0, + 'gold' => 0, + 'silver' => 0, + 'copper' => 0 + ); + + foreach ($tabs as list($t, $tabId, $tabName)) + { + // stuff received + $res = DB::Aowow()->select(' + SELECT + a.id AS ARRAY_KEY, + a.displayName AS username, + a.userGroups AS groups, + a.joinDate AS creation, + SUM(r.amount) AS reputation, + SUM(IF(r.`action` = 3, 1, 0)) AS comments, + SUM(IF(r.`action` = 6, 1, 0)) AS screenshots, + SUM(IF(r.`action` = 9, 1, 0)) AS reports + FROM ?_account_reputation r + JOIN ?_account a ON a.id = r.userId + {WHERE r.date > ?d} + GROUP BY a.id + ORDER BY reputation DESC + LIMIT ?d + ', $t ?: DBSIMPLE_SKIP, CFG_SQL_LIMIT_SEARCH); + + $data = []; + if ($res) + { + // stuff given + $votes = DB::Aowow()->selectCol( + 'SELECT sourceB AS ARRAY_KEY, SUM(1) FROM ?_account_reputation WHERE action IN (4, 5) AND sourceB IN (?a) {AND date > ?d} GROUP BY sourceB', + array_keys($res), + $t ?: DBSIMPLE_SKIP + ); + foreach ($res as $uId => &$r) + { + $r['creation'] = date('c', $r['creation']); + $r['votes'] = empty($votes[$uId]) ? 0 : $votes[$uId]; + $r = array_merge($r, $nullFields); + } + + $data = array_values($res); + } + + $this->lvTabs[] = ['topusers', array( + 'hiddenCols' => ['achievements', 'posts', 'uploads'], + 'visibleCols' => ['created'], + 'name' => '$LANG.lastweek_stc', + 'name' => $tabName, + 'id' => $tabId, + 'data' => $data + )]; + } + } } ?> diff --git a/static/js/global.js b/static/js/global.js index e7ca4cf8..8708e716 100644 --- a/static/js/global.js +++ b/static/js/global.js @@ -28,6 +28,7 @@ var U_GROUP_PENDING = 0x4000; var U_GROUP_STAFF = U_GROUP_ADMIN | U_GROUP_EDITOR | U_GROUP_MOD | U_GROUP_BUREAU | U_GROUP_DEV | U_GROUP_BLOGGER | U_GROUP_LOCALIZER | U_GROUP_SALESAGENT; var U_GROUP_EMPLOYEE = U_GROUP_ADMIN | U_GROUP_BUREAU | U_GROUP_DEV; var U_GROUP_GREEN_TEXT = U_GROUP_MOD | U_GROUP_BUREAU | U_GROUP_DEV; +var U_GROUP_PREMIUMISH = U_GROUP_PREMIUM | U_GROUP_EDITOR; var U_GROUP_MODERATOR = U_GROUP_ADMIN | U_GROUP_MOD | U_GROUP_BUREAU; var U_GROUP_COMMENTS_MODERATOR = U_GROUP_BUREAU | U_GROUP_MODERATOR | U_GROUP_LOCALIZER; var U_GROUP_PREMIUM_PERMISSIONS = U_GROUP_PREMIUM | U_GROUP_STAFF | U_GROUP_VIP; @@ -1081,6 +1082,9 @@ function g_GetStaffColorFromRoles(roles) { if (roles & U_GROUP_VIP) { // VIP return 'comment-gold'; } + if (roles & U_GROUP_PREMIUMISH) { // Premium, Editor + return 'comment-gold'; + } return ''; } @@ -8458,12 +8462,16 @@ Listview.funcBox = { break; case 3: // Post reply (forums) + if (comment.roles & U_GROUP_PREMIUMISH) + return ' comment-gold'; case 4: // Signature (account settings) if(comment.roles & U_GROUP_ADMIN) return ' comment-blue'; if(comment.roles & U_GROUP_GREEN_TEXT) // Mod, Bureau, Dev return ' comment-green'; - else if(comment.roles & U_GROUP_VIP) // VIP + if(comment.roles & U_GROUP_VIP) // VIP + return ' comment-gold'; + if (comment.roles & U_GROUP_PREMIUMISH) // Premium, Editor return ' comment-gold'; break; } @@ -8474,6 +8482,8 @@ Listview.funcBox = { return ' comment-green'; else if(comment.rating < -2) return ' comment-bt'; + else if(comment.roles & U_GROUP_PREMIUMISH) + return ' comment-gold'; return ''; }, @@ -11371,6 +11381,193 @@ Listview.templates = { ] }, + topusers: + { + sort: ['reputation'], + searchable: 1, + filtrable: 0, + + columns: [ + { + id: 'username', + name: LANG.username, + type: 'text', + align: 'left', + compute: function(user, td) { + var a = $(''); + var color = g_GetStaffColorFromRoles(user.groups); + if (color != '') + a.addClass(color); + else + a.css('color', 'white'); + + a.text(user.username); + a.addClass('listview-cleartext'); + a.attr('href', '?user=' + user.username); + $(td).append(a); + return; + }, + getVisibleText: function(user) { + return user.username; + }, + sortFunc: function(a, b) { + return $WH.stringCompare(a.username, b.username); + }, + getItemLink: function(user) { + return '?user=' + user.username; + } + }, + { + id: 'reputation', + name: LANG.reputation, + type: 'text', + compute: function(user, td) { + $(td).append($WH.number_format(user.reputation)); + return; + }, + sortFunc: function(a, b) { + if (b.reputation == a.reputation) + return 0; + + return a.reputation < b.reputation ? 1 : -1; + } + }, + { + id: 'achievements', + name: LANG.achievements, + type: 'text', + compute: function(user, td) { + var sp = $('').addClass('wsach-pts').css('font-size', 'inherit'); + var buf = ''; + if (user.gold) + buf += '' + user.gold + '·'; + if (user.silver) + buf += '' + user.silver + '·'; + buf += '' + user.copper + ''; + + sp.html(buf); + $(td).append(sp); + + return; + }, + sortFunc: function(a, b) { + var sumA = (a.gold * 1000 * 1000) + (a.silver * 1000) + a.copper; + var sumB = (b.gold * 1000 * 1000) + (b.silver * 1000) + b.copper; + if (sumA == sumB) + return 0; + return sumA < sumB ? 1 : -1; + } + }, + { + id: 'comments', + name: LANG.comments, + type: 'text', + compute: function(user, td) { + $(td).append($WH.number_format(user.comments)); + return; + }, + sortFunc: function(a, b) { + if (a.comments == b.comments) + return 0; + return a.comments < b.comments ? 1 : -1; + } + }, + { + id: 'posts', + name: LANG.posts, + type: 'text', + compute: function(user, td) { + $(td).append($WH.number_format(user.posts)); + return; + }, + sortFunc: function(a, b) { + if (a.posts == b.posts) + return 0; + return a.posts < b.posts ? 1 : -1; + } + }, + { + id: 'screenshots', + name: LANG.screenshots, + type: 'text', + compute: function(user, td) { + $(td).append($WH.number_format(user.screenshots)); + return; + }, + sortFunc: function(a, b) { + if (a.screenshots == b.screenshots) + return 0; + return a.screenshots < b.screenshots ? 1 : -1; + } + }, + { + id: 'reports', + name: LANG.reports, + type: 'text', + compute: function(user, td) { + $(td).append($WH.number_format(user.reports)); + return; + }, + sortFunc: function(a, b) { + if (a.reports == b.reports) + return 0; + return a.reports < b.reports ? 1 : -1; + } + }, + { + id: 'votes', + name: LANG.votes, + type: 'text', + compute: function(user, td) { + $(td).append($WH.number_format(user.votes)); + return; + }, + sortFunc: function(a, b) { + if (a.votes == b.votes) + return 0; + return a.votes < b.votes ? 1 : -1; + } + }, + { + id: 'uploads', + name: LANG.uploads, + type: 'text', + compute: function(user, c) { + $(c).append($WH.number_format(user.uploads)); + return; + }, + sortFunc: function(a, c) { + if (a.uploads == c.uploads) + return 0; + return a.uploads < c.uploads ? 1 : -1; + } + }, + { + id: 'created', + name: LANG.created, + type: 'text', + hidden: 1, + compute: function(user, td) { + var date = new Date(user.creation), + diff = (g_serverTime - date) / 1000; + + sp = $WH.ce('span'); + g_formatDate(sp, diff, date); + $WH.ae(td, sp); + }, + sortFunc: function(a, b) { + if (a.creation == b.creation) + return 0; + return a.creation < b.creation ? 1 : -1; + } + } + ], + + getItemLink: function(user) { + return '?user=' + user.username; + } + }, + skill: { sort: [1], searchable: 1, @@ -13730,7 +13927,7 @@ Listview.templates = { td.className = 'q1'; var a = $WH.ce('a'); - a.href = '/user=' + reply.user; + a.href = '?user=' + reply.user; $WH.ae(a, $WH.ct(reply.user)) $WH.ae(td, a); } diff --git a/static/js/locale_dede.js b/static/js/locale_dede.js index d13c28ef..e40b7433 100644 --- a/static/js/locale_dede.js +++ b/static/js/locale_dede.js @@ -2370,6 +2370,10 @@ var g_conditions = { /* end custom */ var LANG = { + alltime_stc: "Allzeit", + lastmonth_stc: "Letzter Monat", + lastweek_stc: "Letzte Woche", + linkremoved: "Link entfernt", linkremoved_tip: "Neue Benutzer können nicht
zu nicht-weißgelisteten Seiten verlinken.", diff --git a/static/js/locale_enus.js b/static/js/locale_enus.js index c0b9f2f2..5d9ccc38 100644 --- a/static/js/locale_enus.js +++ b/static/js/locale_enus.js @@ -2417,6 +2417,10 @@ var g_conditions = { /* end custom */ var LANG = { + alltime_stc: "All Time", + lastmonth_stc: "Last Month", + lastweek_stc: "Last Week", + linkremoved: "link removed", linkremoved_tip: "Newly registered users cannot
post links.", diff --git a/static/js/locale_eses.js b/static/js/locale_eses.js index 76617bea..d111f3b5 100644 --- a/static/js/locale_eses.js +++ b/static/js/locale_eses.js @@ -2371,6 +2371,10 @@ var g_conditions = { }; var LANG = { + alltime_stc: "Todo el tiempo", + lastmonth_stc: "Mes pasado", + lastweek_stc: "Semana pasada", + linkremoved: "enlace eliminado", linkremoved_tip: "Los nuevos usuarios no pueden enlazar a
webs que no estén aprobadas.", diff --git a/static/js/locale_frfr.js b/static/js/locale_frfr.js index 74172c09..f00a4ede 100644 --- a/static/js/locale_frfr.js +++ b/static/js/locale_frfr.js @@ -2360,6 +2360,10 @@ var g_conditions = { /* end custom */ var LANG = { + alltime_stc: "A chaque fois", + lastmonth_stc: "Mois dernier", + lastweek_stc: "Semaine dernière", + linkremoved: "lien enlevé", linkremoved_tip: "Les nouveaux utilisateurs ne peuvent pas donner de liens vers
des sites web non-approuvés.", diff --git a/static/js/locale_ruru.js b/static/js/locale_ruru.js index 15860368..7c771682 100644 --- a/static/js/locale_ruru.js +++ b/static/js/locale_ruru.js @@ -2360,6 +2360,10 @@ var g_conditions = { /* end custom */ var LANG = { + alltime_stc: "Все время", + lastmonth_stc: "Последний месяц", + lastweek_stc: "Последняя неделя", + linkremoved: "ссылка удалена", linkremoved_tip: "Новые пользователи не могут публиковать
\nссылки на не разрешенные сайты.",