]> git.mxchange.org Git - friendica.git/commitdiff
Improved queries for the nodeinfo functionality and the admin page
authorMichael Vogel <ike@pirati.ca>
Tue, 4 Oct 2016 03:51:13 +0000 (03:51 +0000)
committerMichael Vogel <ike@pirati.ca>
Tue, 4 Oct 2016 03:51:13 +0000 (03:51 +0000)
mod/admin.php
mod/nodeinfo.php

index 4dc6064a7d9eb8576cef9290f1523a201dfafeb3..2856c164018cc16d7ad76ed75edaf5e5684e2410 100644 (file)
@@ -1277,14 +1277,14 @@ function admin_page_users(&$a){
 
        /* ordering */
        $valid_orders = array(
-               'contact.name', 
+               'contact.name',
                'user.email',
                'user.register_date',
                'user.login_date',
-               'lastitem.lastitem_date',
+               'lastitem_date',
                'user.page-flags'
        );
-       
+
        $order = "contact.name";
        $order_direction = "+";
        if (x($_GET,'o')){
@@ -1293,19 +1293,18 @@ function admin_page_users(&$a){
                        $order_direction = "-";
                        $new_order = substr($new_order,1);
                }
-               
+
                if (in_array($new_order, $valid_orders)){
                        $order = $new_order;
                }
                if (x($_GET,'d')){
                        $new_direction = $_GET['d'];
-                       
                }
        }
        $sql_order = "`".str_replace('.','`.`',$order)."`";
        $sql_order_direction = ($order_direction==="+")?"ASC":"DESC";
-       
-       $users = q("SELECT `user`.* , `contact`.`name` , `contact`.`url` , `contact`.`micro`, `lastitem`.`lastitem_date`, `user`.`account_expired`
+
+/*     $users = q("SELECT `user`.* , `contact`.`name` , `contact`.`url` , `contact`.`micro`, `lastitem`.`lastitem_date`, `user`.`account_expired`
                                FROM
                                        (SELECT MAX(`item`.`changed`) as `lastitem_date`, `item`.`uid`
                                        FROM `item`
@@ -1322,9 +1321,19 @@ function admin_page_users(&$a){
                                intval($a->pager['start']),
                                intval($a->pager['itemspage'])
                                );
-    
+*/
+       $users = q("SELECT `user`.*, `contact`.`name`, `contact`.`url`, `contact`.`micro`, `user`.`account_expired`,
+                               (SELECT `changed` FROM `item` WHERE `wall` AND `uid` = `user`.`uid` ORDER BY `changed` DESC LIMIT 1) AS `lastitem_date`
+                               FROM `user`
+                               INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
+                               WHERE `user`.`verified`
+                               ORDER BY $sql_order $sql_order_direction LIMIT %d, %d",
+                               intval($a->pager['start']),
+                               intval($a->pager['itemspage'])
+                               );
+
        //echo "<pre>$users"; killme();
-                               
+
        $adminlist = explode(",", str_replace(" ", "", $a->config['admin_email']));
        $_setup_users = function ($e) use ($adminlist){
                $accounts = array(
index ba310a10514151c6cac11a507709164a6b4046c6..fae2b10522af3f13a97e24c4a1fb728abf2c6b69 100644 (file)
@@ -184,7 +184,7 @@ function nodeinfo_cron() {
                }
        }
         logger("cron_start");
-
+/*
        $users = q("SELECT profile.*, `user`.`login_date`, `lastitem`.`lastitem_date`
                        FROM (SELECT MAX(`item`.`changed`) as `lastitem_date`, `item`.`uid`
                                FROM `item`
@@ -198,7 +198,14 @@ function nodeinfo_cron() {
                                        AND NOT `user`.`blocked`
                                        AND NOT `user`.`account_removed`
                                        AND NOT `user`.`account_expired`");
-
+*/
+       $users = q("SELECT `user`.`uid`, `user`.`login_date`,
+                       (SELECT `changed` FROM `item` WHERE `wall` AND `uid` = `user`.`uid` ORDER BY `changed` DESC LIMIT 1) AS `lastitem_date`
+                       FROM `user`
+                       INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid` AND `profile`.`is-default`
+                       WHERE (`profile`.`publish` OR `profile`.`net-publish`) AND `user`.`verified`
+                               AND NOT `user`.`blocked` AND NOT `user`.`account_removed`
+                               AND NOT `user`.`account_expired`");
        if (is_array($users)) {
                        $total_users = count($users);
                        $active_users_halfyear = 0;