login/list: option to order by seen date
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 7 Jul 2018 20:50:59 +0000 (22:50 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Sat, 7 Jul 2018 22:22:29 +0000 (00:22 +0200)
Feature parity with login/visits.

auth.inc.php
login/list.php

index fc30ccfa48db240fb1398507f6f66cede496ee1d..c8b6b319c74a347538456392a47cc093bdc143d7 100644 (file)
@@ -23,6 +23,11 @@ class User
        {
                return @file_exists("{$this->dir}/.admin");
        }
+
+       function seen()
+       {
+               return @filemtime("{$this->dir}/last.log");
+       }
 }
 
 function login_password_verify($input, $test)
index cae89f078dab62f64013ec89738428004e46629e..d3b1f177005ebc91be910f0af119e7dd9574690e 100644 (file)
@@ -8,6 +8,12 @@ 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);
+}
+
 print '<ul';
 if (@$Place['view'] == 'avatar') {
        print ' class="gallery cat"';