summaryrefslogtreecommitdiff
path: root/lib/account/list.php
blob: 56392c0a7e296a269369f39384230b9a98183367 (plain) (blame)
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
<?php

$filters = array (
	"order" => array (
			"name" => "username",
			"reg_date" => "date registered",
			"nbNotes" => "number of notes",
		),
	"cat" => array (
		"WHERE nc.count != 0 OR pc.count != 0" => "interesting",
		"" => "all",
	),
	"way" => $ord_ways,
);
$fdefaults = array (
	"order" => "name",
	"way" => "ASC",
	"cat" => "WHERE nc.count != 0 OR pc.count != 0",
);

$users = array();
$n = sql("SELECT account.id AS id, login AS name, nc.count AS nbNotes, pc.count AS nbPosts ".
	"FROM account ".
	"LEFT JOIN (SELECT notes.owner AS owner, COUNT(notes.id) AS count FROM notes ".
		"WHERE notes.public != 0 GROUP BY notes.owner) nc ON nc.owner = account.id ".
	"LEFT JOIN (SELECT blog_posts.owner AS owner, COUNT(blog_posts.id) AS count FROM blog_posts ".
		"GROUP BY blog_posts.owner) pc ON pc.owner = account.id ".
	get_filter("cat") .
	" ORDER BY " . get_filter("order") . " " . get_filter("way") . " ");
while ($nn = mysql_fetch_assoc($n)) $users[] = $nn;
require("tpl/account/list.php");