<?php

// -----------------------------------------------------------------------
// This file is part of AROUNDMe
//
// Copyright (C) 2003 - 2006 Barnraiser
// http://www.barnraiser.org/
// info@barnraiser.org
//
// 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, or (at your option) any
// later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with program; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
// 02110-1301, USA.
// -----------------------------------------------------------------------
$menu_section = "my";
include "inc/header.inc.php";

if (!isset($me['user_id']) || $me['user_id'] < 1) {
	header("Location: index.php?" . strip_tags(SID));
	exit;
}

//setup bookmark items
require_once('class/Bookmark.class.php');
$bookmark = new Bookmark($db, null, $me['user_id']);


//get watched bookmark ids
$bookmark->bookmark_type = $c_node['bookmark']['type']['watch'];
$bookmark->rsp_item_type_id = $c_node['rsp']['item_type']['blog'];
if (isset($_POST['watch_blog_delete_id']) && $_POST['watch_blog_delete_id'] > 0) {
	$bookmark->deleteBookmark($_POST['watch_blog_delete_id']);
}
$watched_blog_ids = $bookmark->getBookmarks();


$bookmark->rsp_item_type_id = $c_node['rsp']['item_type']['schedule'];
if (isset($_POST['watch_schedule_delete_id']) && $_POST['watch_schedule_delete_id'] > 0) {
	$bookmark->deleteBookmark($_POST['watch_schedule_delete_id']);
}
$watched_schedule_ids = $bookmark->getBookmarks();


$bookmark->rsp_item_type_id = $c_node['rsp']['item_type']['library'];
if (isset($_POST['watch_library_delete_name']) && $_POST['watch_library_delete_name'] > 0) {
	$bookmark->deleteBookmark($_POST['watch_library_delete_name']);
}
$watched_library_ids = $bookmark->getBookmarks();


$bookmark->rsp_item_type_id = $c_node['rsp']['item_type']['forum'];
if (isset($_POST['watch_subject_delete_id']) && $_POST['watch_subject_delete_id'] > 0) {
	$bookmark->deleteBookmark($_POST['watch_subject_delete_id']);
}
$watched_subject_ids = $bookmark->getBookmarks();


$bookmark->rsp_item_type_id = $c_node['rsp']['item_type']['poll'];
if (isset($_POST['watch_poll_delete_id']) && $_POST['watch_poll_delete_id'] > 0) {
	$bookmark->deleteBookmark($_POST['watch_poll_delete_id']);
}
$watched_poll_ids = $bookmark->getBookmarks();


//get recommended item ids
$bookmark->bookmark_type = $c_node['bookmark']['type']['recommend'];
$bookmark->rsp_item_type_id = $c_node['rsp']['item_type']['blog'];
if (isset($_POST['rec_blog_delete_id']) && $_POST['rec_blog_delete_id'] > 0) {
	$bookmark->deleteBookmark($_POST['rec_blog_delete_id']);
}
$recommended_blog_ids = $bookmark->getBookmarks();


$bookmark->rsp_item_type_id = $c_node['rsp']['item_type']['schedule'];
if (isset($_POST['rec_schedule_delete_id']) && $_POST['rec_schedule_delete_id'] > 0) {
	$bookmark->deleteBookmark($_POST['rec_schedule_delete_id']);
}
$recommended_schedule_ids = $bookmark->getBookmarks();


$bookmark->rsp_item_type_id = $c_node['rsp']['item_type']['library'];
if (isset($_POST['rec_library_delete_id']) && $_POST['rec_library_delete_id'] > 0) {
	$bookmark->deleteBookmark($_POST['rec_library_delete_id']);
}
$recommended_library_ids = $bookmark->getBookmarks();


$bookmark->rsp_item_type_id = $c_node['rsp']['item_type']['forum'];
if (isset($_POST['rec_subject_delete_id']) && $_POST['rec_subject_delete_id'] > 0) {
	$bookmark->deleteBookmark($_POST['rec_subject_delete_id']);
}
$recommended_subject_ids = $bookmark->getBookmarks();


$bookmark->rsp_item_type_id = $c_node['rsp']['item_type']['poll'];
if (isset($_POST['rec_poll_delete_id']) && $_POST['rec_poll_delete_id'] > 0) {
	$bookmark->deleteBookmark($_POST['rec_poll_delete_id']);
}
$recommended_poll_ids = $bookmark->getBookmarks();

