Skip to content

Commit 7f931f2

Browse files
committed
add ability to change password, fix #2
1 parent e7cbc6e commit 7f931f2

File tree

4 files changed

+66
-61
lines changed

4 files changed

+66
-61
lines changed

Diff for: locales/fr/main.lang.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
L10n::$locales['Selection:'] = 'Séléction :';
2323
L10n::$locales['Comments status:'] = 'Status des commentaires :';
2424
L10n::$locales['Trackbacks status:'] = 'Status des rétroliens :';
25+
L10n::$locales['Change password'] = 'Modifier le mot de passe';
26+
L10n::$locales['Leave empty to remove it'] = 'Laisser vide pour le supprimer';
2527
L10n::$locales['Not changed'] = 'Inchangé';
26-
L10n::$locales['Opened'] = 'Ouvert';
27-
L10n::$locales['Closed'] = 'Fermé';
2828
L10n::$locales['Expired on'] = 'Expire le';
2929
L10n::$locales['This entry has no expiration date'] = 'Ce billet n\'a pas de date de péremption';

Diff for: locales/fr/main.po

+9-36
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,60 @@
1-
# Language: Français
2-
# Module: postExpired - 2013.11.03
3-
# Date: 2013-11-03 22:12:31
4-
# Translated with translater 2013.05.11
5-
61
msgid ""
72
msgstr ""
83
"Content-Type: text/plain; charset=UTF-8\n"
9-
"Project-Id-Version: postExpired 2013.11.03\n"
4+
"Project-Id-Version: postExpired 2023.05.21\n"
105
"POT-Creation-Date: \n"
11-
"PO-Revision-Date: 2013-11-03T22:12:31+00:00\n"
6+
"PO-Revision-Date: 2023-05-21T13:03:45+00:00\n"
127
"Last-Translator: Jean-Christian Denis\n"
138
"Language-Team: \n"
149
"MIME-Version: 1.0\n"
1510
"Content-Transfer-Encoding: 8bit\n"
11+
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
1612

17-
#: _admin.php:100
18-
#: _admin.php:110
1913
msgid "Expired entries"
2014
msgstr "Billets périmés"
2115

22-
#: _admin.php:101
2316
msgid "Add expired date"
2417
msgstr "Ajouter une date de péremption"
2518

26-
#: _admin.php:111
2719
msgid "Remove expired date"
2820
msgstr "Retirer une date de péremption"
2921

30-
#: _admin.php:139
3122
msgid "Expired date"
3223
msgstr "Date de péremption"
3324

34-
#: _admin.php:209
3525
msgid "Expired date added."
3626
msgstr "Date de péremption ajoutée."
3727

38-
#: _admin.php:222
3928
msgid "Add expired date to this selection"
4029
msgstr "Ajouter une date de péremtion à cette sélection"
4130

42-
#: _admin.php:269
4331
msgid "Expired date deleted."
4432
msgstr "Dtae de péremtion supprimé"
4533

46-
#: _admin.php:370
4734
msgid "On this date, change:"
4835
msgstr "Á cette date, changer :"
4936

50-
#: _admin.php:398
5137
msgid "Selection:"
5238
msgstr "Séléction :"
5339

54-
#: _admin.php:409
5540
msgid "Comments status:"
5641
msgstr "Status des commentaires :"
5742

58-
#: _admin.php:419
5943
msgid "Trackbacks status:"
6044
msgstr "Status des rétroliens :"
6145

62-
#: _admin.php:440
63-
#: _admin.php:470
64-
#: _admin.php:485
65-
#: _admin.php:499
66-
#: _admin.php:513
67-
msgid "Not changed"
68-
msgstr "Inchangé"
46+
msgid "Change password"
47+
msgstr "Modifier le mot de passe"
6948

70-
#: _admin.php:500
71-
#: _admin.php:514
72-
msgid "Opened"
73-
msgstr "Ouvert"
49+
msgid "Leave empty to remove it"
50+
msgstr "Laisser vide pour le supprimer"
7451

75-
#: _admin.php:501
76-
#: _admin.php:515
77-
msgid "Closed"
78-
msgstr "Fermé"
52+
msgid "Not changed"
53+
msgstr "Inchangé"
7954

80-
#: _public.php:25
8155
msgid "Expired on"
8256
msgstr "Expire le"
8357

84-
#: _public.php:26
8558
msgid "This entry has no expiration date"
8659
msgstr "Ce billet n'a pas de date de péremption"
8760

Diff for: src/BackendBehaviors.php

+50-23
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@
2424
MetaRecord
2525
};
2626
use Dotclear\Helper\Html\Form\{
27+
Checkbox,
2728
Datetime,
2829
Form,
2930
Hidden,
31+
Input,
3032
Label,
33+
Note,
3134
Option,
3235
Para,
3336
Text,
@@ -124,11 +127,15 @@ public static function adminAfterPostSave(Cursor $cur, int $post_id): void
124127
self::delPostExpired($post_id);
125128

126129
if (!empty($_POST['post_expired_date'])
127-
&& (!empty($_POST['post_expired_status'])
128-
|| !empty($_POST['post_expired_category'])
129-
|| !empty($_POST['post_expired_selected'])
130-
|| !empty($_POST['post_expired_comment'])
131-
|| !empty($_POST['post_expired_trackback']))) {
130+
&& (
131+
!empty($_POST['post_expired_status'])
132+
|| !empty($_POST['post_expired_category'])
133+
|| !empty($_POST['post_expired_selected'])
134+
|| !empty($_POST['post_expired_comment'])
135+
|| !empty($_POST['post_expired_trackback'])
136+
|| !empty($_POST['post_expired_password'])
137+
)
138+
) {
132139
self::setPostExpired($post_id, new ArrayObject($_POST));
133140
}
134141
}
@@ -152,13 +159,17 @@ public static function callbackAdd(dcPostsActions $pa, ArrayObject $post): void
152159
throw new Exception(__('No entry selected'));
153160
}
154161

155-
// Add epired date
162+
// Add expired date
156163
if (!empty($post['post_expired_date'])
157-
&& (!empty($post['post_expired_status'])
158-
|| !empty($post['post_expired_category'])
159-
|| !empty($post['post_expired_selected'])
160-
|| !empty($post['post_expired_comment'])
161-
|| !empty($post['post_expired_trackback']))) {
164+
&& (
165+
!empty($post['post_expired_status'])
166+
|| !empty($post['post_expired_category'])
167+
|| !empty($post['post_expired_selected'])
168+
|| !empty($post['post_expired_comment'])
169+
|| !empty($post['post_expired_trackback'])
170+
|| !empty($post['post_expired_password'])
171+
)
172+
) {
162173
foreach ($posts_ids as $post_id) {
163174
self::delPostExpired($post_id);
164175
self::setPostExpired($post_id, $post);
@@ -242,12 +253,14 @@ private static function delPostExpired(int $post_id): void
242253
private static function setPostExpired(int $post_id, ArrayObject $post): void
243254
{
244255
$post_expired = [
245-
'status' => '',
246-
'category' => '',
247-
'selected' => '',
248-
'comment' => '',
249-
'trackback' => '',
250-
'date' => self::dateFromUser($post['post_expired_date']),
256+
'status' => '',
257+
'category' => '',
258+
'selected' => '',
259+
'comment' => '',
260+
'trackback' => '',
261+
'password' => '',
262+
'newpassword' => '',
263+
'date' => self::dateFromUser($post['post_expired_date']),
251264
];
252265

253266
if (!empty($post['post_expired_status'])) {
@@ -265,6 +278,12 @@ private static function setPostExpired(int $post_id, ArrayObject $post): void
265278
if (!empty($post['post_expired_trackback'])) {
266279
$post_expired['trackback'] = (string) $post['post_expired_trackback'];
267280
}
281+
if (!empty($post['post_expired_password'])) {
282+
$post_expired['password'] = (string) $post['post_expired_password'];
283+
}
284+
if (!empty($post['post_expired_newpassword'])) {
285+
$post_expired['newpassword'] = (string) $post['post_expired_newpassword'];
286+
}
268287

269288
dcCore::app()->meta->setPostMeta(
270289
$post_id,
@@ -303,20 +322,20 @@ private static function fieldsPostExpired(string $post_type, ?int $post_id = nul
303322
}
304323

305324
$fields['post_expired_date'] = (new Para())->items([
306-
(new Label(__('Date:')))->for('post_expired_date'),
325+
(new Label(__('Date:'), Label::OUTSIDE_LABEL_BEFORE))->for('post_expired_date'),
307326
(new Datetime('post_expired_date', Html::escapeHTML(self::dateToUser($post_expired['date'] ?? 'now'))))->class(empty($post_expired['date']) ? 'invalid' : ''),
308327
]);
309328

310329
$fields['post_expired_status'] = (new Para())->items([
311330
(new Text('strong', __('On this date, change:'))),
312331
(new Text('br')),
313-
(new Label(__('Status:')))->for('post_expired_status'),
332+
(new Label(__('Status:'), Label::OUTSIDE_LABEL_BEFORE))->for('post_expired_status'),
314333
(new Select('post_expired_status'))->default(empty($post_expired['status']) ? '' : $post_expired['status'])->items(self::statusCombo()),
315334
]);
316335

317336
if ($post_type == 'post') {
318337
$fields['post_expired_category'] = (new Para())->items([
319-
(new Label(__('Category:')))->for('post_expired_category'),
338+
(new Label(__('Category:'), Label::OUTSIDE_LABEL_BEFORE))->for('post_expired_category'),
320339
(new Select('post_expired_category'))->default(empty($post_expired['category']) ? '' : $post_expired['category'])->items(self::categoriesCombo(
321340
dcCore::app()->blog->getCategories(
322341
['post_type' => 'post']
@@ -325,21 +344,29 @@ private static function fieldsPostExpired(string $post_type, ?int $post_id = nul
325344
]);
326345

327346
$fields['post_expired_selected'] = (new Para())->items([
328-
(new Label(__('Selection:')))->for('post_expired_selected'),
347+
(new Label(__('Selection:'), Label::OUTSIDE_LABEL_BEFORE))->for('post_expired_selected'),
329348
(new Select('post_expired_selected'))->default(empty($post_expired['selected']) ? '' : $post_expired['selected'])->items(self::selectedCombo()),
330349
]);
331350
}
332351

333352
$fields['post_expired_comment'] = (new Para())->items([
334-
(new Label(__('Comments status:')))->for('post_expired_comment'),
353+
(new Label(__('Comments status:'), Label::OUTSIDE_LABEL_BEFORE))->for('post_expired_comment'),
335354
(new Select('post_expired_comment'))->default(empty($post_expired['comment']) ? '' : $post_expired['comment'])->items(self::commentCombo()),
336355
]);
337356

338357
$fields['post_expired_trackback'] = (new Para())->items([
339-
(new Label(__('Trackbacks status:')))->for('post_expired_trackback'),
358+
(new Label(__('Trackbacks status:'), Label::OUTSIDE_LABEL_BEFORE))->for('post_expired_trackback'),
340359
(new Select('post_expired_trackback'))->default(empty($post_expired['trackback']) ? '' : $post_expired['trackback'])->items(self::trackbackCombo()),
341360
]);
342361

362+
$fields['post_expired_password'] = (new Para())->items([
363+
(new Checkbox('post_expired_password', !empty($post_expired['password'])))->value(1),
364+
(new Label(__('Change password'), Label::OUTSIDE_LABEL_AFTER))->for('post_expired_password')->class('classic'),
365+
(new Label(__('New password:'), Label::OUTSIDE_LABEL_BEFORE))->for('post_expired_newpassword'),
366+
(new Input('post_expired_newpassword'))->size(65)->maxlenght(255)->class('maximal')->value(empty($post_expired['newpassword']) ? '' : $post_expired['newpassword']),
367+
(new Note())->text(__('Leave empty to remove it'))->class('form-note'),
368+
]);
369+
343370
if ($render) {
344371
foreach ($fields as $k => $v) {
345372
$fields[$k] = $v->render();

Diff for: src/FrontendBehaviors.php

+5
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ public static function publicBeforeDocument(): void
128128
case 'trackback':
129129
$post_cur->setField('post_open_tb', $v);
130130

131+
break;
132+
133+
case 'password':
134+
$post_cur->setField('post_password', empty($post_expired['newpassword']) ? '' : $post_expired['newpassword']);
135+
131136
break;
132137
}
133138
}

0 commit comments

Comments
 (0)