From 33a6623d3904627aae02a8bd855f9f5d4e6724cb Mon Sep 17 00:00:00 2001 From: Pico Date: Sat, 15 Nov 2014 07:07:18 +0100 Subject: [PATCH] Some fixes --- acp/reputation_module.php | 3 - controller/details_controller.php | 138 ++++++++---------- controller/rating_controller.php | 3 +- core/reputation_manager.php | 3 +- migrations/v10x/m5_initial_columns.php | 2 - styles/prosilver/template/details.html | 10 +- styles/prosilver/template/postdetails.html | 12 +- styles/prosilver/template/userdetails.html | 14 +- styles/prosilver/theme/reputation_common.css | 7 +- .../prosilver/theme/reputation_viewtopic.css | 10 +- 10 files changed, 102 insertions(+), 100 deletions(-) diff --git a/acp/reputation_module.php b/acp/reputation_module.php index 8577cdf..54f1241 100644 --- a/acp/reputation_module.php +++ b/acp/reputation_module.php @@ -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'); diff --git a/controller/details_controller.php b/controller/details_controller.php index 0d72213..14bc50a 100644 --- a/controller/details_controller.php +++ b/controller/details_controller.php @@ -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 @@ -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'], @@ -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'); @@ -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'); @@ -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); @@ -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 @@ -675,8 +657,8 @@ 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'])), @@ -684,7 +666,7 @@ public function userdetails($uid, $sort_key, $sort_dir) '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'); diff --git a/controller/rating_controller.php b/controller/rating_controller.php index 58f0a9c..aef98b4 100644 --- a/controller/rating_controller.php +++ b/controller/rating_controller.php @@ -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'); @@ -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( diff --git a/core/reputation_manager.php b/core/reputation_manager.php index 558b658..9547e49 100644 --- a/core/reputation_manager.php +++ b/core/reputation_manager.php @@ -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); diff --git a/migrations/v10x/m5_initial_columns.php b/migrations/v10x/m5_initial_columns.php index cd8e717..82f00d3 100644 --- a/migrations/v10x/m5_initial_columns.php +++ b/migrations/v10x/m5_initial_columns.php @@ -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), @@ -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', diff --git a/styles/prosilver/template/details.html b/styles/prosilver/template/details.html index 4607832..4a19ef9 100644 --- a/styles/prosilver/template/details.html +++ b/styles/prosilver/template/details.html @@ -122,9 +122,15 @@

{L_RS_STATS}

-
+
-
{reputation.AVATAR}
+
+ + {reputation.AVATAR} + + + +
{L_DELETE} diff --git a/styles/prosilver/template/postdetails.html b/styles/prosilver/template/postdetails.html index 744c020..f415262 100644 --- a/styles/prosilver/template/postdetails.html +++ b/styles/prosilver/template/postdetails.html @@ -9,9 +9,15 @@

{L_RS_POST_REPUTATION} - {POST_SUBJECT}

-
+
-
{reputation.AVATAR}
+
+ + {reputation.AVATAR} + + + +
{L_DELETE} @@ -34,7 +40,7 @@

{L_RS_POST_REPUTATION} - {POST_SUBJECT}

-