-
Notifications
You must be signed in to change notification settings - Fork 0
/
userslist.php
35 lines (30 loc) · 1.24 KB
/
userslist.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
require_once(__DIR__ . '/../../config.php');
// Ensure this script is accessed within Moodle.
defined('MOODLE_INTERNAL') || die();
// Require the user to be logged in.
require_login();
$PAGE->set_url(new moodle_url('/auth/faceauth/userslist.php'));
$PAGE->set_context(context_system::instance());
$PAGE->set_title(get_string('userslist', 'auth_faceauth'));
// Query to fetch users with enrolled face images.
$users = $DB->get_records_sql('SELECT u.id, u.username, u.firstname, u.lastname
FROM {user} u
JOIN {auth_faceauth_metadata} fm ON u.id = fm.userid');
// Prepare the data for the template.
$template_data = [
'users' => array_map(function($user) {
return [
'id' => $user->id,
'username' => $user->username,
'firstname' => $user->firstname,
'lastname' => $user->lastname,
'image_path' => '/path/to/user/images/' . $user->id . '.jpg', // Adjust the path as needed
'wwwroot' => $CFG->wwwroot
];
}, $users)
];
// Render the template.
echo $OUTPUT->header();
echo $OUTPUT->render_from_template('auth_faceauth/users_list', $template_data);
echo $OUTPUT->footer();