<?php
/**************************************************************************
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
@Authors: Ryan Thompson(hide@address.com)
***************************************************************************/
include("./data.php");
$service['add_header'] = TRUE;
include("../config.inc.php");
include($here. "/class.notebook.php");
$notes = new notebook;
echo $layout->page_header;
echo $layout->service_header($notes->msg('service_name'), $notes->nav_buttons());
echo $html->create_filter($user->user_id, 'nb', 'index', $_GET['category']);
$uid = $user->user_id;
if(isset($_POST['confirm_delete']))
{
$O->delete_items('nb', 'o_notebook', 'note_id', $_POST['delete_values'], $user->user_id);
}
if(isset($_POST['delete_notes']))
{
echo $html->delete_confirm($O->create_link('/notebook/index.php'), 'nb', $_POST['delete']);
} else {
if(isset($_GET['sort']))
{
//User wants to sort notes
$sort_order = " ORDER BY {$_GET['sort']}";
}
if(isset($_GET['category']) && $_GET['category'] != '*')
{
//If there is a category set the we have to filter out by category.
$sql = "SELECT * FROM o_notebook
LEFT JOIN o_categorize ON o_notebook.note_id=o_categorize.id WHERE o_categorize.service='nb'
AND o_notebook.user_id='{$user->user_id}' AND o_categorize.category='{$_GET['category']}'$sort_order";
$db->query($sql);
while($db->fetch_results())
{
$results[] = $db->record;
}
} else {
//This will display all notes that the user has the rights to see.
$results = $share->run_share_query('nb', $user->user_id, 'o_notebook', 'note_id', $sort_order);
}
if(count($results) == 0)
{
echo $html->message_box($text['no_notes']);
} else {
echo $html->create_list(
array("STYLE"=>"list_header",
"SUBJECT"=>$O->create_link("/notebook/index.php?sort=subject","Subject", "list_header"),
"DATE"=>$O->create_link("/notebook/index.php?sort=date", "Date", "list_header"),
"FORM_LINK"=>$_SERVER['PHP_SELF']),
"{$layout->service_theme}/header.html");
$i = 0;
foreach($results AS $note_data)
{
$class = $html->list_class($class);
unset($owner);
unset($shared);
unset($disabled);
if($note_data['user_id'] != $user->user_id)
{
$shared = '&s=TRUE';
$owner = "({$note_data['username']})";
$disabled = " disabled=\"disabled\"";
}
echo $html->create_list(
array("STYLE"=>$class,
"NOTE_ID"=>$note_data['note_id'],
"DISABLED"=>$disabled,
"SUBJECT"=> $O->create_link("/notebook/view_note.php?nid={$note_data['note_id']}$shared",
$note_data['title'],
$class),
"OWNER"=>"$owner",
"DATE"=>date($date->long_date, $note_data['posted'])),
"{$layout->service_theme}/list.html");
$i++;
}
echo $buffer = $html->create_list(
array("DELETE_NOTES"=>$notes->msg('delete_notes')),
"{$layout->service_theme}/footer.html");
}
}
echo $layout->create_footer();
?>