From 3bca4bc6e0f6288d566e12a479261a7febd74a9b Mon Sep 17 00:00:00 2001 From: Mark Vincent Date: Mon, 4 Dec 2017 19:02:07 -0600 Subject: [PATCH 1/5] Fixes #289 --- Upload/inc/plugins/asb/modules/goals.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Upload/inc/plugins/asb/modules/goals.php b/Upload/inc/plugins/asb/modules/goals.php index 27cef3d..04e029d 100644 --- a/Upload/inc/plugins/asb/modules/goals.php +++ b/Upload/inc/plugins/asb/modules/goals.php @@ -184,6 +184,7 @@ function asb_goals_get_progress($args) $query = $db->simple_select($table, "{$function}({$field}) AS total"); $total = $db->fetch_field($query, 'total'); + $formatted_total = my_number_format($total); $goal = (int) $settings['goal']; $formatted_goal = my_number_format($goal); @@ -203,7 +204,7 @@ function asb_goals_get_progress($args) $percentage = round(($total / $goal) * 100, 1); $stats = $lang->sprintf($lang->asb_goals_footer_progress, $itemsLeft, $goal_type_plural); $progress_message = $lang->sprintf($lang->asb_goals_progress_message, $formatted_goal, $goal_type_plural); - $progress_bar_title = $lang->sprintf($lang->asb_goals_progress_bar_title, $total, $formatted_goal); + $progress_bar_title = $lang->sprintf($lang->asb_goals_progress_bar_title, $formatted_total, $formatted_goal); eval("\$progress = \"{$templates->get('asb_goals_progress')}\";"); } From 4b5c29ac60941993bfc91555e2dbfe78bb6b279c Mon Sep 17 00:00:00 2001 From: Mark Vincent Date: Tue, 19 Dec 2017 19:19:57 -0600 Subject: [PATCH 2/5] Fixes #291 --- .../english/admin/asb_addon.lang.php | 6 ++++- .../inc/languages/english/asb_addon.lang.php | 6 ++++- Upload/inc/plugins/asb/modules/top_poster.php | 26 ++++++++++++++++--- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/Upload/inc/languages/english/admin/asb_addon.lang.php b/Upload/inc/languages/english/admin/asb_addon.lang.php index 28f04c4..542660b 100644 --- a/Upload/inc/languages/english/admin/asb_addon.lang.php +++ b/Upload/inc/languages/english/admin/asb_addon.lang.php @@ -246,13 +246,17 @@ $l['asb_top_poster_congrats'] = 'Congratulations to {1}, our current top poster for the last {2} with {3} {4}{5}!'; $l['asb_top_poster_congrats_all_time'] = 'Congratulations to {1}, our all time top poster with {2} {3}{4}!'; $l['asb_top_poster_specific_thread_congrats'] = ' in {1}'; +$l['asb_top_poster_specific_forum_congrats'] = ' in {1}'; $l['asb_top_poster_description'] = 'Top Posters For {1}'; $l['asb_top_poster_time_frame_title'] = 'Time Frame'; $l['asb_top_poster_time_frame_desc'] = 'time to compare for top poster stats'; +$l['asb_top_poster_fid_title'] = 'Forum ID'; +$l['asb_top_poster_fid_desc'] = 'enter a forum id to show the top poster for that forum, leave this field blank to show the top poster from all forums (default)'; + $l['asb_top_poster_tid_title'] = 'Thread ID'; -$l['asb_top_poster_tid_desc'] = 'enter a thread id to show the top poster for that thread, leave this field blank to show the top poster from all threads (default)'; +$l['asb_top_poster_tid_desc'] = 'enter a thread id to show the top poster for that thread, leave this field blank to show the top poster from all threads (default) [this setting will override the above forum setting'; $l['asb_top_poster_max_posters_title'] = 'Number Of Top Posters'; $l['asb_top_poster_max_posters_desc'] = '0 or invalid values default to 1'; diff --git a/Upload/inc/languages/english/asb_addon.lang.php b/Upload/inc/languages/english/asb_addon.lang.php index 28f04c4..542660b 100644 --- a/Upload/inc/languages/english/asb_addon.lang.php +++ b/Upload/inc/languages/english/asb_addon.lang.php @@ -246,13 +246,17 @@ $l['asb_top_poster_congrats'] = 'Congratulations to {1}, our current top poster for the last {2} with {3} {4}{5}!'; $l['asb_top_poster_congrats_all_time'] = 'Congratulations to {1}, our all time top poster with {2} {3}{4}!'; $l['asb_top_poster_specific_thread_congrats'] = ' in {1}'; +$l['asb_top_poster_specific_forum_congrats'] = ' in {1}'; $l['asb_top_poster_description'] = 'Top Posters For {1}'; $l['asb_top_poster_time_frame_title'] = 'Time Frame'; $l['asb_top_poster_time_frame_desc'] = 'time to compare for top poster stats'; +$l['asb_top_poster_fid_title'] = 'Forum ID'; +$l['asb_top_poster_fid_desc'] = 'enter a forum id to show the top poster for that forum, leave this field blank to show the top poster from all forums (default)'; + $l['asb_top_poster_tid_title'] = 'Thread ID'; -$l['asb_top_poster_tid_desc'] = 'enter a thread id to show the top poster for that thread, leave this field blank to show the top poster from all threads (default)'; +$l['asb_top_poster_tid_desc'] = 'enter a thread id to show the top poster for that thread, leave this field blank to show the top poster from all threads (default) [this setting will override the above forum setting'; $l['asb_top_poster_max_posters_title'] = 'Number Of Top Posters'; $l['asb_top_poster_max_posters_desc'] = '0 or invalid values default to 1'; diff --git a/Upload/inc/plugins/asb/modules/top_poster.php b/Upload/inc/plugins/asb/modules/top_poster.php index 49ffa32..7edbbdd 100644 --- a/Upload/inc/plugins/asb/modules/top_poster.php +++ b/Upload/inc/plugins/asb/modules/top_poster.php @@ -51,6 +51,13 @@ function asb_top_poster_info() , 'value' => '1', ), + 'fid' => array( + 'name' => 'fid', + 'title' => $lang->asb_top_poster_fid_title, + 'description' => $lang->asb_top_poster_fid_desc, + 'optionscode' => 'text', + 'value' => '', + ), 'tid' => array( 'name' => 'tid', 'title' => $lang->asb_top_poster_tid_title, @@ -203,8 +210,9 @@ function asb_top_poster_build_template($args) $where['hide'] = asb_build_SQL_where($hide, ' OR ', ' NOT '); $group_where = asb_build_SQL_where($where, ' AND ', ' AND '); - $thread_where = $extraCongrats = ''; + $forum_where = $thread_where = $extraCongrats = ''; $tid = (int) $settings['tid']; + $fid = (int) $settings['fid']; if ($tid) { $thread_where = " AND p.tid='{$tid}'"; $threadQuery = $db->simple_select('threads', 'subject', "tid='{$tid}'"); @@ -220,6 +228,17 @@ function asb_top_poster_build_template($args) EOF; $extraCongrats = $lang->sprintf($lang->asb_top_poster_specific_thread_congrats, $threadLink); } + } elseif ($fid) { + $forum_where = " AND p.fid='{$fid}'"; + $forumQuery = $db->simple_select('forums', 'name', "fid='{$fid}'"); + if ($db->num_rows($forumQuery) > 0) { + $forumTitle = $db->fetch_field($forumQuery, 'name'); + $forumUrl = get_forum_link($fid); + $forumLink = <<{$forumTitle} +EOF; + $extraCongrats = $lang->sprintf($lang->asb_top_poster_specific_forum_congrats, $forumLink); + } } $group_by = 'p.uid'; @@ -228,12 +247,13 @@ function asb_top_poster_build_template($args) } if ($time_frame > 0 || - $tid) { + $tid || + $fid) { $query = $db->query(" SELECT u.uid, u.username, u.usergroup, u.displaygroup, u.avatar, COUNT(p.pid) AS totalposts FROM {$db->table_prefix}posts p LEFT JOIN {$db->table_prefix}users u ON (p.uid=u.uid) - WHERE p.dateline > {$timesearch}{$group_where}{$thread_where} + WHERE p.dateline > {$timesearch}{$group_where}{$thread_where}{$forum_where} GROUP BY {$group_by} ORDER BY totalposts DESC LIMIT {$limit} "); From f688ed5a345c6c26a3f3f2be90c1c4a66a757477 Mon Sep 17 00:00:00 2001 From: Mark Vincent Date: Wed, 20 Dec 2017 19:07:16 -0600 Subject: [PATCH 3/5] Fixes #292 --- .../english/admin/asb_addon.lang.php | 10 ++- .../inc/languages/english/asb_addon.lang.php | 10 ++- Upload/inc/plugins/asb/modules/top_poster.php | 75 ++++++++++++++++--- 3 files changed, 83 insertions(+), 12 deletions(-) diff --git a/Upload/inc/languages/english/admin/asb_addon.lang.php b/Upload/inc/languages/english/admin/asb_addon.lang.php index 542660b..0baed45 100644 --- a/Upload/inc/languages/english/admin/asb_addon.lang.php +++ b/Upload/inc/languages/english/admin/asb_addon.lang.php @@ -243,20 +243,28 @@ $l['asb_top_poster_no_avatar'] = 'no avatar'; $l['asb_top_poster_posts'] = 'posts'; $l['asb_top_poster_post'] = 'post'; +$l['asb_top_poster_threads'] = 'threads'; +$l['asb_top_poster_thread'] = 'thread'; $l['asb_top_poster_congrats'] = 'Congratulations to {1}, our current top poster for the last {2} with {3} {4}{5}!'; +$l['asb_top_poster_congrats_threads'] = 'Congratulations to {1}, our current top thread starter for the last {2} with {3} {4}{5}!'; $l['asb_top_poster_congrats_all_time'] = 'Congratulations to {1}, our all time top poster with {2} {3}{4}!'; +$l['asb_top_poster_congrats_all_time_threads'] = 'Congratulations to {1}, our all time thread starter with {2} {3}{4}!'; $l['asb_top_poster_specific_thread_congrats'] = ' in {1}'; $l['asb_top_poster_specific_forum_congrats'] = ' in {1}'; $l['asb_top_poster_description'] = 'Top Posters For {1}'; +$l['asb_top_poster_description_threads'] = 'Top Thread Starters For {1}'; $l['asb_top_poster_time_frame_title'] = 'Time Frame'; $l['asb_top_poster_time_frame_desc'] = 'time to compare for top poster stats'; +$l['asb_top_poster_threads_only_title'] = 'Threads Only?'; +$l['asb_top_poster_threads_only_desc'] = 'YES to only count the creation of new threads, NO (default) to include any post in the count'; + $l['asb_top_poster_fid_title'] = 'Forum ID'; $l['asb_top_poster_fid_desc'] = 'enter a forum id to show the top poster for that forum, leave this field blank to show the top poster from all forums (default)'; $l['asb_top_poster_tid_title'] = 'Thread ID'; -$l['asb_top_poster_tid_desc'] = 'enter a thread id to show the top poster for that thread, leave this field blank to show the top poster from all threads (default) [this setting will override the above forum setting'; +$l['asb_top_poster_tid_desc'] = 'enter a thread id to show the top poster for that thread, leave this field blank to show the top poster from all threads (default)

