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['Comments status:'] = 'Status des commentaires :';
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['Opened'] = 'Ouvert';
L10n::$locales['Closed'] = 'Fermé';
L10n::$locales['Expired on'] = 'Expire le';
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 ""
msgstr ""
"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"
"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"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: _admin.php:100
#: _admin.php:110
msgid "Expired entries"
msgstr "Billets périmés"
#: _admin.php:101
msgid "Add expired date"
msgstr "Ajouter une date de péremption"
#: _admin.php:111
msgid "Remove expired date"
msgstr "Retirer une date de péremption"
#: _admin.php:139
msgid "Expired date"
msgstr "Date de péremption"
#: _admin.php:209
msgid "Expired date added."
msgstr "Date de péremption ajoutée."
#: _admin.php:222
msgid "Add expired date to this selection"
msgstr "Ajouter une date de péremtion à cette sélection"
#: _admin.php:269
msgid "Expired date deleted."
msgstr "Dtae de péremtion supprimé"
#: _admin.php:370
msgid "On this date, change:"
msgstr "Á cette date, changer :"
#: _admin.php:398
msgid "Selection:"
msgstr "Séléction :"
#: _admin.php:409
msgid "Comments status:"
msgstr "Status des commentaires :"
#: _admin.php:419
msgid "Trackbacks status:"
msgstr "Status des rétroliens :"
#: _admin.php:440
#: _admin.php:470
#: _admin.php:485
#: _admin.php:499
#: _admin.php:513
msgid "Change password"
msgstr "Modifier le mot de passe"
msgid "Leave empty to remove it"
msgstr "Laisser vide pour le supprimer"
msgid "Not changed"
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"
msgstr "Expire le"
#: _public.php:26
msgid "This entry has no expiration date"
msgstr "Ce billet n'a pas de date de péremption"

View File

@ -24,10 +24,13 @@ use Dotclear\Database\{
MetaRecord
};
use Dotclear\Helper\Html\Form\{
Checkbox,
Datetime,
Form,
Hidden,
Input,
Label,
Note,
Option,
Para,
Text,
@ -124,11 +127,15 @@ class BackendBehaviors
self::delPostExpired($post_id);
if (!empty($_POST['post_expired_date'])
&& (!empty($_POST['post_expired_status'])
|| !empty($_POST['post_expired_category'])
|| !empty($_POST['post_expired_selected'])
|| !empty($_POST['post_expired_comment'])
|| !empty($_POST['post_expired_trackback']))) {
&& (
!empty($_POST['post_expired_status'])
|| !empty($_POST['post_expired_category'])
|| !empty($_POST['post_expired_selected'])
|| !empty($_POST['post_expired_comment'])
|| !empty($_POST['post_expired_trackback'])
|| !empty($_POST['post_expired_password'])
)
) {
self::setPostExpired($post_id, new ArrayObject($_POST));
}
}
@ -152,13 +159,17 @@ class BackendBehaviors
throw new Exception(__('No entry selected'));
}
// Add epired date
// Add expired date
if (!empty($post['post_expired_date'])
&& (!empty($post['post_expired_status'])
|| !empty($post['post_expired_category'])
|| !empty($post['post_expired_selected'])
|| !empty($post['post_expired_comment'])
|| !empty($post['post_expired_trackback']))) {
&& (
!empty($post['post_expired_status'])
|| !empty($post['post_expired_category'])
|| !empty($post['post_expired_selected'])
|| !empty($post['post_expired_comment'])
|| !empty($post['post_expired_trackback'])
|| !empty($post['post_expired_password'])
)
) {
foreach ($posts_ids as $post_id) {
self::delPostExpired($post_id);
self::setPostExpired($post_id, $post);
@ -242,12 +253,14 @@ class BackendBehaviors
private static function setPostExpired(int $post_id, ArrayObject $post): void
{
$post_expired = [
'status' => '',
'category' => '',
'selected' => '',
'comment' => '',
'trackback' => '',
'date' => self::dateFromUser($post['post_expired_date']),
'status' => '',
'category' => '',
'selected' => '',
'comment' => '',
'trackback' => '',
'password' => '',
'newpassword' => '',
'date' => self::dateFromUser($post['post_expired_date']),
];
if (!empty($post['post_expired_status'])) {
@ -265,6 +278,12 @@ class BackendBehaviors
if (!empty($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(
$post_id,
@ -303,20 +322,20 @@ class BackendBehaviors
}
$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' : ''),
]);
$fields['post_expired_status'] = (new Para())->items([
(new Text('strong', __('On this date, change:'))),
(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()),
]);
if ($post_type == 'post') {
$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(
dcCore::app()->blog->getCategories(
['post_type' => 'post']
@ -325,21 +344,29 @@ class BackendBehaviors
]);
$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()),
]);
}
$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()),
]);
$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()),
]);
$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) {
foreach ($fields as $k => $v) {
$fields[$k] = $v->render();

View File

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