Skip to content

Commit

Permalink
1.2.0-b1
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeWCS committed Mar 27, 2024
1 parent f445004 commit c4f0c92
Show file tree
Hide file tree
Showing 13 changed files with 216 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@ legend {
background-color: inherit;
}

legend.legend_sub {
border: 0;
margin: 1em 0;
padding: 0;
display: flex;
white-space: nowrap;
}

legend.legend_sub:after {
content: "";
border-bottom: 1px solid #cccccc;
width: 100%;
margin: 0 0 0.5em 1em;
}

fieldset dt label {
cursor: inherit;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,29 @@ <h1>{{ lang('STATS_PERMISSIONS_CONFIG_TITLE') }}</h1>
</dd>
</dl>

<dl>
<dt><label>{{ lang('STATS_PERMISSIONS_DISP_FOR_GUESTS') ~ lang('COLON') }}</label><br><span>{{ lang('STATS_PERMISSIONS_DISP_FOR_GUESTS_EXP') }}</span></dt>
<legend class="legend_sub simple_permissions">{{ lang('STATS_PERMISSIONS_SECTION_SIMPLE_PERMISSIONS') }}</legend>
<dl class="simple_permissions">
<dt>
<span>{{ lang('STATS_PERMISSIONS_SIMPLE_PERMISSIONS_EXP') }}</span>
</dt>
</dl>

<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) }}
<!-- {{ _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>
</dl>

<dl>
<dt><label>{{ lang('STATS_PERMISSIONS_DISP_FOR_BOTS') ~ lang('COLON') }}</label><br><span>{{ lang('STATS_PERMISSIONS_DISP_FOR_BOTS_EXP') }}</span></dt>
<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) }}
<!-- {{ _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>

</dd>
</dl>
</fieldset>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,38 @@
'use strict';

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

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

function setState() {
var c = constants;

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

$('.simple_permissions').css('opacity',
$('[name="stats_permissions_admin_mode"]').prop('checked')
|| $('[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) {
Expand All @@ -46,19 +57,35 @@ function setDefaults() {

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);

// $( '[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);

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) {
var $elementObject = $(selector);
const $elementObject = $(selector);
const elementType = $elementObject.attr('type');

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

Expand All @@ -68,7 +95,7 @@ function formReset() {
});
};

$(window).ready(function() {
$(function() {
setState();

$('[name="stats_permissions_admin_mode"]') .on('change', setState);
Expand Down
8 changes: 4 additions & 4 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.1.0",
"time": "2023-12-09",
"version": "1.2.0-b1",
"time": "2024-03-27",
"license": "GPL-2.0-only",
"authors": [
{
Expand All @@ -14,14 +14,14 @@
}
],
"require": {
"php": ">=7.1.0,<8.4.0@dev",
"php": ">=7.1.3,<8.4.0@dev",
"composer/installers": "~1.0.0"
},
"extra": {
"display-name": "Stats Permissions",
"lang-min-ver": "1.1.0",
"soft-require": {
"phpbb/phpbb": ">=3.2.11,<3.4.0@dev"
"phpbb/phpbb": ">=3.3.0,<3.4.0@dev"
},
"version-check": {
"host": "lukewcs.github.io",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,17 @@ 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));
$this->config->set('stats_permissions_disp_for_bots' , $this->request->variable('stats_permissions_disp_for_bots', 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);

// config end
trigger_error($this->language->lang('STATS_PERMISSIONS_MSG_SAVED_SETTINGS') . adm_back_link($this->u_action));
}
Expand All @@ -72,14 +81,16 @@ public function module_settings(): void
// 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_disp_for_guests'],
'STATS_PERMISSIONS_DISP_FOR_BOTS' => $this->config['stats_permissions_disp_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',
],
// '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
36 changes: 20 additions & 16 deletions lukewcs/statspermissions/core/stats_permissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,29 @@ public function set_template_vars(): void
}
else if (!empty($this->user->data['is_bot'])) // bot
{
$permission_stats = (
$this->config['stats_permissions_disp_for_bots'] == self::PERM_STATS
|| $this->config['stats_permissions_disp_for_bots'] == self::PERM_STATS_NEWEST
);
$permission_newest = (
$this->config['stats_permissions_disp_for_bots'] == self::PERM_NEWEST
|| $this->config['stats_permissions_disp_for_bots'] == self::PERM_STATS_NEWEST
);
// $permission_stats = (
// $this->config['stats_permissions_disp_for_bots'] == self::PERM_STATS
// || $this->config['stats_permissions_disp_for_bots'] == self::PERM_STATS_NEWEST
// );
// $permission_newest = (
// $this->config['stats_permissions_disp_for_bots'] == self::PERM_NEWEST
// || $this->config['stats_permissions_disp_for_bots'] == self::PERM_STATS_NEWEST
// );
$permission_stats = $this->config['stats_permissions_perm_for_bots'] & self::PERM_STATS;
$permission_newest = $this->config['stats_permissions_perm_for_bots'] & self::PERM_NEWEST;
}
else // guest
{
$permission_stats = (
$this->config['stats_permissions_disp_for_guests'] == self::PERM_STATS
|| $this->config['stats_permissions_disp_for_guests'] == self::PERM_STATS_NEWEST
);
$permission_newest = (
$this->config['stats_permissions_disp_for_guests'] == self::PERM_NEWEST
|| $this->config['stats_permissions_disp_for_guests'] == self::PERM_STATS_NEWEST
);
// $permission_stats = (
// $this->config['stats_permissions_disp_for_guests'] == self::PERM_STATS
// || $this->config['stats_permissions_disp_for_guests'] == self::PERM_STATS_NEWEST
// );
// $permission_newest = (
// $this->config['stats_permissions_disp_for_guests'] == self::PERM_NEWEST
// || $this->config['stats_permissions_disp_for_guests'] == self::PERM_STATS_NEWEST
// );
$permission_stats = $this->config['stats_permissions_perm_for_guests'] & self::PERM_STATS;
$permission_newest = $this->config['stats_permissions_perm_for_guests'] & self::PERM_NEWEST;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions lukewcs/statspermissions/ext.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class ext extends \phpbb\extension\base
{
public function is_enableable()
{
$valid_phpbb = phpbb_version_compare(PHPBB_VERSION, '3.2.11', '>=') && phpbb_version_compare(PHPBB_VERSION, '3.4.0-dev', '<');
$valid_php = phpbb_version_compare(PHP_VERSION, '7.1.0', '>=') && phpbb_version_compare(PHP_VERSION, '8.4.0-dev', '<');
$valid_phpbb = phpbb_version_compare(PHPBB_VERSION, '3.3.0', '>=') && phpbb_version_compare(PHPBB_VERSION, '3.4.0-dev', '<');
$valid_php = phpbb_version_compare(PHP_VERSION, '7.1.3', '>=') && phpbb_version_compare(PHP_VERSION, '8.4.0-dev', '<');

return $valid_phpbb && $valid_php;
}
Expand Down
14 changes: 8 additions & 6 deletions lukewcs/statspermissions/language/de/acp_stats_permissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,16 @@
'STATS_PERMISSIONS_ADMIN_MODE_EXP' => 'Dieser Modus setzt alle Berechtigungssysteme außer Kraft und nur Benutzer mit administrativen Rechten können die Statistik sehen. Hilfreich wenn die Statistik kurzfristig für andere nicht sichtbar sein soll.',
'STATS_PERMISSIONS_USE_PERMISSIONS' => 'Benutze das Berechtigungssystem von phpBB',
'STATS_PERMISSIONS_USE_PERMISSIONS_EXP' => 'Ermöglicht es, für jede Benutzergruppe getrennt festlegen zu können, welchen Umfang die Statistik haben soll. Die Rechte können wie folgt angepasst werden: „BERECHTIGUNGEN » Gruppenrechte » [Benutzergruppe] » Benutzer-Berechtigungen » Erweiterte Berechtigungen » Diverses“.',
'STATS_PERMISSIONS_DISP_FOR_GUESTS' => 'Anzeige für Gäste',
'STATS_PERMISSIONS_DISP_FOR_GUESTS_EXP' => 'Legt fest, was Gäste sehen können. „Statistik“ zeigt nur die anonymen Zahlen und „Nichts“ schaltet die Anzeige für Gäste komplett aus.',
'STATS_PERMISSIONS_DISP_FOR_BOTS' => 'Anzeige für Bots',
'STATS_PERMISSIONS_DISP_FOR_BOTS_EXP' => 'Legt fest, was Bots sehen können. „Statistik“ zeigt nur die anonymen Zahlen und „Nichts“ schaltet die Anzeige für Bots komplett aus.',
'STATS_PERMISSIONS_PERM_STATS_NEWEST' => 'Statistik und neuestes Mitglied',
'STATS_PERMISSIONS_SECTION_SIMPLE_PERMISSIONS' => 'Vereinfachtes Berechtigungssystem',
'STATS_PERMISSIONS_SIMPLE_PERMISSIONS_EXP' => 'Damit kann bei Gästen und Bots festgelegt werden, was diese von der Statistik sehen dürfen. Alle anderen Gruppen sehen die Statistik immer vollständig. Wenn differenziertere Berechtigungen benötigt werden, muss das phpBB Berechtigungssystem aktiviert werden.',
'STATS_PERMISSIONS_PERM_FOR_GUESTS' => 'Anzeige für Gäste',
'STATS_PERMISSIONS_PERM_FOR_GUESTS_EXP' => 'Legt fest, was Gäste sehen können. Wenn alle Schalter deaktiviert sind, wird die Statistik-Anzeige für Gäste komplett ausgeschaltet.',
'STATS_PERMISSIONS_PERM_FOR_BOTS' => 'Anzeige für Bots',
'STATS_PERMISSIONS_PERM_FOR_BOTS_EXP' => 'Legt fest, was Bots sehen können. Wenn alle Schalter deaktiviert sind, wird die Statistik-Anzeige für Bots komplett ausgeschaltet.',
// 'STATS_PERMISSIONS_PERM_STATS_NEWEST' => 'Statistik und neuestes Mitglied',
'STATS_PERMISSIONS_PERM_NEWEST' => 'Neuestes Mitglied',
'STATS_PERMISSIONS_PERM_STATS' => 'Statistik',
'STATS_PERMISSIONS_PERM_NOTHING' => 'Nichts',
// 'STATS_PERMISSIONS_PERM_NOTHING' => 'Nichts',

// config section 2
'STATS_PERMISSIONS_SECTION_RESET' => 'Zurücksetzen',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,16 @@
'STATS_PERMISSIONS_ADMIN_MODE_EXP' => 'Dieser Modus setzt alle Berechtigungssysteme außer Kraft und nur Benutzer mit administrativen Rechten können die Statistik sehen. Hilfreich wenn die Statistik kurzfristig für andere nicht sichtbar sein soll.',
'STATS_PERMISSIONS_USE_PERMISSIONS' => 'Benutze das Berechtigungssystem von phpBB',
'STATS_PERMISSIONS_USE_PERMISSIONS_EXP' => 'Ermöglicht es, für jede Benutzergruppe getrennt festlegen zu können, welchen Umfang die Statistik haben soll. Die Rechte können wie folgt angepasst werden: „BERECHTIGUNGEN » Gruppenrechte » [Benutzergruppe] » Benutzer-Berechtigungen » Erweiterte Berechtigungen » Diverses“.',
'STATS_PERMISSIONS_DISP_FOR_GUESTS' => 'Anzeige für Gäste',
'STATS_PERMISSIONS_DISP_FOR_GUESTS_EXP' => 'Legt fest, was Gäste sehen können. „Statistik“ zeigt nur die anonymen Zahlen und „Nichts“ schaltet die Anzeige für Gäste komplett aus.',
'STATS_PERMISSIONS_DISP_FOR_BOTS' => 'Anzeige für Bots',
'STATS_PERMISSIONS_DISP_FOR_BOTS_EXP' => 'Legt fest, was Bots sehen können. „Statistik“ zeigt nur die anonymen Zahlen und „Nichts“ schaltet die Anzeige für Bots komplett aus.',
'STATS_PERMISSIONS_PERM_STATS_NEWEST' => 'Statistik und neuestes Mitglied',
'STATS_PERMISSIONS_SECTION_SIMPLE_PERMISSIONS' => 'Vereinfachtes Berechtigungssystem',
'STATS_PERMISSIONS_SIMPLE_PERMISSIONS_EXP' => 'Damit kann bei Gästen und Bots festgelegt werden, was diese von der Statistik sehen dürfen. Alle anderen Gruppen sehen die Statistik immer vollständig. Wenn differenziertere Berechtigungen benötigt werden, muss das phpBB Berechtigungssystem aktiviert werden.',
'STATS_PERMISSIONS_PERM_FOR_GUESTS' => 'Anzeige für Gäste',
'STATS_PERMISSIONS_PERM_FOR_GUESTS_EXP' => 'Legt fest, was Gäste sehen können. Wenn alle Schalter deaktiviert sind, wird die Statistik-Anzeige für Gäste komplett ausgeschaltet.',
'STATS_PERMISSIONS_PERM_FOR_BOTS' => 'Anzeige für Bots',
'STATS_PERMISSIONS_PERM_FOR_BOTS_EXP' => 'Legt fest, was Bots sehen können. Wenn alle Schalter deaktiviert sind, wird die Statistik-Anzeige für Bots komplett ausgeschaltet.',
// 'STATS_PERMISSIONS_PERM_STATS_NEWEST' => 'Statistik und neuestes Mitglied',
'STATS_PERMISSIONS_PERM_NEWEST' => 'Neuestes Mitglied',
'STATS_PERMISSIONS_PERM_STATS' => 'Statistik',
'STATS_PERMISSIONS_PERM_NOTHING' => 'Nichts',
// 'STATS_PERMISSIONS_PERM_NOTHING' => 'Nichts',

// config section 2
'STATS_PERMISSIONS_SECTION_RESET' => 'Zurücksetzen',
Expand Down
Loading

0 comments on commit c4f0c92

Please sign in to comment.