blob: a2982be41ea94fb150ab93ba44ab55c02c7ebb3d (
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
32
33
|
<?php
assert_redir(count($args) == 3, 'notes');
$userid = intval($args[2]);
if ($userid == $user['id']) {
$note_owner = $user;
} else {
$note_owner = sql("SELECT login AS name, id FROM account WHERE id = $userid")->fetch();
assert_error($note_owner, "That user id does not exist.", "no such user");
}
$users = array();
$n = sql("SELECT account.id AS id, login AS name, COUNT(notes.id) AS nbNotes FROM account ".
"LEFT JOIN notes ON notes.owner = account.id ".
"WHERE notes.public != 0 AND notes.id != 0 ".
"GROUP BY account.id ORDER BY nbNotes DESC");
while ($nn =$n->fetch()) $users[] = $nn;
$notes_tree = array();
$n = sql("SELECT id, parent, title FROM notes ".
"WHERE owner = ? ".
($userid == $user['id'] ? "" : "AND public != 0 ").
"ORDER BY title ASC", $userid);
while ($nn = $n->fetch()) {
if (isset($notes_tree[$nn['parent']])) {
$notes_tree[$nn['parent']][] = $nn;
} else {
$notes_tree[$nn['parent']] = array($nn);
}
}
require("tpl/notes/user.php");
|