summaryrefslogtreecommitdiffstats
path: root/admin/survey/modules/mod_chat/class.SurveyChat.php
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2022-01-11 12:35:47 +0100
committerAnton Luka Šijanec <anton@sijanec.eu>2022-01-11 12:35:47 +0100
commit19985dbb8c0aa66dc4bf7905abc1148de909097d (patch)
tree2cd5a5d20d7e80fc2a51adf60d838d8a2c40999e /admin/survey/modules/mod_chat/class.SurveyChat.php
download1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.gz
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.bz2
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.lz
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.xz
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.zst
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.zip
Diffstat (limited to 'admin/survey/modules/mod_chat/class.SurveyChat.php')
-rw-r--r--admin/survey/modules/mod_chat/class.SurveyChat.php82
1 files changed, 82 insertions, 0 deletions
diff --git a/admin/survey/modules/mod_chat/class.SurveyChat.php b/admin/survey/modules/mod_chat/class.SurveyChat.php
new file mode 100644
index 0000000..4f65b13
--- /dev/null
+++ b/admin/survey/modules/mod_chat/class.SurveyChat.php
@@ -0,0 +1,82 @@
+<?php
+
+/*
+ * Modul za chat z respondenti
+ *
+ * Zaenkrat se uporablja storitev TAWK
+ *
+ */
+
+
+class SurveyChat{
+
+ var $anketa; # id ankete
+
+
+ function __construct($anketa){
+ global $site_url;
+
+ // Ce imamo anketo
+ if ((int)$anketa > 0){
+ $this->anketa = $anketa;
+ }
+ }
+
+
+ // Nastavitve chat-a (na kateri strani se prikaze...)
+ public function displaySettings(){
+ global $lang;
+
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+
+ echo '<fieldset><legend>'.$lang['settings'].'</legend>';
+
+ // Koda za embed tawk chat widgeta
+ $code = '';
+ $sql = sisplet_query("SELECT * FROM srv_chat_settings WHERE ank_id='".$this->anketa."'");
+ if(mysqli_num_rows($sql) > 0){
+
+ $row = mysqli_fetch_array($sql);
+ $code = $row['code'];
+ }
+ echo '<span class="nastavitveSpan2" style="vertical-align:top;">'.$lang['srv_chat_code'].':</span>';
+ echo '<textarea id="chat_code" name="chat_code" rows="5" cold="20">'.$code.'</textarea>';
+
+ echo '<br /><br />';
+
+ // Prikaz vklopa chata
+ echo '<span class="nastavitveSpan2" >'.$lang['srv_chat_type'].':</span>';
+ echo '<input type="radio" name="chat_type" id="chat_type_0" value="0" '.(($row['chat_type'] == 0) ? ' checked="checked" ' : '').' /><label for="chat_type_0">'.$lang['srv_chat_type_0'].'</label>';
+ echo '<input type="radio" name="chat_type" id="chat_type_1" value="1" '.(($row['chat_type'] == 1) ? ' checked="checked" ' : '').' /><label for="chat_type_1">'.$lang['srv_chat_type_1'].'</label>';
+ echo '<input type="radio" name="chat_type" id="chat_type_2" value="2" '.(($row['chat_type'] == 2) ? ' checked="checked" ' : '').' /><label for="chat_type_2">'.$lang['srv_chat_type_2'].'</label>';
+
+ echo '<br /><br />';
+
+ echo '</fieldset>';
+
+
+ // Gumb shrani
+ echo '<br class="clr" />';
+ echo '<span class="floatLeft spaceRight"><div class="buttonwrapper"><a class="ovalbutton ovalbutton_orange btn_savesettings" href="#" onclick="chat_save_settings(); return false;"><span>';
+ echo $lang['edit1337'] . '</span></a></div></span>';
+ echo '<div class="clr"></div>';
+ echo '<div id="success_save"></div>';
+ }
+
+
+ public function ajax() {
+
+ if(isset($_GET['a']) && $_GET['a'] == 'save_settings'){
+
+ $code = isset($_POST['code']) ? $_POST['code'] : '';
+ $chat_type = isset($_POST['chat_type']) ? $_POST['chat_type'] : '0';
+
+ $sql = sisplet_query("INSERT INTO srv_chat_settings
+ (ank_id, code, chat_type) VALUES ('".$this->anketa."', '".$code."', '".$chat_type."')
+ ON DUPLICATE KEY UPDATE code='".$code."', chat_type='".$chat_type."'");
+ if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
+ }
+
+ }
+} \ No newline at end of file