From 6f7977b1751e50e24f1302ef8630a7726182fe53 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Thu, 2 Aug 2018 05:41:25 +0200 Subject: [PATCH] login/members: order by full name Login may not match in which case visible results appear random. Support sort by any ?order column, assuming anything besides seen date is alphanumeric. --- auth.inc.php | 8 ++++++-- login/list.php | 18 +++++++++++++----- login/members/index.html | 2 +- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/auth.inc.php b/auth.inc.php index 772e256..631bf8b 100644 --- a/auth.inc.php +++ b/auth.inc.php @@ -14,10 +14,14 @@ class User return $this->$col = $this->$col(); # run method and cache } + function rawname() + { + return @file_get_contents("{$this->dir}/name.txt"); + } + function name() { - $name = @file_get_contents("{$this->dir}/name.txt"); - return htmlspecialchars(implode(' & ', explode("\n", $name))); + return htmlspecialchars(implode(' & ', explode("\n", $this->rawname))); } function admin() diff --git a/login/list.php b/login/list.php index 0d9eec2..7872bd6 100644 --- a/login/list.php +++ b/login/list.php @@ -8,11 +8,19 @@ foreach ($users as $col => $userdir) { $users[$col] = new User($userdir); } -if (@$Place['order'] == 'seen') { - $order = array_map(function ($col) { return $col->seen; }, $users); -# $order = array_column($users, 'seen'); #TODO php7 simplification - array_multisort($order, SORT_DESC, SORT_NUMERIC, $users); - $users = array_intersect_key($users, array_filter($order)); +if (isset($Place['order'])) { + $ordercol = $Place['order']; + $order = array_map(function ($row) use ($ordercol) { + return $row->$ordercol; + }, $users); +# $order = array_column($users, $ordercol); #TODO php7 simplification + if ($ordercol == 'seen') { + array_multisort($order, SORT_DESC, SORT_NUMERIC, $users); + $users = array_intersect_key($users, array_filter($order)); + } + else { + array_multisort($order, SORT_ASC, SORT_NATURAL, $users); + } } if (isset($Place['n'])) { diff --git a/login/members/index.html b/login/members/index.html index 149c62f..8ad05da 100644 --- a/login/members/index.html +++ b/login/members/index.html @@ -1,7 +1,7 @@

Ledenlijst

-[[login/list view=visit]] +[[login/list view=visit order=name]]