diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2024-05-27 13:08:29 +0200 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2024-05-27 13:08:29 +0200 |
commit | 75160b12821f7f4299cce7f0b69c83c1502ae071 (patch) | |
tree | 27e25e4ccaef45f0c58b22831164050d1af1d4db /main/survey/app/Models/SaveSurvey.php | |
parent | prvi-commit (diff) | |
download | 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.gz 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.bz2 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.lz 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.xz 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.zst 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.zip |
Diffstat (limited to '')
-rw-r--r-- | main/survey/app/Models/SaveSurvey.php | 125 |
1 files changed, 77 insertions, 48 deletions
diff --git a/main/survey/app/Models/SaveSurvey.php b/main/survey/app/Models/SaveSurvey.php index be62517..8bbd372 100644 --- a/main/survey/app/Models/SaveSurvey.php +++ b/main/survey/app/Models/SaveSurvey.php @@ -92,7 +92,7 @@ class SaveSurvey extends Model SurveySetting::getInstance()->Init(get('anketa'));
$date = SurveySetting::getInstance()->getSurveyMiscSetting('survey_date');
- if ($date == 0) $_time_insert = "NOW()"; else $_time_insert = "''";
+ if ($date == 0 || $date == '') $_time_insert = "NOW()"; else $_time_insert = "''";
if (isset($_GET['language'])) save('language', (int)$_GET['language']); else save('language', $lang['id']);
// popravimo cas updata
@@ -105,6 +105,15 @@ class SaveSurvey extends Model sisplet_query("REPLACE INTO srv_user_grupa" . get('db_table') . " (gru_id, usr_id, time_edit, preskocena) VALUES ('" . get('grupa') . "', '" . get('usr_id') . "', " . $_time_insert . ", '$preskocena')");
if ($preskocena == 1) save('preskocena_first', 0);
+ // Ce imamo napredni modul za belezenje casovc po straneh
+ if(SurveyInfo::getInstance()->checkSurveyModule('advanced_timestamps')){
+ sisplet_query("INSERT INTO srv_advanced_timestamps
+ (gru_id, usr_id, time_edit)
+ VALUES
+ ('".get('grupa')."', '".get('usr_id')."', NOW())
+ ");
+ }
+
# potrebno bo osvežit seznam anket
Model::setUpdateSurveyList();
}
@@ -169,15 +178,17 @@ class SaveSurvey extends Model // vnesemo komentar vprasanja
if ($question_resp_comment == 1) {
- $text = $_POST['question_comment_' . $row['id']];
+
+ $text = isset($_POST['question_comment_' . $row['id']]) ? strip_tags($_POST['question_comment_' . $row['id']]) : '';
+
sisplet_query("DELETE FROM srv_data_text" . get('db_table') . " WHERE spr_id='0' AND vre_id='$row[id]' AND usr_id='" . get('usr_id') . "'");
+
if ($text != '') {
if (isset($_POST['inicialke']) && $_POST['inicialke'] != '')
$text = '<b>' . $_POST['inicialke'] . '</b> (__DATE__):' . "\n\r" . $text;
$s = sisplet_query("INSERT INTO srv_data_text" . get('db_table') . " (spr_id, vre_id, text, usr_id) VALUES ('0', '$row[id]', '$text', '" . get('usr_id') . "')");
if (!$s) echo mysqli_error($GLOBALS['connect_db']);
}
-
}
if (($row['tip'] < 14) || ($row['tip'] > 15)) {
@@ -249,7 +260,7 @@ class SaveSurvey extends Model Model::user_not_lurker();
- if ($_POST['textfield_' . $vrednost] != '')
+ if (isset($_POST['textfield_' . $vrednost]) && $_POST['textfield_' . $vrednost] != '')
$srv_data_text .= "('$row[id]', '$vrednost', '" . $_POST['textfield_' . $vrednost] . "', '', '" . get('usr_id') . "', $loop_id),";
}
else {
@@ -321,7 +332,7 @@ class SaveSurvey extends Model $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$row[id]'");
while ($row1 = mysqli_fetch_array($sql1)) {
- $grid_id = $_POST['vrednost_' . $row1['id']];
+ $grid_id = isset($_POST['vrednost_' . $row1['id']]) ? $_POST['vrednost_' . $row1['id']] : '';
// $grid_id > 0
if ((string)$grid_id != "") {
@@ -337,7 +348,7 @@ class SaveSurvey extends Model }
// vsebino text polja vnesemo v vsakem primeru
- if ($_POST['textfield_' . $row1['id']] != '') {
+ if (isset($_POST['textfield_' . $row1['id']]) && $_POST['textfield_' . $row1['id']] != '') {
$srv_data_text .= "('$row[id]', '$row1[id]', '" . $_POST['textfield_' . $row1['id']] . "', '', '" . get('usr_id') . "', $loop_id),";
Model::user_not_lurker();
}
@@ -364,8 +375,8 @@ class SaveSurvey extends Model $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$row[id]'");
while ($row1 = mysqli_fetch_array($sql1)) {
- $grid_id = $_POST['vrednost_' . $row1['id']];
- $grid_id2 = $_POST['vrednost_' . $row1['id'] . '_part_2'];
+ $grid_id = isset($_POST['vrednost_' . $row1['id']]) ? $_POST['vrednost_' . $row1['id']] : "";
+ $grid_id2 = isset($_POST['vrednost_' . $row1['id'] . '_part_2']) ? $_POST['vrednost_' . $row1['id'] . '_part_2'] : "";
if ((string)$grid_id != "") // $grid_id > 0
{ # grid_id je lahko tudi negativen za missing vrednosti
@@ -416,7 +427,7 @@ class SaveSurvey extends Model } else {
while ($row2 = mysqli_fetch_array($sql2)) {
- $grid_id = $_POST['vrednost_' . $row1['id'] . '_grid_' . $row2['id']];
+ $grid_id = isset($_POST['vrednost_' . $row1['id'] . '_grid_' . $row2['id']]) ? $_POST['vrednost_' . $row1['id'] . '_grid_' . $row2['id']] : "";
// $grid_id > 0
if ((string)$grid_id != ""){
@@ -490,7 +501,7 @@ class SaveSurvey extends Model }
// vsebino text polja vnesemo v vsakem primeru
- if ($_POST['textfield_' . $row1['id']] != '') {
+ if (isset($_POST['textfield_' . $row1['id']]) && $_POST['textfield_' . $row1['id']] != '') {
$srv_data_text .= "('$row[id]', '$row1[id]', '" . $_POST['textfield_' . $row1['id']] . "', '', '" . get('usr_id') . "', $loop_id),";
Model::user_not_lurker();
}
@@ -572,7 +583,7 @@ class SaveSurvey extends Model }
// vsebino text polja vnesemo v vsakem primeru
- if ($_POST['textfield_' . $row1['id']] != '') {
+ if (isset($_POST['textfield_' . $row1['id']]) && $_POST['textfield_' . $row1['id']] != '') {
//sisplet_query("INSERT INTO srv_data_text (spr_id, vre_id, text, usr_id) VALUES ('$row[id]', '$row1[id]', '".$_POST['textfield_'.$row1['id']]."', '".get('usr_id')."')");
$srv_data_text .= "('$row[id]', '$row1[id]', '" . $_POST['textfield_' . $row1['id']] . "', '', '" . get('usr_id') . "', $loop_id),";
Model::user_not_lurker();
@@ -602,7 +613,7 @@ class SaveSurvey extends Model $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '" . $spr_row['id'] . "'");
while ($row1 = mysqli_fetch_array($sql1)) {
- $grid_id = $_POST['multi_' . $spr_row['id'] . '_' . $row1['id']];
+ $grid_id = isset($_POST['multi_' . $spr_row['id'] . '_' . $row1['id']]) ? $_POST['multi_' . $spr_row['id'] . '_' . $row1['id']] : "";
if ((string)$grid_id != "") // $grid_id > 0
{ # grid_id je lahko tudi negativen za missing vrednosti
@@ -614,7 +625,7 @@ class SaveSurvey extends Model //$srv_data_grid .= "('$row[id]', '$row1[id]', '".get('usr_id')."', '-1'),";
}
// vsebino text polja vnesemo v vsakem primeru
- if ($_POST['textfield_' . $row1['id']] != '') {
+ if (isset($_POST['textfield_' . $row1['id']]) && $_POST['textfield_' . $row1['id']] != '') {
//sisplet_query("INSERT INTO srv_data_text (spr_id, vre_id, text, usr_id) VALUES ('$row[id]', '$row1[id]', '".$_POST['textfield_'.$row1['id']]."', '".get('usr_id')."')");
$srv_data_text .= "('$spr_row[id]', '$row1[id]', '" . $_POST['textfield_' . $row1['id']] . "', '', '" . get('usr_id') . "', $loop_id),";
Model::user_not_lurker();
@@ -698,7 +709,7 @@ class SaveSurvey extends Model }
// vsebino text polja vnesemo v vsakem primeru
- if ($_POST['textfield_' . $row1['id']] != '') {
+ if (isset($_POST['textfield_' . $row1['id']]) && $_POST['textfield_' . $row1['id']] != '') {
//sisplet_query("INSERT INTO srv_data_text (spr_id, vre_id, text, usr_id) VALUES ('$row[id]', '$row1[id]', '".$_POST['textfield_'.$row1['id']]."', '".get('usr_id')."')");
$srv_data_text .= "('$spr_row[id]', '$row1[id]', '" . $_POST['textfield_' . $row1['id']] . "', '', '" . get('usr_id') . "', $loop_id),";
Model::user_not_lurker();
@@ -799,7 +810,7 @@ class SaveSurvey extends Model $file_allowed = true;
// Preverimo ce je file type dovoljen (prava koncnica)
- if( !in_array(strtolower($ext), array("jpeg", "jpg", "png", "gif", "pdf", "doc", "docx", "xls", "xlsx")) ){
+ if( !in_array(strtolower($ext), array("jpeg", "jpg", "png", "gif", "pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "zip", "rar", "rds", "rdata", "rmd", "qmd")) ){
$file_allowed = false;
}
@@ -1174,36 +1185,38 @@ class SaveSurvey extends Model $input = $spremenljivkaParams->get('multi_input_type');
- foreach ($_POST['vrednost_' . $row['id']] AS $key => $val) {
+ if(isset($_POST['vrednost_' . $row['id']])){
+ foreach ($_POST['vrednost_' . $row['id']] AS $key => $val) {
- $data = explode("|", $val);
+ $data = explode("|", $val);
- //izberi lokacijo
- if($enota == 3){
- $je_odgovoril = (isset($_POST[$data[0] . '_text']) && $_POST[$data[0] . '_text'] != '');
- $srv_data_map .= "(" . get('usr_id') . ", '$row[id]', $loop_id, $data[0], ". get('anketa') . ", '', '', '', '".
- ($je_odgovoril ? $_POST[$data[0] . '_text'] : '-1')."', ''),";
- if($je_odgovoril)
- Model::user_not_lurker();
- }
- else{
- //linija ali poligon
- if($enota == 2 && $input != 'marker'){
- $srv_data_map .= "(" . get('usr_id') . ", '$row[id]', $loop_id, NULL, ". get('anketa') . ", '$data[1]', '$data[2]', '', '', '$data[0]'),";
+ //izberi lokacijo
+ if($enota == 3){
+ $je_odgovoril = (isset($_POST[$data[0] . '_text']) && $_POST[$data[0] . '_text'] != '');
+ $srv_data_map .= "(" . get('usr_id') . ", '$row[id]', $loop_id, $data[0], ". get('anketa') . ", '', '', '', '".
+ ($je_odgovoril ? $_POST[$data[0] . '_text'] : '-1')."', ''),";
+ if($je_odgovoril)
+ Model::user_not_lurker();
}
- //marker
else{
- //nastavi odgovor na podvprasanje
- if(isset($_POST[$data[0] . '_text']))
- $marker_text = $_POST[$data[0] . '_text'] != '' ? $_POST[$data[0] . '_text'] : '-1';
- else
- $marker_text = '-4';
-
- $srv_data_map .= "(" . get('usr_id') . ", '$row[id]', $loop_id, NULL, ". get('anketa') . ", '$data[1]', '$data[2]', '$data[3]', '".
- $marker_text."', ''),";
+ //linija ali poligon
+ if($enota == 2 && $input != 'marker'){
+ $srv_data_map .= "(" . get('usr_id') . ", '$row[id]', $loop_id, NULL, ". get('anketa') . ", '$data[1]', '$data[2]', '', '', '$data[0]'),";
+ }
+ //marker
+ else{
+ //nastavi odgovor na podvprasanje
+ if(isset($_POST[$data[0] . '_text']))
+ $marker_text = $_POST[$data[0] . '_text'] != '' ? $_POST[$data[0] . '_text'] : '-1';
+ else
+ $marker_text = '-4';
+
+ $srv_data_map .= "(" . get('usr_id') . ", '$row[id]', $loop_id, NULL, ". get('anketa') . ", '$data[1]', '$data[2]', '$data[3]', '".
+ $marker_text."', ''),";
+ }
+ Model::user_not_lurker();
}
- Model::user_not_lurker();
- }
+ }
}
}
else {
@@ -1218,20 +1231,25 @@ class SaveSurvey extends Model elseif ($row['tip'] == 27) {
if ($_POST['visible_' . $row['id']] == 1) {
+
//za koordinate
- foreach ($_POST['vrednost_' . $row['id']] AS $key => $val) {
+ if(isset($_POST['vrednost_' . $row['id']])){
+ foreach ($_POST['vrednost_' . $row['id']] AS $key => $val) {
$data = explode("|", $val);
-
+
$srv_data_heatmap .= "(" . get('usr_id') . ", '$row[id]', $loop_id, NULL, ". get('anketa') . ", '$data[1]', '$data[2]', '$data[3]', '".
(isset($_POST[$data[0] . '_text']) ? $_POST[$data[0] . '_text'] : '-2')."', ''),";
Model::user_not_lurker();
$empty = false;
- }//za koordinate - konec
+ }
+ }
+ //za koordinate - konec
//za checkbox
- foreach ($_POST['vrednostHeatmap_' . $row['id']] AS $key => $val) {
-
+ if(isset($_POST['vrednostHeatmap_' . $row['id']])){
+ foreach ($_POST['vrednostHeatmap_' . $row['id']] AS $key => $val) {
+
if ($val > 0) {
//sisplet_query("INSERT INTO srv_data_vrednost".get('db_table')." (spr_id, vre_id, usr_id) VALUES ('$row[id]', '$val', '".get('usr_id')."')");
$srv_data_vrednost .= "('$row[id]', '$val', '" . get('usr_id') . "', $loop_id),";
@@ -1240,7 +1258,9 @@ class SaveSurvey extends Model //sisplet_query("INSERT INTO srv_data_text (spr_id, vre_id, text, usr_id) VALUES ('$row[id]', '$val', '".$_POST['textfield_'.$val]."', '".get('usr_id')."')");
$srv_data_text .= "('$row[id]', '$val', '" . $_POST['textfield_' . $val] . "', '', '" . get('usr_id') . "', $loop_id),";
}
- }//za checkbox - konec
+ }
+ }
+ //za checkbox - konec
// če imamo if na vprašanjij, imamo v arrayu vrednosti katere so -2
if (isset($_POST['cond_vrednost_' . $row['id']])) {
@@ -1391,7 +1411,10 @@ class SaveSurvey extends Model if (!$s) {
echo 'err08: ' . mysqli_error($GLOBALS['connect_db']);
}
- //$s = sisplet_query("DELETE FROM srv_data_glasovanje WHERE spr_id IN ($delete) AND usr_id='".get('usr_id')."'"); if (!$s) echo 'err07: '.mysqli_error($GLOBALS['connect_db']);
+ $s = sisplet_query("DELETE FROM srv_data_vrednost_cond WHERE spr_id IN ($delete) AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ if (!$s) {
+ echo 'err09: ' . mysqli_error($GLOBALS['connect_db']);
+ }
}
// odrezemo zadnjo vejico, ker smo jo dodajali kar povsod
@@ -1481,11 +1504,17 @@ class SaveSurvey extends Model $sql2 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$row1[id]' AND naslov='$password'");
$row2 = mysqli_fetch_array($sql2);
+
$s = sisplet_query("DELETE FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$row1[id]' AND usr_id='" . get('usr_id') . "'");
if (!$s) echo mysqli_error($GLOBALS['connect_db']);
+
$data = $row2['id'];
+
$s = sisplet_query("INSERT INTO srv_data_vrednost" . get('db_table') . " (spr_id, vre_id, usr_id) VALUES ('$row1[id]', '$data', '" . get('usr_id') . "')");
if (!$s) echo 'err6543' . mysqli_error($GLOBALS['connect_db']);
+
+ // Na koncu pocistimo piskotek z geslom
+ setcookie('password_'. get('anketa'), '', time() - 3600);
}
}
@@ -1530,7 +1559,7 @@ class SaveSurvey extends Model $student = $url_params['sifstud'];
- $s = sisplet_query("INSERT INTO eval_data_user (student, ank_id, usr_id) VALUES ('".$student."', '".get('anketa')."', '".get('usr_id')."')");
+ $s = sisplet_query("INSERT INTO eval_data_user (student, ank_id, usr_id) VALUES ('".$student."', '".get('anketa')."', '".get('usr_id')."') ON DUPLICATE KEY UPDATE student='".$student."'");
if (!$s) echo 'err9988' . mysqli_error($GLOBALS['connect_db']);
}
|