Skip to content

Commit

Permalink
Some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Pico committed Nov 15, 2014
1 parent a613afd commit 33a6623
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 100 deletions.
3 changes: 0 additions & 3 deletions acp/reputation_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ function main($id, $mode)
{
global $phpbb_container, $user;

// Add the pages ACP lang file
$user->add_lang_ext('pico/reputation', 'reputation_acp');

// Define acp controller
$acp_controller = $phpbb_container->get('pico.reputation.acp.controller');

Expand Down
138 changes: 60 additions & 78 deletions controller/details_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,29 +194,21 @@ public function details($uid, $sort_key, $sort_dir, $page)

while ($row = $this->db->sql_fetchrow($result))
{
// Display avatar if it is enabled
$avatar_dimensions = $this->reputation_helper->avatar_dimensions('medium');
$row['user_avatar_width'] = !$row['user_avatar'] ?: ($row['user_avatar_width'] > $row['user_avatar_height']) ? $avatar_dimensions : ($avatar_dimensions / $row['user_avatar_height']) * $row['user_avatar_width'];
$row['user_avatar_height'] = !$row['user_avatar'] ?: ($row['user_avatar_height'] > $row['user_avatar_width']) ? $avatar_dimensions : ($avatar_dimensions / $row['user_avatar_width']) * $row['user_avatar_height'];

$can_delete = ($this->auth->acl_get('m_rs_moderate') || ($row['user_id_from'] == $this->user->data['user_id'] && $this->auth->acl_get('u_rs_delete'))) ? true : false;

$this->template->assign_block_vars('reputation', array(
'REP_ID' => $row['reputation_id'],
'USERNAME' => get_username_string('full', $row['user_id_from'], $row['username'], $row['user_colour']),
'ACTION' => $this->user->lang('RS_' . strtoupper($row['reputation_type_name']) . '_RATING'),
'AVATAR' => phpbb_get_user_avatar($row),
'AVATAR_DIM' => $avatar_dimensions,
'TIME' => $this->user->format_date($row['reputation_time']),
'COMMENT' => $row['reputation_comment'],
'POINTS' => $row['reputation_points'],
'POINTS_CLASS' => $this->reputation_helper->reputation_class($row['reputation_points']),
'POINTS_TITLE' => $this->user->lang('RS_POINTS_TITLE', $row['reputation_points']),

'U_DELETE' => $this->helper->route('reputation_delete_controller', array('rid' => $row['reputation_id'])),

'S_COMMENT' => !empty($row['reputation_comment']),
'S_DELETE' => $can_delete,
'ID' => $row['reputation_id'],
'USERNAME' => get_username_string('full', $row['user_id_from'], $row['username'], $row['user_colour']),
'ACTION' => $this->user->lang('RS_' . strtoupper($row['reputation_type_name']) . '_RATING'),
'AVATAR' => phpbb_get_user_avatar($row),
'TIME' => $this->user->format_date($row['reputation_time']),
'COMMENT' => $row['reputation_comment'],
'POINTS' => $row['reputation_points'],
'POINTS_CLASS' => $this->reputation_helper->reputation_class($row['reputation_points']),
'POINTS_TITLE' => $this->user->lang('RS_POINTS_TITLE', $row['reputation_points']),

'U_DELETE' => $this->helper->route('reputation_delete_controller', array('rid' => $row['reputation_id'])),

'S_COMMENT' => !empty($row['reputation_comment']),
'S_DELETE' => ($this->auth->acl_get('m_rs_moderate') || ($row['user_id_from'] == $this->user->data['user_id'] && $this->auth->acl_get('u_rs_delete'))) ? true : false,
));

// Generate post url
Expand Down Expand Up @@ -340,7 +332,13 @@ public function details($uid, $sort_key, $sort_dir, $page)
'sort_key' => $sort_key,
'sort_dir' => $sort_dir,
),
), 'pagination', 'page', $total_reps, $this->config['rs_per_page'], $start);
),
'pagination',
'page',
$total_reps,
$this->config['rs_per_page'],
$start
);

