summaryrefslogtreecommitdiffstats
path: root/admin/survey/modules/mod_chat/class.SurveyChat.php
blob: 4f65b1389dcf14f81266d78115700cf975608b41 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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']);
		}

	}
}