summaryrefslogtreecommitdiffstats
path: root/main/survey/app/Controllers/AjaxController.php
diff options
context:
space:
mode:
Diffstat (limited to 'main/survey/app/Controllers/AjaxController.php')
-rw-r--r--main/survey/app/Controllers/AjaxController.php181
1 files changed, 124 insertions, 57 deletions
diff --git a/main/survey/app/Controllers/AjaxController.php b/main/survey/app/Controllers/AjaxController.php
index 33662e4..91a524b 100644
--- a/main/survey/app/Controllers/AjaxController.php
+++ b/main/survey/app/Controllers/AjaxController.php
@@ -10,6 +10,7 @@ namespace App\Controllers;
// Osnovni razredi
use App\Controllers\StatisticController as Statistic;
use App\Controllers\Vprasanja\VprasanjaController as Vprasanja;
+use App\Controllers\LanguageController as Language;
use App\Models\Model;
use Common;
use Branching;
@@ -17,57 +18,84 @@ use SurveyAdvancedParadataLog;
use SurveySetting;
use MailAdapter;
use GDPR;
+use AppSettings;
+use SurveyEmailAccess;
class AjaxController extends Controller
{
//ajax zahteve
- public function __construct()
- {
+ public function __construct(){
+
if(empty($_GET['a'])){
return '';
}
+
+ // inicializiramo jezik za multilang anketo
+ Language::getInstance()->multilang_init();
+
+
if ($_GET['a'] == 'accept_droppable') {
$this->ajax_accept_droppable();
- } elseif ($_GET['a'] == 'accept_ranking') {
+ }
+ elseif ($_GET['a'] == 'accept_ranking') {
$this->ajax_accept_ranking();
- } elseif ($_GET['a'] == 'accept_dragdrop1') {
+ }
+ elseif ($_GET['a'] == 'accept_dragdrop1') {
$this->ajax_accept_dragdrop1();
- } elseif ($_GET['a'] == 'get_dragdrop1_data') {
+ }
+ elseif ($_GET['a'] == 'get_dragdrop1_data') {
$this->ajax_get_dragdrop1_data();
- } elseif ($_GET['a'] == 'delete_dragdrop1_data') {
+ }
+ elseif ($_GET['a'] == 'delete_dragdrop1_data') {
$this->ajax_delete_dragdrop1_data();
- } elseif ($_GET['a'] == 'delete_dragdrop2_data') {
+ }
+ elseif ($_GET['a'] == 'delete_dragdrop2_data') {
$this->ajax_delete_dragdrop2_data();
- } elseif ($_GET['a'] == 'accept_dragdrop_grid') {
+ }
+ elseif ($_GET['a'] == 'accept_dragdrop_grid') {
$this->ajax_accept_dragdrop_grid();
- } elseif ($_GET['a'] == 'accept_sortable_ranking') {
+ }
+ elseif ($_GET['a'] == 'accept_sortable_ranking') {
$this->ajax_accept_sortable_ranking();
- } elseif ($_GET['a'] == 'edit_size') {
+ }
+ elseif ($_GET['a'] == 'edit_size') {
$this->ajax_edit_size();
- } elseif ($_GET['a'] == 'dodaj_ime') {
+ }
+ elseif ($_GET['a'] == 'dodaj_ime') {
$this->ajax_dodaj_ime();
- } elseif ($_GET['a'] == 'spol') {
+ }
+ elseif ($_GET['a'] == 'spol') {
$this->ajax_glasovanje_spol();
- } elseif ($_GET['a'] == 'vote_spol') {
+ }
+ elseif ($_GET['a'] == 'vote_spol') {
$this->ajax_glasovanje_vote_spol();
- } elseif ($_GET['a'] == 'captcha') {
+ }
+ elseif ($_GET['a'] == 'captcha') {
$this->ajax_captcha();
- } elseif ($_GET['a'] == 'skin') {
+ }
+ elseif ($_GET['a'] == 'skin') {
$this->ajax_skin();
- } elseif ($_GET['a'] == 'grupa_for_if') {
+ }
+ elseif ($_GET['a'] == 'grupa_for_if') {
$this->ajax_grupa_for_if();
- } elseif ($_GET['a'] == 'enable_comments') {
+ }
+ elseif ($_GET['a'] == 'enable_comments') {
$this->ajax_enable_comments();
- } elseif ($_GET['a'] == 'continue_later') {
+ }
+ elseif ($_GET['a'] == 'continue_later') {
$this->ajax_continue_later();
- } elseif ($_GET['a'] == 'continue_later_send') {
+ }
+ elseif ($_GET['a'] == 'continue_later_send') {
$this->ajax_continue_later_send();
- } elseif ($_GET['a'] == 'usr_id_data') {
+ }
+ elseif ($_GET['a'] == 'usr_id_data') {
$this->ajax_delete_signature_data();
- }elseif ($_GET['a'] == 'get_tip_opozorila') {
+ }
+ elseif ($_GET['a'] == 'get_tip_opozorila') {
$this->ajax_get_tip_opozorila();
- } // genericna resitev za vse nadaljne
+ }
+ // genericna resitev za vse nadaljne
else {
$ajax = 'ajax_' . $_GET['a'];
if (method_exists($this, $ajax))
@@ -343,30 +371,22 @@ class AjaxController extends Controller
}
//asinhrono pobiranje podatkov za ureditev missing
- public function ajax_get_dragdrop1_data()
- {
+ public function ajax_get_dragdrop1_data(){
+
Model::user_not_lurker();
+
$anketa = $_GET['anketa'];
$spremenljivka = $_GET['spremenljivka'];
+
$vre_id = array();
- //echo 'Spremenljivka: '.$spremenljivka;
- //echo 'Anketa: '.$anketa;
- //$sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$spremenljivka' AND other!=0 ");
+
$sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$spremenljivka'");
$num = mysqli_num_rows($sql1);
- /* echo '
- <script>
- console.log('.$num.');
- </script>
- '; */
-
while ($row1 = mysqli_fetch_array($sql1)) {
- //$vre_id[$i] = $row1['id'];
array_push($vre_id, $row1['id']);
}
- //echo 'Podatek je: '.$num;
- //echo $vre_id;
+
echo json_encode($vre_id);
}
@@ -472,14 +492,6 @@ class AjaxController extends Controller
}
}
- // respondent se strinja z uporabo piskotvkov - nastavimo piskotek ok
- public function ajax_cookie_ok()
- {
-
- setcookie('cookie_ok', '1', time() + 2500000, '/');
-
- }
-
//izpis statistike glede na spol
public function ajax_glasovanje_spol()
{
@@ -494,7 +506,6 @@ class AjaxController extends Controller
*
*/
public function ajax_captcha(){
- global $secret_captcha;
$text = strtoupper($_GET['text']);
$code = $_GET['code'];
@@ -502,7 +513,7 @@ class AjaxController extends Controller
$usr_id = $_GET['usr_id'];
$recaptchaResponse = $_POST['g-recaptcha-response'];
- $request = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secret_captcha."&response=".$recaptchaResponse);
+ $request = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".AppSettings::getInstance()->getSetting('google-secret_captcha')."&response=".$recaptchaResponse);
// zdaj pa zabeleži mail (pred pošiljanjem)
// zdaj pa še v bazi tistih ki so se ročno dodali
@@ -556,6 +567,7 @@ class AjaxController extends Controller
public function ajax_continue_later(){
save('lang_id', (int)$_GET['language']);
+ save('anketa', (int)$_POST['anketa']);
$url = $_POST['url'] . '&return=1';
@@ -571,13 +583,14 @@ class AjaxController extends Controller
$srv_forma_send = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_forma_send' . $_lang);
if ($srv_forma_send == '') $srv_forma_send = self::$lang['srv_forma_send'];
+
echo '<div id="continue_later">';
echo '<p>' . $srv_continue_later_txt . ':</p><p class="url">' . $url . '</p>';
echo '<input type="hidden" name="url" id="url" value="' . $url . '">';
- echo '<p>' . $srv_continue_later_email . ': <input type="email" name="email" id="email" value="" placeholder="' . self::$lang['srv_email_example2'] . '"> <button type="submit" onclick="continue_later_send(\'' . self::$site_url . '\', \'' . get('lang_id') . '\'); return false;">' . $srv_forma_send . '</button></p>';
+ echo '<p>' . $srv_continue_later_email . ': <input type="email" name="email" id="email" value="" placeholder="' . self::$lang['srv_email_example2'] . '"> <button class="blue send_later" type="submit" onclick="continue_later_send(\'' . self::$site_url . '\', \'' . get('lang_id') . '\'); return false;">' . $srv_forma_send . '</button></p>';
echo '</div>';
}
@@ -610,6 +623,38 @@ class AjaxController extends Controller
catch (Exception $e) {
}
}
+
+ public function ajax_return_edit_send(){
+ global $mysql_database_name;
+
+ ob_clean();
+
+ $s = self::$lang['srv_return_edit_subject'];
+ $t = self::$lang['srv_return_edit_content'] . ': <a href="' . $_POST['url'] . '">' . $_POST['url'] . '</a>';
+
+ // Podpis
+ $signature = Common::getEmailSignature();
+ $t .= $signature;
+
+ $mail = $_POST['email'];
+
+ if ($mail == ''){
+ echo self::$lang['srv_continue_later_fail'];
+ return;
+ }
+
+ try {
+ $MA = new MailAdapter(get('anketa'), $type='alert');
+ $MA->addRecipients($mail);
+ $result = $MA->sendMail(stripslashes($t), $s);
+ }
+ catch (Exception $e) {
+ echo self::$lang['srv_continue_later_fail'];
+ return;
+ }
+
+ echo self::$lang['srv_continue_later_success'];
+ }
public function ajax_get_tip_opozorila() {
$spr_id = $_POST['spr_id'];
@@ -628,7 +673,7 @@ class AjaxController extends Controller
$spremenljivka = $_POST['spremenljivka'];
- echo '<h3>'.self::$lang['srv_prevAnswers'].'</h3>';
+ echo '<h2>'.self::$lang['srv_prevAnswers'].'</h2>';
$sql = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='".$spremenljivka."' AND usr_id!='".get('usr_id')."' ORDER BY id DESC");
while($row = mysqli_fetch_array($sql)){
@@ -638,8 +683,8 @@ class AjaxController extends Controller
}
// Gumb zapri
- echo '<div class="prevAnswers_button">';
- echo '<a href="#" onClick="hide_prevAnswers_all(\''.$spremenljivka.'\'); return false;"><span>'.self::$lang['srv_zapri'].'</span></a>';
+ echo '<div class="button_holder">';
+ echo ' <button class="medium blue" onClick="hide_prevAnswers_all(\''.$spremenljivka.'\'); return false;">'.self::$lang['srv_zapri'].'</button>';
echo '</div>';
echo '<script>
@@ -656,7 +701,7 @@ class AjaxController extends Controller
$gdpr_settings = GDPR::getSurveySettings($anketa);
- echo '<h3>'.$lang['srv_gdpr_survey_gdpr_about'].'</h3>';
+ echo '<h2>'.$lang['srv_gdpr_survey_gdpr_about'].'</h2>';
if($gdpr_settings['about'] == ''){
$about_array = GDPR::getGDPRInfoArray($anketa);
@@ -667,20 +712,42 @@ class AjaxController extends Controller
else{
echo nl2br($gdpr_settings['about']);
}
-
- echo '<br />';
+
// Gumb zapri
- echo '<div class="prevAnswers_button">';
- echo '<a href="#" onClick="hide_gdpr_about(); return false;"><span>'.$lang['srv_zapri'].'</span></a>';
+ echo '<div class="button_holder">';
+ echo ' <button class="medium blue" onClick="hide_gdpr_about(); return false;">'.$lang['srv_zapri'].'</button>';
echo '</div>';
echo '<script>
$("#fade").on("click", function() {
hide_gdpr_about();
});</script>';
-
- echo '<br />';
+ }
+
+ // Izpisemo popup s pogoji uporabe za modul dostop z emailom (mju)
+ public function ajax_show_email_access_terms() {
+ global $lang;
+
+ $anketa = $_POST['anketa'];
+
+
+ echo '<h2>'.$lang['user_agreement'].'</h2>';
+
+ $sea = new SurveyEmailAccess($anketa);
+ $terms_text = $sea->getEmailAccessSettings('terms_text');
+ echo nl2br($terms_text);
+
+
+ // Gumb zapri
+ echo '<div class="button_holder">';
+ echo ' <button class="medium blue" onClick="hide_email_access_terms(); return false;">'.$lang['srv_zapri'].'</button>';
+ echo '</div>';
+
+ echo '<script>
+ $("#fade").on("click", function() {
+ hide_email_access_terms();
+ });</script>';
}