add ability to change password, fix #2

This commit is contained in:
Jean-Christian Paul Denis 2023-05-21 15:11:02 +02:00
parent e7cbc6eedb
commit 7f931f24ad
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
4 changed files with 66 additions and 61 deletions

View File

@ -22,8 +22,8 @@ L10n::$locales['On this date, change:'] = 'Á cette date, changer :
L10n::$locales['Selection:'] = 'Séléction :'; L10n::$locales['Selection:'] = 'Séléction :';
L10n::$locales['Comments status:'] = 'Status des commentaires :'; L10n::$locales['Comments status:'] = 'Status des commentaires :';
L10n::$locales['Trackbacks status:'] = 'Status des rétroliens :'; L10n::$locales['Trackbacks status:'] = 'Status des rétroliens :';
L10n::$locales['Change password'] = 'Modifier le mot de passe';
L10n::$locales['Leave empty to remove it'] = 'Laisser vide pour le supprimer';
L10n::$locales['Not changed'] = 'Inchangé'; L10n::$locales['Not changed'] = 'Inchangé';
L10n::$locales['Opened'] = 'Ouvert';
L10n::$locales['Closed'] = 'Fermé';
L10n::$locales['Expired on'] = 'Expire le'; L10n::$locales['Expired on'] = 'Expire le';
L10n::$locales['This entry has no expiration date'] = 'Ce billet n\'a pas de date de péremption'; L10n::$locales['This entry has no expiration date'] = 'Ce billet n\'a pas de date de péremption';

View File

@ -1,87 +1,60 @@
# Language: Français
# Module: postExpired - 2013.11.03
# Date: 2013-11-03 22:12:31
# Translated with translater 2013.05.11
msgid "" msgid ""
msgstr "" msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Project-Id-Version: postExpired 2013.11.03\n" "Project-Id-Version: postExpired 2023.05.21\n"
"POT-Creation-Date: \n" "POT-Creation-Date: \n"
"PO-Revision-Date: 2013-11-03T22:12:31+00:00\n" "PO-Revision-Date: 2023-05-21T13:03:45+00:00\n"
"Last-Translator: Jean-Christian Denis\n" "Last-Translator: Jean-Christian Denis\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: _admin.php:100
#: _admin.php:110
msgid "Expired entries" msgid "Expired entries"
msgstr "Billets périmés" msgstr "Billets périmés"
#: _admin.php:101
msgid "Add expired date" msgid "Add expired date"
msgstr "Ajouter une date de péremption" msgstr "Ajouter une date de péremption"
#: _admin.php:111
msgid "Remove expired date" msgid "Remove expired date"
msgstr "Retirer une date de péremption" msgstr "Retirer une date de péremption"
#: _admin.php:139
msgid "Expired date" msgid "Expired date"
msgstr "Date de péremption" msgstr "Date de péremption"
#: _admin.php:209
msgid "Expired date added." msgid "Expired date added."
msgstr "Date de péremption ajoutée." msgstr "Date de péremption ajoutée."
#: _admin.php:222
msgid "Add expired date to this selection" msgid "Add expired date to this selection"
msgstr "Ajouter une date de péremtion à cette sélection" msgstr "Ajouter une date de péremtion à cette sélection"
#: _admin.php:269
msgid "Expired date deleted." msgid "Expired date deleted."
msgstr "Dtae de péremtion supprimé" msgstr "Dtae de péremtion supprimé"
#: _admin.php:370
msgid "On this date, change:" msgid "On this date, change:"
msgstr "Á cette date, changer :" msgstr "Á cette date, changer :"
#: _admin.php:398
msgid "Selection:" msgid "Selection:"
msgstr "Séléction :" msgstr "Séléction :"
#: _admin.php:409
msgid "Comments status:" msgid "Comments status:"
msgstr "Status des commentaires :" msgstr "Status des commentaires :"
#: _admin.php:419
msgid "Trackbacks status:" msgid "Trackbacks status:"
msgstr "Status des rétroliens :" msgstr "Status des rétroliens :"
#: _admin.php:440 msgid "Change password"
#: _admin.php:470 msgstr "Modifier le mot de passe"
#: _admin.php:485
#: _admin.php:499 msgid "Leave empty to remove it"
#: _admin.php:513 msgstr "Laisser vide pour le supprimer"
msgid "Not changed" msgid "Not changed"
msgstr "Inchangé" msgstr "Inchangé"
#: _admin.php:500
#: _admin.php:514
msgid "Opened"
msgstr "Ouvert"
#: _admin.php:501
#: _admin.php:515
msgid "Closed"
msgstr "Fermé"
#: _public.php:25
msgid "Expired on" msgid "Expired on"
msgstr "Expire le" msgstr "Expire le"
#: _public.php:26
msgid "This entry has no expiration date" msgid "This entry has no expiration date"
msgstr "Ce billet n'a pas de date de péremption" msgstr "Ce billet n'a pas de date de péremption"

