From 75160b12821f7f4299cce7f0b69c83c1502ae071 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?=
Date: Mon, 27 May 2024 13:08:29 +0200
Subject: 2024-02-19 upstream
---
main/survey/app/Controllers/BodyController.php | 771 +++++++++++++++++--------
1 file changed, 546 insertions(+), 225 deletions(-)
(limited to 'main/survey/app/Controllers/BodyController.php')
diff --git a/main/survey/app/Controllers/BodyController.php b/main/survey/app/Controllers/BodyController.php
index 308b30c..7a5f819 100644
--- a/main/survey/app/Controllers/BodyController.php
+++ b/main/survey/app/Controllers/BodyController.php
@@ -30,7 +30,9 @@ use SurveyGorenje;
use SurveyNIJZ;
use GDPR;
use UserAccess;
-
+use AppSettings;
+use BranchingAjax;
+use SurveyEmailAccess;
class BodyController extends Controller
{
@@ -216,10 +218,55 @@ class BodyController extends Controller
$lang_array[$rowl['lang_id']] = $rowl['language'];
}
+
echo ' ' . "\n";
+ // Posebna izbira jezika za špance - IAS skin
+ if($row['skin'] == 'IAS'){
+
+ echo '
';
+
+ // Ikona in text
+ echo '
';
+ echo '
';
+ echo '
'.self::$lang['lang'].' ';
+ echo '
';
+
+ // Div z jeziki ki se prikaze na kkliku na ikono
+ echo '
';
+
+ foreach ($lang_array AS $key => $val) {
+ echo '';
+ echo ' ';
+
+ // Font awesome checkbox
+ //echo ' ';
+
+ echo $val;
+
+ echo ' ';
+ }
+
+ echo '
';
+ }
// Izbira jezika z dropdown menijem
- if (SurveySetting::getInstance()->getSurveyMiscSetting('resp_change_lang_type') == 1) {
+ else if (SurveySetting::getInstance()->getSurveyMiscSetting('resp_change_lang_type') == 1) {
+
echo '
' . self::$lang['lang'] . ': ';
echo ' ' . self::$lang['lang'] . ': ';
- echo '
';
+ echo '';
foreach ($lang_array AS $key => $val) {
- echo '';
- echo ' ';
+ echo '';
+ echo '';
+
+ echo ' ';
+
// Font awesome checkbox
echo ' ';
-
+
echo $val;
-
- echo ' ';
+
+ echo '';
+ echo '
';
}
+
echo ' ';
}
-
echo ' ' . "\n";
-
}
echo '
' . "\n"; // - grupa
@@ -300,14 +351,11 @@ class BodyController extends Controller
// JS na submitu prve strani - lahko da preverjamo privacy ali sprejetje cookija
$survey_privacy = SurveySetting::getInstance()->getSurveyMiscSetting('survey_privacy');
- if(($row['cookie_continue'] == 0 && $row['cookie'] != -1) || $survey_privacy == 2){
+ if($survey_privacy == 2){
$js_submit = ' onclick="';
if($survey_privacy == 2)
- $js_submit .= 'privacy_check();';
-
- if($row['cookie_continue'] == 0 && $row['cookie'] != -1)
- $js_submit .= 'cookie_check();';
+ $js_submit .= 'privacy_check();';
$js_submit .= 'return false;"';
}
@@ -395,14 +443,13 @@ class BodyController extends Controller
// Ce imamo staticen uvod in preverjanje s captcho
if($row['intro_static'] == 2){
- global $recaptcha_sitekey;
$captcha_error = (isset($_GET['captcha_error']) && $_GET['captcha_error'] == 1) ? true : false;
echo ' ';
echo '';
- echo '
';
+ echo '
';
echo '
';
if($captcha_error){
@@ -427,7 +474,7 @@ class BodyController extends Controller
echo GDPR::getSurveyIntro(get('anketa'));
// JS za prikaz popup-a
- echo '';
+ echo '';
echo '' . "\n";
// Radio buttons
@@ -445,7 +492,6 @@ class BodyController extends Controller
************************************************/
public function displayStaticIntroduction()
{
-
$row = SurveyInfo::getInstance()->getSurveyRow();
// datapiping
@@ -459,6 +505,24 @@ class BodyController extends Controller
elseif (isset($_GET['mobile']) && $_GET['mobile'] == 2)
$class .= ' tablet_preview';
+
+ // Spremenljivke, ki se rabijo v JS
+ echo ' ' . "\n";
+
+
+ // crn div za ozadje popupov
+ echo '
';
+ echo '';
+
echo '';
echo '
';
@@ -565,12 +629,19 @@ class BodyController extends Controller
}
echo ' ';
echo '' . "\n";
- } // Izbira jezika z radio gumbi (default)
+ }
+ // Izbira jezika z radio gumbi (default)
else {
+
echo '
' . self::$lang['lang'] . ': ';
- echo '
';
+
+ echo '';
+
foreach ($lang_array AS $key => $val) {
+
+ echo '';
echo '';
+
echo ' ';
+ echo ' ';
+ echo '
';
}
echo ' ';
}
@@ -610,14 +682,12 @@ class BodyController extends Controller
if (!get('printPreview')) {
- // JS na submitu prve strani - lahko da preverjamo privacy ali sprejetje cookija
+ // JS na submitu prve strani - lahko da preverjamo privacy
$survey_privacy = SurveySetting::getInstance()->getSurveyMiscSetting('survey_privacy');
- if(($row['cookie_continue'] == 0 && $row['cookie'] != -1) || $survey_privacy == 2){
- $js_submit = ' onclick="';
+ if($survey_privacy == 2){
+ $js_submit = ' onclick="';
if($survey_privacy == 2)
- $js_submit .= 'privacy_check();';
- if($row['cookie_continue'] == 0 && $row['cookie'] != -1)
- $js_submit .= 'cookie_check();';
+ $js_submit .= 'privacy_check();';
$js_submit .= 'return false;"';
}
else{
@@ -647,6 +717,239 @@ class BodyController extends Controller
echo ' '; // -outercontainer_holder
}
+ /************************************************
+ * Izrišemo uvod za modul email dostop - ne shranimo nicesar, samo prikazemo email s captcho ali pa polje za kodo
+ ************************************************/
+ public function displayEmailAccessIntroduction($response){
+ global $lang;
+
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ // datapiping
+ $row['introduction'] = Helper::dataPiping($row['introduction']);
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $hide_mobile_img = SurveySetting::getInstance()->getSurveyMiscSetting('hide_mobile_img');
+ $class = ($hide_mobile_img == '1') ? 'hide_mobile_img' : '';
+ if (isset($_GET['mobile']) && $_GET['mobile'] == 1)
+ $class .= ' mobile_preview';
+ elseif (isset($_GET['mobile']) && $_GET['mobile'] == 2)
+ $class .= ' tablet_preview';
+
+
+ // Spremenljivke, ki se rabijo v JS
+ echo ' ' . "\n";
+
+
+ // crn div za ozadje popupov
+ echo '
';
+ echo '';
+
+
+ echo '';
+ echo '
';
+
+ echo '
';
+ echo '';
+
+
+ echo '
' . "\n";
+
+ Display::getInstance()->logo();
+
+ Display::getInstance()->progress_bar();
+
+ if (!get('printPreview')) {
+ echo '
checkSurveyModule('uporabnost') ? ' class="evalvacija"' : '') . '>' . Helper::getInstance()->displayAkronim() . ' ' . "\n";
+ }
+
+ //opozorilo ce urejamo ze reseno anketo
+ if (get('quick_view') == true) {
+ echo '
';
+ echo self::$lang['srv_quick_view_text'];
+ echo '
';
+ }
+ //opozorilo ce urejamo ze reseno anketo
+ if (isset($_GET['urejanje'])) {
+ echo '
';
+ echo self::$lang['srv_edit_text'];
+ echo '
';
+
+ // Preverimo ce gre za prvo popravljanje podatkov in avtomatsko ustvarimo arhiv podatkov ce je potrebno
+ ob_flush(); // ZAKAJ JE TUKAJ TA FLUSH? KER POTEM NE DELA NAKNADNO UREJANJE CE IMA ANKETA LOOPE
+ $sas = new SurveyAdminSettings();
+ $sas->checkFirstDataChange();
+
+ // Updatamo tracking (ker gre za editiranje odgovorov)
+ TrackingClass::update(get('anketa'), 4);
+ }
+
+ $sea = new SurveyEmailAccess(get('anketa'));
+
+
+ echo '
' . "\n"; // - grupa
+
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = '';
+ $srv_nextpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_nextpage_uvod' . $_lang);
+ $label = $srv_nextpage != '' ? $srv_nextpage : self::$lang['srv_nextpage_uvod'];
+
+ if (!get('printPreview')) {
+
+ echo '
' . "\n";
+
+ if (isset($_GET['popup']) && $_GET['popup'] == '1')
+ echo ' ' . "\n";
+
+ echo '
';
+ }
+
+ echo '' . "\n";
+
+
+ echo '
' . "\n"; // - container
+
+ if (!get('printPreview')) {
+ $this->displayFooterNote();
+ }
+
+ echo '
' . "\n"; // - outercontainer
+
+ echo '
';
+ echo ''; // -outercontainer_holder
+ }
+
/************************************************
* Izrišemo konec ankete
@@ -657,7 +960,6 @@ class BodyController extends Controller
global $lang;
global $admin_type;
global $site_url;
- global $app_settings;
Header::getInstance()->displaySistemske();
@@ -676,6 +978,7 @@ class BodyController extends Controller
$sql4 = sisplet_query("SELECT d.* FROM srv_spremenljivka s, srv_grupa g, srv_data_text" . get('db_table') . " d WHERE g.ank_id='" . get('anketa') . "'AND s.gru_id=g.id AND s.sistem='1' AND s.variable='sifizv1' AND d.spr_id=s.id AND d.usr_id='" . get('usr_id') . "'");
$sql5 = sisplet_query("SELECT s.* FROM srv_spremenljivka s, srv_grupa g WHERE g.ank_id='" . get('anketa') . "'AND s.gru_id=g.id AND s.sistem='1' AND s.variable='podipl'");
$sql6 = sisplet_query("SELECT s.* FROM srv_spremenljivka s, srv_grupa g WHERE g.ank_id='" . get('anketa') . "'AND s.gru_id=g.id AND s.sistem='1' AND s.variable='podipl2'");
+ $sql7 = sisplet_query("SELECT s.* FROM srv_spremenljivka s, srv_grupa g WHERE g.ank_id='" . get('anketa') . "'AND s.gru_id=g.id AND s.sistem='1' AND s.variable='podipl3'");
// Ce imamo sifro predmeta gre za anketo za ocenjevanje predmetov
if (mysqli_num_rows($sql2) > 0) {
@@ -714,8 +1017,18 @@ class BodyController extends Controller
// Pobrisemo md5 (id studenta) iz zacasne tabele eval_data_user zaradi anonimnosti
sisplet_query("DELETE FROM eval_data_user WHERE usr_id='".get('usr_id')."' AND ank_id='".get('anketa')."'");
}
+ // splosna PODIPLOMSKA anketa 3 (ena na studenta, brez predmetov)
+ elseif (mysqli_num_rows($sql7) > 0) {
+ $row1 = mysqli_fetch_array($sql1);
+
+ // student je v celoti odgovoril na anketo
+ sisplet_query("INSERT INTO eval_data_podipl3 (student, ank_id) VALUES ('$row1[student]', '" . get('anketa') . "')");
+
+ // Pobrisemo md5 (id studenta) iz zacasne tabele eval_data_user zaradi anonimnosti
+ sisplet_query("DELETE FROM eval_data_user WHERE usr_id='".get('usr_id')."' AND ank_id='".get('anketa')."'");
+ }
// SPLOSNA anketa (ena na studenta, brez predmetov)
- elseif (mysqli_num_rows($sql1) > 0) {
+ elseif ($sql1 !== false && mysqli_num_rows($sql1) > 0) {
$row1 = mysqli_fetch_array($sql1);
// student je v celoti odgovoril na anketo
@@ -827,7 +1140,7 @@ class BodyController extends Controller
$panel_settings = $sp->getPanelSettings();
// Posebno samo za ipanel - Izraelski projekt
- if($app_settings['app_name'] == 'www.1ka.si' && (get('anketa') == '232992' || get('anketa') == '232795' || get('anketa') == '248217' || get('anketa') == '248757' || get('anketa') == '248762')){
+ if(AppSettings::getInstance()->getSetting('app_settings-app_name') == 'www.1ka.si' && (get('anketa') == '232992' || get('anketa') == '232795' || get('anketa') == '248217' || get('anketa') == '248757' || get('anketa') == '248762')){
// Pridobimo id panelista ki je bil shranjen na zacetku resevanja v sistemsko spremenljivko
$sqlP = sisplet_query("SELECT d.*, s.variable FROM srv_data_text".get('db_table')." d, srv_spremenljivka s, srv_grupa g
@@ -868,10 +1181,25 @@ class BodyController extends Controller
$panelist_id = $rowP['text'];
// Pridobimo koncen status panelista (ce ni bil nikjer nastavljen uporabimo default)
- $panel_status = (isset($_COOKIE['panel_status']) && $_COOKIE['panel_status'] != '') ? $_COOKIE['panel_status'] : $panel_settings['status_default'];
+ if(isset($_POST['panel_status']) && $_POST['panel_status'] != ''){
+ $panel_status = $_POST['panel_status'];
+ }
+ elseif(isset($_COOKIE['panel_status']) && $_COOKIE['panel_status'] != ''){
+ $panel_status = $_COOKIE['panel_status'];
+ }
+ else{
+ $panel_status = $panel_settings['status_default'];
+ }
- // Nastavimo koncen url za redirect
- $finishUrl = $row['url'].'?'.$panel_settings['user_id_name'].'='.$panelist_id.'&'.$panel_settings['status_name'].'='.$panel_status;
+ // Dodaten pogoj, ce imamo slucajno ? ze v osnovnem delu urlja (da vracamo tudi recimo fiksen parameter)
+ if(strpos($row['url'], "?") !== false){
+ // Nastavimo koncen url za redirect
+ $finishUrl = $row['url'].'&'.$panel_settings['user_id_name'].'='.$panelist_id.'&'.$panel_settings['status_name'].'='.$panel_status;
+ }
+ else{
+ // Nastavimo koncen url za redirect
+ $finishUrl = $row['url'].'?'.$panel_settings['user_id_name'].'='.$panelist_id.'&'.$panel_settings['status_name'].'='.$panel_status;
+ }
}
}
@@ -890,10 +1218,10 @@ class BodyController extends Controller
// Glede na vrednost
$naslednja = array_search($resevanje->koda, $kode) + 1;
- $url = sisplet_query("SELECT url FROM srv_hierarhija_koda WHERE koda='".$kode[$naslednja]."'", "obj");
+ $url = sisplet_query("SELECT h.url, a.hash FROM srv_hierarhija_koda h, srv_anketa a WHERE h.koda='".$kode[$naslednja]."' AND h.anketa_id=a.id", "obj");
$url_encode_spremenljivke = urlencode(base64_encode($url->url . '&supersifra=' . $resevanje->supersifra.'&resujem='.$naslednja));
- $redirect = $site_url .'a/'.get('anketa').'?enc='.$url_encode_spremenljivke;
+ $redirect = $site_url .'a/'.$url->hash.'?enc='.$url_encode_spremenljivke;
header("Location: $redirect");
}
@@ -943,8 +1271,8 @@ class BodyController extends Controller
// URL na katerega skocimo ce se zapre okno - pogledamo ce imamo nastavljen custom url (settings_optional.php)
- if(isset($app_settings['survey_finish_url']) && $app_settings['survey_finish_url'] != '')
- $close_url = $app_settings['survey_finish_url'];
+ if(AppSettings::getInstance()->getSetting('app_settings-survey_finish_url') !== false)
+ $close_url = AppSettings::getInstance()->getSetting('app_settings-survey_finish_url');
else
$close_url = 'https://www.1ka.si/';
@@ -1013,7 +1341,6 @@ class BodyController extends Controller
echo '' . "\n"; //-grupa
if ($row['user_from_cms'] == 2) {
- //echo ''.$lang['srv_nextins'].'
';
echo '' . $lang['srv_nextins'] . '
';
}
@@ -1088,11 +1415,15 @@ class BodyController extends Controller
}
+ // Ce imamo url za naknadno urejanje - posiljanje na mail, posljemo avtomatsko mail, ce je vnesel email
+ if ((int)$row['concl_return_edit'] == 1) {
+ $js = 'continueLaterCheckEmail(\''.self::$lang['srv_continue_later_alert'].'\', function(){'.$js.'});';
+ }
+
+
if (!get('printPreview')) {
$srv_konec = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_konec' . $_lang);
- /*if ($row['text'] != '') // besedilo koncne povezave shranimo v misc setting, da bo konsistentno z ostalimi prevodi
- $text = $row['text'];
- else*/
+
if ($srv_konec != '')
$text = $srv_konec;
else
@@ -1108,7 +1439,7 @@ class BodyController extends Controller
if ($row['user_from_cms'] == 2 && $row['user_from_cms_email'] == 1 && $admin_type <= 2) { // vnosos
$sqlg = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='" . get('anketa') . "'ORDER BY vrstni_red ASC LIMIT 1");
$rowg = mysqli_fetch_array($sqlg);
- //echo ''.$lang['srv_nextins'].' | '.$lang['srv_insend'].'
';
+
echo '' . $lang['srv_nextins'] . ' | ' . $lang['srv_insend'] . '
';
}
@@ -1230,7 +1561,7 @@ class BodyController extends Controller
// SKAVTI - prikaz povzetka odgovorov in grafa
global $mysql_database_name;
- //if($mysql_database_name == '1ka' && get('anketa') == '64'){
+ //if($mysql_database_name == '1ka' && get('anketa') == '52'){
if($mysql_database_name == 'real1kasi' && (get('anketa') == '293926' || get('anketa') == '314856' || get('anketa') == '332793')){
echo '';
Display::getInstance()->displaySkavtiAnswers();
@@ -1263,11 +1594,10 @@ class BodyController extends Controller
* @desc prikaze konec ankete
*/
public function displayKonecGlasovanje(){
- global $app_settings;
echo '';
- //izpis zakljucka
+ // izpis zakljucka
if (isset($_GET['glas_end']) && $_GET['glas_end'] == 1) {
if (!get('printPreview')) {
@@ -1287,8 +1617,8 @@ class BodyController extends Controller
// URL na katerega skocimo ce se zapre okno - pogledamo ce imamo nastavljen custom url (settings_optional.php)
- if(isset($app_settings['survey_finish_url']) && $app_settings['survey_finish_url'] != '')
- $close_url = $app_settings['survey_finish_url'];
+ if(AppSettings::getInstance()->getSetting('app_settings-survey_finish_url') !== false)
+ $close_url = AppSettings::getInstance()->getSetting('app_settings-survey_finish_url');
else
$close_url = 'https://www.1ka.si/';
@@ -1304,11 +1634,19 @@ class BodyController extends Controller
}
}
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $hide_mobile_img = SurveySetting::getInstance()->getSurveyMiscSetting('hide_mobile_img');
+ $class = ($hide_mobile_img == '1') ? 'hide_mobile_img' : '';
+ if (isset($_GET['mobile']) && $_GET['mobile'] == 1)
+ $class .= ' mobile_preview';
+ elseif (isset($_GET['mobile']) && $_GET['mobile'] == 2)
+ $class .= ' tablet_preview';
+
- echo '
';
+ echo '
';
echo '
';
- echo '
' . "\n";
+ echo '
' . "\n";
echo '';
echo '
' . "\n";
@@ -1328,7 +1666,7 @@ class BodyController extends Controller
} else {
$concl = $row['conclusion'];
}
- echo '
' . $concl . '
' . "\n";
+ echo '
' . "\n";
echo '
' . "\n";
@@ -1397,14 +1735,29 @@ class BodyController extends Controller
//ce statistike ne prikazujemo skocimo na zakljucek (ce imammo izklopljeno ali nastavleno na samo urednike in ni urednik)
if ($rows['stat'] == 0 || ($rows['stat'] == 2 && self::$admin_type != 0 && self::$admin_type != 1)) {
- //header('Location: '.self::$site_url.'a/'.get('anketa').'&grupa='.get('grupa').'&glas_end=1'.get('cookie_url').'');
- header('Location: ' . SurveyInfo::getSurveyLink() . '&grupa=' . get('grupa') . (isset($_GET['language']) ? '&language=' . $_GET['language'] : '') . '&glas_end=1' . get('cookie_url') . '');
- } else {
+ header('Location: ' . SurveyInfo::getSurveyLink()
+ . '&grupa=' . get('grupa')
+ . (isset($_GET['language']) ? '&language=' . $_GET['language'] : '')
+ . '&glas_end=1'
+ . (isset($_GET['preview']) ? '&preview=' . $_GET['preview'] : '')
+ . (isset($_GET['mobile']) ? '&mobile=' . $_GET['mobile'] : '')
+ . get('cookie_url') . '');
+ }
+ else {
- echo '
';
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $hide_mobile_img = SurveySetting::getInstance()->getSurveyMiscSetting('hide_mobile_img');
+ $class = ($hide_mobile_img == '1') ? 'hide_mobile_img' : '';
+ if (isset($_GET['mobile']) && $_GET['mobile'] == 1)
+ $class .= ' mobile_preview';
+ elseif (isset($_GET['mobile']) && $_GET['mobile'] == 2)
+ $class .= ' tablet_preview';
+
+
+ echo '
';
echo '
';
- echo '
' . "\n";
+ echo '
' . "\n";
echo '';
echo '
' . "\n";
@@ -1420,8 +1773,8 @@ class BodyController extends Controller
echo '
' . "\n";
echo '