code review

This commit is contained in:
Jean-Christian Paul Denis 2023-10-20 21:28:21 +02:00
parent 4150bf1b19
commit 5e7765d395
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
9 changed files with 33 additions and 52 deletions

View File

@ -1,3 +1,10 @@
simplyFavicon 2023.10.20
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1
* Fix use of interface
* Use default permissions
simplyFavicon 2023.10.14 simplyFavicon 2023.10.14
=========================================================== ===========================================================
* Require Dotclear 2.28 * Require Dotclear 2.28

View File

@ -1,14 +1,14 @@
# README # README
[![Release](https://img.shields.io/badge/release-2023.10.14-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/simplyFavicon/releases) [![Release](https://img.shields.io/badge/release-2023.10.20-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/simplyFavicon/releases)
![Date](https://img.shields.io/badge/date-2023.10.13-c44d58.svg) ![Date](https://img.shields.io/badge/date-2023.10.20-c44d58.svg)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download) [![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/simplyFavicon) [![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/simplyFavicon)
[![License](https://img.shields.io/github/license/JcDenis/simplyFavicon)](https://git.dotclear.watch/JcDenis/simplyFavicon/blob/master/LICENSE) [![License](https://img.shields.io/github/license/JcDenis/simplyFavicon)](https://git.dotclear.watch/JcDenis/simplyFavicon/blob/master/LICENSE)
## ABOUT ## ABOUT
_pacKman_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org). _simplyFavicon_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
> Add a favicon to your blog. > Add a favicon to your blog.
@ -17,7 +17,7 @@ _pacKman_ is a plugin for the open-source web publishing software called [Dotcle
* Dotclear 2.28 * Dotclear 2.28
* PHP 8.1+ * PHP 8.1+
* A readable public directory * A readable public directory
* Administrator permissions * Dotclear admin permissions
## USAGE ## USAGE

View File

@ -1,16 +1,5 @@
<?php <?php
/** /**
* @brief simplyFavicon, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
/*
* @file * @file
* @brief The simplyFavicon pacKman definition * @brief The simplyFavicon pacKman definition
* @ingroup simplyFavicon * @ingroup simplyFavicon
@ -28,13 +17,11 @@ $this->registerModule(
'Simply favicon', 'Simply favicon',
'Multi-agents favicon', 'Multi-agents favicon',
'Jean-Christian Denis', 'Jean-Christian Denis',
'2023.10.14', '2023.10.20',
[ [
'requires' => [['core', '2.28']], 'requires' => [['core', '2.28']],
'permissions' => 'My', 'permissions' => 'My',
'settings' => [ 'settings' => ['blog' => '#params.' . basename(__DIR__) . '_params'],
'blog' => '#params.' . basename(__DIR__) . '_params',
],
'type' => 'plugin', 'type' => 'plugin',
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues', 'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md', 'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',

View File

@ -2,10 +2,10 @@
<modules xmlns:da="http://dotaddict.org/da/"> <modules xmlns:da="http://dotaddict.org/da/">
<module id="simplyFavicon"> <module id="simplyFavicon">
<name>Simply favicon</name> <name>Simply favicon</name>
<version>2023.10.14</version> <version>2023.10.20</version>
<author>Jean-Christian Denis</author> <author>Jean-Christian Denis</author>
<desc>Multi-agents favicon</desc> <desc>Multi-agents favicon</desc>
<file>https://git.dotclear.watch/JcDenis/simplyFavicon/releases/download/v2023.10.14/plugin-simplyFavicon.zip</file> <file>https://git.dotclear.watch/JcDenis/simplyFavicon/releases/download/v2023.10.20/plugin-simplyFavicon.zip</file>
<da:dcmin>2.28</da:dcmin> <da:dcmin>2.28</da:dcmin>
<da:details>https://git.dotclear.watch/JcDenis/simplyFavicon/src/branch/master/README.md</da:details> <da:details>https://git.dotclear.watch/JcDenis/simplyFavicon/src/branch/master/README.md</da:details>
<da:support>https://git.dotclear.watch/JcDenis/simplyFavicon/issues</da:support> <da:support>https://git.dotclear.watch/JcDenis/simplyFavicon/issues</da:support>

View File

@ -5,7 +5,6 @@ declare(strict_types=1);
namespace Dotclear\Plugin\simplyFavicon; namespace Dotclear\Plugin\simplyFavicon;
use Dotclear\App; use Dotclear\App;
use Dotclear\Core\BlogSettings;
use Dotclear\Core\Process; use Dotclear\Core\Process;
use Dotclear\Helper\File\Path; use Dotclear\Helper\File\Path;
use Dotclear\Helper\Html\Form\{ use Dotclear\Helper\Html\Form\{
@ -15,6 +14,7 @@ use Dotclear\Helper\Html\Form\{
Note, Note,
Para Para
}; };
use Dotclear\Interface\Core\BlogSettingsInterface;
/** /**
* @brief simplyFavicon backend class. * @brief simplyFavicon backend class.
@ -37,7 +37,7 @@ class Backend extends Process
} }
App::behavior()->addBehaviors([ App::behavior()->addBehaviors([
'adminBlogPreferencesFormV2' => function (BlogSettings $blog_settings): void { 'adminBlogPreferencesFormV2' => function (BlogSettingsInterface $blog_settings): void {
if (!App::blog()->isDefined()) { if (!App::blog()->isDefined()) {
return; return;
} }
@ -78,7 +78,7 @@ class Backend extends Process
) . ) .
'</div></div><br class="clear" /></div>'; '</div></div><br class="clear" /></div>';
}, },
'adminBeforeBlogSettingsUpdate' => function (BlogSettings $blog_settings): void { 'adminBeforeBlogSettingsUpdate' => function (BlogSettingsInterface $blog_settings): void {
$blog_settings->get('system')->put('simply_favicon', !empty($_POST['simply_favicon'])); $blog_settings->get('system')->put('simply_favicon', !empty($_POST['simply_favicon']));
}, },
]); ]);

View File

@ -4,7 +4,6 @@ declare(strict_types=1);
namespace Dotclear\Plugin\simplyFavicon; namespace Dotclear\Plugin\simplyFavicon;
use Dotclear\App;
use Dotclear\Module\MyPlugin; use Dotclear\Module\MyPlugin;
/** /**
@ -16,17 +15,5 @@ use Dotclear\Module\MyPlugin;
*/ */
class My extends MyPlugin class My extends MyPlugin
{ {
protected static function checkCustomContext(int $context): ?bool // Use default permissions
{
return match ($context) {
// Limit BACKEND to admin
self::BACKEND => App::task()->checkContext('BACKEND')
&& App::blog()->isDefined()
&& App::auth()->check(App::auth()->makePermissions([
App::auth()::PERMISSION_ADMIN,
]), App::blog()->id()),
default => null,
};
}
} }