Skip to content

Commit

Permalink
ticket issue #69
Browse files Browse the repository at this point in the history
fix #69
  • Loading branch information
3D-I committed Sep 2, 2020
1 parent 6c8e988 commit e5ecd31
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 32 deletions.
41 changes: 28 additions & 13 deletions core/tpotm.php
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ protected function perform_cache_on_main_db_query()
$this->db->sql_freeresult($result);

/* There is a TPOTM, let's update the DB then */
if (((int) $row['total_posts'] >= 1) && empty($row['user_tpotm']))
if ( (isset($row['total_posts']) && (int) $row['total_posts'] >= 1) && empty($row['user_tpotm']) )
{
$this->perform_user_reset((int) $row['user_id']);
}
Expand Down Expand Up @@ -606,11 +606,17 @@ public function show_the_winner()
* Data Syncronization
*/
$row = $this->perform_cache_on_main_db_query();
$tpotm_tot_posts = $this->perform_cache_on_tpotm_tot_posts((int) $row['user_id']);
$tpotm_tot_posts = isset($row['user_id']) ? $this->perform_cache_on_tpotm_tot_posts((int) $row['user_id']) : false;
$total_month = $this->perform_cache_on_this_month_total_posts();

/* Only authed can view the profile */
$tpotm_un_string = ($this->auth->acl_get('u_viewprofile')) ? get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']) : get_username_string('no_profile', $row['user_id'], $row['username'], $row['user_colour']);
if ($row)
{
$tpotm_un_string_full = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
$tpotm_un_string_noprofile = get_username_string('no_profile', $row['user_id'], $row['username'], $row['user_colour']);

/* Only authed can view the profile */
$tpotm_un_string = ($this->auth->acl_get('u_viewprofile')) ? $tpotm_un_string_full : $tpotm_un_string_noprofile;
}

/**
* Fresh install (one starting post by founder)
Expand Down Expand Up @@ -643,7 +649,8 @@ public function show_the_winner()
];

/* Prevents a potential Division by Zero below */
$tpotm_tot_posts = ($tpotm_tot_posts === 0) ? true : (int) $tpotm_tot_posts;
$tpotm_tot_posts = ($tpotm_tot_posts == 0) ? true : (int) $tpotm_tot_posts;

/**
* Percentages for Hall of Fame's styling etc..
* It could happen an user posted more than the total posts in the month.
Expand All @@ -663,13 +670,16 @@ public function show_the_winner()
*/
if ((int) $tpotm_tot_posts >= 1)
{
/* Map arguments for phpbb_get_avatar() */
$row_avatar = [
'avatar' => $row['user_avatar'],
'avatar_type' => $row['user_avatar_type'],
'avatar_height' => $row['user_avatar_height'],
'avatar_width' => $row['user_avatar_width'],
];
if ($row)
{
/* Map arguments for phpbb_get_avatar() */
$row_avatar = [
'avatar' => $row['user_avatar'],
'avatar_type' => $row['user_avatar_type'],
'avatar_height' => $row['user_avatar_height'],
'avatar_width' => $row['user_avatar_width'],
];
}

/**
* DAE (Default Avatar Extended) extension compatibility
Expand All @@ -695,7 +705,12 @@ public function show_the_winner()
*/
if ($this->enable_miniavatar())
{
$tpotm_av_url = ($this->auth->acl_get('u_viewprofile')) ? get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']) : '';
$tpotm_av_url = '';

if ($row)
{
$tpotm_av_url = ($this->auth->acl_get('u_viewprofile')) ? get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']) : '';
}

/* DAE (Default Avatar Extended) extension compatibility */
if ($this->is_dae())
Expand Down
21 changes: 2 additions & 19 deletions ext.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,9 @@ class ext extends \phpbb\extension\base
*/
public function is_enableable()
{
$is_enableable = true;

$user = $this->container->get('user');
$user->add_lang_ext('threedi/tpotm', 'ext_require');
$lang = $user->lang;

if (!( (phpbb_version_compare(PHPBB_VERSION, '3.2.1', '>=') && phpbb_version_compare(PHPBB_VERSION, '3.3.0@dev', '<')) || (phpbb_version_compare(PHPBB_VERSION, '3.1.11', '>=') && phpbb_version_compare(PHPBB_VERSION, '3.2.0@dev', '<')) ) )
if ((phpbb_version_compare(PHPBB_VERSION, '3.1.11', '>=') && phpbb_version_compare(PHPBB_VERSION, '4.0.0@dev', '<')))
{
$lang['EXTENSION_NOT_ENABLEABLE'] .= '<br>' . $user->lang('ERROR_MSG_3111_321_MISTMATCH');
$is_enableable = false;
return true;
}

if (!phpbb_version_compare(PHP_VERSION, '5.4.0', '>='))
{
$lang['EXTENSION_NOT_ENABLEABLE'] .= '<br>' . $user->lang('ERROR_MSG_PHP_VERSION');
$is_enableable = false;
}

$user->lang = $lang;

return $is_enableable;
}
}

0 comments on commit e5ecd31

Please sign in to comment.