Admin: Fix query in users to URL assignation

pull/5671/head
Yannick Warnier 4 months ago
parent 214c817c35
commit da295a514c
  1. 6
      public/main/admin/access_url_add_users_to_url.php

@ -80,9 +80,9 @@ $first_letter_user_lower = Database::escape_string(api_strtolower($first_letter_
$target_name = api_sort_by_first_name() ? 'firstname' : 'lastname'; $target_name = api_sort_by_first_name() ? 'firstname' : 'lastname';
$target_name = 'lastname'; $target_name = 'lastname';
$sql = "SELECT user_id,lastname,firstname,username FROM $tbl_user $sql = "SELECT id, lastname, firstname, username FROM $tbl_user
WHERE active <> ".USER_SOFT_DELETED." AND ".$target_name." LIKE '".$first_letter_user_lower."%' OR ".$target_name." LIKE '".$first_letter_user_lower."%' WHERE active <> ".USER_SOFT_DELETED." AND ".$target_name." LIKE '".$first_letter_user_lower."%' OR ".$target_name." LIKE '".$first_letter_user_lower."%'
ORDER BY ".(count($users) > 0 ? '(user_id IN('.implode(',', $users).')) DESC,' : '').' '.$target_name; ORDER BY ".(count($users) > 0 ? '(id IN('.implode(',', $users).')) DESC,' : '').' '.$target_name;
$result = Database::query($sql); $result = Database::query($sql);
$db_users = Database::store_result($result); $db_users = Database::store_result($result);
unset($result); unset($result);
@ -119,7 +119,7 @@ unset($result);
<?php <?php
foreach ($db_users as $user) { foreach ($db_users as $user) {
?> ?>
<option value="<?php echo $user['user_id']; ?>" <?php if (in_array($user['user_id'], $users)) { <option value="<?php echo $user['id']; ?>" <?php if (in_array($user['id'], $users)) {
echo 'selected="selected"'; echo 'selected="selected"';
} ?>> } ?>>
<?php echo api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')'; ?> <?php echo api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')'; ?>

Loading…
Cancel
Save