diff options
Diffstat (limited to 'admin/survey/classes/class.Common.php')
-rw-r--r-- | admin/survey/classes/class.Common.php | 220 |
1 files changed, 161 insertions, 59 deletions
diff --git a/admin/survey/classes/class.Common.php b/admin/survey/classes/class.Common.php index 6f761b6..66946f0 100644 --- a/admin/survey/classes/class.Common.php +++ b/admin/survey/classes/class.Common.php @@ -19,7 +19,7 @@ class Common { // konstrutor
protected function __construct() {}
// kloniranje
- final private function __clone() {}
+ private function __clone() {}
/**
* Poskrbimo za samo eno instanco
@@ -42,10 +42,9 @@ class Common { {
if ($anketa) {
self::$anketa = $anketa;
- SurveyInfo::getInstance()->SurveyInit(self::$anketa);
- if (SurveyInfo::getInstance()->getSurveyColumn('db_table') == 1)
- self::$db_table = '_active';
+ SurveyInfo::getInstance()->SurveyInit(self::$anketa);
+ self::$db_table = SurveyInfo::getInstance()->getSurveyArchiveDBString();
}
}
@@ -240,9 +239,8 @@ class Common { $sql = sisplet_query("SELECT id FROM srv_user WHERE preview='1' AND time_edit < NOW() - INTERVAL 3 HOUR AND ank_id = '".$sid."'");
# polovimo vrsto tabel za to anketo
- $strDbTable = "SELECT db_table FROM srv_anketa WHERE id = $sid";
- $qryDbTable = sisplet_query($strDbTable);
- list($db_table) = mysqli_fetch_row($qryDbTable);
+ SurveyInfo::getInstance()->SurveyInit($sid);
+ $db_table = SurveyInfo::getInstance()->getSurveyArchiveDBString();
$list = '';
// se je dogajalo da je 0 ... pa se je pojavljal mysql_fetch error
@@ -255,6 +253,7 @@ class Common { }
if ($list != '') {
sisplet_query("BEGIN");
+
// tabela z respondenti
$deleted = sisplet_query("DELETE FROM srv_user WHERE preview='1' AND id IN ($list) AND ank_id = '$sid'");
@@ -311,6 +310,10 @@ class Common { global $admin_type;
global $global_user_id;
+ $anketa = 0;
+ $grupa = 0;
+ $spremenljivka = 0;
+
if (isset ($_REQUEST['spremenljivka']))
$spremenljivka = $_REQUEST['spremenljivka'];
if (isset ($_REQUEST['anketa']))
@@ -708,27 +711,15 @@ class Common { */
function getFromEmail() {
global $global_user_id, $site_domain;
- $MailFrom = 'info@1ka.si';
- # nastavimo pošiljatelja
- # za SAFE.SI naredimo hardcoded da se pošilja kao iz SAFE.SI
- if (strpos($site_domain, "safe.si") === false)
- {
- #nismo iz SAFE.SI
- $r = sisplet_query("SELECT value FROM misc WHERE what='AlertFrom'");
- list ($MailFrom) = mysqli_fetch_row($r);
- }
- else
- {
- # smo na SAFE.SI
- $MailFrom = 'info@safe.si';
- }
+ if(AppSettings::getInstance()->getSetting('email_server_settings-SMTPFrom') !== false)
+ $MailFrom = AppSettings::getInstance()->getSetting('email_server_settings-SMTPFrom');
# Če je slučanjo napaka nastavimo info@1ka.si
- if ($MailFrom == null || trim($MailFrom) == '' || !$this->validEmail($MailFrom))
- {
+ if ($MailFrom == null || trim($MailFrom) == '' || !$this->validEmail($MailFrom)){
$MailFrom = 'info@1ka.si';
}
+
return $MailFrom;
}
@@ -814,15 +805,21 @@ class Common { return $result;
}
- static function formatNumber ($value, $digit = 0, $form=null,$sufix = "") {
+ static function formatNumber ($value, $digit = 0, $form=null, $sufix = "") {
+
# Kako izpisujemo decimalke in tisočice
- $default_seperators = array( 0=>array('decimal_point'=>'.', 'thousands'=>','),
- 1=>array('decimal_point'=>',', 'thousands'=>'.'));
+ $default_seperators = array(
+ 'decimal_point' => '.',
+ 'thousands' => ','
+ /*0=>array('decimal_point'=>'.', 'thousands'=>','),
+ 1=>array('decimal_point'=>',', 'thousands'=>'.')*/
+ );
if (is_array($form) && isset($form['decimal_point'])&& isset($form['thousands'])) {
$decimal_point = $form['decimal_point'];
$thousands = $form['thousands'];
- } else {
+ }
+ else {
$decimal_point = $default_seperators['decimal_point'];
$thousands = $default_seperators['thousands'];
}
@@ -844,7 +841,7 @@ class Common { private $dataPiping_query = null; // kesiramo query, ker ga bomo ponavljali za vsako spremenljivko
public function dataPiping ($text, $usr_id, $loop_id=null, $lang_id=null) {
- if (stripos($text, "#") !== false) {
+ if ($text != null && stripos($text, "#") !== false) {
if ($this->dataPiping_query == null)
$this->dataPiping_query = sisplet_query("SELECT s.* FROM srv_spremenljivka s, srv_grupa g WHERE g.ank_id='".self::$anketa."' AND s.gru_id=g.id AND s.tip!='5' AND (s.tip < '10' OR s.tip = '17' OR s.tip = '22' OR s.tip = '25' OR s.tip='21')");
if (mysqli_num_rows($this->dataPiping_query))
@@ -1125,7 +1122,7 @@ class Common { while (!feof($f)) {
$r = fgets($f);
- if (strpos($r, "^".$nice_url.'\b(.*) ') !== false && strpos($r, "?anketa=".$ank_id."") !== false) {
+ if (strpos($r, "^".$nice_url.'\b') !== false && strpos($r, "?anketa=".$ank_id."") !== false) {
// kao pobrisemo vrstico
} else {
$output[] = $r;
@@ -1165,7 +1162,7 @@ class Common { while($rowS = mysqli_fetch_array($sqlS)){
- if (strpos($r, "^".$rowS['link'].'\b(.*) ') !== false && strpos($r, "?anketa=".$ank_id."&skupina=".$rowS['vre_id']."") !== false) {
+ if (strpos($r, "^".$rowS['link'].'\b') !== false && strpos($r, "?anketa=".$ank_id."&skupina=".$rowS['vre_id']."") !== false) {
// pobrisemo vrstico in vnos v bazi
$sqlD = sisplet_query("DELETE FROM srv_nice_links_skupine WHERE ank_id='$ank_id' AND nice_link_id='$row[id]' AND vre_id='$rowS[vre_id]'");
@@ -1217,7 +1214,7 @@ class Common { if($subdomain == 'english'){
// Nastavitve in podzavihki
- if ($_GET['anketa'] == '' && ($_GET['a'] == 'nastavitve' # in podzavihki
+ if ((!isset($_GET['anketa']) || $_GET['anketa'] == '') && ($_GET['a'] == 'nastavitve' # in podzavihki
|| $_GET['a'] == 'osn_pod'
|| $_GET['a'] == 'trajanje'
|| $_GET['a'] == 'dostop'
@@ -1606,7 +1603,7 @@ class Common { }
//Urejanje - Nastavitve
- else if ($_GET['anketa'] != '' && $_GET['a'] == 'nastavitve') {
+ else if ((!isset($_GET['anketa']) || $_GET['anketa'] == '') && $_GET['a'] == 'nastavitve') {
$help_url = 'https://www.1ka.si/d/en/help/user-guide/edit/settings';
}
@@ -2076,29 +2073,23 @@ class Common { return $help_url;
}
- // Nov algoritem za id ankete v url-ju (ni vec stevilka ampak string - vsako liho stevilko zamenjamo z ustrezno crko npr. 1234 -> A2C4)
- public static function encryptAnketaID($anketa_id){
+ // Nov algoritem za id ankete v url-ju za izpolnjevanje
+ public static function generateSurveyHash(){
+
+ $unique = false;
- // Ali imamo vklopljeno sifriranje id-ja anket v url-ju - ZENKRAT UGASNJENO
- //if(true){
- if(false){
- $anketa_arr = str_split($anketa_id);
- $anketa_string = '';
+ while(!$unique){
- foreach($anketa_arr as $pos => $num){
+ // Zgeneriramo random string z 8 znaki
+ $hash = substr(md5(uniqid(mt_rand(), true)), 0, 8);
- // Na lihih mestih pretvorimo stevilko v crko
- if($pos % 2 == 0)
- $anketa_string .= chr(97 + $num);
- else
- $anketa_string .= $num;
- }
- //$anketa_string = strtolower($anketa_string);
- }
- else
- $anketa_string = $anketa_id;
-
- return $anketa_string;
+ // Preverimo ce slucajno ze obstaja v bazi
+ $sql = sisplet_query("SELECT 1 FROM srv_anketa WHERE hash='".$hash."' LIMIT 1");
+ if (mysqli_num_rows($sql) == 0)
+ $unique = true;
+ }
+
+ return $hash;
}
// Algoritem, ki iz texta ustvari strukturo vprasanj in variabel (za uvoz anekte iz texta)
@@ -2148,21 +2139,132 @@ class Common { }
// Izpise obvestilo, da ni podatkov
- static function noDataAlert() {
+ static function noDataAlert($location='') {
global $lang;
+ global $anketa;
+ global $site_url;
echo '<div class="no_data_alert">';
- echo $lang['srv_data_no_data'];
+
+ if($lang['id'] == '1')
+ echo '<img src="/public/img/images/no_data.svg" />';
+ else
+ echo '<img src="/public/img/images/no_data_eng.svg" />';
+
+ if($location == 'status') {
+ echo '<h2>'.$lang['srv_dashboard_no_data'].'</h2>';
+ }
+ else {
+ echo '<h2>'.$lang['srv_data_no_data'].'</h2>';
+ }
+
+ echo '<div id="note">';
+ if($location == 'status') {
+ echo '<p>'.$lang['srv_data_no_data3'].'</p>';
+ }
+ else {
+ echo '<p>'.$lang['srv_data_no_data2'].'</p>';
+ }
+ echo '</div>';
+
+ if($location == 'status') {
+ $buttonA = 'index.php?anketa='.$anketa.'&a=branching'; //urejanje
+ $buttonB = 'index.php?anketa='.$anketa.'&a=testiranje'; //testiranje
+ $textA = $lang['edit2'];
+ $textB = $lang['srv_testiranje'];
+ $textC = $lang['srv_vabila'];
+ }
+ else {
+ $buttonA = 'index.php?anketa='.$anketa.'&a=testiranje&m=testnipodatki'; //avtomatski testni vnos
+ $buttonB = SurveyInfo::getSurveyLink() . '?preview=on&testdata=on'; //ročni testni vnos
+ $textA = $lang['srv_testiranje_vnosi2'];
+ $textB = $lang['srv_archive_test_data_text2a'];
+ $textC = $lang['srv_anketa_share'];
+ }
+
+ $buttonC = 'index.php?anketa='.$anketa.'&a=vabila'; //objava
+
+ echo '<div id="buttons">';
+ echo ' <a href="'.$buttonA.'"><button class="medium white-blue buttonA" onClick="window.location.href='.$buttonA.';return false;">'.$textA.'</button></a>';
+ echo ' <a href="'.$buttonB.'"><button class="medium white-blue buttonB" onClick="window.open('.$buttonB.', \'_blank\');return false;">'.$textB.'</button></a>';
+ echo ' <a href="'.$buttonC.'"><button class="medium blue buttonC">'.$textC.'</button></a>';
+ echo '</div>';
+
echo '</div>';
}
+ // Izpise obvestilo, da ni podatkov v javni povezavi
+ static function noDataAlertPublic($action) {
+ global $lang;
+ global $anketa;
+ global $site_url;
+
+ header('Cache-Control: no-cache');
+ header('Pragma: no-cache');
+
+ #izpišemo HTML
+ echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
+ echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';
+
+
+ echo '<head>';
+
+ echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
+ echo '<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />';
+ echo '<link type="text/css" href="'.$site_url.'admin/survey/minify/g=css" media="screen" rel="stylesheet" />';
+ echo '<link type="text/css" href="'.$site_url.'admin/survey/minify/g=cssPrint" media="print" rel="stylesheet" />';
+ echo '<style>';
+ echo 'body{box-sizing: border-box; padding: 40px 20px; width: 100%; display: flex; align-items: center; justify-content: center; flex-direction: column;} h2{font-weight: 300; font-size: 24px; margin-block-start: 0; margin-block-end: 0; margin-bottom: 16px; text-align: center;} img {width: 100%; max-width: 466px; margin-bottom: 32px;}';
+ echo '</style>';
+
+ echo '</head>';
+
+
+ echo '<body class="public_link data">';
+
+
+ switch ($action) {
+ case 'data':
+ case 'data_nijz':
+ echo '<h2>'.$lang['srv_publc_data_title_for'].SurveyInfo::getSurveyTitle() .'</h2>';
+ break;
+
+ case M_ANALYSIS_CHARTS:
+ echo '<h2>'.$lang['srv_publc_chart_title_for'].SurveyInfo::getSurveyTitle() .'</h2>';
+ break;
+
+ case M_ANALYSIS_CREPORT:
+ echo '<h2>'.$lang['srv_publc_creport_title_for'].SurveyInfo::getSurveyTitle() .'</h2>';
+ break;
+
+ case 'analysis':
+ echo '<h2>'.$lang['srv_publc_analysis_title_for'].SurveyInfo::getSurveyTitle() .'</h2>';
+ break;
+
+ default:
+ echo 'Error!';
+ break;
+ }
+
+ if($lang['id'] == '1')
+ echo '<img src="/public/img/images/no_data.svg" />';
+ else
+ echo '<img src="/public/img/images/no_data_eng.svg" />';
+
+ echo '<h2>'.$lang['srv_data_no_data'].'</h2>';
+
+ echo '</body>';
+
+
+ echo '</html>';
+ }
+
// Vrne string s signaturjem za email v ustreznem jeziku (default slovenski)
public static function getEmailSignature($lang_id = 0){
global $lang;
- global $app_settings;
- if(isset($app_settings['email_signature_custom']) && $app_settings['email_signature_custom'] == 1){
- $signature = '<br /><br /><br />'.$app_settings['email_signature_text'];
+ if(AppSettings::getInstance()->getSetting('app_settings-email_signature_custom') !== false){
+ $signature = '<br /><br /><br />'.AppSettings::getInstance()->getSetting('app_settings-email_signature_text');
}
else{
@@ -2174,9 +2276,9 @@ class Common { // Logo
if($lang['id'] == '1')
- $signature .= '<img src="https://www.1ka.si/public/img/logo/1ka_slo.png" width=90 style="width:90px; height:auto; border:0;" />';
+ $signature .= '<img src="https://www.1ka.si/public/img/logo/1ka_logo_slo.jpg" width=90 style="width:90px; height:auto; border:0;" />';
else
- $signature .= '<img src="https://www.1ka.si/public/img/logo/1ka_eng.png" width=90 style="width:90px; height:auto; border:0;" />';
+ $signature .= '<img src="https://www.1ka.si/public/img/logo/1ka_logo_eng.jpg" width=90 style="width:90px; height:auto; border:0;" />';
$signature .= '<br/>-------------------------------------------------------------------<br/>';
|