Compare commits
No commits in common. "master" and "v0.4" have entirely different histories.
5 changed files with 46 additions and 11 deletions
|
@ -20,10 +20,4 @@ Proofreading 0.4 - 2025.01.11
|
||||||
===========================================================
|
===========================================================
|
||||||
* Require Dotclear 2.33
|
* Require Dotclear 2.33
|
||||||
* Require PHP 8.1
|
* Require PHP 8.1
|
||||||
* Change status levels
|
* Change status levels
|
||||||
|
|
||||||
Proofreading 0.5 - 2025.01.11
|
|
||||||
===========================================================
|
|
||||||
* Require Dotclear 2.33
|
|
||||||
* Require PHP 8.1
|
|
||||||
* Remove subscriber stuff (now to plugin RestrictedReading)
|
|
|
@ -17,7 +17,7 @@ $this->registerModule(
|
||||||
'Proofreading',
|
'Proofreading',
|
||||||
'Add proofreading statuses for your posts',
|
'Add proofreading statuses for your posts',
|
||||||
'Jean-Christian Denis and Contributors',
|
'Jean-Christian Denis and Contributors',
|
||||||
'0.5',
|
'0.4',
|
||||||
[
|
[
|
||||||
'requires' => [['core', '2.33']],
|
'requires' => [['core', '2.33']],
|
||||||
'permissions' => 'My',
|
'permissions' => 'My',
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
<modules xmlns:da="http://dotaddict.org/da/">
|
<modules xmlns:da="http://dotaddict.org/da/">
|
||||||
<module id="Proofreading">
|
<module id="Proofreading">
|
||||||
<name>Proofreading</name>
|
<name>Proofreading</name>
|
||||||
<version>0.5</version>
|
<version>0.4</version>
|
||||||
<author>Jean-Christian Paul Denis and contributors</author>
|
<author>Jean-Christian Paul Denis and contributors</author>
|
||||||
<desc>Add proofreading statuses for your posts.</desc>
|
<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.4/plugin-Proofreading.zip</file>
|
||||||
<da:dcmin>2.33</da:dcmin>
|
<da:dcmin>2.33</da:dcmin>
|
||||||
<da:details>https://git.dotclear.watch/JcDenis/Proofreading/src/branch/master/README.md</da:details>
|
<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>
|
<da:support>https://git.dotclear.watch/JcDenis/Proofreading/issues</da:support>
|
||||||
|
|
|
@ -21,6 +21,8 @@ use Dotclear\Module\MyPlugin;
|
||||||
*/
|
*/
|
||||||
class My extends MyPlugin
|
class My extends MyPlugin
|
||||||
{
|
{
|
||||||
|
public const PERMISSION_SUBSCRIBER = 'subscriber';
|
||||||
|
public const POST_SUBSCRIBED = -110;
|
||||||
public const POST_READY = -111;
|
public const POST_READY = -111;
|
||||||
public const POST_PROOFREAD = -112;
|
public const POST_PROOFREAD = -112;
|
||||||
public const POST_DRAFT = -113;
|
public const POST_DRAFT = -113;
|
||||||
|
|
|
@ -29,8 +29,11 @@ class Prepend extends Process
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add "Posts subscriber" user permission
|
||||||
|
App::auth()->setPermissionType(My::PERMISSION_SUBSCRIBER, __('Posts subscriber'));
|
||||||
|
|
||||||
// Add post status
|
// Add post status
|
||||||
return
|
$status =
|
||||||
// Add "Draft" post status, used on backend only.
|
// Add "Draft" post status, used on backend only.
|
||||||
App::status()->post()->set(
|
App::status()->post()->set(
|
||||||
(new Status(My::POST_DRAFT , My::id() . 'draft', 'Draft', 'Draft (>1)', My::fileURL('img/draft.svg'))),
|
(new Status(My::POST_DRAFT , My::id() . 'draft', 'Draft', 'Draft (>1)', My::fileURL('img/draft.svg'))),
|
||||||
|
@ -42,6 +45,42 @@ class Prepend extends Process
|
||||||
// Add "Fulfilled" post status, used on backend only.
|
// Add "Fulfilled" post status, used on backend only.
|
||||||
&& App::status()->post()->set(
|
&& App::status()->post()->set(
|
||||||
(new Status(My::POST_READY , My::id() . 'ready', 'Fulfilled', 'Fulfilled (>1)', My::fileURL('img/ready.svg'))),
|
(new Status(My::POST_READY , My::id() . 'ready', 'Fulfilled', 'Fulfilled (>1)', My::fileURL('img/ready.svg'))),
|
||||||
|
)
|
||||||
|
// Add "Subscription" post status on backend and frontend.
|
||||||
|
&& App::status()->post()->set(
|
||||||
|
(new Status(My::POST_SUBSCRIBED , My::id() . 'subscriber', 'Subscription', 'Subscription (>1)', My::fileURL('img/subscriber.svg'))),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Tweak frontend post related queries
|
||||||
|
if ($status) {
|
||||||
|
App::behavior()->addBehaviors([
|
||||||
|
'coreBlogBeforeGetPostsAddingParameters' => self::coreBlogBeforeGetPostsAddingParameters(...),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add subscriber post status.
|
||||||
|
*
|
||||||
|
* This adds post marked with status subscriber
|
||||||
|
* to Frontend if user is loggued and has subscriber right.
|
||||||
|
*
|
||||||
|
* @param ArrayObject<string, mixed> $params Parameters
|
||||||
|
*/
|
||||||
|
public static function coreBlogBeforeGetPostsAddingParameters(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['post_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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue