aboutsummaryrefslogtreecommitdiffstats
path: root/theme/admin
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2021-09-19 14:27:03 +0200
committerThomas Lange <code@nerdmind.de>2021-09-19 14:58:04 +0200
commit8c9aff90b6e0a935188b20060dbdcbe9f7aeb28f (patch)
tree09944adc275f770eab3daa3fa789578f67d9323e /theme/admin
parent19a7e6d54de4286461c6ae74970dfdbe994a335c (diff)
downloadblog-8c9aff90b6e0a935188b20060dbdcbe9f7aeb28f.tar.gz
blog-8c9aff90b6e0a935188b20060dbdcbe9f7aeb28f.tar.xz
blog-8c9aff90b6e0a935188b20060dbdcbe9f7aeb28f.zip
Pre-select the current user in page/post form
Pre-select the user with the user ID of the current session in the forms for creating a page or a post. This fixes the problem that occurs if one have multiple users in the database, but the create forms were not using the *current* logged-in user as the default selected user. The forms for modifying a page or post are not affected because they use the ID from "$FORM['DATA']['USER']" for selecting the correct user. This key is undefined on the create forms, so we use "$_SESSION['USER_ID']" for selecting the default user for creating new pages and posts.
Diffstat (limited to 'theme/admin')
-rw-r--r--theme/admin/html/page/form.php3
-rw-r--r--theme/admin/html/post/form.php3
2 files changed, 4 insertions, 2 deletions
diff --git a/theme/admin/html/page/form.php b/theme/admin/html/page/form.php
index 97713e2..f4655da 100644
--- a/theme/admin/html/page/form.php
+++ b/theme/admin/html/page/form.php
@@ -32,8 +32,9 @@
<div class="form-grid-item">
<select id="form_user" name="user">
+ <?php $selected_user_id = $FORM['DATA']['USER'] ?? $_SESSION['USER_ID'] ?>
<?php foreach($FORM['USER_LIST'] as $user): ?>
- <option value="<?=$user['ID']?>"<?=($FORM['DATA']['USER'] == $user['ID']) ? ' selected' : '' ?>><?=escapeHTML($user['FULLNAME'])?> [<?=$user['USERNAME']?>]</option>
+ <option value="<?=$user['ID']?>"<?=($selected_user_id == $user['ID']) ? ' selected' : '' ?>><?=escapeHTML($user['FULLNAME'])?> [<?=$user['USERNAME']?>]</option>
<?php endforeach; ?>
</select>
</div>
diff --git a/theme/admin/html/post/form.php b/theme/admin/html/post/form.php
index e4df2ba..d2a22eb 100644
--- a/theme/admin/html/post/form.php
+++ b/theme/admin/html/post/form.php
@@ -57,8 +57,9 @@ function categorySelectList($category_tree, $selected = NULL, $prefix = '') {
<div class="form-grid-item">
<select id="form_user" name="user">
+ <?php $selected_user_id = $FORM['DATA']['USER'] ?? $_SESSION['USER_ID'] ?>
<?php foreach($FORM['USER_LIST'] as $user): ?>
- <option value="<?=$user['ID']?>"<?=($FORM['DATA']['USER'] == $user['ID']) ? ' selected' : '' ?>><?=escapeHTML($user['FULLNAME'])?> [<?=$user['USERNAME']?>]</option>
+ <option value="<?=$user['ID']?>"<?=($selected_user_id == $user['ID']) ? ' selected' : '' ?>><?=escapeHTML($user['FULLNAME'])?> [<?=$user['USERNAME']?>]</option>
<?php endforeach; ?>
</select>
</div>