Skip to content

Commit

Permalink
Merge pull request #55 from 3D-I/Branch_v2.0
Browse files Browse the repository at this point in the history
Branch v2.0
  • Loading branch information
3Di authored Oct 8, 2017
2 parents 1e54f72 + 48c356e commit eb9d8ba
Show file tree
Hide file tree
Showing 18 changed files with 152 additions and 101 deletions.
2 changes: 2 additions & 0 deletions acp/tpotm_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']));
Expand All @@ -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,
Expand Down
11 changes: 11 additions & 0 deletions adm/style/tpotm_body.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@ <h1>{{ lang('ACP_TPOTM_TITLE') }}</h1>
<input type="number" min="1" max="300" name="threedi_tpotm_users_page" id="threedi_tpotm_users_page" size="6" value="{{ TPOTM_USERS_PAGE }}" />
</dd>
</dl>

<div class="tpotm-acp-rules">{{ lang('ACP_TPOTM_HALL_EPOCH_EXPLAIN') }}</div>
<dl>
<dt>
<label for="threedi_tpotm_since_epoch">{{ lang('TPOTM_HALL_EPOCH') }}{{ lang('COLON') }}</label>
</dt>
<dd>
<input type="radio" class="radio" name="threedi_tpotm_since_epoch" value="1"{% if TPOTM_HALL_EPOCH %} checked="checked"{% endif %}/> {{ lang('YES') }} &nbsp;
<input type="radio" class="radio" name="threedi_tpotm_since_epoch" value="0"{% if not TPOTM_HALL_EPOCH %} checked="checked"{% endif %} /> {{ lang('NO') }}
</dd>
</dl>
</fieldset>

<fieldset class="tpotm-acp-inner">
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down
15 changes: 11 additions & 4 deletions controller/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}

Expand Down
5 changes: 4 additions & 1 deletion core/tpotm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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'],

));
}

Expand Down Expand Up @@ -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';
Expand Down
58 changes: 32 additions & 26 deletions event/listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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,
]);
}
}

Expand All @@ -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'],
]);
}
}

Expand All @@ -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')]),
]);
}
}

Expand All @@ -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')]);
}
}
}
Expand Down Expand Up @@ -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']) : '';

Expand All @@ -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]);
}
}
}
2 changes: 2 additions & 0 deletions language/en/acp_tpotm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <em>Epoch</em> the fetch starts since <em>Epoch time 1970-01-01 00:00</em> 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 <em>Top posters ever</em> list, which is based also on the post time.',
'TPOTM_HALL_EPOCH' => 'Fetch users since <em>Epoch</em>',
// Variouses
'ACP_TPOTM_VARIOUSES' => 'Various settings',
'TPOTM_TTL' => 'Time to live',
Expand Down
2 changes: 2 additions & 0 deletions language/en/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
'TPOTM_BADGE_MINIPROFILE' => 'Top poster of the Month',
'TOTAL_MONTH' => ' out of <strong>%1s</strong> (%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',
Expand All @@ -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',
Expand Down
8 changes: 5 additions & 3 deletions language/en/ucp_tpotm.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
}

$lang = array_merge($lang, array(
'USER_TOOLTIP_HOVER' => '<em><< tooltip</em>',
'USER_TOOLTIP' => 'Date format UTC+00:00 in Tooltips',
'USER_TOOLTIP_EXPLAIN' => 'Yes = Ex. <em>01 10 2017 00:01</em> to <em>01 11 2027 00:00</em><br>No = Your above date format',
'USER_TOOLTIP_HOVER' => '<em><< tooltip</em>',
'USER_TOOLTIP' => 'Date format UTC+00:00 in Tooltips',
'USER_TOOLTIP_EXPLAIN' => '<strong>Yes</strong> = Ex. <em>01 10 2017 00:01</em> to <em>01 11 2027 00:00</em><br><strong>No</strong> = Your above date format',
'USER_TOOLTIP_SEL' => 'Display date format in tooltips',
'USER_TOOLTIP_SEL_EXPLAIN' => '<strong>No</strong> = Tooltips will be shown with a standard message ignoring the above selection',
));
16 changes: 8 additions & 8 deletions migrations/m1_install_perms.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']],
];
}
}
21 changes: 11 additions & 10 deletions migrations/m2_install_acp_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
],
]],
];
}
}
29 changes: 15 additions & 14 deletions migrations/m3_install_configs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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]],
];
}
}
Loading

0 comments on commit eb9d8ba

Please sign in to comment.