diff --git a/acp/tpotm_module.php b/acp/tpotm_module.php index dc519dc..2cfff47 100644 --- a/acp/tpotm_module.php +++ b/acp/tpotm_module.php @@ -78,6 +78,7 @@ public function main($id, $mode) $config->set('threedi_tpotm_forums', $request->variable('threedi_tpotm_forums', (int) $config['threedi_tpotm_forums'])); $config->set('threedi_tpotm_hall', $request->variable('threedi_tpotm_hall', (int) $config['threedi_tpotm_hall'])); $config->set('threedi_tpotm_users_page', $request->variable('threedi_tpotm_users_page', (int) $config['threedi_tpotm_users_page'])); + $config->set('threedi_tpotm_since_epoch', $request->variable('threedi_tpotm_since_epoch', (int) $config['threedi_tpotm_since_epoch'])); $config->set('threedi_tpotm_ttl', $request->variable('threedi_tpotm_ttl', (int) $config['threedi_tpotm_ttl'])); $config->set('threedi_tpotm_miniavatar', $request->variable('threedi_tpotm_miniavatar', (int) $config['threedi_tpotm_miniavatar'])); $config->set('threedi_tpotm_miniprofile', $request->variable('threedi_tpotm_miniprofile', (int) $config['threedi_tpotm_miniprofile'])); @@ -100,6 +101,7 @@ public function main($id, $mode) // Hall of fame 'TPOTM_HALL' => ($config['threedi_tpotm_hall']) ? true : false, 'TPOTM_USERS_PAGE' => (int) $config['threedi_tpotm_users_page'], + 'TPOTM_HALL_EPOCH' => ($config['threedi_tpotm_since_epoch']) ? true : false, // General Settings 'TPOTM_TTL' => (int) $config['threedi_tpotm_ttl'], 'TPOTM_MINIAVATAR' => ($config['threedi_tpotm_miniavatar']) ? true : false, diff --git a/adm/style/tpotm_body.html b/adm/style/tpotm_body.html index c6c9823..6ab0ffa 100644 --- a/adm/style/tpotm_body.html +++ b/adm/style/tpotm_body.html @@ -79,6 +79,17 @@

{{ lang('ACP_TPOTM_TITLE') }}