$this->template->assign_vars(array(
'USER_ID' => $user_row['user_id'],
Expand Down Expand Up @@ -432,7 +430,7 @@ public function postdetails($post_id, $sort_key, $sort_dir)
$post_row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);

//We couldn't find this post. May be it was deleted while user voted?
//We couldn't find the post. It might be deleted while user tried voting?
if (empty($post_row))
{
$message = $this->user->lang('RS_NO_POST');
Expand Down Expand Up @@ -487,49 +485,41 @@ public function postdetails($post_id, $sort_key, $sort_dir)

while ($row = $this->db->sql_fetchrow($result))
{
// Display avatar if it is enabled
$avatar_dimensions = $this->reputation_helper->avatar_dimensions($is_ajax ? 'small' : 'medium');
$row['user_avatar_width'] = !$row['user_avatar'] ?: ($row['user_avatar_width'] > $row['user_avatar_height']) ? $avatar_dimensions : ($avatar_dimensions / $row['user_avatar_height']) * $row['user_avatar_width'];
$row['user_avatar_height'] = !$row['user_avatar'] ?: ($row['user_avatar_height'] > $row['user_avatar_width']) ? $avatar_dimensions : ($avatar_dimensions / $row['user_avatar_width']) * $row['user_avatar_height'];

$can_delete = ($this->auth->acl_get('m_rs_moderate') || ($row['user_id_from'] == $this->user->data['user_id'] && $this->auth->acl_get('u_rs_delete'))) ? true : false;

$this->template->assign_block_vars('reputation', array(
'REP_ID' => $row['reputation_id'],
'USERNAME' => get_username_string('full', $row['user_id_from'], $row['username'], $row['user_colour']),
'AVATAR' => phpbb_get_user_avatar($row),
'AVATAR_DIM' => $avatar_dimensions,
'TIME' => $this->user->format_date($row['reputation_time']),
'COMMENT' => $row['reputation_comment'],
'POINTS' => $row['reputation_points'],
'POINTS_CLASS' => $this->reputation_helper->reputation_class($row['reputation_points']),
'POINTS_TITLE' => $this->user->lang('RS_POINTS_TITLE', $row['reputation_points']),

'U_DELETE' => $this->helper->route('reputation_delete_controller', array('rid' => $row['reputation_id'])),

'S_COMMENT' => !empty($row['reputation_comment']),
'S_DELETE' => $can_delete,
'ID' => $row['reputation_id'],
'USERNAME' => get_username_string('full', $row['user_id_from'], $row['username'], $row['user_colour']),
'AVATAR' => phpbb_get_user_avatar($row),
'TIME' => $this->user->format_date($row['reputation_time']),
'COMMENT' => $row['reputation_comment'],
'POINTS' => $row['reputation_points'],
'POINTS_CLASS' => $this->reputation_helper->reputation_class($row['reputation_points']),
'POINTS_TITLE' => $this->user->lang('RS_POINTS_TITLE', $row['reputation_points']),

'U_DELETE' => $this->helper->route('reputation_delete_controller', array('rid' => $row['reputation_id'])),

'S_COMMENT' => !empty($row['reputation_comment']),
'S_DELETE' => ($this->auth->acl_get('m_rs_moderate') || ($row['user_id_from'] == $this->user->data['user_id'] && $this->auth->acl_get('u_rs_delete'))) ? true : false,
));
}
$this->db->sql_freeresult($result);

$this->template->assign_vars(array(
'POST_ID' => $post_id,
'POST_SUBJECT' => $post_row['post_subject'],
'POST_AUTHOR' => get_username_string('full', $post_row['poster_id'], $post_row['username'], $post_row['user_colour']),
'POST_ID' => $post_id,
'POST_SUBJECT' => $post_row['post_subject'],
'POST_AUTHOR' => get_username_string('full', $post_row['poster_id'], $post_row['username'], $post_row['user_colour']),

'U_SORT_USERNAME' => $this->helper->route('reputation_post_details_controller', array('post_id' => $post_id, 'sort_key' => 'username', 'sort_dir' => ($sort_key == 'username' && $sort_dir == 'asc') ? 'dsc' : 'asc')),
'U_SORT_TIME' => $this->helper->route('reputation_post_details_controller', array('post_id' => $post_id, 'sort_key' => 'time', 'sort_dir' => ($sort_key == 'time' && $sort_dir == 'asc') ? 'dsc' : 'asc')),
'U_SORT_POINT' => $this->helper->route('reputation_post_details_controller', array('post_id' => $post_id, 'sort_key' => 'point', 'sort_dir' => ($sort_key == 'point' && $sort_dir == 'asc') ? 'dsc' : 'asc')),

'U_CLEAR' => $this->helper->route('reputation_clear_post_controller', array('post_id' => $post_id)),
'U_RS_REFERER' => $referer,
'U_CLEAR' => $this->helper->route('reputation_clear_post_controller', array('post_id' => $post_id)),
'U_REPUTATION_REFERER' => $referer,

'S_RS_AVATAR' => $this->config['rs_display_avatar'] ? true : false,
'S_RS_COMMENT' => $this->config['rs_enable_comment'] ? true : false,
'S_RS_POINTS_IMG' => $this->config['rs_point_type'] ? true : false,
'S_CLEAR' => $this->auth->acl_gets('m_rs_moderate') ? true : false,
'S_IS_AJAX' => $is_ajax,
'S_IS_AJAX' => $is_ajax ? true : false,
));

return $this->helper->render('postdetails.html');
Expand Down Expand Up @@ -566,9 +556,9 @@ public function userdetails($uid, $sort_key, $sort_dir)
}

$sql = 'SELECT user_id, username, user_colour
FROM ' . USERS_TABLE . "
FROM ' . USERS_TABLE . '
WHERE user_type <> 2
AND user_id = $uid";
AND user_id =' . (int) $uid;
$result = $this->db->sql_query($sql);
$user_row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
Expand Down Expand Up @@ -636,29 +626,21 @@ public function userdetails($uid, $sort_key, $sort_dir)

while ($row = $this->db->sql_fetchrow($result))
{
// Display avatar if it is enabled
$avatar_dimensions = $this->reputation_helper->avatar_dimensions($is_ajax ? 'small' : 'medium');
$row['user_avatar_width'] = !$row['user_avatar'] ?: ($row['user_avatar_width'] > $row['user_avatar_height']) ? $avatar_dimensions : ($avatar_dimensions / $row['user_avatar_height']) * $row['user_avatar_width'];
$row['user_avatar_height'] = !$row['user_avatar'] ?: ($row['user_avatar_height'] > $row['user_avatar_width']) ? $avatar_dimensions : ($avatar_dimensions / $row['user_avatar_width']) * $row['user_avatar_height'];

$can_delete = ($this->auth->acl_get('m_rs_moderate') || ($row['user_id_from'] == $this->user->data['user_id'] && $this->auth->acl_get('u_rs_delete'))) ? true : false;

$this->template->assign_block_vars('reputation', array(
'REP_ID' => $row['reputation_id'],
'USERNAME' => get_username_string('full', $row['user_id_from'], $row['username'], $row['user_colour']),
'ACTION' => $this->user->lang('RS_' . strtoupper($row['reputation_type_name']) . '_RATING'),
'AVATAR' => phpbb_get_user_avatar($row),
'AVATAR_DIM' => $avatar_dimensions,
'TIME' => $this->user->format_date($row['reputation_time']),
'COMMENT' => $row['reputation_comment'],
'POINTS' => $row['reputation_points'],
'POINTS_CLASS' => $this->reputation_helper->reputation_class($row['reputation_points']),
'POINTS_TITLE' => $this->user->lang('RS_POINTS_TITLE', $row['reputation_points']),

'U_DELETE' => $this->helper->route('reputation_delete_controller', array('rid' => $row['reputation_id'])),

'S_COMMENT' => !empty($row['reputation_comment']),
'S_DELETE' => $can_delete,
'ID' => $row['reputation_id'],
'USERNAME' => get_username_string('full', $row['user_id_from'], $row['username'], $row['user_colour']),
'ACTION' => $this->user->lang('RS_' . strtoupper($row['reputation_type_name']) . '_RATING'),
'AVATAR' => phpbb_get_user_avatar($row),
'TIME' => $this->user->format_date($row['reputation_time']),
'COMMENT' => $row['reputation_comment'],
'POINTS' => $row['reputation_points'],
'POINTS_CLASS' => $this->reputation_helper->reputation_class($row['reputation_points']),
'POINTS_TITLE' => $this->user->lang('RS_POINTS_TITLE', $row['reputation_points']),

'U_DELETE' => $this->helper->route('reputation_delete_controller', array('rid' => $row['reputation_id'])),

'S_COMMENT' => !empty($row['reputation_comment']),
'S_DELETE' => ($this->auth->acl_get('m_rs_moderate') || ($row['user_id_from'] == $this->user->data['user_id'] && $this->auth->acl_get('u_rs_delete'))) ? true : false,
));

// Generate post url
Expand All @@ -675,16 +657,16 @@ public function userdetails($uid, $sort_key, $sort_dir)
'U_SORT_POINT' => $this->helper->route('reputation_user_details_controller', array('uid' => $uid, 'sort_key' => 'point', 'sort_dir' => ($sort_key == 'point' && $sort_dir == 'asc') ? 'dsc' : 'asc')),
'U_SORT_ACTION' => $this->helper->route('reputation_user_details_controller', array('uid' => $uid, 'sort_key' => 'action', 'sort_dir' => ($sort_key == 'action' && $sort_dir == 'asc') ? 'dsc' : 'asc')),

'U_CLEAR' => $this->helper->route('reputation_clear_user_controller', array('uid' => $uid)),
'U_RS_REFERER' => $referer,
'U_CLEAR' => $this->helper->route('reputation_clear_user_controller', array('uid' => $uid)),
'U_REPUTATION_REFERER' => $referer,

'L_RS_USER_REPUTATION' => $this->user->lang('RS_USER_REPUTATION', get_username_string('username', $user_row['user_id'], $user_row['username'], $user_row['user_colour'])),

'S_RS_AVATAR' => $this->config['rs_display_avatar'] ? true : false,
'S_RS_COMMENT' => $this->config['rs_enable_comment'] ? true : false,
'S_RS_POINTS_IMG' => $this->config['rs_point_type'] ? true : false,
'S_CLEAR' => $this->auth->acl_gets('m_rs_moderate') ? true : false,
'S_IS_AJAX' => $is_ajax,
'S_IS_AJAX' => $is_ajax ? true : false,
));

