42 require_once(
"../config.php");
43 require_once(
"../inc/user.class.php");
44 require_once(
"../inc/tools.php");
46 require_once(
"../inc/check_login.php");
47 require_once(
"../inc/db.class.php");
48 require_once(
"../inc/config.class.php");
49 require_once(
"../inc/html.class.php");
50 require_once(
"../inc/poll.class.php");
51 require_once(
"../inc/messages.class.php");
52 $db=
new db( DB_USER, DB_PASS, DB_DATABASE, DB_HOST );
81 if( (isset($_GET[
"optionID"])) AND ($_GET[
"optionID"] !=
"") AND ( is_numeric($_GET[
"optionID"]) ) AND (isset(
$widget) ) ){
82 $optionID = intval($_GET[
"optionID"]);
84 if( ($optionID ==
$widget->ID) AND ( isset($_GET[
"action"]) ) AND ($_GET[
"action"] ==
"add") ){
86 }
else if ( ($optionID ==
$widget->ID) AND ( isset($_GET[
"action"]) ) AND ($_GET[
"action"] ==
"addq") ){
89 $option =
$widget->get_option_by_id($optionID);
90 if( !isset($option) ){
91 $option =
$widget->get_widget_by_id($optionID);
94 if( !isset($option) ){
95 $messages->add_message(
new errorMessage(
"Option $optionID der Frage {$widget->ID} der Umfrage {$poll->ID} existiert leider nicht ... ") );
107 if( (intval($_SESSION[
"user"]->ID) !== intval($poll->owner) ) AND
108 ( !in_array(
"{$_SESSION["user"]->ID}",explode(
",",SUPER_ADMIN) )) ){
109 die(
"Umfrage Bearbeiten nicht erlaubt.");
118 if( isset($_GET[
"action"]) ){
123 if( $_GET[
"action"] ==
"add"){
135 $widget->insert_option($option->index,$new_option);
136 if( !(
$widget instanceof matrix) ){
137 $new_option->set_dispName(
"Option{$new_option->index}");
139 $new_option->set_dispName(
"");
141 $new_option->set_value(
"Option{$new_option->index}");
142 $db->insert_widget($new_option,$poll->type);
144 $_SESSION[
"last_option_edit"] = $new_option->ID;
146 $widget->insert_option(-1,$new_option);
147 if( !(
$widget instanceof matrix) ){
148 $new_option->set_dispName(
"Option{$new_option->index}");
150 $new_option->set_dispName(
"");
152 $new_option->set_value(
"Option{$new_option->index}");
153 $db->insert_widget($new_option,$poll->type);
155 $_SESSION[
"last_option_edit"] = $new_option->ID;
159 }
else if( $_GET[
"action"] ==
"rm" ){
162 }
else if( $_GET[
"action"] ==
"mvup" ){
163 $widget->move_option(
$db,$option->index,$option->index-1);
164 $_SESSION[
"last_option_edit"] = $option->ID;
166 }
else if( $_GET[
"action"] ==
"mvdwn" ){
167 $widget->move_option(
$db,$option->index,$option->index+1);
168 $_SESSION[
"last_option_edit"] = $option->ID;
174 }
else if( $_GET[
"action"] ==
"addq"){
179 if( (isset($_GET[
"type"])) AND ($_GET[
"type"] ==
"text") ){
180 $new_option =
new text();
181 }
else if( (isset($_GET[
"type"])) AND ($_GET[
"type"] ==
"labelTiny") ){
187 $new_option =
new label();
195 if($option->ID !=
$widget->ID){
196 $widget->insert_widget($option->index,$new_option);
198 $widget->insert_widget(-1,$new_option);
205 $new_option->set_default_values(
$db);
206 $db->insert_widget($new_option,$poll->type);
209 $db->garbage_collect_result_table($poll);
210 $_SESSION[
"last_option_edit"] = $new_option->ID;
214 }
else if( $_GET[
"action"] ==
"rmq" ){
217 $db->garbage_collect_result_table($poll);
219 }
else if( $_GET[
"action"] ==
"mvupq" ){
220 $widget->move_widget(
$db,$option->index,$option->index-1);
221 $_SESSION[
"last_option_edit"] = $option->ID;
223 }
else if( $_GET[
"action"] ==
"mvdwnq" ){
224 $widget->move_widget(
$db,$option->index,$option->index+1);
225 $_SESSION[
"last_option_edit"] = $option->ID;
237 header(
"Location: edit.php?pollID={$poll->ID}&widgetID={$widget->ID}");