Umfragen
text.php
Go to the documentation of this file.
1 <?php
2 /*
3  * page.php
4  *
5  * Copyright 2012 Johannes <jojo@jojo-42>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20  * MA 02110-1301, USA.
21  *
22  *
23  */
24 
25 // SESSION
26 require_once("inc/user.class.php");
27 if( !(isset($_SESSION)) ){
28  session_start();
29 }
30 
31 require_once("config.php");
32 require_once("inc/tools.php");
33 require_once("inc/db.class.php");
34 require_once("inc/poll.class.php");
35 require_once("inc/html.class.php");
36 require_once("inc/messages.class.php");
37 require_once("inc/chart.class.php");
38 
39 $db= new db( DB_USER, DB_PASS, DB_DATABASE, DB_HOST );
40 
41 if( (isset($_GET["pollID"])) AND ($_GET["pollID"] != "") AND (is_numeric($_GET["pollID"])) ){
42  $poll = new poll();
43  if (!$poll->load_from_id($db, intval($_GET["pollID"]) ) ){
44  die("Umfrage existiert nicht.");
45  }
46 }
47 if( !isset($poll) ){
48  die("Umfrage laden fehlgeschlagen");
49 }else{
50  if( (isset($_GET["widget"])) AND ($_GET["widget"] != "") AND (is_numeric($_GET["widget"])) ){
51  foreach($poll->widget_list as $wid){
52  if($wid instanceof container){
53  foreach( $wid->get_all_childs() as $child){
54  if( $child->ID == $_GET["widget"] ){
55  $option = $child;
56  break 2;
57  }
58  }
59  }else{
60  continue;
61  } // end if container
62  } // end foreach poll widget
63  } // end if widget
64 } // end if poll
65 if( !isset($option) ){
66  die("widget existiert nicht");
67 }
68 
69 if( $poll->anonymous === false ){
70  require_once("inc/check_login.php");
71  check_login();
72 
73  $granted = false;
74  if ( in_array("*", $poll->groups) ){
75  $granted = true;
76  }else{
77  if( in_array($_SESSION["user"]->group,$poll->groups) ){
78  $granted = true;
79  }
80  // go through each group ID and check if one of the given groups is matching
81  $projects = array();
82  if( isset($_SESSION["projects"]) ){
83  foreach( $_SESSION["projects"] as $pr ){
84  $projects[] = $pr[1]; // get groupID
85  }
86  }
87  foreach($poll->groups as $poll_group){
88  if( in_array($poll_group,$projects) ){
89  $granted = true;
90  }
91  }
92  }
93  // owners have the expicit right to use their polls
94  if( intval($_SESSION["user"]->ID) === intval($poll->owner) ){
95  $granted = true;
96  }
97 
98 
99  if( $granted === false ){
100  die( "Das ansehen dieses Textes ist nicht erlaubt" );
101  }
102 
103 }
104 
105 $messages = new messageHandler();
106 
107 
108 
109 // BEGIN HTML
110 HTML::doctype();
111 
112 HTML::head();
113 
114 HTML::menu();
115 
116 
117 if( $option instanceof label ){
118  $option->display();
119 }
120 
121 
122 HTML::foot();
123 
124 ?>
125