43 require_once(
"../config.php");
44 require_once(
"../inc/user.class.php");
45 require_once(
"../inc/tools.php");
46 require_once(
"../inc/check_login.php");
48 require_once(
"../inc/db.class.php");
49 require_once(
"../inc/config.class.php");
50 require_once(
"../inc/auth.class.php");
52 require_once(
"../inc/poll.class.php");
53 require_once(
"../inc/messages.class.php");
54 require_once(
"../inc/html.class.php");
56 $db=
new db( DB_USER, DB_PASS, DB_DATABASE, DB_HOST );
70 if( (isset($_GET[
"action"])) AND ($_GET[
"action"] ==
"import_XML_widget") ){
73 if( isset($_POST[
"add_widget"]) ){
77 if( isset($_POST[
"add_widget"]) ){
103 if( ! isset($poll) ){
104 header(
"Location: index.php");
108 header(
"Location: index.php");
118 if( (intval($_SESSION[
"user"]->ID) !== intval($poll->owner) ) AND
119 ( !in_array(
"{$_SESSION["user"]->ID}",explode(
",",SUPER_ADMIN) )) ){
120 die(
"Umfrage Bearbeiten nicht erlaubt.");
127 if( isset($_GET[
"action"]) ){
129 if( ($_GET[
"action"] ==
"mvup") AND (isset(
$widget)) ){
131 $_SESSION[
"last_widget_edit"] =
$widget->ID;
132 header(
"location: edit.php?pollID={$poll->ID}#widget{$widget->ID}");
135 }
else if( ($_GET[
"action"] ==
"mvdwn") AND (isset(
$widget) ) ){
137 $_SESSION[
"last_widget_edit"] =
$widget->ID;
138 header(
"location: edit.php?pollID={$poll->ID}#widget{$widget->ID}");
141 }
else if( ($_GET[
"action"] ==
"rmwid") AND (isset(
$widget) ) AND (isset($_POST[
"rmwid_confirm"])) ){
143 $db->garbage_collect_result_table($poll);
144 header(
"location: edit.php?pollID={$poll->ID}");
146 }
else if( ($_GET[
"action"] ==
"rmwid") AND (isset($_POST[
"cancel_action"])) AND (isset(
$widget)) ){
147 header(
"location: edit.php?pollID={$poll->ID}");
149 }
else if( ($_GET[
"action"] ==
"rmwid") AND (isset(
$widget) ) ){
150 $edit=
"confirm widget remove";
153 }
else if( ($_GET[
"action"] ==
"duplicate_widget") AND (isset(
$widget)) ){
154 $new_id =
$db->duplicate_widget($poll->ID,
$widget->ID);
155 $_SESSION[
"last_widget_edit"] = $new_id;
156 header(
"location: edit.php?pollID={$poll->ID}#widget{$new_id}");
160 }
else if( ($_GET[
"action"] ==
"export_XML_widget") AND (isset(
$widget)) ){
161 require_once(
"../inc/xml.class.php");
162 $fn =
"Frage-".$widget->ID;
164 $fn = preg_replace(array(
'/\s/',
'/\.[\.]+/',
'/[^\w_\.\-]/'), array(
'_',
'.',
''),
$widget->dispName);
167 header(
'Content-type: text/xml; charset="utf-8"');
168 header(
"Content-Disposition: attachment; filename=\"$fn.xml\"");
169 header(
"Expires: 0");
170 header(
"Cache-Control: must-revalidate, post-check=0, pre-check=0");
172 $xml = $xmlobj->export(
$widget);
174 $dom =
new DOMDocument(
'1.0',
"UTF-8");
175 $dom->preserveWhiteSpace =
false;
176 $dom->formatOutput =
true;
178 echo $dom->saveXML();
182 }
else if( ($_GET[
"action"] ==
"import_XML_widget") AND (isset($_FILES[
"pollxmlfile"])) ){
183 $finfo =
new finfo();
184 $mime = $finfo->file($_FILES[
"pollxmlfile"][
"tmp_name"],FILEINFO_MIME_TYPE);
185 if( ($mime ===
"application/xml") OR ($mime ===
"application/xml") ){
186 require_once(
"../inc/xml.class.php");
187 $xml = file_get_contents( $_FILES[
"pollxmlfile"][
"tmp_name"] );
189 $widget_list = $xmlobj->import($xml);
190 if( (is_array($widget_list)) AND (
sizeof($widget_list) > 0 ) AND ($widget_list[0] instanceof
widget) ){
191 $widget_list[0]->pollID = $poll->ID;
192 if( $widget_list[0] instanceof
container ){
193 $childs = $widget_list[0]->get_all_childs();
194 foreach( $childs as $child ){
195 $child->pollID = $poll->ID;
199 if( (is_numeric($widget_list[0]->
name)) ){
200 $widget_list[0]->name=
'-';
202 $poll->insert_widget(-1,$widget_list[0]);
203 $db->insert_widget($widget_list[0],$poll->type);
204 $_SESSION[
"last_widget_edit"] = $widget_list[0]->ID;
212 header(
"Location: edit.php?pollID={$poll->ID}");
217 }
else if( (isset( $_POST[
"add_widget"])) AND ($_POST[
"add_widget"] !=
"") ){
219 if( (isset($_POST[
"widget_typ"])) AND ($_POST[
"widget_typ"] !=
"") ){
220 $widget_whitelist = array(
"label",
"text",
"textExt",
"longtext",
"radioButtonList",
"line",
"checkBoxList",
"checkBoxSingle",
"matrix",
"schedule");
221 if( in_array($_POST[
"widget_typ"],$widget_whitelist) ){
223 if(
sizeof(class_parents(
$widget)) == 0 ){
227 $err_reason=
"Bitte einen Fragetyp auswählen um eine Frage hinzuzufügen";
230 $err_reason=
"Bitte einen Fragetyp auswählen um eine Frage hinzuzufügen";
241 $poll->insert_widget(-1,
$widget);
242 $widget->set_config(
"font-size", $poll->get_widget_default_font_config(
"font-size") );
243 $widget->set_config(
"font-family", $poll->get_widget_default_font_config(
"font-family") );
244 $db->insert_widget( $poll->widget_list[
sizeof($poll->widget_list)-1 ] ,$poll->type);
247 if(
$widget instanceof container){
252 $db->garbage_collect_result_table($poll);
256 header(
"Location: edit.php?pollID={$poll->ID}");
258 header(
"location: edit.php?pollID={$poll->ID}&widgetID={$widget->ID}");
270 $navbar = array( 0 => array(
"name"=>
"Backend",
"href"=>
"index.php",
"onclick"=>
"") );
271 $navbar[] = array(
"name"=>
"Umfrage {$poll->ID} Bearbeiten" ,
"href"=>
"edit.php?pollID={$poll->ID}" ,
"onclick"=>
"");
272 $navbar[] = array(
"name"=>
"Frage {$widget->ID} Bearbeiten" ,
"href"=>
"" ,
"onclick"=>
"");
282 if(
$edit ==
"confirm widget remove" ){
283 print_warning(
"<b>{$widget->dispName}</b> mit der ID <b>{$widget->ID}</b> in der Umfrage <b>{$poll->name}</b> wirklich löschen?");
284 echo
"<form method='POST' action=''>";
285 echo
"<input type='submit' name='cancel_action' value='Abbrechen' />";
286 echo
"<input type='submit' name='rmwid_confirm' value='Ja, wirklich' />";