<?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.
// -----------------------------------------------------------------------

include "inc/header_group.inc.php";

// SETUP LANGUAGE --------------------------------------------------------
require_once($languagePath . 'common.lang.php');
require_once($languagePath . 'grp_common.lang.php');
require_once($languageArrayPath . 'arr_group.lang.php');


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


if (isset($me['user_id'])) {
	$output_my_groups = $group->getMyGroups();
}

$group->group_visibility = 1;


if (!empty($_REQUEST['grp_tag'])) {
	$group->level_id = $c_node['tag']['level']['recommended'];
	$group->item_types = $c_node['rsp']['item_type'];
	$output_groups = $group->getGroups(null, $_REQUEST['grp_tag']);
	$_REQUEST['tag'] = $_REQUEST['grp_tag'];
}
elseif (!empty($_REQUEST['tag'])) {
	$group->item_types = $c_node['rsp']['item_type'];
	$output_groups = $group->getGroups(null, $_REQUEST['tag']);
}
else {
	$group->level_id = $c_node['tag']['level']['recommended'];
	$group->limit = $c_node['display']['max_list_rows'];
	$output_groups = $group->getGroups();
}

//setup statistics
require_once('class/Statistic.class.php');
$statistic = new Statistic($db);
//$output_group_statistics = $statistic->getGroupStatistics();


// get group meta tags
require_once('class/Tag.class.php');
$tag = new Tag($db, $c_node['rsp']['item_type']['group']);
$tag->level_id = $c_node['tag']['level']['recommended'];
$output_group_tags = $tag->selTags();
unset ($tag->level_id);

if (isset($me['user_id'])) {
	$tag->user_id = $me['user_id'];
	$output_my_tags = $tag->selTags();
}

//move to template
if (!empty($_REQUEST['tag'])) {
	$body->set('tag', $_REQUEST['tag']);
}

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

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

if (!empty($output_groups)) {
	$body->set('groups', $output_groups);
}

if (!empty($output_my_groups)) {
	$body->set('my_groups', $output_my_groups);
}

if (!empty($output_group_statistics)) {
	$body->set('group_statistics', $output_group_statistics);
}

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

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

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


include "inc/footer.inc.php";

?>
