Compare commits

..

No commits in common. "master" and "v0.3" have entirely different histories.
master ... v0.3

5 changed files with 44 additions and 24 deletions

View file

@ -14,16 +14,4 @@ Proofreading 0.3 - 2025.01.09
===========================================================
* Require Dotclear 2.33
* Require PHP 8.1
* Add 1 post status and 1 user permission
Proofreading 0.4 - 2025.01.11
===========================================================
* Require Dotclear 2.33
* Require PHP 8.1
* Change status levels
Proofreading 0.5 - 2025.01.11
===========================================================
* Require Dotclear 2.33
* Require PHP 8.1
* Remove subscriber stuff (now to plugin RestrictedReading)
* Add 1 post status and 1 user permission

View file

@ -17,7 +17,7 @@ $this->registerModule(
'Proofreading',
'Add proofreading statuses for your posts',
'Jean-Christian Denis and Contributors',
'0.5',
'0.3',
[
'requires' => [['core', '2.33']],
'permissions' => 'My',

View file

@ -2,10 +2,10 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="Proofreading">
<name>Proofreading</name>
<version>0.5</version>
<version>0.3</version>
<author>Jean-Christian Paul Denis and contributors</author>
<desc>Add proofreading statuses for your posts.</desc>
<file>https://github.com/JcDenis/Proofreading/releases/download/v0.5/plugin-Proofreading.zip</file>
<file>https://github.com/JcDenis/Proofreading/releases/download/v0.3/plugin-Proofreading.zip</file>
<da:dcmin>2.33</da:dcmin>
<da:details>https://git.dotclear.watch/JcDenis/Proofreading/src/branch/master/README.md</da:details>
<da:support>https://git.dotclear.watch/JcDenis/Proofreading/issues</da:support>

View file

@ -21,7 +21,9 @@ use Dotclear\Module\MyPlugin;
*/
class My extends MyPlugin
{
public const POST_READY = -111;
public const POST_PROOFREAD = -112;
public const POST_DRAFT = -113;
public const PERMISSION_SUBSCRIBER = 'subscriber';
public const POST_SUBSCRIBED = -200;
public const POST_READY = -100;
public const POST_PROOFREAD = -110;
public const POST_DRAFT = -120;
}

View file

@ -29,19 +29,49 @@ class Prepend extends Process
return false;
}
// Add post status
return
// Add "Draft" post status, used on backend only.
// subscirber permission
App::auth()->setPermissionType(My::PERMISSION_SUBSCRIBER, __('Posts subscriber'));
// posts status
$status =
App::status()->post()->set(
(new Status(My::POST_DRAFT , My::id() . 'draft', 'Draft', 'Draft (>1)', My::fileURL('img/draft.svg'))),
)
// Add "To proofread" post status, used on backend only.
&& App::status()->post()->set(
(new Status(My::POST_PROOFREAD , My::id() . 'proofread', 'To proofread', 'To proofread (>1)', My::fileURL('img/proofread.svg'))),
)
// Add "Fulfilled" post status, used on backend only.
&& App::status()->post()->set(
(new Status(My::POST_READY , My::id() . 'ready', 'Fulfilled', 'Fulfilled (>1)', My::fileURL('img/ready.svg'))),
)
&& App::status()->post()->set(
(new Status(My::POST_SUBSCRIBED , My::id() . 'subscriber', 'Subscription', 'Subscription (>1)', My::fileURL('img/subscriber.svg'))),
);
// tweak frontend
if ($status) {
App::behavior()->addBehaviors([
'coreBlogBeforeGetPostsAddingParameters' => self::getPosts(...),
]);
}
return $status;
}
/**
* @param array<string, mixed>|ArrayObject<string, mixed> $params Parameters
*/
public static function getPosts(ArrayObject $params, string|null $arg = null): void
{
if (App::task()->checkContext('FRONTEND') && App::auth()->check(My::PERMISSION_SUBSCRIBER, App::blog()->id()) === true) {
if (!isset($params['psot_status'])) {
$params['post_status'] = [];
}
if (!is_array($params['post_status'])) {
$params['post_status'] = [$params['post_status']];
}
//$params['post_status'][] = App::status()->post()::PUBLISHED;
$params['post_status'][] = My::POST_SUBSCRIBED;
}
}
}