View File

@ -24,10 +24,13 @@ use Dotclear\Database\{
MetaRecord MetaRecord
}; };
use Dotclear\Helper\Html\Form\{ use Dotclear\Helper\Html\Form\{
Checkbox,
Datetime, Datetime,
Form, Form,
Hidden, Hidden,
Input,
Label, Label,
Note,
Option, Option,
Para, Para,
Text, Text,
@ -124,11 +127,15 @@ class BackendBehaviors
self::delPostExpired($post_id); self::delPostExpired($post_id);
if (!empty($_POST['post_expired_date']) if (!empty($_POST['post_expired_date'])
&& (!empty($_POST['post_expired_status']) && (
|| !empty($_POST['post_expired_category']) !empty($_POST['post_expired_status'])
|| !empty($_POST['post_expired_selected']) || !empty($_POST['post_expired_category'])
|| !empty($_POST['post_expired_comment']) || !empty($_POST['post_expired_selected'])
|| !empty($_POST['post_expired_trackback']))) { || !empty($_POST['post_expired_comment'])
|| !empty($_POST['post_expired_trackback'])
|| !empty($_POST['post_expired_password'])
)
) {
self::setPostExpired($post_id, new ArrayObject($_POST)); self::setPostExpired($post_id, new ArrayObject($_POST));
} }
} }
@ -152,13 +159,17 @@ class BackendBehaviors
throw new Exception(__('No entry selected')); throw new Exception(__('No entry selected'));
} }
// Add epired date // Add expired date
if (!empty($post['post_expired_date']) if (!empty($post['post_expired_date'])
&& (!empty($post['post_expired_status']) && (
|| !empty($post['post_expired_category']) !empty($post['post_expired_status'])
|| !empty($post['post_expired_selected']) || !empty($post['post_expired_category'])
|| !empty($post['post_expired_comment']) || !empty($post['post_expired_selected'])
|| !empty($post['post_expired_trackback']))) { || !empty($post['post_expired_comment'])
|| !empty($post['post_expired_trackback'])
|| !empty($post['post_expired_password'])
)
) {
foreach ($posts_ids as $post_id) { foreach ($posts_ids as $post_id) {
self::delPostExpired($post_id); self::delPostExpired($post_id);
self::setPostExpired($post_id, $post); self::setPostExpired($post_id, $post);
@ -242,12 +253,14 @@ class BackendBehaviors
private static function setPostExpired(int $post_id, ArrayObject $post): void private static function setPostExpired(int $post_id, ArrayObject $post): void
{ {
$post_expired = [ $post_expired = [
'status' => '', 'status' => '',
'category' => '', 'category' => '',
'selected' => '', 'selected' => '',
'comment' => '', 'comment' => '',
'trackback' => '', 'trackback' => '',
'date' => self::dateFromUser($post['post_expired_date']), 'password' => '',
'newpassword' => '',
'date' => self::dateFromUser($post['post_expired_date']),
]; ];
if (!empty($post['post_expired_status'])) { if (!empty($post['post_expired_status'])) {
@ -265,6 +278,12 @@ class BackendBehaviors
if (!empty($post['post_expired_trackback'])) { if (!empty($post['post_expired_trackback'])) {
$post_expired['trackback'] = (string) $post['post_expired_trackback']; $post_expired['trackback'] = (string) $post['post_expired_trackback'];
} }
if (!empty($post['post_expired_password'])) {
$post_expired['password'] = (string) $post['post_expired_password'];
}
if (!empty($post['post_expired_newpassword'])) {
$post_expired['newpassword'] = (string) $post['post_expired_newpassword'];
}
dcCore::app()->meta->setPostMeta( dcCore::app()->meta->setPostMeta(
$post_id, $post_id,
@ -303,20 +322,20 @@ class BackendBehaviors
} }
$fields['post_expired_date'] = (new Para())->items([ $fields['post_expired_date'] = (new Para())->items([
(new Label(__('Date:')))->for('post_expired_date'), (new Label(__('Date:'), Label::OUTSIDE_LABEL_BEFORE))->for('post_expired_date'),
(new Datetime('post_expired_date', Html::escapeHTML(self::dateToUser($post_expired['date'] ?? 'now'))))->class(empty($post_expired['date']) ? 'invalid' : ''), (new Datetime('post_expired_date', Html::escapeHTML(self::dateToUser($post_expired['date'] ?? 'now'))))->class(empty($post_expired['date']) ? 'invalid' : ''),
]); ]);
$fields['post_expired_status'] = (new Para())->items([ $fields['post_expired_status'] = (new Para())->items([
(new Text('strong', __('On this date, change:'))), (new Text('strong', __('On this date, change:'))),
(new Text('br')), (new Text('br')),
(new Label(__('Status:')))->for('post_expired_status'), (new Label(__('Status:'), Label::OUTSIDE_LABEL_BEFORE))->for('post_expired_status'),
(new Select('post_expired_status'))->default(empty($post_expired['status']) ? '' : $post_expired['status'])->items(self::statusCombo()), (new Select('post_expired_status'))->default(empty($post_expired['status']) ? '' : $post_expired['status'])->items(self::statusCombo()),
]); ]);
if ($post_type == 'post') { if ($post_type == 'post') {
$fields['post_expired_category'] = (new Para())->items([ $fields['post_expired_category'] = (new Para())->items([
(new Label(__('Category:')))->for('post_expired_category'), (new Label(__('Category:'), Label::OUTSIDE_LABEL_BEFORE))->for('post_expired_category'),
(new Select('post_expired_category'))->default(empty($post_expired['category']) ? '' : $post_expired['category'])->items(self::categoriesCombo( (new Select('post_expired_category'))->default(empty($post_expired['category']) ? '' : $post_expired['category'])->items(self::categoriesCombo(
dcCore::app()->blog->getCategories( dcCore::app()->blog->getCategories(
['post_type' => 'post'] ['post_type' => 'post']
@ -325,21 +344,29 @@ class BackendBehaviors
]); ]);
$fields['post_expired_selected'] = (new Para())->items([ $fields['post_expired_selected'] = (new Para())->items([
(new Label(__('Selection:')))->for('post_expired_selected'), (new Label(__('Selection:'), Label::OUTSIDE_LABEL_BEFORE))->for('post_expired_selected'),
(new Select('post_expired_selected'))->default(empty($post_expired['selected']) ? '' : $post_expired['selected'])->items(self::selectedCombo()), (new Select('post_expired_selected'))->default(empty($post_expired['selected']) ? '' : $post_expired['selected'])->items(self::selectedCombo()),
]); ]);
} }
$fields['post_expired_comment'] = (new Para())->items([ $fields['post_expired_comment'] = (new Para())->items([
(new Label(__('Comments status:')))->for('post_expired_comment'), (new Label(__('Comments status:'), Label::OUTSIDE_LABEL_BEFORE))->for('post_expired_comment'),
(new Select('post_expired_comment'))->default(empty($post_expired['comment']) ? '' : $post_expired['comment'])->items(self::commentCombo()), (new Select('post_expired_comment'))->default(empty($post_expired['comment']) ? '' : $post_expired['comment'])->items(self::commentCombo()),
]); ]);
$fields['post_expired_trackback'] = (new Para())->items([ $fields['post_expired_trackback'] = (new Para())->items([
(new Label(__('Trackbacks status:')))->for('post_expired_trackback'), (new Label(__('Trackbacks status:'), Label::OUTSIDE_LABEL_BEFORE))->for('post_expired_trackback'),
(new Select('post_expired_trackback'))->default(empty($post_expired['trackback']) ? '' : $post_expired['trackback'])->items(self::trackbackCombo()), (new Select('post_expired_trackback'))->default(empty($post_expired['trackback']) ? '' : $post_expired['trackback'])->items(self::trackbackCombo()),
]); ]);
$fields['post_expired_password'] = (new Para())->items([
(new Checkbox('post_expired_password', !empty($post_expired['password'])))->value(1),
(new Label(__('Change password'), Label::OUTSIDE_LABEL_AFTER))->for('post_expired_password')->class('classic'),
(new Label(__('New password:'), Label::OUTSIDE_LABEL_BEFORE))->for('post_expired_newpassword'),
(new Input('post_expired_newpassword'))->size(65)->maxlenght(255)->class('maximal')->value(empty($post_expired['newpassword']) ? '' : $post_expired['newpassword']),
(new Note())->text(__('Leave empty to remove it'))->class('form-note'),
]);
if ($render) { if ($render) {
foreach ($fields as $k => $v) { foreach ($fields as $k => $v) {
$fields[$k] = $v->render(); $fields[$k] = $v->render();

View File

@ -128,6 +128,11 @@ class FrontendBehaviors
case 'trackback': case 'trackback':
$post_cur->setField('post_open_tb', $v); $post_cur->setField('post_open_tb', $v);
break;
case 'password':
$post_cur->setField('post_password', empty($post_expired['newpassword']) ? '' : $post_expired['newpassword']);
break; break;
} }
} }