<?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_pol.inc.php";

if (!empty($_REQUEST['group_id'])) { // page under group section
    //ACS check
	if (!$group_acs->checkPermission($c_acs['arr_acs']['resource']['group_poll'], $c_acs['arr_acs']['privilege']['allow_access'])) { //resourece_id, Priv_id
		header("Location: g_group.php?group_id=" . $_REQUEST['group_id']."&".SID);
		exit;
	}
}




$poll->before_start_timestamp = mktime();
$poll->after_end_timestamp = mktime();

//get $poll
if (!empty($_REQUEST['group_id'])) { // page under group section
	unset($poll->user_id);
	$output_polls = $poll->selPolls();
}
elseif ($menu_section == "my") {
    $output_polls = $poll->selPolls();
}
else {
	$output_polls = $poll->selRspBlogs();
}



unset($poll->before_start_timestamp, $poll->after_end_timestamp);
$poll->before_end_timestamp = mktime();
$output_archive_polls = $poll->selPolls();

if (!empty($_REQUEST['group_id'])) { // page under group section
	//ACS check
	if ($group_acs->checkPermission($c_acs['arr_acs']['resource']['group_poll'], $c_acs['arr_acs']['privilege']['allow_edit'])) { //resourece_id, Priv_id
		unset($poll->before_end_timestamp);
		$poll->after_start_timestamp = mktime();
		$output_forthcoming_polls = $poll->selPolls();
	}
}

$display = "view_polls";


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

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

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

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

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

include "inc/footer.inc.php";

?>
