diff options
Diffstat (limited to 'admin/survey/classes/class.VprasanjeInline.php')
-rw-r--r-- | admin/survey/classes/class.VprasanjeInline.php | 55 |
1 files changed, 24 insertions, 31 deletions
diff --git a/admin/survey/classes/class.VprasanjeInline.php b/admin/survey/classes/class.VprasanjeInline.php index 660a22f..e5e349d 100644 --- a/admin/survey/classes/class.VprasanjeInline.php +++ b/admin/survey/classes/class.VprasanjeInline.php @@ -31,8 +31,7 @@ class VprasanjeInline { SurveyInfo::getInstance()->SurveyInit($this->anketa);
- if (SurveyInfo::getInstance()->getSurveyColumn('db_table') == 1)
- $this->db_table = '_active';
+ $this->db_table = SurveyInfo::getInstance()->getSurveyArchiveDBString();
if (SurveyInfo::getInstance()->getSurveyColumn('expanded') == 1)
$this->expanded = 1;
@@ -71,8 +70,8 @@ class VprasanjeInline { $vrednost = $_POST['vrednost'];
$v = explode('_', $vrednost);
- $vrednost = $v[0];
- $vrednost2 = $v[1]; // naslov2 za diferencial
+ $vrednost = isset($v[0]) ? $v[0] : '';
+ $vrednost2 = isset($v[1]) ? $v[1] : ''; // naslov2 za diferencial
$purifier = New Purifier();
$naslov = $purifier->purify_DB($naslov);
@@ -216,7 +215,7 @@ class VprasanjeInline { function ajax_inline_grid_variable_save () {
Common::updateEditStamp();
- $variable = $_POST['variable'];
+ $variable = strip_tags($_POST['variable']);
$grid = $_POST['grid'];
@@ -356,11 +355,20 @@ class VprasanjeInline { $variable = $_POST['variable'];
$vre_id = $_POST['vre_id'];
- $sql = sisplet_query("SELECT variable FROM srv_vrednost WHERE id = '$vre_id'");
+ $sql = sisplet_query("SELECT variable, spr_id FROM srv_vrednost WHERE id = '".$vre_id."'");
$row = mysqli_fetch_array($sql);
if ($row['variable'] != $variable) {
- sisplet_query("UPDATE srv_vrednost SET variable='$variable', variable_custom='1' WHERE id = '$vre_id'");
+
+ // Preverimo, ce ze obstaja kaksna variabla z istim imenom - pri kvizu pa ima lahko isto ime
+ if(!SurveyInfo::getInstance()->checkSurveyModule('quiz')){
+
+ $sql2 = sisplet_query("SELECT id FROM srv_vrednost WHERE variable='".$variable."' AND spr_id='".$row['spr_id']."'");
+ if(mysqli_num_rows($sql2) > 0)
+ return false;
+ }
+
+ sisplet_query("UPDATE srv_vrednost SET variable='".$variable."', variable_custom='1' WHERE id='".$vre_id."'");
}
}
@@ -460,7 +468,6 @@ class VprasanjeInline { if ($lang_id != 0) {
if ($naslov != ''){
$s = sisplet_query("REPLACE INTO srv_language_grid (ank_id, spr_id, grd_id, lang_id, naslov) VALUES ('$anketa', '$this->spremenljivka', '$grid', '$lang_id', '$naslov')");
- //$s = sisplet_query("INSERT INTO srv_language_grid (ank_id, spr_id, grd_id, lang_id, naslov) VALUES ('$anketa', '$this->spremenljivka', '$grid', '$lang_id', '$naslov')");
}
else{
$s = sisplet_query("DELETE FROM srv_language_grid WHERE ank_id='$anketa' AND spr_id='$this->spremenljivka' AND grd_id='$grid' AND lang_id='$lang_id'");
@@ -486,40 +493,29 @@ class VprasanjeInline { if($TrenutnaLabela != ''){
- //echo "Update labele";
- $TipLabelepart1 = strchr($row['params'], $TipLabele."="); //iz stringa, kjer so vsi params izlusci le string od TipLabele dalje
- //print_r (explode("\n",$row['params'])); //explode(separator,string,limit)
- $newTipLabele = $TipLabele.'='.$Label; //formiraj nov tip labele z labelo
+
+ $TipLabelepart1 = strchr($row['params'], $TipLabele."="); //iz stringa, kjer so vsi params izlusci le string od TipLabele dalje
+
+ $newTipLabele = $TipLabele.'='.$Label; //formiraj nov tip labele z labelo
$explodedparams = explode("\n",$row['params']); //spremeni string v array
for($i=0; $i<=sizeof($explodedparams); $i++){ //za vse elemente array-a
- //echo 'Sem v for zanki';
+
if((strstr($explodedparams[$i], $TipLabele.'=') != '')){ //ce element array-a vsebuje besedilo z ustreznim tipom labele //strstr(string,search,before_search)
- //echo 'Smo dobili string na indeksu: '.$i;
- $indeks = $i; //zabele�i indeks
- //echo 'Indeks1: '.$indeks;
- //$explodedparams[$i] = $newTipLabele; //povozi ustrezen element array-a z novim tipom labele
- //echo 'Exploded: '.$explodedparams[$i];
+ $indeks = $i; //zabelezi indeks
}
}
- //echo 'Indeks2: '.$indeks;
$explodedparams[$indeks] = $newTipLabele; //povozi ustrezen element array-a z novim tipom labele
- //print_r ($explodedparams);
$newparams = implode("\n",$explodedparams); //zdruzi array ponovno v string
- //echo 'New params: '.$newparams;
- $s = sisplet_query("UPDATE srv_spremenljivka SET params = '$newparams' WHERE id='$this->spremenljivka'"); //posodobi params
+
+ $s = sisplet_query("UPDATE srv_spremenljivka SET params = '$newparams' WHERE id='$this->spremenljivka'"); //posodobi params
}
elseif ($TrenutnaLabela == ''){
$s = sisplet_query("UPDATE srv_spremenljivka SET params = CONCAT( srv_spremenljivka.params , '\n$TipLabele=$Label ') WHERE id='$this->spremenljivka'"); //k obstoje�im params dodaj �e naslednje
- //echo $Label;
- //print_r (explode("\n",$row['params'])); //explode(separator,string,limit)
- //echo "Trenutna labela je prazna";
}
}
-/* error_log($anketa);
- error_log($grid);
- error_log($naslov); */
+
if (!$s) echo mysqli_error($GLOBALS['connect_db']);
@@ -615,9 +611,6 @@ class VprasanjeInline { $Label = substr($Label, 0, -4);
}
-/* error_log("Label: ".$Label);
- error_log("TipLabele: ".$TipLabele);
- error_log("spr: ".$this->spremenljivka); */
$spremenljivkaParams->set($TipLabele, $Label);
|