blob: 01cb956f68182e1013d4e2175a5251f56f5187c7 (
plain) (
tree)
|
|
<?php
$notes_tree = array();
$notes_parents = array();
$n = sql("SELECT id, parent, title FROM notes ".
"WHERE owner = ?" .
($note['owner'] == $user['id'] ? " " : " AND public != 0 ") .
"ORDER BY title ASC", $note['owner']);
while ($nn = $n->fetch()) {
$notes_parents[$nn['id']] = $nn['parent'];
if (isset($notes_tree[$nn['parent']])) {
$notes_tree[$nn['parent']][] = $nn;
} else {
$notes_tree[$nn['parent']] = array($nn);
}
}
$notest = array(0 => @$notes_tree[0]);
for($id = $note['id']; $id != 0; $id = $notes_parents[$id]) {
$notest[$id] = @$notes_tree[$id];
}
echo '</div><div class="contents-left">';
echo '<h1>' . $note['ownername'] . '</h1><br />';
echo '<div class="small_right"><a href="?p=user-notes-' . $note['owner'] . '">voir tout</a></div>';
function n_tree_branch($id) {
global $notest, $note, $can_new;
if (!isset($notest[$id])) return;
foreach($notest[$id] as $branch) {
if ($branch['id'] == $note['id'])
echo '<p>' . $branch['title'] . '</p>';
else
echo '<p><a href="?p=view-notes-' . $branch['id'] . '">' . $branch['title'] . '</a></p>';
if (isset($notest[$branch['id']])) {
echo '<div class="tree_branch">';
n_tree_branch($branch['id']);
echo '</div>';
} else if ($can_new && $branch['id'] == $note['id']) {
echo '<div class="tree_branch">';
if ($can_new) echo '<p><a class="tool_link" href="?p=new-notes-' . $branch['id'] . '">+ nouvelle note</a></p>';
echo '</div>';
}
}
if ($can_new) echo '<p><a class="tool_link" href="?p=new-notes-' . $id . '">+ nouvelle note</a></p>';
}
echo '<div class="tree_root">';
n_tree_branch(0);
echo '</div>';
|