//setup file
$file->noimage = $c_node['file']['image']['thumb'][3]['noimage'];
$file->thumb = $c_node['file']['image']['thumb'][3]['name'];


//setup forum
require_once('class/Forum.class.php');
$forum = new Forum($db, null, $file);
$forum->include_hidden = 1;


//setup blog
require_once('class/Blog.class.php');
$blog = new Blog($db, null, $file);
$blog->user_id = $me['user_id'];


//library setup
require_once('class/Library.class.php');
$library = new Library($db, null, $file);
$library->user_id = $me['user_id'];


//schedule setup
require_once('class/Schedule.class.php');
$schedule = new Schedule($db, null, $date, $file);
$schedule->user_id = $me['user_id'];
$schedule->schedule_config = $c_node['schedule'];


// poll setup
require_once('class/Poll.class.php');
$poll = new Poll($db, null);
$poll->user_id = $me['user_id'];



//get watched blogs
if (!empty($watched_blog_ids)) {
	$blog->blog_ids = $watched_blog_ids;
	$output_watched_blogs = $blog->selBlogs();
}
//get watched subjects
if (!empty($watched_subject_ids)) {
	$forum->subject_ids = $watched_subject_ids;
	$output_watched_subjects = $forum->selSubjects();
}
//get watched group library items
if (!empty($watched_library_ids)) {
	$library->library_ids = $watched_library_ids;
	$output_watched_library_items = $library->selLibraryItems();
}
//get watched events
if (!empty($watched_schedule_ids)) {
	$schedule->schedule_ids = $watched_schedule_ids;
	$output_watched_schedule_items = $schedule->selScheduleItems();
}
//get watched polls
if (!empty($watched_poll_ids)) {
	$poll->poll_ids = $watched_poll_ids;
	$output_watched_polls = $poll->selPolls();
}

//get recommended user blogs
if (!empty($recommended_blog_ids)) {
	$blog->blog_ids = $recommended_blog_ids;
	$output_recommended_blogs = $blog->selBlogs();
}
//get recommended subjects
if (!empty($recommended_subject_ids)) {
	$forum->subject_ids = $recommended_subject_ids;
	$output_recommended_subjects = $forum->selSubjects();
}
//get recommended group library items
if (!empty($recommended_library_ids)) {
	$library->library_ids = $recommended_library_ids;
	$output_recommended_library_items = $library->selLibraryItems();
}
//get recommended events
if (!empty($recommended_schedule_ids)) {
	$schedule->schedule_ids = $recommended_schedule_ids;
	$output_recommended_schedule_items = $schedule->selScheduleItems();
}
//get recommended polls
if (!empty($recommended_poll_ids)) {
	$poll->poll_ids = $recommended_poll_ids;
	$output_recommended_polls = $poll->selPolls();
}

//move to template
if (isset($output_user)) {
	$body->set('user', $output_user);
}

if (isset($output_watched_subjects)) {
	$body->set('watched_subjects', $output_watched_subjects);
}

if (isset($output_watched_library_items)) {
	$body->set('watched_library', $output_watched_library_items);
}

if (isset($output_watched_blogs)) {
	$body->set('watched_blogs', $output_watched_blogs);
}

if (isset($output_watched_schedule_items)) {
	$body->set('watched_schedule_items', $output_watched_schedule_items);
}

if (isset($output_watched_polls)) {
	$body->set('watched_polls', $output_watched_polls);
}

if (isset($output_recommended_subjects)) {
	$body->set('recommended_subjects', $output_recommended_subjects);
}

if (isset($output_recommended_library_items)) {
	$body->set('recommended_library', $output_recommended_library_items);
}

if (isset($output_recommended_schedule_items)) {
	$body->set('recommended_schedule_items', $output_recommended_schedule_items);
}

if (isset($output_recommended_blogs)) {
	$body->set('recommended_blogs', $output_recommended_blogs);
}

if (isset($output_recommended_polls)) {
	$body->set('recommended_polls', $output_recommended_polls);
}

$template_pageLink = $lang['href_watching'];
include "inc/footer.inc.php";

?>