+ +
{{ lang('ACP_TPOTM_HALL_EPOCH_EXPLAIN') }}
+
+
+ +
+
+ {{ lang('YES') }}   + {{ lang('NO') }} +
+
diff --git a/composer.json b/composer.json index 072c6ff..abe5655 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "type": "phpbb-extension", "description": " Have a Top Poster of the Month and a Hall of Fame to show on your phpBB. The last poster with the max number of posts made into the current month's lapse of time will win.", "homepage": "https://github.com/3D-I/tpotm", - "version": "2.0.0-RC2", + "version": "2.0.1-RC", "license": "GPL-2.0", "authors": [ { diff --git a/controller/main.php b/controller/main.php index f0d6838..6b3a742 100644 --- a/controller/main.php +++ b/controller/main.php @@ -94,7 +94,14 @@ public function handle($name) $this->template->assign_var('TPOTM_MESSAGE', $this->user->lang($message, $name)); /* Starting point in time */ - $board_start = (int) $this->config['board_startdate']; + if (!$this->config['threedi_tpotm_since_epoch']) + { + $board_start = (int) $this->config['board_startdate']; + } + else + { + $board_start = (int) '0'; // Epoch time 1970-01-01 00:00 + } /** * if the current month is 01 (January) date() will decrement the year by one @@ -199,16 +206,16 @@ public function handle($name) } /* Date range (tooltip) */ - if ($this->user->data['user_tooltip']) + if ($this->user->data['user_tt_tpotm'] && $this->user->data['user_tt_sel_tpotm']) { /* User prefs hard-coded since it is a fake any way */ - $data_begin = $this->user->format_date((int) $this->config['board_startdate'], $this->config['threedi_tpotm_utc'] . ' H:i'); + $data_begin = $this->user->format_date((int) $board_start, $this->config['threedi_tpotm_utc'] . ' H:i'); $data_end = $this->user->format_date((int) $end_last_month, $this->config['threedi_tpotm_utc']) . ' 00:00'; } else { /* Classic data range based on UCP prefs native */ - $data_begin = $this->user->format_date((int) $this->config['board_startdate']); + $data_begin = $this->user->format_date((int) $board_start); $data_end = $this->user->format_date((int) $end_last_month); } diff --git a/core/tpotm.php b/core/tpotm.php index 74dfda3..6073cd9 100644 --- a/core/tpotm.php +++ b/core/tpotm.php @@ -202,6 +202,7 @@ public function auth_admin_mody_ary() */ $admin_ary = $this->auth->acl_get_list(false, 'a_', false); $admin_ary = (!empty($admin_ary[0]['a_'])) ? $admin_ary[0]['a_'] : array(); + $mod_ary = $this->auth->acl_get_list(false, 'm_', false); $mod_ary = (!empty($mod_ary[0]['m_'])) ? $mod_ary[0]['m_'] : array(); @@ -287,6 +288,8 @@ public function template_switches_over_all() 'S_TPOTM_MINIPROFILE' => ($this->config['threedi_tpotm_miniprofile']) ? true : false, 'S_TPOTM_HALL' => ($this->config['threedi_tpotm_hall']) ? true : false, 'S_IS_BADGE_IMG' => $this->style_badge_is_true(), + 'S_U_TOOLTIP_SEL' => (bool) $this->user->data['user_tt_sel_tpotm'], + )); } @@ -477,7 +480,7 @@ public function show_the_winner() $tpotm_name = ((int) $tpotm_tot_posts < 1) ? $tpotm_un_nobody : $tpotm_un_string; /* Date range (tooltip) UCP */ - if ($this->user->data['user_tooltip']) + if ($this->user->data['user_tt_tpotm'] && $this->user->data['user_tt_sel_tpotm']) { /* User prefs hard-coded since it is a fake any way */ $time = $this->user->lang('TPOTM_EXPLAIN', $this->user->format_date($this->get_month_data(00, 00, 00, true, false), $this->config['threedi_tpotm_utc']) . ' 00:01', $this->user->format_date($this->get_month_data(23, 59, 59, false, false), $this->config['threedi_tpotm_utc'])) . ' 00:00'; diff --git a/event/listener.php b/event/listener.php index 5d052e0..8d7d3bc 100644 --- a/event/listener.php +++ b/event/listener.php @@ -42,7 +42,7 @@ public function __construct(\phpbb\request\request $request, \phpbb\controller\h static public function getSubscribedEvents() { - return array( + return [ 'core.user_setup' => 'load_language_on_setup', 'core.permissions' => 'permissions', 'core.ucp_prefs_personal_data' => 'tpotm_ucp_prefs_data', @@ -53,16 +53,16 @@ static public function getSubscribedEvents() 'core.user_setup_after' => 'display_tpotm', 'core.viewtopic_cache_user_data' => 'viewtopic_tpotm_cache_user_data', 'core.viewtopic_modify_post_row' => 'viewtopic_tpotm', - ); + ]; } public function load_language_on_setup($event) { $lang_set_ext = $event['lang_set_ext']; - $lang_set_ext[] = array( + $lang_set_ext[] = [ 'ext_name' => 'threedi/tpotm', 'lang_set' => 'common', - ); + ]; $event['lang_set_ext'] = $lang_set_ext; } @@ -74,16 +74,16 @@ public function load_language_on_setup($event) public function permissions($event) { $permissions = $event['permissions']; - $permissions += array( - 'u_allow_tpotm_view' => array( + $permissions += [ + 'u_allow_tpotm_view' => [ 'lang' => 'ACL_U_ALLOW_TPOTM_VIEW', 'cat' => 'misc', - ), - 'a_tpotm_admin' => array( + ], + 'a_tpotm_admin' => [ 'lang' => 'ACL_A_TPOTM_ADMIN', 'cat' => 'misc', - ), - ); + ], + ]; $event['permissions'] = $permissions; } @@ -101,15 +101,20 @@ public function tpotm_ucp_prefs_data($event) $this->user->add_lang_ext('threedi/tpotm', 'ucp_tpotm'); /* Collects the user decision */ - $user_tooltip = $this->request->variable('user_tooltip', (bool) $this->user->data['user_tooltip']); + $user_tooltip = $this->request->variable('user_tt_tpotm', (bool) $this->user->data['user_tt_tpotm']); + $user_tooltip_sel = $this->request->variable('user_tt_sel_tpotm', (bool) $this->user->data['user_tt_sel_tpotm']); /* Merges that decision in the already existing array */ - $event['data'] = array_merge($event['data'], array('user_tooltip' => $user_tooltip,)); - - $this->template->assign_vars(array( - 'TPOTM_UCP_BADGE' => $this->tpotm->style_miniprofile_badge('tpotm_badge.png'), - 'S_USER_TOOLTIP' => $user_tooltip, - )); + $event['data'] = array_merge($event['data'], [ + 'user_tt_tpotm' => $user_tooltip, + 'user_tt_sel_tpotm' => $user_tooltip_sel, + ]); + + $this->template->assign_vars([ + 'TPOTM_UCP_BADGE' => $this->tpotm->style_miniprofile_badge('tpotm_badge.png'), + 'S_USER_TOOLTIP' => $user_tooltip, + 'S_USER_TOOLTIP_SEL' => $user_tooltip_sel, + ]); } } @@ -123,9 +128,10 @@ public function tpotm_ucp_prefs_update_data($event) */ if ($this->tpotm->is_authed()) { - $event['sql_ary'] = array_merge($event['sql_ary'], array( - 'user_tooltip' => $event['data']['user_tooltip'], - )); + $event['sql_ary'] = array_merge($event['sql_ary'], [ + 'user_tt_tpotm' => $event['data']['user_tt_tpotm'], + 'user_tt_sel_tpotm' => $event['data']['user_tt_sel_tpotm'], + ]); } } @@ -139,9 +145,9 @@ public function add_page_header_link() */ if ($this->tpotm->is_authed() && $this->tpotm->is_hall()) { - $this->template->assign_vars(array( - 'U_TPOTM_HALL' => $this->helper->route('threedi_tpotm_controller', array('name' => $this->user->lang('TPOTM_ROUTE_NAME'))), - )); + $this->template->assign_vars([ + 'U_TPOTM_HALL' => $this->helper->route('threedi_tpotm_controller', ['name' => $this->user->lang('TPOTM_ROUTE_NAME')]), + ]); } } @@ -161,7 +167,7 @@ public function viewonline_page($event) { $event['location'] = $this->user->lang('VIEWING_TPOTM_HALL'); - $event['location_url'] = $this->helper->route('threedi_tpotm_controller', array('name' => $this->user->lang('TPOTM_ROUTE_NAME'))); + $event['location_url'] = $this->helper->route('threedi_tpotm_controller', ['name' => $this->user->lang('TPOTM_ROUTE_NAME')]); } } } @@ -215,7 +221,7 @@ public function viewtopic_tpotm_cache_user_data($event) * Sat as default to be empty string for everyone * Only the TPOTM gets the badge's filename in it. */ - $user_tpotm = array(); + $user_tpotm = []; $user_tpotm[] = ($array['user_tpotm']) ? (string) $this->tpotm->style_miniprofile_badge($array['user_tpotm']) : ''; @@ -238,7 +244,7 @@ public function viewtopic_tpotm($event) { $user_tpotm = (!empty($event['user_poster_data']['user_tpotm'])) ? $this->tpotm->style_miniprofile_badge($event['user_poster_data']['user_tpotm']) : ''; - $event['post_row'] = array_merge($event['post_row'], array('TPOTM_BADGE' => $user_tpotm)); + $event['post_row'] = array_merge($event['post_row'], ['TPOTM_BADGE' => $user_tpotm]); } } } diff --git a/language/en/acp_tpotm.php b/language/en/acp_tpotm.php index 45fb3f2..7cef9a9 100644 --- a/language/en/acp_tpotm.php +++ b/language/en/acp_tpotm.php @@ -38,6 +38,8 @@ 'TPOTM_HALL_EXPLAIN' => 'Enable the page', 'TPOTM_USERS_PAGE' => 'Top posters', 'TPOTM_USERS_PAGE_EXPLAIN' => 'How many users to show per page', + 'ACP_TPOTM_HALL_EPOCH_EXPLAIN' => 'Using Epoch the fetch starts since Epoch time 1970-01-01 00:00 instead of the start date of the Board. To be used if you did reset at some point that date and some users are being excluded from the Top posters ever list, which is based also on the post time.', + 'TPOTM_HALL_EPOCH' => 'Fetch users since Epoch', // Variouses 'ACP_TPOTM_VARIOUSES' => 'Various settings', 'TPOTM_TTL' => 'Time to live', diff --git a/language/en/common.php b/language/en/common.php index 2ed2e19..a2bda60 100644 --- a/language/en/common.php +++ b/language/en/common.php @@ -42,6 +42,7 @@ 'TPOTM_BADGE_MINIPROFILE' => 'Top poster of the Month', 'TOTAL_MONTH' => ' out of %1s (%2s%%)', 'TPOTM_EXPLAIN' => 'From %1s to %2s', + 'TPOTM_NO_EXPLAIN' => 'During the current month', 'TPOTM_TOT_POST' => 'Total posts', 'TPOTM_DATE' => 'Year and Month', 'TPOTM_LAST_POST_IN_MONTH' => 'Last on', @@ -66,6 +67,7 @@ 'TPOTM_HELLO' => 'Top Poster Of The Month - Hall Of Fame', 'TPOTM_ROUTE_NAME' => 'hall_of_fame', 'TPOTM_EXPLAIN_HALL' => 'From %1s to %2s', + 'TPOTM_HALL_NO_EXPLAIN' => 'Since Epoch till the very end of the previous month', 'HALL_OF_FAME' => array( 0 => 'Hall of fame', diff --git a/language/en/ucp_tpotm.php b/language/en/ucp_tpotm.php index 5bfb66e..a931b4c 100644 --- a/language/en/ucp_tpotm.php +++ b/language/en/ucp_tpotm.php @@ -19,7 +19,9 @@ } $lang = array_merge($lang, array( - 'USER_TOOLTIP_HOVER' => '<< tooltip', - 'USER_TOOLTIP' => 'Date format UTC+00:00 in Tooltips', - 'USER_TOOLTIP_EXPLAIN' => 'Yes = Ex. 01 10 2017 00:01 to 01 11 2027 00:00
No = Your above date format', + 'USER_TOOLTIP_HOVER' => '<< tooltip', + 'USER_TOOLTIP' => 'Date format UTC+00:00 in Tooltips', + 'USER_TOOLTIP_EXPLAIN' => 'Yes = Ex. 01 10 2017 00:01 to 01 11 2027 00:00
No = Your above date format', + 'USER_TOOLTIP_SEL' => 'Display date format in tooltips', + 'USER_TOOLTIP_SEL_EXPLAIN' => 'No = Tooltips will be shown with a standard message ignoring the above selection', )); diff --git a/migrations/m1_install_perms.php b/migrations/m1_install_perms.php index d8a00e3..1777e71 100644 --- a/migrations/m1_install_perms.php +++ b/migrations/m1_install_perms.php @@ -22,19 +22,19 @@ public function effectively_installed() static public function depends_on() { - return array('\phpbb\db\migration\data\v31x\v3111'); + return ['\phpbb\db\migration\data\v31x\v3111']; } public function update_data() { - return array( + return [ /* First set a milestone */ - array('config.add', array('threedi_tpotm', '2.0.0-rc2')), + ['config.add', ['threedi_tpotm', '2.0.1-rc']], /* Permissions now */ - array('permission.add', array('u_allow_tpotm_view')), - array('permission.permission_set', array('REGISTERED', 'u_allow_tpotm_view', 'group')), - array('permission.add', array('a_tpotm_admin')), - array('permission.permission_set', array('ADMINISTRATORS', 'a_tpotm_admin', 'group')), - ); + ['permission.add', ['u_allow_tpotm_view']], + ['permission.permission_set', ['REGISTERED', 'u_allow_tpotm_view', 'group']], + ['permission.add', ['a_tpotm_admin']], + ['permission.permission_set', ['ADMINISTRATORS', 'a_tpotm_admin', 'group']], + ]; } } diff --git a/migrations/m2_install_acp_module.php b/migrations/m2_install_acp_module.php index 4fb11c2..8a9d2f9 100644 --- a/migrations/m2_install_acp_module.php +++ b/migrations/m2_install_acp_module.php @@ -14,29 +14,30 @@ class m2_install_acp_module extends \phpbb\db\migration\migration { public function effectively_installed() { + // } static public function depends_on() { - return array('\phpbb\db\migration\data\v31x\v3111'); + return ['\phpbb\db\migration\data\v31x\v3111']; } public function update_data() { - return array( - array('module.add', array( + return [ + ['module.add', [ 'acp', 'ACP_CAT_DOT_MODS', 'ACP_TPOTM_TITLE' - )), - array('module.add', array( + ]], + ['module.add', [ 'acp', 'ACP_TPOTM_TITLE', - array( + [ 'module_basename' => '\threedi\tpotm\acp\tpotm_module', - 'modes' => array('settings'), - ), - )), - ); + 'modes' => ['settings'], + ], + ]], + ]; } } diff --git a/migrations/m3_install_configs.php b/migrations/m3_install_configs.php index 6dcc7af..8b6ea44 100644 --- a/migrations/m3_install_configs.php +++ b/migrations/m3_install_configs.php @@ -17,7 +17,7 @@ public function effectively_installed() /** * If does exists go ahead */ - return !phpbb_version_compare($this->config['threedi_tpotm'], '2.0.0-rc2', '>='); + return !phpbb_version_compare($this->config['threedi_tpotm'], '2.0.1-rc', '>='); } static public function depends_on() @@ -29,18 +29,19 @@ static public function depends_on() public function update_data() { - return array( - array('config.add', array('threedi_tpotm_miniavatar', 1)), - array('config.add', array('threedi_tpotm_miniprofile', 1)), - array('config.add', array('threedi_tpotm_hall', 0)), - array('config.add', array('threedi_tpotm_adm_mods', 1)), - array('config.add', array('threedi_tpotm_founders', 0)), - array('config.add', array('threedi_tpotm_forums', 0)), - array('config.add', array('threedi_tpotm_index', 1)), - array('config.add', array('threedi_tpotm_ttl', 30)), - array('config.add', array('threedi_tpotm_badge_exists', 1)), - array('config.add', array('threedi_tpotm_users_page', 12)), - array('config.add', array('threedi_tpotm_utc', 'd m Y')), - ); + return [ + ['config.add', ['threedi_tpotm_miniavatar', 1]], + ['config.add', ['threedi_tpotm_miniprofile', 1]], + ['config.add', ['threedi_tpotm_hall', 0]], + ['config.add', ['threedi_tpotm_adm_mods', 1]], + ['config.add', ['threedi_tpotm_founders', 0]], + ['config.add', ['threedi_tpotm_forums', 0]], + ['config.add', ['threedi_tpotm_index', 1]], + ['config.add', ['threedi_tpotm_ttl', 5]], + ['config.add', ['threedi_tpotm_badge_exists', 1]], + ['config.add', ['threedi_tpotm_users_page', 12]], + ['config.add', ['threedi_tpotm_utc', 'd m Y']], + ['config.add', ['threedi_tpotm_since_epoch', 0]], + ]; } } diff --git a/migrations/m4_install_user_schema.php b/migrations/m4_install_user_schema.php index 0a2fd57..849e9c4 100644 --- a/migrations/m4_install_user_schema.php +++ b/migrations/m4_install_user_schema.php @@ -24,30 +24,32 @@ public function effectively_installed() static public function depends_on() { - return array('\phpbb\db\migration\data\v31x\v3111'); + return ['\phpbb\db\migration\data\v31x\v3111']; } public function update_schema() { - return array( - 'add_columns' => array( - $this->table_prefix . 'users' => array( - 'user_tpotm' => array('VCHAR:255', ''), - 'user_tooltip' => array('BOOL', 0), - ), - ), - ); + return [ + 'add_columns' => [ + $this->table_prefix . 'users' => [ + 'user_tpotm' => ['VCHAR:255', ''], + 'user_tt_tpotm' => ['BOOL', 0], + 'user_tt_sel_tpotm' => ['BOOL', 1], + ], + ], + ]; } public function revert_schema() { - return array( - 'drop_columns' => array( - $this->table_prefix . 'users' => array( + return [ + 'drop_columns' =>[ + $this->table_prefix . 'users' => [ 'user_tpotm', - 'user_tooltip', - ), - ), - ); + 'user_tt_tpotm', + 'user_tt_sel_tpotm', + ], + ], + ]; } } diff --git a/styles/prosilver/template/event/ucp_prefs_personal_append.html b/styles/prosilver/template/event/ucp_prefs_personal_append.html index 1b877b9..8e6abbc 100644 --- a/styles/prosilver/template/event/ucp_prefs_personal_append.html +++ b/styles/prosilver/template/event/ucp_prefs_personal_append.html @@ -3,9 +3,9 @@

{{ lang('TPOTM_CAT') }} {% if S_IS_RHEA %} - + {% elseif S_IS_BADGE_IMG %} - + {% else %} {{ lang('TPOTM_BADGE') }} {% endif %} @@ -13,12 +13,20 @@

-

{{ lang('USER_TOOLTIP_EXPLAIN') }}
+

{{ lang('USER_TOOLTIP_EXPLAIN') }}
- + - +
+
+

{{ lang('USER_TOOLTIP_SEL_EXPLAIN') }}
+
+ + + +
+
{% endif %} diff --git a/styles/prosilver/template/event/viewtopic_body_contact_fields_after.html b/styles/prosilver/template/event/viewtopic_body_contact_fields_after.html index 9b868cd..1ed1047 100644 --- a/styles/prosilver/template/event/viewtopic_body_contact_fields_after.html +++ b/styles/prosilver/template/event/viewtopic_body_contact_fields_after.html @@ -3,9 +3,9 @@
{{ lang('TPOTM_BADGE_MINIPROFILE') }} {% if S_IS_RHEA %} - + {% elseif S_IS_BADGE_IMG %} - + {% else %} {{ lang('TPOTM_BADGE') }} {% endif %} diff --git a/styles/prosilver/template/tpotm.html b/styles/prosilver/template/tpotm.html index d17a3c3..9b318f4 100644 --- a/styles/prosilver/template/tpotm.html +++ b/styles/prosilver/template/tpotm.html @@ -8,17 +8,18 @@

{% endif %}

-

{{ lang('TPOTM_NOW') }} +

+ {{ lang('TPOTM_NOW') }} {% if S_TPOTM_AVATAR %} {% endif %} {{ TPOTM_NAME }}{{ lang('TPOTM_POST') }}{{ lang('TOTAL_MONTH') }} {% if S_IS_RHEA %} -   +   {% else %} -   +   {% endif %} - {{ lang('TPOTM_CACHE') }} + {{ lang('TPOTM_CACHE') }}

{% endif %} diff --git a/styles/prosilver/template/tpotm_hall.html b/styles/prosilver/template/tpotm_hall.html index 7137698..1bb104b 100644 --- a/styles/prosilver/template/tpotm_hall.html +++ b/styles/prosilver/template/tpotm_hall.html @@ -24,9 +24,9 @@

{{ lang('TPOTM_CAT') }}

{{ lang('TPOTM_POST') }}{{ lang('TOTAL_MONTH') }}{{ lang('TPOTM_CACHE') }} {% if S_IS_RHEA %} -   +   {% else %} -   +   {% endif %}
@@ -36,9 +36,11 @@

{{ lang('TPOTM_CAT') }}

{# start Hall of fame #}

{{ lang('TPOTM_EVER_CAT') }} {% if S_IS_RHEA %} -   + +   + {% else %} -   +   {% endif %}

diff --git a/styles/prosilver/theme/tpotm.css b/styles/prosilver/theme/tpotm.css index 1a0d52a..a7f052f 100644 --- a/styles/prosilver/theme/tpotm.css +++ b/styles/prosilver/theme/tpotm.css @@ -6,11 +6,12 @@ width: auto; } -i.fa-trophy { +/* viewtopic */ +i.fa-spinner { cursor: pointer; - color: #105289; /* prosilver */ + color: #2a6496; } - +*/ /* index and hall */ i.fa-question-circle-o fa-fw { cursor: pointer;