Umfragen
edit.php
Go to the documentation of this file.
1 <?php
2 /*
3  * backend/edit.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 
45 require_once("../config.php");
46 require_once("../inc/user.class.php");
47 require_once("../inc/tools.php");
48 require_once("../inc/check_login.php");
49 
50 require_once("../inc/db.class.php");
51 require_once("../inc/config.class.php");
52 require_once("../inc/auth.class.php");
53 
54 require_once("../inc/poll.class.php");
55 require_once("../inc/messages.class.php");
56 require_once("../inc/html.class.php");
57 
58 $db= new db( DB_USER, DB_PASS, DB_DATABASE, DB_HOST );
60 $config->load();
61 
63 // SESSION
64 make_session();
65 
66 $edit = "";
67 // SET VARS
68 if ( (isset($_GET["pollID"])) AND
69  (is_numeric($_GET["pollID"])) AND
70  ($_GET["pollID"] != "")
71  )
72 {
73  $poll = new poll();
74  if (!$poll->load_from_id($db, intval($_GET["pollID"]) ) ){
75  die("Umfrage existiert nicht.");
76  }
77 
78  if ( (isset($_GET["widgetID"])) AND ($_GET["widgetID"] != "") AND (is_numeric($_GET["widgetID"])) ){
79  $widget = $poll->get_widget_by_id( intval($_GET["widgetID"]) );
80  if (isset($widget)){
81  $edit = "widget";
82  }
83  }else{
84  $edit = "poll";
85  }
86 
87  if ( (isset($_GET["optionID"])) AND ($_GET["optionID"] != "") AND (is_numeric($_GET["optionID"])) ){
88  $option = $widget->get_widget_by_id( intval($_GET["optionID"]) );
89  if (isset($option)){
90  $edit = "option";
91  }
92  }
93 
94 }else{
95  header("Location: index.php");
96  exit();
97 }
98 
99 
100 check_login();
101 
102 // edit needs ownership or admin rights
103 if( (intval($_SESSION["user"]->ID) !== intval($poll->owner) ) AND
104  ( !in_array("{$_SESSION["user"]->ID}",explode(",",SUPER_ADMIN) )) ){
105  die("Umfrage Bearbeiten nicht erlaubt.");
106 }
107 
108 
109 if( isset($_GET["action"]) ){
110 
111 }
112 
113 
114 if( $edit == "poll" ){
115  $extra = "<script src='".APP_ROOT."/JS/edit.poll.js'></script>";
116 }else{
117  $extra = "";
118 }
119 $navbar = array( 0 => array("name"=>"Backend","href"=>"index.php","onclick"=>"") );
120 
121 if( (isset($widget)) AND (isset($option)) ){
122  $navbar[] = array( "name"=>"Umfrage {$poll->ID} Bearbeiten" , "href"=>"edit.php?pollID={$poll->ID}" , "onclick"=>"");
123  $navbar[] = array( "name"=>"Frage {$widget->ID} Bearbeiten" , "href"=>"edit.php?pollID={$poll->ID}&widgetID={$widget->ID}" , "onclick"=>"");
124  $navbar[] = array( "name"=>"Option {$option->ID} Bearbeiten" , "href"=>"" , "onclick"=>"");
125 }else if( isset($widget) ){
126  $navbar[] = array( "name"=>"Umfrage {$poll->ID} Bearbeiten" , "href"=>"edit.php?pollID={$poll->ID}" , "onclick"=>"");
127  $navbar[] = array( "name"=>"Frage {$widget->ID} Bearbeiten" , "href"=>"" , "onclick"=>"");
128 }else{
129  $navbar[] = array( "name"=>"Umfrage {$poll->ID} Bearbeiten" , "href"=>"" , "onclick"=>"");
130 }
131 
132 HTML::doctype();
133 HTML::head($extra,1); // extra header section , level of deepness for relative paths
134 HTML::menu($navbar); // navbar array
135 
136 
137 // messages in polledit are handled by inc/backend/pages/poll.edit.php
138 if ($edit != "poll"){
139  $messages->display_messages();
140  $messages->del_all_messages();
141 }
142 
143 if ($edit == "poll"){
144  include(INCLUDE_DIR."/backend/pages/edit.poll.php");
145 
146 
147 }else if ($edit == "widget"){
148  echo "<div class='widget_edit_container'>";
149  include(INCLUDE_DIR."/backend/pages/edit.".$widget->typ.".php");
150  echo "</div>";
151 
152 
153 }else if($edit == "option"){
154  echo "<div class='widget_edit_container'>";
155  if( $option instanceof label ){
156  include(INCLUDE_DIR."/backend/pages/edit.label.child.php");
157  }
158  echo "</div>";
159 }
160 
161 HTML::foot();
162 
163 
164 ?>