Skip to content

Commit

Permalink
1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeWCS committed Mar 29, 2024
1 parent c4f0c92 commit 9937380
Show file tree
Hide file tree
Showing 30 changed files with 215 additions and 241 deletions.
2 changes: 1 addition & 1 deletion docs/version_check.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"stable": {
"3.3": {
"current": "1.1.0",
"current": "1.2.0",
"announcement": "https://github.com/LukeWCS/stats-permissions/releases",
"eol": null,
"security": false
Expand Down
3 changes: 3 additions & 0 deletions lukewcs/statspermissions/acp/acp_stats_permissions_info.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
* @copyright (c) 2019, LukeWCS, https://www.wcsaga.org/
* @license GNU General Public License, version 2 (GPL-2.0)
*
* Note: This extension is 100% genuine handcraft and consists of selected
* natural raw materials. There was no AI involved in making it.
*
*/

namespace lukewcs\statspermissions\acp;
Expand Down
3 changes: 3 additions & 0 deletions lukewcs/statspermissions/acp/acp_stats_permissions_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
* @copyright (c) 2019, LukeWCS, https://www.wcsaga.org/
* @license GNU General Public License, version 2 (GPL-2.0)
*
* Note: This extension is 100% genuine handcraft and consists of selected
* natural raw materials. There was no AI involved in making it.
*
*/

namespace lukewcs\statspermissions\acp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ fieldset dt label {
cursor: inherit;
}

.simple_permissions dd {
line-height: 2em;
}

/*
* phpBB ACP Toggles - A CSS class that makes it easy to display checkboxes as toggles.
* Source : https://danklammer.com/articles/simple-css-toggle-switch/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
* @copyright (c) 2019, LukeWCS, https://www.wcsaga.org/
* @license GNU General Public License, version 2 (GPL-2.0)
*
* Note: This extension is 100% genuine handcraft and consists of selected
* natural raw materials. There was no AI involved in making it.
*
#}

{% INCLUDE 'overall_header.html' %}
Expand Down Expand Up @@ -46,7 +49,6 @@ <h1>{{ lang('STATS_PERMISSIONS_CONFIG_TITLE') }}</h1>
<dl class="simple_permissions">
<dt><label>{{ lang('STATS_PERMISSIONS_PERM_FOR_GUESTS') ~ lang('COLON') }}</label><br><span>{{ lang('STATS_PERMISSIONS_PERM_FOR_GUESTS_EXP') }}</span></dt>
<dd>
<!-- {{ _self.select('stats_permissions_disp_for_guests', STATS_PERMISSIONS_DISP_FOR_GUESTS, STATS_PERMISSIONS_OPTIONS) }}<br> -->
{{ _self.switch('stats_permissions_perm_for_guests_stats' , STATS_PERMISSIONS_PERM_FOR_GUESTS b-and 1, switch_type) }} {{ lang('STATS_PERMISSIONS_PERM_STATS') }}<br>
{{ _self.switch('stats_permissions_perm_for_guests_newest' , STATS_PERMISSIONS_PERM_FOR_GUESTS b-and 2, switch_type) }} {{ lang('STATS_PERMISSIONS_PERM_NEWEST') }}<br>
</dd>
Expand All @@ -55,7 +57,6 @@ <h1>{{ lang('STATS_PERMISSIONS_CONFIG_TITLE') }}</h1>
<dl class="simple_permissions">
<dt><label>{{ lang('STATS_PERMISSIONS_PERM_FOR_BOTS') ~ lang('COLON') }}</label><br><span>{{ lang('STATS_PERMISSIONS_PERM_FOR_BOTS_EXP') }}</span></dt>
<dd>
<!-- {{ _self.select('stats_permissions_disp_for_bots', STATS_PERMISSIONS_DISP_FOR_BOTS, STATS_PERMISSIONS_OPTIONS) }}<br> -->
{{ _self.switch('stats_permissions_perm_for_bots_stats' , STATS_PERMISSIONS_PERM_FOR_BOTS b-and 1, switch_type) }} {{ lang('STATS_PERMISSIONS_PERM_STATS') }}<br>
{{ _self.switch('stats_permissions_perm_for_bots_newest' , STATS_PERMISSIONS_PERM_FOR_BOTS b-and 2, switch_type) }} {{ lang('STATS_PERMISSIONS_PERM_NEWEST') }}<br>

Expand Down Expand Up @@ -102,14 +103,6 @@ <h1>{{ lang('STATS_PERMISSIONS_CONFIG_TITLE') }}</h1>
{%- endif %}
{%- endmacro %}

{% macro select(name, value, options) -%}
<select name="{{ name }}">
{% for opt_lang_var, opt_value in options %}
<option value="{{ opt_value }}"{{ opt_value == value ? ' selected' }}>{{ lang(opt_lang_var) }}</option>
{% endfor %}
</select>
{%- endmacro %}

{% macro js_button(name, lang_var) -%}
<input type="button" class="button2" name="{{ name }}" value="{{ lang(lang_var) }}">
{%- endmacro %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,22 @@
* @copyright (c) 2019, LukeWCS, https://www.wcsaga.org/
* @license GNU General Public License, version 2 (GPL-2.0)
*
* Note: This extension is 100% genuine handcraft and consists of selected
* natural raw materials. There was no AI involved in making it.
*
*/

(function ($) { // IIFE start

'use strict';

var constants = Object.freeze({
// PermNothing : 0,
// PermStats : 1,
// PermUsers : 2,
// PermStatsUsers : 3,

OpacityEnabled : '1.0',
OpacityDisabled : '0.35',
});

function setState() {
var c = constants;
const c = constants;

dimOptionGroup('stats_permissions_use_permissions',
$('[name="stats_permissions_admin_mode"]').prop('checked')
Expand All @@ -33,51 +31,25 @@ function setState() {
|| $('[name="stats_permissions_use_permissions"]').prop('checked')
? c.OpacityDisabled : c.OpacityEnabled
);

// dimOptionGroup('stats_permissions_disp_for_guests',
// dimOptionGroup('stats_permissions_perm_for_guests_stats',
// $('[name="stats_permissions_admin_mode"]').prop('checked')
// || $('[name="stats_permissions_use_permissions"]').prop('checked')
// );
// dimOptionGroup('stats_permissions_disp_for_bots',
// dimOptionGroup('stats_permissions_perm_for_bots_stats',
// $('[name="stats_permissions_admin_mode"]').prop('checked')
// || $('[name="stats_permissions_use_permissions"]').prop('checked')
// );
};

function dimOptionGroup(elememtName, dimCondition) {
var c = constants;
const c = constants;

$('[name="' + elememtName + '"]').parents('dl').css('opacity', dimCondition ? c.OpacityDisabled : c.OpacityEnabled);
}

function setDefaults() {
var c = constants;

setSwitch( '[name="stats_permissions_admin_mode"]', false);
setSwitch( '[name="stats_permissions_use_permissions"]', false);

// $( '[name="stats_permissions_disp_for_guests"]') .prop('value', c.PermStats);
// $( '[name="stats_permissions_disp_for_bots"]') .prop('value', c.PermNothing);
setSwitch( '[name="stats_permissions_perm_for_guests_stats"]', true);
setSwitch( '[name="stats_permissions_perm_for_guests_newest"]', false);
setSwitch( '[name="stats_permissions_perm_for_bots_stats"]', false);
setSwitch( '[name="stats_permissions_perm_for_bots_newest"]', false);
setSwitch('[name="stats_permissions_admin_mode"]', false);
setSwitch('[name="stats_permissions_use_permissions"]', false);
setSwitch('[name="stats_permissions_perm_for_guests_stats"]', true);
setSwitch('[name="stats_permissions_perm_for_guests_newest"]', false);
setSwitch('[name="stats_permissions_perm_for_bots_stats"]', false);
setSwitch('[name="stats_permissions_perm_for_bots_newest"]', false);

setState();
};

// function setSwitch(selector, checked) {
// var $elementObject = $(selector);

// if ($elementObject.get(0).type == 'checkbox') {
// $elementObject.prop('checked', checked);
// } else if ($elementObject.get(0).type == 'radio') {
// $('[name="' + $elementObject[0].name + '"][value="' + (checked ? 1 : 0) + '"]').prop('checked', true);
// }
// };

function setSwitch(selector, checked) {
const $elementObject = $(selector);
const elementType = $elementObject.attr('type');
Expand Down
6 changes: 3 additions & 3 deletions lukewcs/statspermissions/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"type": "phpbb-extension",
"description": "Allows to define independent permissions for viewing statistics and newest member.",
"homepage": "https://github.com/LukeWCS/stats-permissions",
"version": "1.2.0-b1",
"time": "2024-03-27",
"version": "1.2.0",
"time": "2024-03-29",
"license": "GPL-2.0-only",
"authors": [
{
Expand All @@ -19,7 +19,7 @@
},
"extra": {
"display-name": "Stats Permissions",
"lang-min-ver": "1.1.0",
"lang-min-ver": "1.2.0",
"soft-require": {
"phpbb/phpbb": ">=3.3.0,<3.4.0@dev"
},
Expand Down
14 changes: 5 additions & 9 deletions lukewcs/statspermissions/config/services.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
services:
lukewcs.statspermissions.listener:
class: lukewcs\statspermissions\event\listener
arguments:
- '@lukewcs.statspermissions.core'
tags:
- { name: event.listener }
lukewcs.statspermissions.core:
class: lukewcs\statspermissions\core\stats_permissions
arguments:
- '@config'
- '@template'
- '@language'
- '@auth'
- '@user'
- '@dispatcher'
- '@language'
tags:
- { name: event.listener }
lukewcs.statspermissions.controller.acp:
class: lukewcs\statspermissions\controller\acp_stats_permissions_controller
arguments:
- '@language'
- '@config'
- '@template'
- '@language'
- '@request'
- '@config'
- '@ext.manager'
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,37 @@
* @copyright (c) 2019, LukeWCS, https://www.wcsaga.org/
* @license GNU General Public License, version 2 (GPL-2.0)
*
* Note: This extension is 100% genuine handcraft and consists of selected
* natural raw materials. There was no AI involved in making it.
*
*/

namespace lukewcs\statspermissions\controller;

class acp_stats_permissions_controller
{
protected $language;
protected $config;
protected $template;
protected $language;
protected $request;
protected $config;
protected $ext_manager;

protected $metadata;

public $u_action;

public function __construct(
\phpbb\language\language $language,
\phpbb\config\config $config,
\phpbb\template\template $template,
\phpbb\language\language $language,
\phpbb\request\request $request,
\phpbb\config\config $config,
\phpbb\extension\manager $ext_manager
)
{
$this->language = $language;
$this->config = $config;
$this->template = $template;
$this->language = $language;
$this->request = $request;
$this->config = $config;
$this->ext_manager = $ext_manager;

$this->metadata = $this->ext_manager->create_extension_metadata_manager('lukewcs/statspermissions')->get_metadata('all');
Expand All @@ -54,13 +58,9 @@ public function module_settings(): void
// config section 1
$this->config->set('stats_permissions_admin_mode' , $this->request->variable('stats_permissions_admin_mode', 0));
$this->config->set('stats_permissions_use_permissions' , $this->request->variable('stats_permissions_use_permissions', 0));

// $this->config->set('stats_permissions_disp_for_guests' , $this->request->variable('stats_permissions_disp_for_guests', 0));
$perm_for_guests = $this->request->variable('stats_permissions_perm_for_guests_stats', 0) ? 1 : 0;
$perm_for_guests += $this->request->variable('stats_permissions_perm_for_guests_newest', 0) ? 2 : 0;
$this->config->set('stats_permissions_perm_for_guests' , $perm_for_guests);

// $this->config->set('stats_permissions_disp_for_bots' , $this->request->variable('stats_permissions_disp_for_bots', 0));
$perm_for_bots = $this->request->variable('stats_permissions_perm_for_bots_stats', 0) ? 1 : 0;
$perm_for_bots += $this->request->variable('stats_permissions_perm_for_bots_newest', 0) ? 2 : 0;
$this->config->set('stats_permissions_perm_for_bots' , $perm_for_bots);
Expand All @@ -76,22 +76,13 @@ public function module_settings(): void
}

$this->template->assign_vars([
// heading
'STATS_PERMISSIONS_NOTES' => $notes,
// config section 1

'STATS_PERMISSIONS_ADMIN_MODE' => $this->config['stats_permissions_admin_mode'],
'STATS_PERMISSIONS_USE_PERMISSIONS' => $this->config['stats_permissions_use_permissions'],
// 'STATS_PERMISSIONS_DISP_FOR_GUESTS' => $this->config['stats_permissions_perm_for_guests'],
// 'STATS_PERMISSIONS_DISP_FOR_BOTS' => $this->config['stats_permissions_perm_for_bots'],
'STATS_PERMISSIONS_PERM_FOR_GUESTS' => $this->config['stats_permissions_perm_for_guests'],
'STATS_PERMISSIONS_PERM_FOR_BOTS' => $this->config['stats_permissions_perm_for_bots'],
// 'STATS_PERMISSIONS_OPTIONS' => [
// 'STATS_PERMISSIONS_PERM_STATS_NEWEST' => '3',
// 'STATS_PERMISSIONS_PERM_NEWEST' => '2',
// 'STATS_PERMISSIONS_PERM_STATS' => '1',
// 'STATS_PERMISSIONS_PERM_NOTHING' => '0',
// ],
// form elements

'U_ACTION' => $this->u_action,
]);

Expand Down
Loading

0 comments on commit 9937380

Please sign in to comment.