diff --git a/acp/tpotm_module.php b/acp/tpotm_module.php index 395e4a6..15ccdca 100644 --- a/acp/tpotm_module.php +++ b/acp/tpotm_module.php @@ -10,6 +10,8 @@ namespace threedi\tpotm\acp; +use \threedi\tpotm\ext; + /** * Top Poster Of The Month ACP module. */ @@ -49,6 +51,26 @@ public function main($id, $mode) trigger_error($user->lang('TPOTM_BADGE_IMG_INVALID') . adm_back_link($this->u_action), E_USER_WARNING); } + /** + * Drop down construct inspired by MChat. + */ + $time_modes = [ + ext::NO_CACHE => 'no_cache', + ext::ONE_DAY => 'one_day', + ext::ONE_WEEK => 'one_week', + ext::TWO_WEEKS => 'two_weeks', + ext::ONE_MONTH => 'one_month', + ]; + + $selected = $time_row_options = ''; + + foreach ($time_modes as $val => $time_mode) + { + $time_row_options .= ''; + } + /* Do this now and forget */ $errors = []; @@ -80,6 +102,8 @@ 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_ttl_mode', $request->variable('threedi_tpotm_ttl_mode', (int) $config['threedi_tpotm_ttl_mode'])); + $config->set('threedi_tpotm_ttl_tpe', $request->variable('threedi_tpotm_ttl_tpe', (int) $config['threedi_tpotm_ttl_tpe'])); $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'])); @@ -98,18 +122,18 @@ public function main($id, $mode) 'S_ERRORS' => ($errors) ? true : false, 'ERRORS_MSG' => ($errors) ? implode('

', $errors) : '', 'U_ACTION' => $this->u_action, - // Template locations + 'TPOTM_INDEX' => ($config['threedi_tpotm_index']) ? true : false, 'TPOTM_FORUMS' => ($config['threedi_tpotm_forums']) ? true : false, - // Hall of fame 'TPOTM_HALL' => ($config['threedi_tpotm_hall']) ? true : false, 'TPOTM_USERS_PAGE' => (int) $config['threedi_tpotm_users_page'], + 'TPOTM_TTL_MODE' => $config['threedi_tpotm_ttl_mode'] ? true : false, + 'S_TPOTM_TTL_TPE' => $time_row_options, + 'TPOTM_TTL_TPE' => (int) $config['threedi_tpotm_ttl_tpe'], '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, 'TPOTM_MINIPROFILE' => ($config['threedi_tpotm_miniprofile']) ? true : false, - // Founders, admin and mods 'TPOTM_ADM_MODS' => ($config['threedi_tpotm_adm_mods']) ? true : false, 'TPOTM_FOUNDERS' => ($config['threedi_tpotm_founders']) ? true : false, 'TPOTM_BANNEDS' => ($config['threedi_tpotm_banneds']) ? true : false, diff --git a/adm/style/tpotm_acp.css b/adm/style/tpotm_acp.css index 8b87f9f..8a0bb1f 100644 --- a/adm/style/tpotm_acp.css +++ b/adm/style/tpotm_acp.css @@ -1,5 +1,17 @@ /* CSS Document */ +.tpotm-select select { + background: transparent; + width: auto; + padding: 5px; + font-size: inherit; + line-height: inherit; + border: 0; + border-radius: 0; + height: 32px; + webkit-appearance: none; +} + .tpotm-acp-inner { } diff --git a/adm/style/tpotm_body.html b/adm/style/tpotm_body.html index 95d5286..5377316 100644 --- a/adm/style/tpotm_body.html +++ b/adm/style/tpotm_body.html @@ -36,48 +36,46 @@

{{ lang('ACP_TPOTM_TITLE') }}

- {{ lang('ACP_TPOTM_TEMPLATE_LOCATIONS') }} -
{{ lang('ACP_TPOTM_TEMPLATE_LOCATIONS_EXPLAIN') }}
+ {{ lang('ACP_TPOTM_HALL') }}
-
+
{{ lang('TPOTM_HALL_EXPLAIN') }}
- {{ lang('TPOTM_BOTTOM') }}   - {{ lang('TPOTM_TOP') }} + {{ lang('YES') }}   + {{ lang('NO') }}
-
+
{{ lang('TPOTM_USERS_PAGE_EXPLAIN') }}
- {{ lang('YES') }}   - {{ lang('NO') }} +
-
-
- {{ lang('ACP_TPOTM_HALL') }} +
{{ lang('ACP_TPOTM_TTL_MODE') }}
-
{{ lang('TPOTM_HALL_EXPLAIN') }} +
- {{ lang('YES') }}   - {{ lang('NO') }} + {{ lang('YES') }}  + {{ lang('NO') }}
-
-
{{ lang('TPOTM_USERS_PAGE_EXPLAIN') }} +
-
- -
+
+
+ + +
+
{{ lang('ACP_TPOTM_HALL_EPOCH_EXPLAIN') }}
@@ -86,74 +84,98 @@

{{ lang('ACP_TPOTM_TITLE') }}

- {{ lang('YES') }}   - {{ lang('NO') }} + {{ lang('TPOTM_EPOCH') }}   + {{ lang('TPOTM_BOARD_S_DATE') }}
- +
- {{ lang('ACP_TPOTM_VARIOUSES') }} + {{ lang('ACP_TPOTM_MANAGEMENT') }} +
{{ lang('ACP_TPOTM_MANAGEMENT_EXPLAIN') }}
-
{{ lang('TPOTM_TTL_EXPLAIN') }} +
{{ lang('TPOTM_ADM_MODS_EXPLAIN') }}
- + {{ lang('YES') }}   + {{ lang('NO') }}
-
{{ lang('TPOTM_AVATAR_EXPLAIN') }} +
{{ lang('TPOTM_FOUNDERS_EXPLAIN') }}
- {{ lang('YES') }}   - {{ lang('NO') }} + {{ lang('YES') }}   + {{ lang('NO') }}
-
{{ lang('TPOTM_MINIPROFILE_EXPLAIN') }} +
{{ lang('TPOTM_BANNEDS_EXPLAIN') }}
- {{ lang('YES') }}   - {{ lang('NO') }} + {{ lang('YES') }}   + {{ lang('NO') }} +
+
+
+
+
+ {{ lang('ACP_TPOTM_TEMPLATE_LOCATIONS') }} +
{{ lang('ACP_TPOTM_TEMPLATE_LOCATIONS_EXPLAIN') }}
+
+
+
+
+
+ {{ lang('TPOTM_BOTTOM') }}   + {{ lang('TPOTM_TOP') }} +
+
+ +
+
+
+
+
+ {{ lang('YES') }}   + {{ lang('NO') }}
- {{ lang('ACP_TPOTM_MANAGEMENT') }} -
{{ lang('ACP_TPOTM_MANAGEMENT_EXPLAIN') }}
+ {{ lang('ACP_TPOTM_VARIOUSES') }}
-
{{ lang('TPOTM_ADM_MODS_EXPLAIN') }} +
{{ lang('TPOTM_TTL_EXPLAIN') }}
- {{ lang('YES') }}   - {{ lang('NO') }} +
-
{{ lang('TPOTM_FOUNDERS_EXPLAIN') }} +
{{ lang('TPOTM_AVATAR_EXPLAIN') }}
- {{ lang('YES') }}   - {{ lang('NO') }} + {{ lang('YES') }}   + {{ lang('NO') }}
-
{{ lang('TPOTM_BANNEDS_EXPLAIN') }} +
{{ lang('TPOTM_MINIPROFILE_EXPLAIN') }}
- {{ lang('YES') }}   - {{ lang('NO') }} + {{ lang('YES') }}   + {{ lang('NO') }}
diff --git a/composer.json b/composer.json index cb84577..c09ae38 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. Provided is a customizable Hall of fame and a bunch of options in ACP and UCP", "homepage": "https://github.com/3D-I/tpotm", - "version": "2.0.4-RC", + "version": "2.0.5-RC", "license": "GPL-2.0", "authors": [ { diff --git a/controller/main.php b/controller/main.php index 19f08d3..4bbb96f 100644 --- a/controller/main.php +++ b/controller/main.php @@ -117,6 +117,20 @@ public function handle($name) $max_days = date( 't', gmmktime(23, 59, 59, $month, 1, $year) ); $end_last_month = gmmktime(23, 59, 59, $month, $max_days, $year); + /* Top posters ever's dynamic cache TTL */ + $this_max_days = date( 't', gmmktime(23, 59, 59, $month_cur, 1, $year) ); + $end_this_month = gmmktime(23, 59, 59, $month_cur, $this_max_days, $year); + + /* Top posters ever's dynamic cache TTL admin choice*/ + if ($this->config['threedi_tpotm_ttl_mode']) + { + $ttl_diff = (int) ($end_this_month - $now); + } + else + { + $ttl_diff = (int) $this->config['threedi_tpotm_ttl_tpe']; + } + /* These are for pagination */ $total_users = $this->request->variable('user_id', 0); $start = $this->request->variable('start', 0); @@ -136,12 +150,12 @@ public function handle($name) $sql = $this->tpotm->tpotm_sql($and_admmods, $and_bans, $and_founder, (int) $board_start, (int) $end_last_month); /* Rowset array for the viewport */ - $result = $this->db->sql_query_limit($sql, $limit , $start, (int) $this->tpotm->config_time_cache()); + $result = $this->db->sql_query_limit($sql, $limit , $start, (int) $ttl_diff); $rows = $this->db->sql_fetchrowset($result); $this->db->sql_freeresult($result); /* Total users count for pagination */ - $result2 = $this->db->sql_query($sql, (int) $this->tpotm->config_time_cache()); + $result2 = $this->db->sql_query($sql, (int) $ttl_diff); $row2 = $this->db->sql_fetchrowset($result2); $total_users = (int) count($row2); $this->db->sql_freeresult($result2); diff --git a/ext.php b/ext.php index b188227..4162c53 100644 --- a/ext.php +++ b/ext.php @@ -16,6 +16,13 @@ class ext extends \phpbb\extension\base { + /* Define constants */ + const NO_CACHE = '0'; + const ONE_DAY = '86400'; + const ONE_WEEK = '604800'; + const TWO_WEEKS = '1209600'; + const ONE_MONTH = '2419200'; + /** * Check whether the extension can be enabled. * Provides meaningful(s) error message(s) and the back-link on failure. diff --git a/language/en/acp_tpotm.php b/language/en/acp_tpotm.php index 680ddf9..4cf5fd3 100644 --- a/language/en/acp_tpotm.php +++ b/language/en/acp_tpotm.php @@ -27,7 +27,7 @@ 'ACP_TPOTM_HALL' => 'Hall of fame settings', // Legend Board Management 'ACP_TPOTM_MANAGEMENT' => 'Board Administration', - 'ACP_TPOTM_MANAGEMENT_EXPLAIN' => 'Please note: the Founders option works together with the Admin/mods one. Means if you exclude Admin/mods keeping the Founders ON, the Founders will be not included anyway.', + 'ACP_TPOTM_MANAGEMENT_EXPLAIN' => 'These setting apply to both results.
Please note: the Founders option works together with the Admin/mods one. Means if you exclude Admin/mods keeping the Founders ON, the Founders will be not included anyway.', // Tpl locations 'TPOTM_INDEX' => 'Index page', 'TPOTM_BOTTOM' => 'Bottom', @@ -38,8 +38,19 @@ 'TPOTM_HALL_EXPLAIN' => 'Enable the page', 'TPOTM_USERS_PAGE' => 'Top posters', 'TPOTM_USERS_PAGE_EXPLAIN' => 'How many users to show per page', + 'ACP_TPOTM_TTL_MODE' => 'The dynamic automatic cache: takes care of the Leap years and automatically renews at the very begin of each month.
When this option is ON the selection in the drop down box is not being considered any more.
If you want to disable both cache modes select NO.
To enable one of the cache modes select an option (again).', + 'TPOTM_TTL_MODE' => 'TPE Dynamic cache', + 'TPOTM_TTL_TPE' => 'TPE Time to live', + 'TPOTM_TTL_TPE_REAL' => 'Already stored', + 'TPOTM_ACP_NO_CACHE' => 'no cache', + 'TPOTM_ACP_ONE_DAY' => 'one day', + 'TPOTM_ACP_ONE_WEEK' => 'one week', + 'TPOTM_ACP_TWO_WEEKS' => 'two weeks', + 'TPOTM_ACP_ONE_MONTH' => 'one month', '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', + 'TPOTM_HALL_EPOCH' => 'Fetch users since', + 'TPOTM_EPOCH' => 'Epoch', + 'TPOTM_BOARD_S_DATE' => 'Date of when the Board started', // Variouses 'ACP_TPOTM_VARIOUSES' => 'Various settings', 'TPOTM_TTL' => 'Time to live', @@ -55,6 +66,6 @@ 'TPOTM_BANNEDS' => 'Include banned users', 'TPOTM_BANNEDS_EXPLAIN' => 'Yes = improves performance
', // Errors - 'ACP_TPOTM_ERRORS' => 'Errors explaination', + 'ACP_TPOTM_ERRORS' => 'Errors', 'TPOTM_BADGE_IMG_INVALID' => 'The Badge filename is wrong or totally missing. Check your relative extension/style Images folder.
Badge filename must be: tpotm_badge.png.
Extension ACP it is now in a dormant status.
Fix the issue and it will automatically wake-up at runtime.', ]); diff --git a/language/en/info_acp_tpotm.php b/language/en/info_acp_tpotm.php index d54405e..b3b331e 100644 --- a/language/en/info_acp_tpotm.php +++ b/language/en/info_acp_tpotm.php @@ -25,5 +25,5 @@ // Error log 'TPOTM_LOG_CONFIG_SAVED' => 'TPOTM general configuration saved.', - 'TPOTM_LOG_BADGE_IMG_INVALID' => 'TPOTM - Badge IMG filename wrong or totally missing.', + 'TPOTM_LOG_BADGE_IMG_INVALID' => 'TPOTM - Badge IMG filename wrong or totally missing.', ]); diff --git a/migrations/m1_install_perms.php b/migrations/m1_install_perms.php index 0de2344..0d8d518 100644 --- a/migrations/m1_install_perms.php +++ b/migrations/m1_install_perms.php @@ -29,7 +29,7 @@ public function update_data() { return [ /* First set a milestone */ - ['config.add', ['threedi_tpotm', '2.0.4-rc']], + ['config.add', ['threedi_tpotm', '2.0.5-rc']], /* Permissions now */ ['permission.add', ['u_allow_tpotm_view']], ['permission.permission_set', ['REGISTERED', 'u_allow_tpotm_view', 'group']], diff --git a/migrations/m3_install_configs.php b/migrations/m3_install_configs.php index 65e1cc6..5110bdf 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.4-rc', '>='); + return !phpbb_version_compare($this->config['threedi_tpotm'], '2.0.5-rc', '>='); } static public function depends_on() @@ -30,17 +30,19 @@ public function update_data() return [ ['config.add', ['threedi_tpotm_miniavatar', 1]], ['config.add', ['threedi_tpotm_miniprofile', 1]], - ['config.add', ['threedi_tpotm_hall', 0]], + ['config.add', ['threedi_tpotm_hall', 1]], ['config.add', ['threedi_tpotm_adm_mods', 1]], ['config.add', ['threedi_tpotm_founders', 1]], ['config.add', ['threedi_tpotm_banneds', 1]], - ['config.add', ['threedi_tpotm_forums', 0]], - ['config.add', ['threedi_tpotm_index', 1]], - ['config.add', ['threedi_tpotm_ttl', 5]], + ['config.add', ['threedi_tpotm_forums', 1]], + ['config.add', ['threedi_tpotm_index', 0]], + ['config.add', ['threedi_tpotm_ttl', 30]], ['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]], + ['config.add', ['threedi_tpotm_ttl_tpe', 1209600]], + ['config.add', ['threedi_tpotm_ttl_mode', 1]], ]; } }