this setting will override the above forum setting

this setting is ineffective if "Threads Only" is set to YES

'; $l['asb_top_poster_max_posters_title'] = 'Number Of Top Posters'; $l['asb_top_poster_max_posters_desc'] = '0 or invalid values default to 1'; diff --git a/Upload/inc/languages/english/asb_addon.lang.php b/Upload/inc/languages/english/asb_addon.lang.php index 542660b..0baed45 100644 --- a/Upload/inc/languages/english/asb_addon.lang.php +++ b/Upload/inc/languages/english/asb_addon.lang.php @@ -243,20 +243,28 @@ $l['asb_top_poster_no_avatar'] = 'no avatar'; $l['asb_top_poster_posts'] = 'posts'; $l['asb_top_poster_post'] = 'post'; +$l['asb_top_poster_threads'] = 'threads'; +$l['asb_top_poster_thread'] = 'thread'; $l['asb_top_poster_congrats'] = 'Congratulations to {1}, our current top poster for the last {2} with {3} {4}{5}!'; +$l['asb_top_poster_congrats_threads'] = 'Congratulations to {1}, our current top thread starter for the last {2} with {3} {4}{5}!'; $l['asb_top_poster_congrats_all_time'] = 'Congratulations to {1}, our all time top poster with {2} {3}{4}!'; +$l['asb_top_poster_congrats_all_time_threads'] = 'Congratulations to {1}, our all time thread starter with {2} {3}{4}!'; $l['asb_top_poster_specific_thread_congrats'] = ' in {1}'; $l['asb_top_poster_specific_forum_congrats'] = ' in {1}'; $l['asb_top_poster_description'] = 'Top Posters For {1}'; +$l['asb_top_poster_description_threads'] = 'Top Thread Starters For {1}'; $l['asb_top_poster_time_frame_title'] = 'Time Frame'; $l['asb_top_poster_time_frame_desc'] = 'time to compare for top poster stats'; +$l['asb_top_poster_threads_only_title'] = 'Threads Only?'; +$l['asb_top_poster_threads_only_desc'] = 'YES to only count the creation of new threads, NO (default) to include any post in the count'; + $l['asb_top_poster_fid_title'] = 'Forum ID'; $l['asb_top_poster_fid_desc'] = 'enter a forum id to show the top poster for that forum, leave this field blank to show the top poster from all forums (default)'; $l['asb_top_poster_tid_title'] = 'Thread ID'; -$l['asb_top_poster_tid_desc'] = 'enter a thread id to show the top poster for that thread, leave this field blank to show the top poster from all threads (default) [this setting will override the above forum setting'; +$l['asb_top_poster_tid_desc'] = 'enter a thread id to show the top poster for that thread, leave this field blank to show the top poster from all threads (default)

this setting will override the above forum setting

this setting is ineffective if "Threads Only" is set to YES

'; $l['asb_top_poster_max_posters_title'] = 'Number Of Top Posters'; $l['asb_top_poster_max_posters_desc'] = '0 or invalid values default to 1'; diff --git a/Upload/inc/plugins/asb/modules/top_poster.php b/Upload/inc/plugins/asb/modules/top_poster.php index 7edbbdd..2251fb3 100644 --- a/Upload/inc/plugins/asb/modules/top_poster.php +++ b/Upload/inc/plugins/asb/modules/top_poster.php @@ -30,7 +30,7 @@ function asb_top_poster_info() 'title' => $lang->asb_top_poster_title, 'description' => $lang->asb_top_poster_desc, 'wrap_content' => true, - 'version' => '1.2.1', + 'version' => '1.2.2', 'compatibility' => '2.1', 'settings' => array( 'time_frame' => array( @@ -51,6 +51,13 @@ function asb_top_poster_info() , 'value' => '1', ), + 'threads_only' => array( + 'name' => 'threads_only', + 'title' => $lang->asb_top_poster_threads_only_title, + 'description' => $lang->asb_top_poster_threads_only_desc, + 'optionscode' => 'yesno', + 'value' => '0', + ), 'fid' => array( 'name' => 'fid', 'title' => $lang->asb_top_poster_fid_title, @@ -213,7 +220,10 @@ function asb_top_poster_build_template($args) $forum_where = $thread_where = $extraCongrats = ''; $tid = (int) $settings['tid']; $fid = (int) $settings['fid']; - if ($tid) { + $threadsOnly = (bool) $settings['threads_only']; + + if ($tid && + !$threadsOnly) { $thread_where = " AND p.tid='{$tid}'"; $threadQuery = $db->simple_select('threads', 'subject', "tid='{$tid}'"); if ($db->num_rows($threadQuery) > 0) { @@ -230,6 +240,10 @@ function asb_top_poster_build_template($args) } } elseif ($fid) { $forum_where = " AND p.fid='{$fid}'"; + if ($threadsOnly) { + $forum_where = " AND t.fid='{$fid}'"; + } + $forumQuery = $db->simple_select('forums', 'name', "fid='{$fid}'"); if ($db->num_rows($forumQuery) > 0) { $forumTitle = $db->fetch_field($forumQuery, 'name'); @@ -246,21 +260,42 @@ function asb_top_poster_build_template($args) $group_by = $db->build_fields_string('users', 'u.'); } - if ($time_frame > 0 || - $tid || - $fid) { + // all-time top poster (or thread starter) with no specified thread + // can use the simple query + if ($time_frame <= 0 && + !$tid && + !$fid) { + $fieldName = 'postnum'; + if ($threadsOnly) { + $fieldName = 'threadnum'; + } + + $query = $db->simple_select('users', "uid, avatar, username, {$fieldName} as totalposts, usergroup, displaygroup", "{$fieldName} > 0{$group_where}", array('order_by' => $fieldName, 'order_dir' => 'DESC', 'limit' => $limit)); + } elseif ($threadsOnly) { + $group_by = 't.uid'; + + $query = $db->query(" + SELECT u.uid, u.username, u.usergroup, u.displaygroup, u.avatar, COUNT(t.tid) AS totalposts + FROM {$db->table_prefix}threads t + LEFT JOIN {$db->table_prefix}users u ON (t.uid=u.uid) + WHERE t.dateline > {$timesearch}{$group_where}{$forum_where} + GROUP BY {$group_by} + ORDER BY totalposts DESC + LIMIT {$limit} + "); + } else { $query = $db->query(" SELECT u.uid, u.username, u.usergroup, u.displaygroup, u.avatar, COUNT(p.pid) AS totalposts FROM {$db->table_prefix}posts p LEFT JOIN {$db->table_prefix}users u ON (p.uid=u.uid) WHERE p.dateline > {$timesearch}{$group_where}{$thread_where}{$forum_where} - GROUP BY {$group_by} ORDER BY totalposts DESC + GROUP BY {$group_by} + ORDER BY totalposts DESC LIMIT {$limit} "); - } else { - $query = $db->simple_select('users', 'uid, avatar, username, postnum as totalposts, usergroup, displaygroup', "postnum > 0{$group_where}", array('order_by' => 'postnum', 'order_dir' => 'DESC', 'limit' => $limit)); } + // error $altbg = alt_trow(); if ($db->num_rows($query) == 0) { // some defaults @@ -281,9 +316,17 @@ function asb_top_poster_build_template($args) } $top_poster_posts = $user['totalposts']; + $post_lang = $lang->asb_top_poster_posts; + if ($threadsOnly) { + $post_lang = $lang->asb_top_poster_threads; + } + if ($top_poster_posts == 1) { $post_lang = $lang->asb_top_poster_post; + if ($threadsOnly) { + $post_lang = $lang->asb_top_poster_thread; + } } $top_poster_avatar_src = "{$theme['imgdir']}/default_avatar.png"; @@ -298,20 +341,32 @@ function asb_top_poster_build_template($args) if ($db->num_rows($query) == 1) { if ($time_frame == 0) { - $top_poster_text = $lang->sprintf($lang->asb_top_poster_congrats_all_time, $top_poster, $top_poster_posts, $post_lang, $extraCongrats); + if ($threadsOnly) { + $top_poster_text = $lang->sprintf($lang->asb_top_poster_congrats_all_time_threads, $top_poster, $top_poster_posts, $post_lang, $extraCongrats); + } else { + $top_poster_text = $lang->sprintf($lang->asb_top_poster_congrats_all_time, $top_poster, $top_poster_posts, $post_lang, $extraCongrats); + } } else { - $top_poster_text = $lang->sprintf($lang->asb_top_poster_congrats, $top_poster, $top_poster_timeframe, $top_poster_posts, $post_lang, $extraCongrats); + if ($threadsOnly) { + $top_poster_text = $lang->sprintf($lang->asb_top_poster_congrats_threads, $top_poster, $top_poster_timeframe, $top_poster_posts, $post_lang, $extraCongrats); + } else { + $top_poster_text = $lang->sprintf($lang->asb_top_poster_congrats, $top_poster, $top_poster_timeframe, $top_poster_posts, $post_lang, $extraCongrats); + } } $avatar_width = (int) $width * .75; if ((int) $settings['avatar_size']) { $avatar_width = (int) $settings['avatar_size']; } + eval("\$top_poster_avatar = \"" . $templates->get('asb_top_poster_avatar') . "\";"); eval("\$\$template_var = \"" . $templates->get('asb_top_posters_single') . "\";"); } else { $top_poster_description = $lang->sprintf($lang->asb_top_poster_description, $top_poster_timeframe_prelude) . $extraCongrats; + if ($threadsOnly) { + $top_poster_description = $lang->sprintf($lang->asb_top_poster_description_threads, $top_poster_timeframe_prelude) . $extraCongrats; + } $top_poster_text = $top_poster . '
' . $top_poster_posts; $avatar_width = (int) $width * .2; From b566f163500b3a3fdde7570aefe5e44bb894aea2 Mon Sep 17 00:00:00 2001 From: Mark Vincent Date: Wed, 20 Dec 2017 20:00:35 -0600 Subject: [PATCH 4/5] Fixes #293 --- Upload/inc/plugins/asb/classes/SideboxExternalModule.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Upload/inc/plugins/asb/classes/SideboxExternalModule.php b/Upload/inc/plugins/asb/classes/SideboxExternalModule.php index c68c171..0cf23c8 100644 --- a/Upload/inc/plugins/asb/classes/SideboxExternalModule.php +++ b/Upload/inc/plugins/asb/classes/SideboxExternalModule.php @@ -154,6 +154,9 @@ public function install($cleanup = true) $this->uninstall(); } + $this->isUpgraded = $this->isInstalled = true; + $this->setCacheVersion(); + // if there are no templates we're done if (!is_array($this->templates)) { return; From 56fdf16b60d527b0c1110d5301772ac268cb9aac Mon Sep 17 00:00:00 2001 From: Mark Vincent Date: Wed, 20 Dec 2017 20:02:04 -0600 Subject: [PATCH 5/5] 3.1.10 Pre-release --- README.md | 2 +- Upload/inc/plugins/asb.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 117922b..1f5a6e9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Advanced-Sidebox 3.1.9 +## Advanced-Sidebox 3.1.10

Advanced Sidebox Logo diff --git a/Upload/inc/plugins/asb.php b/Upload/inc/plugins/asb.php index 1e66eff..5582d1b 100644 --- a/Upload/inc/plugins/asb.php +++ b/Upload/inc/plugins/asb.php @@ -15,7 +15,7 @@ // for modules define('IN_ASB', true); define('ASB_MODULES_DIR', MYBB_ROOT . 'inc/plugins/asb/modules'); -define('ASB_VERSION', '3.1.9'); +define('ASB_VERSION', '3.1.10'); define('ASB_CUSTOM_VERSION', '2.0'); define('ASB_SCRIPT_VERSION', '2.0');