1<?php
2  /**************************************************************************\
3  * phpGroupWare - Polls                                                     *
4  * http://www.phpgroupware.org                                              *
5  * --------------------------------------------                             *
6  *  This program is free software; you can redistribute it and/or modify it *
7  *  under the terms of the GNU General Public License as published by the   *
8  *  Free Software Foundation; either version 2 of the License, or (at your  *
9  *  option) any later version.                                              *
10  \**************************************************************************/
11
12  /* $Id: admin.php 14330 2004-01-29 05:39:04Z skwashd $ */
13
14	$GLOBALS['phpgw_info'] = Array();
15	$GLOBALS['phpgw_info']['flags'] = array(
16		'admin_only'              => True,
17		'currentapp'              => 'polls',
18		'enable_nextmatchs_class' => True,
19		'admin_header'            => True
20	);
21	include('../header.inc.php');
22
23	$show  = $HTTP_GET_VARS['show'];
24	$order = $HTTP_GET_VARS['order'];
25	$sort  = $HTTP_GET_VARS['sort'];
26
27	if(!$show)
28	{
29		$GLOBALS['phpgw']->common->phpgw_exit(True);
30	}
31
32	if($order)
33	{
34		$ordermethod = " order by $order $sort";
35	}
36
37	if($show == 'questions')
38	{
39		$GLOBALS['phpgw']->template->set_file(array('admin' => 'admin_list_questions.tpl'));
40	}
41	else
42	{
43		$GLOBALS['phpgw']->template->set_file(array('admin' => 'admin_list_answers.tpl'));
44	}
45	$GLOBALS['phpgw']->template->set_block('admin','form','form');
46	$GLOBALS['phpgw']->template->set_block('admin','row','row');
47
48	$GLOBALS['phpgw']->template->set_unknowns('remove');
49
50	$GLOBALS['phpgw']->template->set_var('th_bg',$GLOBALS['phpgw_info']['theme']['th_bg']);
51	$GLOBALS['phpgw']->template->set_var('sort_title',$GLOBALS['phpgw']->nextmatchs->show_sort_order($sort,'poll_title',$order,'admin.php',lang('Title'),'&show=' . $show));
52	if($show == 'answers')
53	{
54		$GLOBALS['phpgw']->template->set_var('sort_answer',$GLOBALS['phpgw']->nextmatchs->show_sort_order($sort,'option_text',$order,'admin.php',lang('Answer'),'&show=' . $show));
55	}
56
57	$GLOBALS['phpgw']->template->set_var('lang_edit',lang('edit'));
58	$GLOBALS['phpgw']->template->set_var('lang_delete',lang('delete'));
59	if($show == 'questions')
60	{
61		$GLOBALS['phpgw']->template->set_var('lang_view',lang('view'));
62	}
63
64	if($show == 'questions')
65	{
66		$GLOBALS['phpgw']->db->query("select * from phpgw_polls_desc $ordermethod",__LINE__,__FILE__);
67	}
68	else
69	{
70		$GLOBALS['phpgw']->db->query("select phpgw_polls_data.*, phpgw_polls_desc.poll_title from phpgw_polls_data,"
71			. "phpgw_polls_desc where phpgw_polls_desc.poll_id = phpgw_polls_data.poll_id $ordermethod",__LINE__,__FILE__);
72	}
73	$GLOBALS['phpgw']->template->set_var('rows','');
74	while ($GLOBALS['phpgw']->db->next_record())
75	{
76		$tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
77		$GLOBALS['phpgw']->template->set_var('tr_color',$tr_color);
78
79		if($show == 'questions')
80		{
81			$GLOBALS['phpgw']->template->set_var('row_title',stripslashes($GLOBALS['phpgw']->db->f('poll_title')));
82			$GLOBALS['phpgw']->template->set_var('row_edit','<a href="' . $GLOBALS['phpgw']->link('/polls/admin_editquestion.php','poll_id=' . $GLOBALS['phpgw']->db->f('poll_id')) . '">' . lang('Edit') . '</a>');
83			$GLOBALS['phpgw']->template->set_var('row_delete','<a href="' . $GLOBALS['phpgw']->link('/polls/admin_deletequestion.php','poll_id=' . $GLOBALS['phpgw']->db->f('poll_id')) . '">' . lang('Delete') . '</a>');
84			$GLOBALS['phpgw']->template->set_var('row_view','<a href="' . $GLOBALS['phpgw']->link('/polls/admin_viewquestion.php','poll_id=' . $GLOBALS['phpgw']->db->f('poll_id')) . '">' . lang('View') . '</a>');
85		}
86		else
87		{
88			$GLOBALS['phpgw']->template->set_var('row_answer',stripslashes($GLOBALS['phpgw']->db->f('option_text')));
89			$GLOBALS['phpgw']->template->set_var('row_title',stripslashes($GLOBALS['phpgw']->db->f('poll_title')));
90			$GLOBALS['phpgw']->template->set_var('row_edit','<a href="' . $GLOBALS['phpgw']->link('/polls/admin_editanswer.php',
91																		array ('vote_id' => $GLOBALS['phpgw']->db->f('vote_id'),
92																			  'poll_id' => $GLOBALS['phpgw']->db->f('poll_id')
93																			  ) ) .'">' . lang('Edit') . '</a>');
94			$GLOBALS['phpgw']->template->set_var('row_delete','<a href="' . $GLOBALS['phpgw']->link('/polls/admin_deleteanswer.php',
95																		array ('vote_id' => $GLOBALS['phpgw']->db->f('vote_id'),
96																			  'poll_id' => $GLOBALS['phpgw']->db->f('poll_id')
97																			  ) ) .'">' . lang('Delete') . '</a>');
98
99		}
100		$GLOBALS['phpgw']->template->parse('rows','row',True);
101	}
102
103	$GLOBALS['phpgw']->template->set_var('add_action',$GLOBALS['phpgw']->link('/polls/admin_add' . substr($show,0,(strlen($show)-1)) . '.php'));
104	$GLOBALS['phpgw']->template->set_var('lang_add',lang('add'));
105
106	$GLOBALS['phpgw']->template->pparse('out','form');
107
108	$GLOBALS['phpgw']->common->phpgw_footer();
109?>
110