Skip to content

Commit

Permalink
Merge pull request #294 from WildcardSearch/maintenance
Browse files Browse the repository at this point in the history
3.1.10 Release
  • Loading branch information
Mark Vincent authored Dec 21, 2017
2 parents be5c1c2 + 56fdf16 commit 7e004a0
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Advanced-Sidebox 3.1.9
## Advanced-Sidebox 3.1.10

<p align="center">
<img title="Advanced Sidebox Logo" alt="Advanced Sidebox Logo" src="http://i.imgur.com/4QWLq5V.png" />
Expand Down
14 changes: 13 additions & 1 deletion Upload/inc/languages/english/admin/asb_addon.lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +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)';
$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)<p style="font-style: italic;">this setting will override the above forum setting</p><p style="font-style: italic;">this setting is ineffective if "Threads Only" is set to YES</p>';

$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';
Expand Down
14 changes: 13 additions & 1 deletion Upload/inc/languages/english/asb_addon.lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +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)';
$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)<p style="font-style: italic;">this setting will override the above forum setting</p><p style="font-style: italic;">this setting is ineffective if "Threads Only" is set to YES</p>';

$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';
Expand Down
2 changes: 1 addition & 1 deletion Upload/inc/plugins/asb.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
3 changes: 3 additions & 0 deletions Upload/inc/plugins/asb/classes/SideboxExternalModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion Upload/inc/plugins/asb/modules/goals.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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')}\";");
}

Expand Down
97 changes: 86 additions & 11 deletions Upload/inc/plugins/asb/modules/top_poster.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -51,6 +51,20 @@ 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,
'description' => $lang->asb_top_poster_fid_desc,
'optionscode' => 'text',
'value' => '',
),
'tid' => array(
'name' => 'tid',
'title' => $lang->asb_top_poster_tid_title,
Expand Down Expand Up @@ -203,9 +217,13 @@ 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'];
if ($tid) {
$fid = (int) $settings['fid'];
$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) {
Expand All @@ -220,27 +238,64 @@ 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}'";
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');
$forumUrl = get_forum_link($fid);
$forumLink = <<<EOF
<a href="{$forumUrl}">{$forumTitle}</a>
EOF;
$extraCongrats = $lang->sprintf($lang->asb_top_poster_specific_forum_congrats, $forumLink);
}
}

$group_by = 'p.uid';
if ($db->type == 'pgsql') {
$group_by = $db->build_fields_string('users', 'u.');
}

if ($time_frame > 0 ||
$tid) {
// 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}
GROUP BY {$group_by} ORDER BY totalposts DESC
WHERE p.dateline > {$timesearch}{$group_where}{$thread_where}{$forum_where}
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
Expand All @@ -261,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";
Expand All @@ -278,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 . '<br />' . $top_poster_posts;

$avatar_width = (int) $width * .2;
Expand Down

0 comments on commit 7e004a0

Please sign in to comment.