<?php

// -----------------------------------------------------------------------
// This file is part of aroundme
// 
// Copyright (C) 2003, 2005 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., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
// -----------------------------------------------------------------------

include "inc/header_group.inc.php";


//append language setup
require_once($languageArrayPath . 'arr_category.lang.php');
require_once($languageArrayPath . 'arr_language_name.lang.php');


$file->noimage = $c_node['file']['image']['thumb'][1]['noimage'];
$file->thumb = $c_node['file']['image']['thumb'][1]['name'];


//setup Wiki
require_once($c_node['dir']['class_path'] . 'Wiki/Wiki.php');
$wiki =& new Text_Wiki();
$wiki->disableRule('freelink');
$wiki->disableRule('wikilink');
$wiki->setRenderConf('xhtml', 'image', 'base', $c_node['dir']['asset_path'] . 'group/');

$output_group['group_home_synopsis'] = $wiki->transform($output_group['group_home_synopsis'], 'Xhtml');
	


//get group image
if (!empty($output_group['file_id'])) {
	$file->file_id = $output_group['file_id'];
	$output_group['image'] = $file->getFileRecord();
}
else {
	$output_group['image']['file_title'] = "";
	$output_group['image']['file'] = $file->noimage;
}


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


//setup statistics
require_once($c_node['dir']['class_path'] . 'Statistic.class.php');
$statistic = new Statistic($db, null, $date);
$statistic->group_id = $group_id;
$output_statistic = $statistic->getStatistics();


//get subjects  -----------------------------------------------------
require_once($c_node['dir']['class_path'] . 'Forum.class.php');
$forum = new Forum($db, $c_node['rsp']['item_type']['forum'], $date, $file);
$forum->rsp_level_id = $c_node['rsp']['rsp_level']['group']['home'];
$forum->rsp_status_id = $c_node['rsp']['status']['live'];
$forum->group_id = $group_id;
$forum->limit = 10;
$output_subjects = $forum->selSubjects();


//get blogs -----------------------------------------------------
require_once($c_node['dir']['class_path'] . 'Blog.class.php');
$blog = new Blog($db, $c_node['rsp']['item_type']['blog'], $date, $file);
$blog->rsp_level_id = $c_node['rsp']['rsp_level']['group']['home'];
$blog->rsp_status_id = $c_node['rsp']['status']['live'];
$blog->group_id = $group_id;
$blog->limit = 10;
$output_blogs = $blog->selBlogs();


//get group poll ids -----------------------------------------------------
require_once($c_node['dir']['class_path'] . 'Poll.class.php');
$poll = new Poll($db, $c_node['rsp']['item_type']['poll'], $date);
$poll->order_by = "poll_start_datetime desc";
$poll->rsp_level_id = $c_node['rsp']['rsp_level']['group']['home'];
$poll->rsp_status_id = $c_node['rsp']['status']['live'];
$poll->group_id = $group_id;
$poll->limit = 10;
$output_polls = $poll->selPolls();


//get library items -----------------------------------------------------
require_once($c_node['dir']['class_path'] . 'Library.class.php');
$library = new Library($db, $c_node['rsp']['item_type']['library'], $date, $file);
$library->rsp_level_id = $c_node['rsp']['rsp_level']['group']['home'];
$library->rsp_status_id = $c_node['rsp']['status']['live'];
$library->group_id = $group_id;
$library->limit = 10;
$output_library = $library->selLibraryItems();


//schedule setup ----------------------------------------------------------------
require_once($c_node['dir']['class_path'] . 'Schedule.class.php');
$schedule = new Schedule($db, $c_node['rsp']['item_type']['schedule'], $date, $file);
$schedule->rsp_level_id = $c_node['rsp']['rsp_level']['group']['home'];
$schedule->rsp_status_id = $c_node['rsp']['status']['live'];
$schedule->group_id = $group_id;
$schedule->limit = 10;
$schedule->schedule_type_id = $c_node['schedule']['type']['event'];
$output_activities = $schedule->selScheduleItems();
$schedule->schedule_type_id = $c_node['schedule']['type']['task'];
$output_tasks = $schedule->selScheduleItems();


//get the user details for the rss feed link
$user->user_id = $me['user_id'];
$output_user = $user->getUser();


// SETUP TAGS
require_once($c_node['dir']['class_path'] . 'Tag.class.php');
$tag = new Tag($db, $c_node['rsp']['item_type']['group']);
$tag->user_id = $me['user_id'];
$tag->group_id = $group_id;

if (isset($_POST['update_tag'])) {
	$tag->deleteTags($frmdata);
	$tag->insertTags($frmdata);
}

//get tags
unset($tag->group_id);
$tag->item_id = $group_id;
$output_my_tags = $tag->selTags();
unset($tag->user_id);
$output_network_tags = $tag->selTags('network');
$tag->group_id = $group_id;
$output_group_tags = $tag->selTags();


//move to template
if (!empty($output_group)) {
	$body->set('group', $output_group);
}

if (!empty($output_subjects)) {
	$body->set('subjects', $output_subjects);
}

if (!empty($output_library)) {
	$body->set('library', $output_library);
}

if (!empty($output_activities)) {
	$body->set('activities', $output_activities);
}

if (!empty($output_my_tags)) {
	$body->set('my_tags', $output_my_tags);
}

if (!empty($output_group_tags)) {
	$body->set('group_tags', $output_group_tags);
}

if (!empty($output_network_tags)) {
	$body->set('network_tags', $output_network_tags);
}

if (!empty($output_tasks)) {
	$body->set('tasks', $output_tasks);
}

if (!empty($output_statistic)) {
	$body->set('group_statistic', $output_statistic);
}

if (!empty($output_blogs)) {
	$body->set('blogs', $output_blogs);
}

if (!empty($output_polls)) {
	$body->set('polls', $output_polls);
}

if (!empty($output_user)) {
	$body->set('user', $output_user);
}

if (!empty($output_group['group_title'])) {
	$template_pageLink = $lang['txt_group'];
	$template_pageLinkNote = $output_group['group_title'];
}

include "inc/footer.inc.php";

?>