return $this->helper->render('userdetails.html');
Expand Down
3 changes: 1 addition & 2 deletions controller/rating_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function post($mode, $post_id)
{
$this->user->add_lang_ext('pico/reputation', 'reputation_rating');

// Define some variables
// Define basic variables
$error = '';
$is_ajax = $this->request->is_ajax();
$referer = $this->symfony_request->get('_referer');
Expand All @@ -130,7 +130,6 @@ public function post($mode, $post_id)

$reputation_type_id = (int) $this->reputation_manager->get_reputation_type_id('post');

// Let get sql data
$sql_array = array(
'SELECT' => 'p.forum_id, p.poster_id, u.user_type, u.user_reputation, f.reputation_enabled, r.reputation_id, r.reputation_points',
'FROM' => array(
Expand Down
3 changes: 1 addition & 2 deletions core/reputation_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ public function store_reputation($data)

// Update user reputation
$sql = 'UPDATE ' . USERS_TABLE . "
SET user_reputation = user_reputation + {$data['reputation_points']},
user_last_reputation = {$data['reputation_time']}
SET user_reputation = user_reputation + {$data['reputation_points']}
WHERE user_id = {$data['user_id_to']}";
$this->db->sql_query($sql);

Expand Down
2 changes: 0 additions & 2 deletions migrations/v10x/m5_initial_columns.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public function update_schema()
),
$this->table_prefix . 'users' => array(
'user_reputation' => array('INT:11', 0),
'user_last_reputation' => array('INT:11', 0),
),
$this->table_prefix . 'posts' => array(
'post_reputation' => array('INT:11', 0),
Expand All @@ -50,7 +49,6 @@ public function revert_schema()
),
$this->table_prefix . 'users' => array(
'user_reputation',
'user_last_reputation',
),
$this->table_prefix . 'posts' => array(
'post_reputation',
Expand Down
10 changes: 8 additions & 2 deletions styles/prosilver/template/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,15 @@ <h3>{L_RS_STATS}</h3>
<div id="post-reputation-list">
<!-- IF .reputation -->
<!-- BEGIN reputation -->
<div class="reputation-list <!-- IF reputation.S_ROW_COUNT is odd -->bg2<!-- ELSE -->bg1<!-- ENDIF -->" id="r{reputation.REP_ID}">
<div class="reputation-list <!-- IF reputation.S_ROW_COUNT is odd -->bg2<!-- ELSE -->bg1<!-- ENDIF -->" id="r{reputation.ID}">
<!-- IF S_RS_AVATAR -->
<div class="reputation-avatar"><!-- IF reputation.AVATAR -->{reputation.AVATAR}<!-- ELSE --><img src="{T_THEME_PATH}/images/no_avatar.gif" width="{reputation.AVATAR_DIM}px;" height="{reputation.AVATAR_DIM}px;"alt="" /><!-- ENDIF --></div>
<div class="reputation-avatar">
<!-- IF reputation.AVATAR -->
{reputation.AVATAR}
<!-- ELSE -->
<img src="{T_THEME_PATH}/images/no_avatar.gif" alt="" />
<!-- ENDIF -->
</div>
<!-- ENDIF -->
<div class="reputation-detail">
<!-- IF reputation.S_DELETE --><a href="{reputation.U_DELETE}" class="reputation-delete" title="{L_DELETE}" data-lang-confirm="{L_RS_REPUTATION_DELETE_CONFIRM}">{L_DELETE}</a><!-- ENDIF -->
Expand Down
12 changes: 9 additions & 3 deletions styles/prosilver/template/postdetails.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ <h3>{L_RS_POST_REPUTATION} - {POST_SUBJECT}</h3>
<div id="post-reputation-list">
<!-- IF .reputation -->
<!-- BEGIN reputation -->
<div class="reputation-list <!-- IF reputation.S_ROW_COUNT is odd -->bg2<!-- ELSE -->bg1<!-- ENDIF -->" id="r{reputation.REP_ID}">
<div class="reputation-list <!-- IF reputation.S_ROW_COUNT is odd -->bg2<!-- ELSE -->bg1<!-- ENDIF -->" id="r{reputation.ID}">
<!-- IF S_RS_AVATAR -->
<div class="reputation-avatar"><!-- IF reputation.AVATAR -->{reputation.AVATAR}<!-- ELSE --><img src="{T_THEME_PATH}/images/no_avatar.gif" width="{reputation.AVATAR_DIM}px;" height="{reputation.AVATAR_DIM}px;" alt="" /><!-- ENDIF --></div>
<div class="reputation-avatar">
<!-- IF reputation.AVATAR -->
{reputation.AVATAR}
<!-- ELSE -->
<img src="{T_THEME_PATH}/images/no_avatar.gif" alt="" />
<!-- ENDIF -->
</div>
<!-- ENDIF -->
<div class="reputation-detail">
<!-- IF reputation.S_DELETE --><a href="{reputation.U_DELETE}" class="reputation-delete" title="{L_DELETE}" data-lang-confirm="{L_RS_REPUTATION_DELETE_CONFIRM}">{L_DELETE}</a><!-- ENDIF -->
Expand All @@ -34,7 +40,7 @@ <h3>{L_RS_POST_REPUTATION} - {POST_SUBJECT}</h3>
</div>

<!-- IF .reputation -->
<div class="footer-popup"<!-- IF S_IS_AJAX --> data-referer="_referer={U_RS_REFERER}"<!-- ENDIF -->>
<div class="footer-popup"<!-- IF S_IS_AJAX --> data-referer="_referer={U_REPUTATION_REFERER}"<!-- ENDIF -->>
<label>{L_SORT_BY}:</label>
<a href="{U_SORT_USERNAME}" class="sort_order">{L_USERNAME}</a> &bull;
<a href="{U_SORT_TIME}" class="sort_order">{L_TIME}</a> &bull;
Expand Down
14 changes: 10 additions & 4 deletions styles/prosilver/template/userdetails.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ <h3>{L_RS_USER_REPUTATION} <span style="float:right;"><a href="{U_USER_DETAILS}"
<div id="post-reputation-list">
<!-- IF .reputation -->
<!-- BEGIN reputation -->
<div class="reputation-list <!-- IF reputation.S_ROW_COUNT is odd -->bg2<!-- ELSE -->bg1<!-- ENDIF -->" id="r{reputation.REP_ID}">
<div class="reputation-list <!-- IF reputation.S_ROW_COUNT is odd -->bg2<!-- ELSE -->bg1<!-- ENDIF -->" id="r{reputation.ID}">
<!-- IF S_RS_AVATAR -->
<div class="reputation-avatar"><!-- IF reputation.AVATAR -->{reputation.AVATAR}<!-- ELSE --><img src="{T_THEME_PATH}/images/no_avatar.gif" width="{reputation.AVATAR_DIM}px;" height="{reputation.AVATAR_DIM}px;" alt="" /><!-- ENDIF --></div>
<div class="reputation-avatar">
<!-- IF reputation.AVATAR -->
{reputation.AVATAR}
<!-- ELSE -->
<img src="{T_THEME_PATH}/images/no_avatar.gif" alt="" />
<!-- ENDIF -->
</div>
<!-- ENDIF -->
<div class="reputation-detail">
<!-- IF reputation.S_DELETE --><a href="{reputation.U_DELETE}" class="reputation-delete" title="{L_DELETE}" data-lang-confirm="{L_RS_REPUTATION_DELETE_CONFIRM}">{L_DELETE}</a><!-- ENDIF -->
Expand All @@ -21,7 +27,7 @@ <h3>{L_RS_USER_REPUTATION} <span style="float:right;"><a href="{U_USER_DETAILS}"
<!-- IF reputation.post.S_POST -->
<br />&raquo;
<!-- IF reputation.post.U_POST --><a href="{reputation.post.U_POST}" title="{L_POST}"><!-- ENDIF -->
{reputation.post.POST_SUBJECT}
{reputation.post.POST_SUBJECT}
<!-- IF reputation.post.U_POST --></a><!-- ENDIF -->
<!-- ENDIF -->
<!-- END reputation.post -->
Expand All @@ -43,7 +49,7 @@ <h3>{L_RS_USER_REPUTATION} <span style="float:right;"><a href="{U_USER_DETAILS}"
</div>

<!-- IF .reputation -->
<div class="footer-popup"<!-- IF S_IS_AJAX --> data-referer="_referer={U_RS_REFERER}"<!-- ENDIF -->>
<div class="footer-popup"<!-- IF S_IS_AJAX --> data-referer="_referer={U_REPUTATION_REFERER}"<!-- ENDIF -->>
<label>{L_SORT_BY}:</label>
<a href="{U_SORT_USERNAME}" class="sort_order">{L_USERNAME}</a> &bull;
<a href="{U_SORT_TIME}" class="sort_order">{L_TIME}</a> &bull;
Expand Down
7 changes: 5 additions & 2 deletions styles/prosilver/theme/reputation_common.css
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,11 @@
border: 1px solid #D5D5D5;
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.1);
}

.reputation-avatar img{ display: block !important; }
.reputation-avatar img {
display: block !important;
width: 60px;
height: initial;
}

.reputation-rating {
display: block;
Expand Down
Loading

0 comments on commit 33a6623

Please sign in to comment.