SurveyAdmin = new SurveyAdmin($action);
if (isset ($surveySkin))
$this->skin = $surveySkin;
else
$this->skin = 0;
// polovimo anketa ID
if (isset ($_GET['anketa']))
$this->anketa = $_GET['anketa'];
elseif (isset ($_POST['anketa']))
$this->anketa = $_POST['anketa'];
elseif ($anketa != 0)
$this->anketa = $anketa;
UserSetting :: getInstance()->Init($global_user_id);
$this->icons_always_on = UserSetting :: getInstance()->getUserSetting('icons_always_on');
$this->full_screen_edit = UserSetting :: getInstance()->getUserSetting('full_screen_edit');
SurveyInfo::getInstance()->SurveyInit($this->anketa);
$this->db_table = SurveyInfo::getInstance()->getSurveyArchiveDBString();
$this->survey_type = $this->SurveyAdmin->getSurvey_type($this->anketa);
if ($_GET['a'] == 'branching' || $this->survey_type > 1)
$this->branching = 1;
if ($this->anketa > 0) {
// preverimo ali anketa sploh obstaja
if (!$this->SurveyAdmin->checkAnketaExist()) {
header('location: ' . $site_url . 'admin/survey/index.php');
} else
// preverimo userjev dostop // posebej je dovoljen dostop za pasiven do analize in reportov
if ($this->SurveyAdmin->checkDostop() || $this->SurveyAdmin->checkDostopAktiven() || $_GET['a']==A_ANALYSIS || $_GET['a']=='analiza' || $_GET['a']=='analizaReloadData' || $_GET['t']==A_ANALYSIS || $_GET['a']==A_REPORTI ) {
// ok
} else {
header('location: ' . $site_url . 'admin/main/login.php?l=' . base64_encode($_SERVER['REQUEST_URI']));
die(); // pri ajax klicih ne sme naprej, da ne more pisat v bazo
}
}
if ($action == 0) {
if (isset ($_GET['anketa'])) {
SurveyInfo :: getInstance()->SurveyInit($this->anketa);
if (isset ($_GET['grupa'])) {
$this->grupa = $_GET['grupa'];
} elseif (!isset ($_GET['a'])) {
$sql = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='$this->anketa' ORDER BY vrstni_red LIMIT 1");
$row = mysqli_fetch_array($sql);
$this->grupa = $row['id'];
if ($this->survey_type == 2)
header('Location: index.php?anketa=' . $this->anketa . '&grupa=' . $this->grupa . '');
}
}
// tole je, ce se inicializira v branhingu z $action=-1 (pa mogoce/najbrz se kje), da se ne prikazujejo 2x te meta podatki in redirecta...
} else {
if ($this->anketa == 0) die();
}
$this->stran = $_GET['a'];
}
/**
* @desc pohendla ajax zahteve
*/
function ajax() {
global $lang;
global $site_path;
global $site_url;
global $global_user_id;
if (isset ($_POST['spremenljivka']))
$spremenljivka = $_POST['spremenljivka'];
if (isset ($_POST['tip']))
$tip = $_POST['tip'];
if (isset ($_POST['survey_type']))
$survey_type = $_POST['survey_type'];
if (isset ($_POST['anketa'])) {
$anketa = $_POST['anketa'];
$this->anketa = $_POST['anketa'];
}
if (isset ($_POST['naslov']))
$naslov = $_POST['naslov'];
if (isset ($_POST['naslov2']))
$naslov2 = $_POST['naslov2'];
if (isset ($_POST['grupa']))
$grupa = $_POST['grupa'];
if (isset ($_POST['vrednost']))
$vrednost = $_POST['vrednost'];
if (isset ($_POST['serialize']))
$serialize = $_POST['serialize'];
if (isset ($_POST['thisgrupa']))
$thisgrupa = $_POST['thisgrupa'];
if (isset ($_POST['intro']))
$intro = $_POST['intro'];
if (isset ($_POST['concl']))
$concl = $_POST['concl'];
if (isset ($_POST['size']))
$size = $_POST['size'];
if (isset ($_POST['skala']))
$skala = $_POST['skala'];
if (isset ($_POST['undecided']))
$undecided = $_POST['undecided'];
if (isset ($_POST['grid']))
$grid = $_POST['grid'];
if (isset ($_POST['text']))
$text = $_POST['text'];
if (isset ($_POST['url']))
$url = $_POST['url'];
if (isset ($_POST['cookie']))
$cookie = $_POST['cookie'];
if (isset ($_POST['cookie_return']))
$cookie_return = $_POST['cookie_return'];
if (isset ($_POST['dostop']))
$dostop = $_POST['dostop'];
if (isset ($_POST['uid']))
$uid = $_POST['uid'];
if (isset ($_POST['variable']))
$variable = $_POST['variable'];
if (isset ($_POST['user_from_cms']))
$user_from_cms = $_POST['user_from_cms'];
if (isset ($_POST['skin']))
$skin = $_POST['skin'];
if (isset ($_POST['odgovarja']))
$odgovarja = $_POST['odgovarja'];
if (isset ($_POST['dostop_edit']))
$dostop_edit = $_POST['dostop_edit'];
if (isset ($_POST['branching']))
$this->branching = $_POST['branching'];
if (isset ($_POST['label']))
$label = strip_tags($_POST['label']);
if (isset ($_POST['cela']))
$cela = $_POST['cela'];
if (isset ($_POST['decimalna']))
$decimalna = $_POST['decimalna'];
if (isset ($_POST['enota']))
$enota = $_POST['enota'];
// posiljanje mailov ob obvescanju
if (isset ($_POST['alert_finish_respondent']))
$alert_finish_respondent = $_POST['alert_finish_respondent'];
if (isset ($_POST['alert_finish_respondent_cms']))
$alert_finish_respondent_cms = $_POST['alert_finish_respondent_cms'];
if (isset ($_POST['alert_finish_author']))
$alert_finish_author = $_POST['alert_finish_author'];
if (isset ($_POST['alert_finish_author_uid']))
$alert_finish_author_uid = $_POST['alert_finish_author_uid'];
if (isset ($_POST['alert_finish_other']))
$alert_finish_other = $_POST['alert_finish_other'];
if (isset ($_POST['alert_finish_other_emails']))
$alert_finish_other_emails = $_POST['alert_finish_other_emails'];
if (isset ($_POST['alert_finish_subject']))
$alert_finish_subject = $_POST['alert_finish_subject'];
if (isset ($_POST['alert_finish_text']))
$alert_finish_text = $_POST['alert_finish_text'];
if (isset ($_POST['alert_expire_days']))
$alert_expire_days = $_POST['alert_expire_days'];
if (isset ($_POST['alert_expire_author']))
$alert_expire_author = $_POST['alert_expire_author'];
if (isset ($_POST['alert_expire_author_uid']))
$alert_expire_author_uid = $_POST['alert_expire_author_uid'];
if (isset ($_POST['alert_expire_other']))
$alert_expire_other = $_POST['alert_expire_other'];
if (isset ($_POST['alert_expire_other_emails']))
$alert_expire_other_emails = $_POST['alert_expire_other_emails'];
if (isset ($_POST['alert_expire_subject']))
$alert_expire_subject = $_POST['alert_expire_subject'];
if (isset ($_POST['alert_expire_text']))
$alert_expire_text = $_POST['alert_expire_text'];
if (isset ($_POST['alert_delete_author']))
$alert_delete_author = $_POST['alert_delete_author'];
if (isset ($_POST['alert_delete_other']))
$alert_delete_other = $_POST['alert_delete_other'];
if (isset ($_POST['alert_delete_author_uid']))
$alert_delete_author_uid = $_POST['alert_delete_author_uid'];
if (isset ($_POST['alert_delete_other_emails']))
$alert_delete_other_emails = $_POST['alert_delete_other_emails'];
if (isset ($_POST['alert_delete_subject']))
$alert_delete_subject = $_POST['alert_delete_subject'];
if (isset ($_POST['alert_delete_text']))
$alert_delete_text = $_POST['alert_delete_text'];
if (isset ($_POST['alert_active_author']))
$alert_active_author = $_POST['alert_active_author'];
if (isset ($_POST['alert_active_author_uid']))
$alert_active_author_uid = $_POST['alert_active_author_uid'];
if (isset ($_POST['alert_active_other']))
$alert_active_other = $_POST['alert_active_other'];
if (isset ($_POST['alert_active_other_emails']))
$alert_active_other_emails = $_POST['alert_active_other_emails'];
if (isset ($_POST['alert_active_subject0']))
$alert_active_subject0 = $_POST['alert_active_subject0'];
if (isset ($_POST['alert_active_text0']))
$alert_active_text0 = $_POST['alert_active_text0'];
if (isset ($_POST['alert_active_subject1']))
$alert_active_subject1 = $_POST['alert_active_subject1'];
if (isset ($_POST['alert_active_text1']))
$alert_active_text1 = $_POST['alert_active_text1'];
// posiljanje mailov ob obvescanju
if (isset ($_POST['user_base']))
$user_base = $_POST['user_base'];
if (isset ($_POST['progressbar']))
$progressbar = $_POST['progressbar'];
if (isset ($_POST['spr_id']))
$spr_id = $_POST['spr_id'];
if (isset ($_POST['vre_id']))
$vre_id = $_POST['vre_id'];
if (isset ($_POST['usr_id']))
$usr_id = $_POST['usr_id'];
if (isset ($_POST['value']))
$value = $_POST['value'];
if (isset ($_POST['textfield']))
$textfield = $_POST['textfield'];
if (isset ($_POST['grd_id']))
$grd_id = $_POST['grd_id'];
if (isset ($_POST['timer']))
$timer = $_POST['timer'];
if (isset ($_POST['intro_opomba']))
$intro_opomba = strip_tags($_POST['intro_opomba']);
if (isset ($_POST['akronim']))
$akronim = $_POST['akronim'];
if (isset ($_POST['paramName']))
$paramName = $_POST['paramName'];
if (isset ($_POST['paramValue']))
$paramValue = $_POST['paramValue'];
if (isset ($_POST['antonucci']))
$antonucci = $_POST['antonucci'];
if (isset ($_POST['podpora']))
$podpora = $_POST['podpora'];
if (isset ($_POST['design']))
$design = $_POST['design'];
if (isset ($_POST['subject']))
$subject = $_POST['subject'];
if (isset ($_POST['grids']))
$grids = $_POST['grids'];
if (isset ($_POST['other']))
$other = $_POST['other'];
if (isset ($_POST['expire']))
$expire = $_POST['expire'];
if (isset ($_POST['starts']))
$starts = $_POST['starts'];
if (isset ($_POST['info']))
$info = $_POST['info'];
if (isset ($_POST['what']))
$what = $_POST['what'];
if (isset ($_POST['state']))
$state = $_POST['state'];
if (isset ($_POST['return_finished']))
$return_finished = $_POST['return_finished'];
if (isset ($_POST['subsequent_answers']))
$subsequent_answers = $_POST['subsequent_answers'];
if (isset ($_POST['cookie_continue']))
$cookie_continue = $_POST['cookie_continue'];
if (isset ($_POST['block_ip']))
$block_ip = $_POST['block_ip'];
if (isset ($_POST['child']))
$child = $_POST['child'];
if (isset ($_POST['reminder']))
$reminder = $_POST['reminder'];
if (isset ($_POST['min']))
$min = $_POST['min'];
if (isset ($_POST['results']))
$results = $_POST['results'];
if (isset ($_POST['vote_limit']))
$vote_limit = $_POST['vote_limit'];
if (isset ($_POST['vote_count']))
$vote_count = $_POST['vote_count'];
if (isset ($_POST['orientation']))
$orientation = $_POST['orientation'];
if (isset ($_POST['pid']))
$pid = $_POST['pid'];
if (strpos($_SERVER['HTTP_REFERER'], 'parent_if') !== false) {
$_GET['parent_if'] = substr( $_SERVER['HTTP_REFERER'], strpos($_SERVER['HTTP_REFERER'], 'parent_if')+10 );
}
SurveyInfo :: getInstance()->SurveyInit($this->anketa);
// vsilimo refresh podatkov
SurveyInfo :: getInstance()->resetSurveyData();
$this->survey_type = SurveyInfo :: getInstance()->getSurveyColumn('survey_type');
Setting :: getInstance()->Init($global_user_id);
// hendlanje AJAX zahtev (po novem so ene tudi obicne, ne-ajax)
if ($_GET['a'] == 'edit_anketa') {
Common::updateEditStamp();
if ($naslov != '' && $naslov != 'undefined') {
sisplet_query("UPDATE srv_anketa SET naslov='$naslov' WHERE id='$anketa'");
// vsilimo refresh podatkov
SurveyInfo :: getInstance()->resetSurveyData();
}
$sql = sisplet_query("SELECT naslov FROM srv_anketa WHERE id='$anketa'");
if (!$sql)
echo mysqli_error($GLOBALS['connect_db']);
$row = mysqli_fetch_array($sql);
// echo ' ';
echo ' ' . $row['naslov'] . ' ';
// echo $naslov;
}
elseif ($_GET['a'] == "anketaadddevice") {
// PDO bom moral dat da bo varno...ko bo čas... torej nikoli :)
$name = str_replace ("'", "", $_POST['tablet_name']);
$secret = str_replace ("'", "", $_POST['tablet_secret']);
$terminal_srv_id = intval($_POST['terminal_srv_id']);
$local_srv_id = intval($_POST['sid']);
if (is_numeric ($terminal_srv_id) && is_numeric ($local_srv_id) && $terminal_srv_id >0 && $local_srv_id > 0) {
$sql = sisplet_query("INSERT INTO srv_fieldwork (terminal_id, sid_terminal, sid_server, secret) VALUES ('" .$name ."', '" .$terminal_srv_id ."', '" .$local_srv_id ."', '" .$secret ."')");
}
header ('location: index.php?anketa=' .$local_srv_id .'&a=fieldwork');
}
elseif ($_GET['a'] == "anketadeldevice") {
// PDO bom moral dat da bo varno...ko bo čas... torej nikoli :)
$dev_id = intval($_GET['dev']);
if (is_numeric ($dev_id) && $dev_id >0) {
$sql = sisplet_query("DELETE FROM srv_fieldwork WHERE id='" .$dev_id ."'");
}
header ('location: index.php?anketa=' .$_GET['srv'] .'&a=fieldwork');
}
elseif ($_GET['a'] == 'edit_anketa_note') {
if ($anketa && isset ($_POST['note']) && $_POST['note'] != '' && $_POST['note'] != 'undefined') {
Common::updateEditStamp();
$sql = sisplet_query("UPDATE srv_anketa SET intro_opomba='" . strip_tags($_POST['note']) . "' WHERE id='$anketa'");
// vsilimo refresh podatkov
SurveyInfo :: getInstance()->resetSurveyData();
}
}
elseif ($_GET['a'] == 'edit_anketa_akronim') {
if ($anketa && isset ($_POST['akronim']) && $_POST['akronim'] != '' && $_POST['akronim'] != 'undefined') {
Common::updateEditStamp();
$sql = sisplet_query("UPDATE srv_anketa SET akronim='" . $_POST['akronim'] . "' WHERE id='$anketa'");
// vsilimo refresh podatkov
SurveyInfo :: getInstance()->resetSurveyData();
}
}
elseif ($_GET['a'] == 'quick_title_edit') {
$row = SurveyInfo::getInstance()->getSurveyRow();
$naslov = $row['naslov'];
$akronim = $row['akronim'];
echo '
';
}
elseif ($_GET['a'] == 'quick_title_edit_save') {
$update=array();
if (isset($_POST['naslov']) && trim($_POST['naslov']) != '') {
$update[] = " naslov='".strip_tags(trim($_POST['naslov']))."'";
}
if (isset($_POST['akronim']) && trim($_POST['akronim']) != '') {
$update[] = " akronim='".strip_tags(trim($_POST['akronim']))."'";
}
if (isset($_POST['intro_opomba']) /*&& trim($_POST['intro_opomba']) != ''*/) {
$update[] = " intro_opomba='".strip_tags(trim($_POST['intro_opomba']))."'";
}
if (count($update) > 0 ) {
sisplet_query("UPDATE srv_anketa SET ".implode(',',$update)." WHERE id='".$this->anketa."'");
SurveyInfo :: getInstance()->resetSurveyData();
if (isset($_POST['quick_settings']) && $_POST['quick_settings'] == 'true') {
echo $site_url . 'admin/survey/index.php?anketa=' . $_POST['anketa'].'&a='.A_QUICK_SETTINGS;
return;
}
if (isset($_GET['ajaxa']) && trim($_GET['ajaxa']) != '') {
echo $site_url . 'admin/survey/index.php?anketa=' . $_POST['anketa'].'&a='.$_GET['ajaxa'];
return;
} else {
echo $site_url . 'admin/survey/index.php?anketa=' . $_POST['anketa'];
return;
}
}
if (isset($_POST['quick_settings']) && $_POST['quick_settings'] == 'true') {
echo $site_url . 'admin/survey/index.php?anketa=' . $_POST['anketa'].'&a='.A_QUICK_SETTINGS;
return;
}
echo $site_url . 'admin/survey/index.php?anketa=' . $_POST['anketa'];
return;
}
elseif ($_GET['a'] == 'editanketaintro') {
Common::updateEditStamp();
$show_intro = $_POST['show_intro'];
$show_concl = $_POST['show_concl'];
$concl_link = $_POST['concl_link'];
$intro_opomba = strip_tags($_POST['intro_opomba']);
$concl_opomba = strip_tags($_POST['concl_opomba']);
if ($_POST['concl_link'] == 1)
$concl_link = 0;
else
$concl_link = 1;
$sql = sisplet_query("UPDATE srv_anketa SET
introduction='$intro', conclusion='$concl', text='$text', url='$url' ,
show_intro = '$show_intro', show_concl='$show_concl', concl_link='$concl_link',
intro_opomba = '$intro_opomba', concl_opomba = '$concl_opomba'
WHERE id='$anketa'");
// vsilimo refresh podatkov
SurveyInfo :: getInstance()->resetSurveyData();
header('Location: index.php?anketa=' . $anketa . '');
}
elseif ($_GET['a'] == 'settings_anketa') {
$this->anketa = $anketa;
$this->grupa = $grupa;
$this->SurveyAdmin->anketa_nastavitve();
}
elseif ($_GET['a'] == 'editanketasettings') {
Common::updateEditStamp();
#sistemske nastavitve
if ($_GET['m'] == 'system') {
if (isset ($_POST['SurveyDostop'])) {
$val = $_POST['SurveyDostop'];
if ($val >= 0) {
$sql = sisplet_query("UPDATE misc SET value='$val' WHERE what = 'SurveyDostop'");
if (!$sql)
echo mysqli_error($GLOBALS['connect_db']);
}
}
if (isset ($_POST['SurveyCookie'])) {
$val = $_POST['SurveyCookie'];
$sql = sisplet_query("UPDATE misc SET value='$val' WHERE what = 'SurveyCookie'");
if (!$sql)
echo mysqli_error($GLOBALS['connect_db']);
}
if (isset ($_POST['SurveyForum'])) {
$val = $_POST['SurveyForum'];
$sql = sisplet_query("UPDATE misc SET value='$val' WHERE what = 'SurveyForum'");
if (!$sql)
echo mysqli_error($GLOBALS['connect_db']);
}
// Save app settings
foreach($_POST as $what => $value){
if(substr($what, 0, 3) == 'as_'){
AppSettings::getInstance()->saveSetting(substr($what, 3), $value);
}
}
}
elseif ($_GET['m'] == 'global_user_settings') {
if (isset ($_POST['language'])) {
$lang = $_POST['language'];
sisplet_query("UPDATE users SET lang = '$lang' WHERE id = '$global_user_id'");
}
$poslane_spremenljivke = [
'advancedMySurveys',
'oneclickCreateMySurveys',
'lockSurvey',
'autoActiveSurvey',
'activeComments',
'showIntro',
'showConcl',
'showSurveyTitle',
'showSAicon',
'showLanguageShortcut'
];
foreach($poslane_spremenljivke as $post_variable) {
if (isset ($_POST[$post_variable])) {
$val = $_POST[$post_variable];
UserSetting::getInstance()->setUserSetting($post_variable, $val);
UserSetting::getInstance()->saveUserSetting();
}
}
} elseif ($_GET['m'] == 'global_user_myProfile') {
// preveri prejsnje podatke
$sqlU = sisplet_query ("SELECT name, surname, email, pass FROM users WHERE id='".$global_user_id."'");
$rowU = mysqli_fetch_assoc($sqlU);
$name_before = $rowU['name'];
$surname_before = $rowU['surname'];
$email_before = $rowU['email'];
$password_before = $rowU['pass'];
// Spremenimo ime
if (isset($_POST['ime']) && $_POST['ime'] != '' && $_POST['ime'] != $name_before) {
$checkIme = sisplet_query ("SELECT * FROM users WHERE name='".$_POST['ime']."' AND surname='" .$_POST['priimek']."' AND id!='".$global_user_id."'");
if (mysqli_num_rows ($checkIme) == 0){
$ime = $_POST['ime'];
//$ime = strtolower($_POST['ime']);
$ime = CleanXSS($ime);
$result = sisplet_query ("UPDATE users SET name='$ime' WHERE id='".$global_user_id."'");
}
}
// Spremenimo priimek
if (isset($_POST['priimek']) && $_POST['priimek'] != '' && $_POST['priimek'] != $surname_before) {
$checkIme = sisplet_query ("SELECT * FROM users WHERE name='".$_POST['ime']."' AND surname='" .$_POST['priimek']."' AND id!='".$global_user_id."'");
if (mysqli_num_rows ($checkIme) == 0){
$priimek = $_POST['priimek'];
//$priimek = strtolower($_POST['priimek']);
$priimek = CleanXSS($priimek);
$result = sisplet_query ("UPDATE users SET surname='$priimek' WHERE id='".$global_user_id."'");
}
}
// Obveščanje posodobi
if(isset($_POST['gdpr_agree'])){
sisplet_query ("UPDATE users SET gdpr_agree='".$_POST['gdpr_agree']."' WHERE id='".$global_user_id."'");
}
if(!empty($_POST['google-2fa']) && !empty($_POST['google-2fa-secret'])){
User::getInstance($global_user_id)->setOption('google-2fa-secret', $_POST['google-2fa-secret']);
User::getInstance($global_user_id)->setOption('google-2fa-validation', 'NOT');
}elseif(!empty($_POST['google_2fa_koda_validate']) && empty($_POST['google-2fa-secret'])){
$google2fa = new \Sonata\GoogleAuthenticator\GoogleAuthenticator();
$secret = User::option($global_user_id, 'google-2fa-secret');
if ($google2fa->checkCode($secret, $_POST['google_2fa_koda_validate'])) {
sisplet_query ("UPDATE user_options SET option_value=NOW() WHERE option_name='google-2fa-validation'");
echo 'success';
return true;
}
}
if(empty($_POST['google-2fa']) && !empty($_POST['google_2fa_akcija']) && $_POST['google_2fa_akcija'] == 'deactivate' && !empty($_POST['google_2fa_deaktiviraj'])){
$user_2fa = User::option($global_user_id, 'google-2fa-secret');
$user_2fa_validate = User::option($global_user_id, 'google_2fa_koda_validate');
$google2fa = new \Sonata\GoogleAuthenticator\GoogleAuthenticator();
if($google2fa->checkCode($user_2fa, $_POST['google_2fa_deaktiviraj']) && $user_2fa_validate != 'NOT'){
sisplet_query("DELETE FROM user_options WHERE user_id='".$global_user_id."' AND option_name IN ('google-2fa-secret', 'google-2fa-validation')");
echo 'success';
return true;
}
else{
echo 'error';
return true;
}
}
//Uporabnik si ni kode shranil
if(empty($_POST['google-2fa']) && !empty($_POST['google_2fa_akcija']) && $_POST['google_2fa_akcija'] == 'reset'){
if(User::option($global_user_id, 'google-2fa-validation') == 'NOT') {
sisplet_query("DELETE FROM user_options WHERE user_id='".$global_user_id."' AND option_name IN ('google-2fa-secret', 'google-2fa-validation')");
echo 'success';
return true;
}
}
// Spremenimo geslo
if (isset($_POST['geslo']) && $_POST['geslo'] != '' && $_POST['geslo'] != $password_before) {
global $pass_salt;
global $cookie_domain;
$geslo = $_POST['geslo'];
$geslo = CleanXSS ($geslo);
if (isset($_POST['geslo'])
&& $_POST['geslo'] != "PRIMERZELODOLGEGAGESLA"
&& $password_before != base64_encode((hash('SHA256', $geslo.$pass_salt)))
&& $_POST['geslo'] == $_POST['geslo2']){
$result = sisplet_query ("UPDATE users SET pass='".base64_encode((hash('SHA256', $geslo.$pass_salt)))."' WHERE id='".$global_user_id."'");
setcookie('uid', '', time() - 3600, '/', $cookie_domain);
setcookie('secret', '', time() - 3600, '/', $cookie_domain);
setcookie('unam', '', time() - 3600, '/', $cookie_domain);
global $site_frontend;
if($site_frontend == 'drupal') {
setcookie('spremembaGesla', '1', time() + 3600, '/',
$cookie_domain);
}
}
}
// Alternativni emaili
if (isset($_POST['alternative_email']) && validEmail($_POST['alternative_email'])) {
global $pass_salt;
$email = $_POST['alternative_email'];
// naredi link za aktivacijo
$code = base64_encode((hash('SHA256', time() .$pass_salt . $email. $rowU['name'])));
//Preverimo, koliko alternativnih emailov ima (dovolimo samo 10)
$sql_user_to_be = sisplet_query ("SELECT count(id) AS skupaj FROM users_to_be WHERE user_id='" . $global_user_id . "'");
$row_user_to_be = mysqli_fetch_array($sql_user_to_be);
if($row_user_to_be['skupaj'] > 10){
echo 'error';
return true;
}
// Vstavimo novega userja v users_to_be kjer caka na aktivacijo
$insert_id = sisplet_query ("INSERT INTO users_to_be
(type, email, name, user_id, timecode, code, lang)
VALUES
('3', '".$email."', '".$rowU['name']."', '".$global_user_id."', '".time()."', '$code', '" .$lang['id']. "')", "id");
$poslji_email = [];
$PageName = AppSettings::getInstance()->getSetting('app_settings-app_name');
// Pošljemo email na alternativni email in nato še na primarni email samo obvestilo o dodanem emailu
$poslji_email['novi'] = [
'email' => $email,
'naslov' => str_replace ("#PAGENAME#", $PageName, $lang['add_alternative_email_subject'])
];
$poslji_email['primarni'] = [
'email' => $email_before,
'naslov' => str_replace ("#PAGENAME#", $PageName, $lang['add_alternative_primary_email_subject'])
];
$uporabnik = sisplet_query("SELECT name, surname FROM users WHERE id='".$global_user_id."'", "obj");
// Sporočilo, ki ga posredujemo na nov email za aktivacijo
$alVsebina = str_replace ("#PRIMARNIEMAIL#", $email_before, $lang['add_alternative_email']);
$alVsebina = str_replace ("#ALTERNATIVNIEMAIL#", $email, $alVsebina);
$alVsebina = str_replace ("#NAME#", $uporabnik->name .' ' .$uporabnik->surname, $alVsebina);
$alVsebina = str_replace ("#PAGENAME#", $PageName, $alVsebina);
$alVsebina = str_replace ("#CODESTART#", '', $alVsebina);
$alVsebina = str_replace ("#CODEEND#", ' ', $alVsebina);
// Pošljemo še email na primarni email
$prVsebina= str_replace ("#ALTERNATIVNIEMAIL#", $email, $lang['add_alternative_primary_email']);
$prVsebina= str_replace ("#NAME#", $uporabnik->name .' ' .$uporabnik->surname, $prVsebina);
$prVsebina= str_replace ("#PAGENAME#", $PageName, $prVsebina);
// Podpis
$signature = Common::getEmailSignature();
$poslji_email['novi']['vsebina'] = $alVsebina . $signature;
$poslji_email['primarni']['vsebina'] = $prVsebina. $signature;
foreach($poslji_email as $poslji) {
try {
$MA = new MailAdapter();
$MA->addRecipients($poslji['email']);
$MA->sendMail(stripslashes($poslji['vsebina']), $poslji['naslov']);
} catch (Exception $e) {
error_log("Email pri dodajanju emaila ni bil poslan: $e");
}
}
echo 'success';
return true;
}
if (isset($_POST['active_email']) && $_POST['active_email'] != 'new') {
$emails = User::getInstance()->allEmails('without master');
foreach($emails as $email){
$active = 0;
if($email->id == $_POST['active_email'] )
$active = 1;
sisplet_query("UPDATE user_emails SET active='".$active."' WHERE id='".$email->id."'");
}
}
if (isset($_POST['izbrisiAlternativniEmail']) && $_POST['izbrisiAlternativniEmail'] == 1 && !empty($_POST['alternativniEmailId'])) {
sisplet_query("DELETE FROM user_emails WHERE user_id='".$global_user_id."' AND id='".$_POST['alternativniEmailId']."'");
}
// Izbriše račun - v bazi posatvimo na 0 in spremenimo email, da je bil odjavljen
if (isset($_POST['izbrisiRacun']) && $_POST['izbrisiRacun'] == 1) {
global $cookie_domain;
$result = sisplet_query ("UPDATE users SET status=0, email=CONCAT('UNSU8MD-', UNIX_TIMESTAMP(), email) WHERE id='".$global_user_id."'");
setcookie ('uid', '', time()-3600, '/', $cookie_domain);
setcookie ('secret', '', time()-3600, '/', $cookie_domain);
setcookie ('unam', '', time()-3600, '/', $cookie_domain);
echo 'izbrisan';
return null;
}
} elseif ($_GET['m'] == A_MAILING || $_GET['m'] == 'inv_server' || $_GET['m'] == 'email_server') { // smtp mailing
if ($_POST['submited'] == 1){
if ((int)$_POST['anketa'] > 0){
$this->anketa = $_POST['anketa'];
}
// Squalo vklopljen
if(isset($_POST['squalo_mode'])){
// Squalo vklopljen
if($_POST['squalo_mode'] == '1'){echo $_POST['squalo_mode'];
sisplet_query("UPDATE srv_anketa_module SET vrednost='2' WHERE ank_id='".$this->anketa."' AND modul='email'");
}
// Squalo izklopljen
else{
sisplet_query("UPDATE srv_anketa_module SET vrednost='1' WHERE ank_id='".$this->anketa."' AND modul='email'");
$MA = new MailAdapter($this->anketa, $type='alert');
$settings = $MA->getSettingsFromRequest($_REQUEST);
$mode = $_REQUEST['SMTPMailMode'];
$MA->setSettings($mode, $settings);
}
}
else{
$MA = new MailAdapter($this->anketa, $type='alert');
$settings = $MA->getSettingsFromRequest($_REQUEST);
$mode = $_REQUEST['SMTPMailMode'];
$MA->setSettings($mode, $settings);
}
}
} elseif ($_GET['m'] == 'predvidenicasi') { // predvideni casi
foreach($_POST AS $key => $val) {
if (substr($key, 0, 7) == 'timing_') {
GlobalMisc::setMisc($key, $val);
}
}
} else { // globalne nastavitve
if (isset ($_POST['phone']) || isset ($_POST['email'])) {
$phone = $_POST['phone'];
$email = $_POST['email'];
// nastavimo respondente iz baze, kreiramo novo sistemsko spremenljivko
if ($phone == 1 or $email == 1) {
$this->SurveyAdmin->createUserbaseSystemVariable($phone, $email);
$user_base = 1;
} else {
$this->SurveyAdmin->createUserbaseSystemVariable($phone, $email);
$user_base = 0;
$_POST['user_base'] = 0;
}
}
SurveySetting::getInstance()->Init($this->anketa);
if (isset($_POST['resp_change_lang'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('resp_change_lang', $_POST['resp_change_lang']);
}
if (isset($_POST['resp_change_lang_type'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('resp_change_lang_type', $_POST['resp_change_lang_type']);
}
if (isset($_POST['display_backlink'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('display_backlink', $_POST['display_backlink']);
}
if (isset($_POST['mobile_friendly'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('mobile_friendly', $_POST['mobile_friendly']);
}
if (isset($_POST['hide_mobile_img'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('hide_mobile_img', $_POST['hide_mobile_img']);
}
if (isset($_POST['mobile_tables'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('mobile_tables', $_POST['mobile_tables']);
}
if (isset($_POST['pc_tables'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('pc_tables', $_POST['pc_tables']);
}
if (isset($_POST['export_font_size'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('export_font_size', $_POST['export_font_size']);
}
if (isset($_POST['export_numbering'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('export_numbering', $_POST['export_numbering']);
}
if (isset($_POST['export_show_if'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('export_show_if', $_POST['export_show_if']);
}
if (isset($_POST['export_show_intro'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('export_show_intro', $_POST['export_show_intro']);
}
if (isset($_POST['export_data_type'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('export_data_type', $_POST['export_data_type']);
}
if (isset($_POST['export_data_font_size'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('export_data_font_size', $_POST['export_data_font_size']);
}
if (isset($_POST['export_data_numbering'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('export_data_numbering', $_POST['export_data_numbering']);
}
if (isset($_POST['export_data_show_if'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('export_data_show_if', $_POST['export_data_show_if']);
}
if (isset($_POST['export_data_show_recnum'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('export_data_show_recnum', $_POST['export_data_show_recnum']);
}
if (isset($_POST['export_data_PB'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('export_data_PB', $_POST['export_data_PB']);
}
if (isset($_POST['export_data_skip_empty'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('export_data_skip_empty', $_POST['export_data_skip_empty']);
}
if (isset($_POST['export_data_skip_empty_sub'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('export_data_skip_empty_sub', $_POST['export_data_skip_empty_sub']);
}
if (isset($_POST['export_data_landscape'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('export_data_landscape', $_POST['export_data_landscape']);
}
if (isset($_POST['privacy'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('survey_privacy', $_POST['privacy']);
}
if (isset($_POST['survey_hint'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('survey_hint', $_POST['survey_hint']);
}
if (isset($_POST['survey_hide_title'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('survey_hide_title', $_POST['survey_hide_title']);
}
if (isset($_POST['survey_track_reminders'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('survey_track_reminders', $_POST['survey_track_reminders']);
}
if (isset($_POST['enumerate'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('enumerate', $_POST['enumerate']);
}
if (isset($_POST['anketa_folder'])) {
if($_POST['anketa_folder'] == '0'){
$sql = sisplet_query("DELETE FROM srv_mysurvey_anketa WHERE ank_id='".$anketa."' AND usr_id='".$global_user_id."'");
}
else{
// Razpremo folder v akterega uvrscamo anketo
$sql = sisplet_query("UPDATE srv_mysurvey_folder SET open='1' WHERE id='".$_POST['anketa_folder']."' AND usr_id='".$global_user_id."'");
// Vstavimo anketo
$sql = sisplet_query("INSERT INTO srv_mysurvey_anketa (ank_id, usr_id, folder) VALUES ('".$anketa."', '".$global_user_id."', '".$_POST['anketa_folder']."') ON DUPLICATE KEY UPDATE folder='".$_POST['anketa_folder']."'");
}
}
// shranjujemo dodatne prevode besedil...
if (isset($_POST['extra_translations'])) {
// Preverimo, če dobimo podatek za izbris vseh prevodov
$post = $_POST;
if(!empty($_POST['remove_lang'])){
$post = [];
parse_str($_POST['data'], $post);
}
foreach ($post AS $key => $val) {
if (substr($key, 0, 8) == 'srvlang_') {
if ($val != '' && empty($_POST['remove_lang'])) {
// očistimo HTML tage, če gre za gumbe
if (in_array(substr($key, 8), [
'srv_nextpage',
'srv_nextpage_uvod',
'srv_prevpage',
'srv_lastpage',
'srv_forma_send',
'srv_konec'
])) {
$val = strip_tags($val);
}
// Počistimo besedilo preden shranimo v bazo, saj je bila težava za tuje jezike
$purifier = New Purifier();
$val = $purifier->purify_DB($val);
SurveySetting::getInstance()->setSurveyMiscSetting($key, $val);
} else {
SurveySetting::removeSurveyMiscSetting($key);
}
// pri osnovnem jeziku vnesemo 2x - enkrat brez pripone ID jezika, enkrat s pripono (ker se nekje uporablja eno, nekje drugo...)
if (! is_numeric(substr($key, strrpos($key, '_') + 1))) {
if ($val != '') {
SurveySetting::getInstance()->setSurveyMiscSetting($key.'_'.SurveyInfo::getInstance()->getSurveyColumn('lang_resp'), $val);
} else {
SurveySetting::removeSurveyMiscSetting($key.'_'.SurveyInfo::getInstance()->getSurveyColumn('lang_resp'));
}
}
}
}
}
// Ce imamo vec jezikov popravimo vrednost v sistemskem vprasanju "language"
if(isset($_POST['lang_resp'])){
// Popravljamo samo ce imamo vec jezikov
$sqlL = sisplet_query("SELECT lang_id FROM srv_language WHERE ank_id='$this->anketa'");
if (mysqli_num_rows($sqlL) > 0){
$new_resp_lang_id = $_POST['lang_resp'];
$old_resp_lang_id = SurveyInfo::getInstance()->getSurveyColumn('lang_resp');
// Dobimo id vprasanja
$sqlS = sisplet_query("SELECT s.id AS spr_id FROM srv_spremenljivka s, srv_grupa g WHERE g.ank_id='$this->anketa' AND s.gru_id=g.id AND s.skupine='3'");
$spr_id = 0;
if(mysqli_num_rows($sqlS) > 0){
$rowS = mysqli_fetch_array($sqlS);
$spr_id = $rowS['spr_id'];
if($spr_id > 0){
$p = new Prevajanje($this->anketa);
$bck_lang_id = $lang['id'];
// Pobrisemo staro vrednost default jezika za respondente
$p->include_lang($old_resp_lang_id);
// Noce prjet zaradi čšž-jev tko da je to se najlazje:)
if (strcmp($lang['language'], 'Slovenščina') == 0)
$sqlV = sisplet_query("DELETE FROM srv_vrednost WHERE naslov='Slovenščina' AND spr_id='$spr_id'");
else
$sqlV = sisplet_query("DELETE FROM srv_vrednost WHERE naslov='".$lang['language']."' AND spr_id='$spr_id'");
// Dodamo novo vrednost v vprasanje "language"
$v = new Vprasanje($this->anketa);
$v->spremenljivka = $spr_id;
$p->include_lang($new_resp_lang_id);
$vre_id = $v->vrednost_new($lang['language']);
// Preklopimo nazaj na originalen jezik
$p->include_lang($bck_lang_id);
// Prestevilcimo in popravimo vrstni red
Common::repareVrednost($spr_id);
Common::prestevilci($spr_id);
}
}
}
}
// Zaradi zavihkov sproti preverjamo katere variable lahko shranimo če so bile podane preko $_POST
$allVariableToSave = array (
'naslov',
'akronim',
'intro_opomba',
'cookie',
'cookie_return',
'return_finished',
'subsequent_answers',
'cookie_continue',
'user_from_cms',
'user_base',
'phone',
'email',
'social_network',
'quiz',
'uporabnost',
'usercode_skip',
'usercode_required',
'usercode_text',
'block_ip',
'starts',
'expire',
'dostop',
'odgovarja',
'vote_limit',
'vote_count',
'form_open',
'lang_admin',
'lang_resp',
'multilang',
'slideshow',
'mass_insert',
'show_email',
'show_concl',
'concl_link',
'url',
'conclusion',
'concl_end_button',
'concl_back_button',
'vprasanje_tracking',
'continue_later',
'js_tracking',
'defValidProfile',
'parapodatki'
);
// ce mamo radio: user_from_cms potem mamo tudi checkbox user_from_cms_email
if(isset($_POST['user_from_cms'])) {
$allVariableToSave[] = 'user_from_cms_email';
if (!isset($_POST['user_from_cms_email']))
$_POST['user_from_cms_email'] = 0;
if ($_POST['user_from_cms']==2 && !isset($_POST['cookie']))
$_POST['cookie'] = -1;
}
$setString = "";
$prefix = "";
foreach ($allVariableToSave as $value) {
if (isset ($_POST[$value]) ) {
$setString .= $prefix . $value . " = '" . $_POST[$value] . "'"; // tale se ze zanasa na mysqli_real_escape_string($GLOBALS['connect_db'], _string() v function.php
$prefix = ", ";
}
}
# če je anketa označena kot trajna, jo hkrati aktiviramo če še ni
if (isset($_POST['trajna_anketa']) && $_POST['trajna_anketa'] == 'on') {
$setString .= $prefix . "active = '1'";
$prefix = ", ";
}
if ($setString != "") {
$sql = sisplet_query("UPDATE srv_anketa SET " . $setString . " WHERE id='$anketa'") or die(mysqli_error($GLOBALS['connect_db']));
// vsilimo refresh podatkov
SurveyInfo :: getInstance()->resetSurveyData();
}
if (isset($_POST['progressbar'])) {
$sql = sisplet_query("UPDATE srv_anketa SET progressbar='$_POST[progressbar]' WHERE id='$anketa'");
}
if (isset($_POST['quiz']) && $_POST['quiz'] == 1) { // za kviz je anketa vedno v pogoji in bloki načinu
sisplet_query("UPDATE srv_anketa SET survey_type='3' WHERE id = '$anketa'");
ob_start();
$ba = new BranchingAjax($this->anketa);
$ba->ajax_dodaj_blok_interpretacije();
ob_get_clean();
}
// nastavitve za knjiznico
if (isset($_POST['javne_ankete'])) {
if ($_POST['javne_ankete'] == 1) {
$sqlk = sisplet_query("SELECT * FROM srv_library_anketa WHERE ank_id='$this->anketa' AND uid='0'");
if (mysqli_num_rows($sqlk) == 0) {
$sql1 = sisplet_query("SELECT id FROM srv_library_folder WHERE uid='0' AND tip='1' AND parent='0' AND lang='$lang[id]'");
$row1 = mysqli_fetch_array($sql1);
sisplet_query("INSERT INTO srv_library_anketa (ank_id, uid, folder) VALUES ('$this->anketa', '0', '$row1[id]')");
}
} else {
sisplet_query("DELETE FROM srv_library_anketa WHERE ank_id='$this->anketa' AND uid='0'");
}
}
if (isset($_REQUEST['moje_ankete'])) {
if ($_REQUEST['moje_ankete'] == 1) {
$sqlk = sisplet_query("SELECT * FROM srv_library_anketa WHERE ank_id='$this->anketa' AND uid='$global_user_id'");
if (mysqli_num_rows($sqlk) == 0) {
$sql1 = sisplet_query("SELECT id FROM srv_library_folder WHERE uid='$global_user_id' AND tip='1' AND parent='0'");
$row1 = mysqli_fetch_array($sql1);
sisplet_query("INSERT INTO srv_library_anketa (ank_id, uid, folder) VALUES ('$this->anketa', '$global_user_id', '$row1[id]')");
}
} else {
sisplet_query("DELETE FROM srv_library_anketa WHERE ank_id='$this->anketa' AND uid='$global_user_id'");
}
}
if (isset($_POST['multilang']) && $_POST['multilang'] == 1) {
$this->SurveyAdmin->createUserbaseSystemVariable(0, 0, 1);
}
SurveySetting::getInstance()->Init($anketa);
$surveysetting = array(
'survey_comment',
'survey_comment_showalways',
'question_comment',
'survey_comment_viewadminonly',
'survey_comment_viewauthor',
'question_comment_viewadminonly',
'question_comment_viewauthor',
'question_resp_comment_viewadminonly',
'question_resp_comment_inicialke',
'question_resp_comment_inicialke_alert',
'question_resp_comment',
'survey_comment_resp',
'survey_comment_showalways_resp',
'survey_comment_viewadminonly_resp',
'survey_comment_viewauthor_resp',
'question_comment_text',
'question_note_write',
'question_note_view',
'question_resp_comment_show_open',
'sortpostorder',
'addfieldposition',
'commentmarks',
'commentmarks_who',
'comment_history',
'survey_ip',
'survey_show_ip',
'survey_browser',
'survey_js',
'survey_referal',
'survey_date',
'preview_disableif',
'preview_disablealert',
'preview_displayifs',
'preview_displayvariables',
'preview_hidecomment',
'preview_hide_survey_comment',
'preview_survey_comment_showalways',
'preview_disable_test_insert',
);
foreach ($surveysetting AS $key) {
if ( isset($_POST[$key]) )
SurveySetting::getInstance()->setSurveyMiscSetting($key, $_POST[$key]);
}
// shranjujemo skrivanje metapodatkov
if (isset($_POST['hide_metadata'])) {
foreach ($_POST AS $key => $val) {
if (substr($key, 0, 14) == 'hide_metadata_') {
if ($val == 1)
SurveySetting::getInstance()->setSurveyMiscSetting($key, '1');
else
SurveySetting::removeSurveyMiscSetting($key);
}
}
}
if (isset($dostop_edit) && $dostop_edit == 1 && isset($global_user_id) && $global_user_id > 0) {
global $admin_type;
$uid = $_POST['uid'];
// ne pustimo da ni izbran noben user, ker potem nihče več nima dostopa do ankete zato dodamo kontrolo na global_user_id
// prav tako ne smemo onemogočiti dostopa avtorju
$avtorSql = sisplet_query("SELECT insert_uid FROM srv_anketa WHERE id='" . $this->anketa . "'");
$avtorRow = mysqli_fetch_assoc($avtorSql);
// da ne more zbrisat avtorja
$avtorPogoj = (isset ($avtorRow['insert_uid']) && $avtorRow['insert_uid'] > 0) ? " AND (uid != ".$avtorRow['insert_uid']." )" : "";
// da ne more zbrisat sam sebe
$avtorID = " AND uid != '" . $global_user_id . "'";
if ($admin_type == 0) {
$avtorPogoj = '';
$avtorID = '';
}
$uid_canedits = " AND uid NOT IN (".implode(',', $uid).") ";
$sql = sisplet_query("DELETE FROM srv_dostop WHERE ank_id='$anketa' ". $avtorID . $avtorPogoj . $uid_canedits);
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
if (isset ($uid) && $uid != null && is_array($uid))
foreach ($uid AS $val) {
//if ($val != $global_user_id)
$sql = sisplet_query("INSERT INTO srv_dostop (ank_id, uid, aktiven) VALUES ('$anketa', '$val', '1')");
}
// pasivnih ni vec.....................
if (isset($_POST['uid_passive']) && $_POST['uid_passive'] != null && is_array($_POST['uid_passive']))
foreach ($_POST['uid_passive'] AS $val) {
//if ($val != $global_user_id)
$sql = sisplet_query("INSERT INTO srv_dostop (ank_id, uid, aktiven) VALUES ('$anketa', '$val', '0')");
}
if (isset($_POST['dostop_language'])) {
sisplet_query("DELETE FROM srv_dostop_language WHERE ank_id = '$anketa'");
foreach ($_POST['dostop_language'] AS $val) {
$val = explode('-', $val);
$uid = $val[0];
$lang_id = $val[1];
sisplet_query("INSERT INTO srv_dostop_language (ank_id, uid, lang_id) VALUES ('$anketa', '$uid', '$lang_id')");
}
}
}
if (isset($_POST['comment_send']) && $_POST['comment_send'] != '') {
// nastavitev, da se okno s komentarji prvic prikaze odprto
if ($_POST['srv_c_alert'] == '1')
$ocena = 5;
else $ocena = 0;
$ba = new BranchingAjax($this->anketa);
$ba->ajax_comment_manage(0, 0, $_POST['comment_send'], $ocena);
// posiljanje komentarjev na maile
if ($_POST['srv_c_to_mail'] == '1') {
$sr = SurveyInfo::getSurveyRow();
foreach ($_POST['mails'] AS $email) {
//$email = $rowa['email'];
$content = $_POST['comment_send'].' '.$site_url.'admin/survey/index.php?anketa='.$this->anketa.' ';
$subject = $lang['srv_admin_s_comments'].': '.$sr['naslov'];
try
{
$MA = new MailAdapter($this->anketa, $type='alert');
$MA->addRecipients($email);
$resultX = $MA->sendMail(stripslashes($content), $subject);
}
catch (Exception $e)
{
}
if ($resultX) {
$status = 1; // poslalo ok
} else {
$status = 2; // ni poslalo
}
}
}
}
}
# nastavimo še stvari za slideshow
if (isset($_POST['slideshow'])) {
if ((int)$_POST['slideshow'] == 1) {
# spremenimo skin v slideshow
$ss = new SurveySlideshow($this->anketa);
$ss -> setSlideshowSkin();
}
}
$urlprefix = "?";
$anketaurl = '';
if (isset ($anketa) && $anketa != null && $anketa != "") {
$anketaurl = $urlprefix . 'anketa=' . $anketa;
$urlprefix = "&";
}
$location = isset($_REQUEST['location']) ? $_REQUEST['location'] : '';
$multilang = isset($_REQUEST['multilang']) ? $_REQUEST['multilang'] : '';
$uporabnost = isset($_REQUEST['uporabnost']) ? $_REQUEST['uporabnost'] : '';
$user_from_cms = isset($_REQUEST['user_from_cms']) ? $_REQUEST['user_from_cms'] : '';
$quiz = isset($_REQUEST['quiz']) ? $_REQUEST['quiz'] : '';
$phone = isset($_REQUEST['phone']) ? $_REQUEST['phone'] : '';
$email = isset($_REQUEST['email']) ? $_REQUEST['email'] : '';
$social_network = isset($_REQUEST['social_network']) ? $_REQUEST['social_network'] : '';
$slideshow = isset($_REQUEST['slideshow']) ? $_REQUEST['slideshow'] : '';
$m = isset($_REQUEST['m']) ? $_REQUEST['m'] : '';
if ($location == 'jezik' && $multilang == '1') {
$locationurl = $urlprefix . 'a=prevajanje';
$urlprefix = "&";
} else if ($uporabnost == 1) {
$locationurl = $urlprefix . 'a=uporabnost';
$urlprefix = "&";
} else if ($user_from_cms == 2 && $location != 'piskot') {
$locationurl = $urlprefix . 'a=vnos';
$urlprefix = "&";
} else if ($quiz == 1) {
$locationurl = $urlprefix . 'a=kviz';
$urlprefix = "&";
} else if ($phone == 1) {
$locationurl = $urlprefix . 'a='.A_TELEPHONE;
$urlprefix = "&";
} else if ($email == 1) {
#$locationurl = $urlprefix . 'a=invitations';
$locationurl = $urlprefix . 'a='.A_VABILA;
$urlprefix = "&";
} else if ($social_network == 1) {
$locationurl = $urlprefix . 'a=social_network';
$urlprefix = "&";
} else if ($m == 'vabila ') {
// izpisemo vsebino nastavitev za vabila
$locationurl = $urlprefix . 'a='.A_VABILA;
$urlprefix = "&";
} else if ($slideshow == 1) {
$locationurl = $urlprefix.'a=slideshow';
$urlprefix = "&";
} else if ($m == 'system') {
$locationurl = $urlprefix.'a=nastavitve&m=system';
$urlprefix = "&";
} else if ($m == 'global_user_settings') {
$locationurl = $urlprefix.'a=nastavitve&m=global_user_settings';
$urlprefix = "&";
} else if ($m == 'global_user_myProfile') {
$locationurl = $urlprefix.'a=nastavitve&m=global_user_myProfile';
$urlprefix = "&";
} else if ($m == 'predvidenicasi') {
$locationurl = $urlprefix.'a=nastavitve&m=predvidenicasi';
$urlprefix = "&";
} else if ($m == 'vabila_settings') {
$locationurl = $urlprefix.'a='.A_VABILA;
$urlprefix = "&";
} else if ($m == 'inv_server') {
$locationurl = $urlprefix.'a=invitations&m=inv_settings';
$urlprefix = "&";
} else if ($m == 'email_server') {
$locationurl = $urlprefix.'a=alert&m=email_server';
$urlprefix = "&";
} else if ($_POST['location'] == 'handleUserCodeSetting') {
$locationurl = $urlprefix.'&a='.A_VABILA;
$urlprefix = "&";
} else {
$location = (isset ($_POST['location']) && $_POST['location'] != null && $_POST['location'] != "") ? $location = $_POST['location'] : 'nastavitve';
$locationurl = $urlprefix . 'a=' . $location;
$urlprefix = "&";
}
if (isset($_REQUEST['submited']) && $_REQUEST['submited'] == 1) {
$locationurl .= $urlprefix.'s=1'.(isset($_GET['show_back']) ? '&show_back=true' : '');
}
if ( isset($_REQUEST['lang_id']) ) {
$locationurl .= $urlprefix.'lang_id='.$_REQUEST['lang_id'];
}
header('Location: ' . $site_url . 'admin/survey/index.php' . $anketaurl . $locationurl);
}
elseif ($_GET['a'] == 'enableEmailInvitation') {
// Vklop vabil z individualizirano kodo (posta, sms)
if(isset($_POST['what']) && $_POST['what'] == '2'){
sisplet_query("UPDATE srv_anketa SET user_base='1', usercode_required='1', show_email='0' WHERE id='$anketa'");
SurveySession::sessionStart($anketa);
SurveySession::set('inv_noEmailing', 1);
}
// Vklop vabil brez individualizirano kode (samo posiljanje mailov)
elseif(isset($_POST['what']) && $_POST['what'] == '3'){
sisplet_query("UPDATE srv_anketa SET user_base='1', individual_invitation='0', usercode_skip='1', show_email='0' WHERE id='$anketa'");
}
// Vklop vabil za rocno posiljanje
elseif(isset($_POST['what']) && $_POST['what'] == '4'){
sisplet_query("UPDATE srv_anketa SET user_base='1', usercode_required='1', show_email='0' WHERE id='$anketa'");
}
// Vklop klasicnih email vabil
else{
sisplet_query("UPDATE srv_anketa SET user_base='1', show_email='0' WHERE id='$anketa'");
}
sisplet_query("INSERT INTO srv_anketa_module (ank_id, modul) VALUES ('".$anketa."', 'email')");
sisplet_query('COMMIT');
echo $site_url . 'admin/survey/index.php?anketa=' . $anketa.'&a=invitations&s=1';
exit();
}
elseif ($_GET['a'] == 'editanketatema') {
Common::updateEditStamp();
$sql = sisplet_query("UPDATE srv_anketa SET skin='$skin', progressbar='$progressbar' WHERE id='$anketa'");
// vsilimo refresh podatkov
SurveyInfo :: getInstance()->resetSurveyData();
header('Location: index.php?anketa=' . $anketa . '&a=tema&s=1');
}
elseif ($_GET['a'] == 'editanketaalert') {
Common::updateEditStamp();
if ($_POST['m'] == 'complete') {
if ($alert_finish_respondent != 1)
$alert_finish_respondent = 0;
if ($alert_finish_respondent_cms != 1)
$alert_finish_respondent_cms = 0;
if ($alert_finish_author != 1)
$alert_finish_author = 0;
if ($alert_finish_other != 1 || !$alert_finish_other_emails)
$alert_finish_other = 0; // če ni emailov, damo alert_more na 0
// shranimo dodatne emaile
$mySqlInsert = sisplet_query("INSERT INTO srv_alert (ank_id, finish_respondent, finish_respondent_cms, finish_author, finish_other, finish_other_emails, finish_subject, finish_text, reply_to) VALUES " .
"('".$this->anketa."', '$alert_finish_respondent', '$alert_finish_respondent_cms', '$alert_finish_author', '$alert_finish_other', '$alert_finish_other_emails', '$alert_finish_subject', '$alert_finish_text', '$_POST[reply_to]') " .
"ON DUPLICATE KEY UPDATE finish_respondent = '$alert_finish_respondent', finish_respondent_cms = '$alert_finish_respondent_cms', finish_author = '$alert_finish_author', finish_other = '$alert_finish_other', finish_other_emails='$alert_finish_other_emails', finish_subject='$alert_finish_subject', finish_text='$alert_finish_text', reply_to='$_POST[reply_to]'");
if (!$mySqlInsert)
echo mysqli_error($GLOBALS['connect_db']);
// ponastavimo alert_admin
// najprej vse stare zapise postavimo na 0 nato pa setiramo na 1 kjer je potrebno
$mysqlUpdate = sisplet_query("UPDATE srv_dostop SET alert_complete='0' WHERE ank_id = '$this->anketa'");
if (!$mysqlUpdate)
echo mysqli_error($GLOBALS['connect_db']);
if ($alert_finish_author && $alert_finish_author_uid) {
foreach ($alert_finish_author_uid as $authorId) {
$sqlInsertUpdate = sisplet_query("INSERT INTO srv_dostop (ank_id, uid, alert_complete) VALUES ('$this->anketa', '$authorId', 1) ON DUPLICATE KEY UPDATE alert_complete=1");
if (!$sqlInsertUpdate)
echo mysqli_error($GLOBALS['connect_db']);
}
}
} else if ($_POST['m'] == 'expired') {
if ($alert_expire_author != 1)
$alert_expire_author = 0;
if ($alert_expire_other != 1 || !$alert_expire_other_emails)
$alert_expire_other = 0; // če ni emailov, damo alert_more na 0
// izračunamo datum kdaj moramo obvestiti uporabnike
$dayDif = is_numeric($alert_expire_days) ? $alert_expire_days : 0;
$mySqlInsert = sisplet_query("INSERT INTO srv_alert (ank_id, expire_days, expire_author, expire_other, expire_other_emails, expire_subject, expire_text, reply_to) VALUES " .
"('".$this->anketa."', '$dayDif', '$alert_expire_author', '$alert_expire_other', '$alert_expire_other_emails', '$alert_expire_subject', '$alert_expire_text', '$_POST[reply_to]') " .
"ON DUPLICATE KEY UPDATE expire_days = '$dayDif', expire_author = '$alert_expire_author', expire_other = '$alert_expire_other', expire_other_emails='$alert_expire_other_emails', expire_subject='$alert_expire_subject', expire_text='$alert_expire_text', reply_to='$_POST[reply_to]'");
if (!$mySqlInsert)
echo mysqli_error($GLOBALS['connect_db']);
// ponastavimo alert_admin
// najprej vse stare zapise postavimo na 0 nato pa setiramo na 1 kjer je potrebno
$mysqlUpdate = sisplet_query("UPDATE srv_dostop SET alert_expire='0' WHERE ank_id = '$anketa'");
if (!$mysqlUpdate)
echo mysqli_error($GLOBALS['connect_db']);
if ($alert_expire_author && $alert_expire_author_uid) {
foreach ($alert_expire_author_uid as $authorId) {
$sqlInsertUpdate = sisplet_query("INSERT INTO srv_dostop (ank_id, uid, alert_expire) VALUES ('$this->anketa', '$authorId', 1) ON DUPLICATE KEY UPDATE alert_expire=1");
if (!$sqlInsertUpdate)
echo mysqli_error($GLOBALS['connect_db']);
}
}
// Ostanek, kjer se uporablja baza surveycrontab za posiljanje obvestil o poteku
/*SurveyAlert::getInstance()->Init($anketa, $global_user_id);
SurveyAlert::getInstance()->prepareSendExpireAlerts();*/
} elseif ($_POST['m'] == 'active') {
if ($alert_active_author != 1)
$alert_active_author = 0;
if ($alert_active_other != 1 || !$alert_active_other_emails)
$alert_active_other = 0; // če ni emailov, damo alert_more na 0
$mySqlInsert = sisplet_query("INSERT INTO srv_alert (ank_id, active_author, active_other, active_other_emails, active_subject0, active_text0, active_subject1, active_text1, reply_to) VALUES " .
"('".$this->anketa."', '$alert_active_author', '$alert_active_other', '$alert_active_other_emails', '$alert_active_subject0', '$alert_active_text0', '$alert_active_subject1', '$alert_active_text1', '$_POST[reply_to]') " .
"ON DUPLICATE KEY UPDATE active_author = '$alert_active_author', active_other = '$alert_active_other', active_other_emails='$alert_active_other_emails', active_subject0='$alert_active_subject0', active_text0='$alert_active_text0', active_subject1='$alert_active_subject1', active_text1='$alert_active_text1', reply_to='$_POST[reply_to]'");
if (!$mySqlInsert)
echo mysqli_error($GLOBALS['connect_db']);
// ponastavimo alert_admin
// najprej vse stare zapise postavimo na 0 nato pa setiramo na 1 kjer je potrebno
$mysqlUpdate = sisplet_query("UPDATE srv_dostop SET alert_active='0' WHERE ank_id = '$anketa'");
if (!$mysqlUpdate)
echo mysqli_error($GLOBALS['connect_db']);
if ($alert_active_author && $alert_active_author_uid) {
foreach ($alert_active_author_uid as $authorId) {
$sqlInsertUpdate = sisplet_query("INSERT INTO srv_dostop (ank_id, uid, alert_active) VALUES ('$this->anketa', '$authorId', 1) ON DUPLICATE KEY UPDATE alert_active=1");
if (!$sqlInsertUpdate)
echo mysqli_error($GLOBALS['connect_db']);
}
}
} else if ($_POST['m'] == 'delete') {
if ($alert_delete_author != 1)
$alert_delete_author = 0;
if ($alert_delete_other != 1 || !$alert_delete_other_emails)
$alert_delete_other = 0; // če ni emailov, damo alert_more na 0
$mySqlInsert = sisplet_query("INSERT INTO srv_alert (ank_id, delete_author, delete_other, delete_other_emails, delete_subject, delete_text, reply_to) VALUES " .
"('".$this->anketa."', '$alert_delete_author', '$alert_delete_other', '$alert_delete_other_emails', '$alert_delete_subject', '$alert_delete_text', '$_POST[reply_to]') " .
"ON DUPLICATE KEY UPDATE delete_author = '$alert_delete_author', delete_other = '$alert_delete_other', delete_other_emails='$alert_delete_other_emails', delete_subject='$alert_delete_subject', delete_text='$alert_delete_text', reply_to='$_POST[reply_to]'");
if (!$mySqlInsert)
echo mysqli_error($GLOBALS['connect_db']);
// ponastavimo alert_admin
// najprej vse stare zapise postavimo na 0 nato pa setiramo na 1 kjer je potrebno
$mysqlUpdate = sisplet_query("UPDATE srv_dostop SET alert_delete='0' WHERE ank_id = '$anketa'");
if (!$mysqlUpdate)
echo mysqli_error($GLOBALS['connect_db']);
if ($alert_delete_author && $alert_delete_author_uid) {
foreach ($alert_delete_author_uid as $authorId) {
$sqlInsertUpdate = sisplet_query("INSERT INTO srv_dostop (ank_id, uid, alert_delete) VALUES ('$this->anketa', '$authorId', 1) ON DUPLICATE KEY UPDATE alert_delete=1");
if (!$sqlInsertUpdate)
echo mysqli_error($GLOBALS['connect_db']);
}
}
}
header('Location: index.php?anketa=' . $anketa . '&a=alert&m='.$_POST['m'].(isset($_REQUEST['submited']) && $_REQUEST['submited'] == 1 ? '&s=1' : ''));
} elseif ($_GET['a'] == 'alert_edit_if') {
Common::updateEditStamp();
$uid = $_POST['uid'];
$type = $_POST['type'];
if ($type == 1) { // avtor oz. kdor ma dostop
$sql = sisplet_query("SELECT alert_complete_if FROM srv_dostop WHERE uid = '$uid' AND ank_id='$this->anketa'");
$row = mysqli_fetch_array($sql);
if ($row['alert_complete_if'] > 0) {
$if = $row['alert_complete_if'];
} else {
sisplet_query("INSERT INTO srv_if (id) VALUES ('')");
$if = mysqli_insert_id($GLOBALS['connect_db']);
$s = sisplet_query("INSERT INTO srv_condition (id, if_id, vrstni_red) VALUES ('', '$if', '1')");
$s = sisplet_query("UPDATE srv_dostop SET alert_complete_if='$if' WHERE uid = '$uid' AND ank_id='$this->anketa'");
}
} elseif ($type == 2) { // respondent
$sql = sisplet_query("SELECT finish_respondent_if FROM srv_alert WHERE ank_id='$this->anketa'");
$row = mysqli_fetch_array($sql);
if ($row['finish_respondent_if'] > 0) {
$if = $row['finish_respondent_if'];
} else {
sisplet_query("INSERT INTO srv_if (id) VALUES ('')");
$if = mysqli_insert_id($GLOBALS['connect_db']);
$s = sisplet_query("INSERT INTO srv_condition (id, if_id, vrstni_red) VALUES ('', '$if', '1')");
$s = sisplet_query("UPDATE srv_alert SET finish_respondent_if='$if' WHERE ank_id='$this->anketa'");
}
} elseif ($type == 3) { // respondent iz cmsja
$sql = sisplet_query("SELECT finish_respondent_cms_if FROM srv_alert WHERE ank_id='$this->anketa'");
$row = mysqli_fetch_array($sql);
if ($row['finish_respondent_cms_if'] > 0) {
$if = $row['finish_respondent_cms_if'];
} else {
sisplet_query("INSERT INTO srv_if (id) VALUES ('')");
$if = mysqli_insert_id($GLOBALS['connect_db']);
$s = sisplet_query("INSERT INTO srv_condition (id, if_id, vrstni_red) VALUES ('', '$if', '1')");
$s = sisplet_query("UPDATE srv_alert SET finish_respondent_cms_if='$if' WHERE ank_id='$this->anketa'");
}
} elseif ($type == 4) { // ostali (vneseni rocno)
$sql = sisplet_query("SELECT finish_other_if FROM srv_alert WHERE ank_id='$this->anketa'");
$row = mysqli_fetch_array($sql);
if ($row['finish_other_if'] > 0) {
$if = $row['finish_other_if'];
} else {
sisplet_query("INSERT INTO srv_if (id) VALUES ('')");
$if = mysqli_insert_id($GLOBALS['connect_db']);
$s = sisplet_query("INSERT INTO srv_condition (id, if_id, vrstni_red) VALUES ('', '$if', '1')");
$s = sisplet_query("UPDATE srv_alert SET finish_other_if='$if' WHERE ank_id='$this->anketa'");
}
}
if ( ! $if > 0 ) return;
$b = new Branching($this->anketa);
$b->condition_editing($if, -3);
} elseif ($_GET['a'] == 'anketa' || $_GET['a'] == 'nova-anketa-in-hierarhija' || $_GET['a'] == 'anketa_from_text') {
Common::updateEditStamp();
if (!isset($_POST['survey_type']) || trim($_POST['survey_type']) == '') {
$_POST['survey_type'] = 2;
}
$anketa = $this->SurveyAdmin->nova_anketa($naslov, $intro_opomba, $akronim, $_POST['survey_type'], $skin);
// Ce imamo pri ustvarjanju doloceno tudi mapo, anketo vstavimo v njo
if(isset($_POST['folder']) && $_POST['folder'] > 0){
// Razpremo folder v akterega uvrscamo anketo
$sql = sisplet_query("UPDATE srv_mysurvey_folder SET open='1' WHERE id='".$_POST['folder']."' AND usr_id='".$global_user_id."'");
// Vstavimo anketo
$sql = sisplet_query("INSERT INTO srv_mysurvey_anketa (ank_id, usr_id, folder) VALUES ('".$anketa."', '".$global_user_id."', '".$_POST['folder']."')");
}
// Če ob ustvarjanju ankete vključimo še hierarhijos
if(!empty($_POST['vkljuciHierarhijo'])){
sisplet_query("INSERT INTO srv_anketa_module (ank_id, modul) VALUES ('".$anketa."', 'hierarhija')");
(new \Hierarhija\Hierarhija($anketa))->DolociPraviceUporabniku();
}
// Ce ustvarjamo anketo preko uvoza iz besedila
if(isset($_POST['from_text']) && $_GET['a'] == 'anketa_from_text'){
$from_text = $_POST['from_text'];
$text_array = Common::anketaArrayFromText($from_text);
$spr_id = 0;
// Loop po vseh vprasanjih, ki jih uvazamo
foreach($text_array as $vprasanje){
$ba = new BranchingAjax($anketa);
// Imamo samo naslov vprasanja - text tip (21)
if(count($vprasanje) == 1){
$b = new Branching($anketa);
$spr_id = $ba->spremenljivka_new(0, 0, 1);
Vprasanje::change_tip($spr_id, $tip='21');
$sql = sisplet_query("UPDATE srv_spremenljivka SET naslov='".$vprasanje['title']."' WHERE id='".$spr_id."'");
}
// Imamo variable - radio tip (1)
else{
$b = new Branching($anketa);
$spr_id = $ba->spremenljivka_new(0, 0, 1);
Vprasanje::change_tip($spr_id, $tip='1');
$sql = sisplet_query("UPDATE srv_spremenljivka SET naslov='".$vprasanje['title']."' WHERE id='".$spr_id."'");
$sql = sisplet_query("DELETE FROM srv_vrednost WHERE spr_id='$spr_id'");
unset($vprasanje['title']);
// Loop po variablah
foreach($vprasanje as $key => $var_title){
$v = new Vprasanje();
$v->spremenljivka = $spr_id;
$vrednost = $v->vrednost_new($var_title);
Common::prestevilci($spr_id);
}
}
}
}
flush();
echo 'index.php?anketa=' . $anketa;
} elseif ($_GET['a'] == 'anketa_active') {
Common::updateEditStamp();
$row = SurveyInfo::getInstance()->getSurveyRow();
$starts = '';
$expire = '';
// Anketa ni aktivna - jo aktiviramo
if ($row['active'] == 0) {
$active = 1;
$backup = 0;
# preverimo ali ima uporabnik izklopljeno zaklepanje
# polovimo nastavitve uporabnika
global $global_user_id;
UserSetting::getInstance()->Init($global_user_id);
# ali zaklepamo anketo ob aktivaciji
$lockSurvey = UserSetting::getInstance()->getUserSetting('lockSurvey');
$locked = "'".(int)$lockSurvey."'";
// ponastavimo datume
if ($_POST['starts']) {
$starts = ", starts='" . $_POST['starts'] . "' ";
$activity_starts = "'".$_POST['starts']."'";
}
else {
$starts = ", starts=NOW() ";
$activity_starts = 'NOW()';
}
if ($_POST['expire']) {
# če je datum expire od trajne ankete '2099-01-01' in anketo deaktiviramo moramo spremeniti datum expire da ni več videti kot trajna
if ($_POST['expire'] == PERMANENT_DATE) {
$dateToday = date("Y-m-d"); // danes
$_POST['expire'] = $dateToday;
}
$expire = ", expire='" . $_POST['expire'] . "' ";
$activity_expire = "'".$_POST['expire']."'";
}
else {
$expire = ", expire=NOW() + INTERVAL 30 DAY ";
$activity_expire = 'NOW() + INTERVAL 30 DAY';
}
}
// Anketa je aktivna - jo deaktiviramo
else {
$active = 0;
$backup = $row['backup'];
$locked = "locked";
$activity_expire = 'NOW()';
if(Common::checkModule('maza') && SurveyInfo::checkSurveyModule('maza')){
$maza = new MAZA($this->anketa);
$maza ->maza_off();
}
}
$sql = sisplet_query("UPDATE srv_anketa SET active='$active', backup='$backup', locked=$locked $starts $expire WHERE id='$anketa'");
# Pri aktivaciji dodamo zapis v srv_activity samo ce
if ($active == 1) {
$sql_insert = sisplet_query("INSERT INTO srv_activity
(sid, starts, expire)
VALUES
('".$anketa."', ".$activity_starts.", ".$activity_expire.")
ON DUPLICATE KEY UPDATE
expire=".$activity_expire."
");
}
else{
$sql_insert = sisplet_query("UPDATE srv_activity
SET expire=".$activity_expire."
WHERE sid='".$anketa."'
");
}
# vsilimo refresh podatkov
SurveyInfo :: getInstance()->resetSurveyData();
# posljemo mail ob spremembi aktivnosti ankete
SurveyAlert::getInstance()->Init($anketa, $global_user_id);
SurveyAlert::getInstance()->sendMailActive();
# popravimo tudi alerte za pošiljanje ob poteku ankete
SurveyAlert::getInstance()->setDefaultAlertBeforeExpire();
$this->anketa = $anketa;
if (isset($_POST['folders']) && $_POST['folders'] == 'true') { // če smo na folderjih zlistamo folderje
# osvezimo samo ikonico in ne celotnih map
$row = SurveyInfo::getInstance()->getSurveyRow();
echo '' .
' '.
' ';
}
else { // čene izpišemo zgornjo vrstico ankete in nardimo link
$this->SurveyAdmin->displayAktivnost();
}
}
elseif ($_GET['a'] == 'anketa_vabila_sending') {
$_GET['a'] = 'email';
$_GET['m'] = 'usermailing';
$sas = new SurveyAdminSettings();
$sas->usermailing();
}
elseif ($_GET['a'] == 'anketa_delete') {
Common::updateEditStamp();
$rowa = SurveyInfo::getInstance()->getSurveyRow();
//notify all maza app users who participate in this survey that this survey has ended
if(SurveyInfo::checkSurveyModule('maza') && $rowa['active'] = 1){
$maza = new MAZA($this->anketa);
$maza ->maza_off();
}
$this->SurveyAdmin->anketa_delete($anketa);
# če postamo iz survey_lista (prva stran) preverimo koliko anket je ostalo, če je bila zadnja osvežimo celotno stran
if (isset($_POST['inList'] ) && $_POST['inList'] == 'true' ) {
global $admin_type, $global_user_id;
# preštejemo število anket.
//SELECT count(sa.id) AS cnt FROM srv_anketa sa WHERE sa.backup='0' AND sa.id > 0 AND (sa.dostop >= '2' OR sa.id IN (SELECT ank_id FROM srv_dostop WHERE uid='90'))
$stringSurveyList = "SELECT count(sa.id) AS cnt FROM srv_anketa sa WHERE sa.backup='0' AND sa.id > 0 AND (sa.dostop >= '".$admin_type."' OR sa.id IN (SELECT ank_id FROM srv_dostop WHERE uid='".$global_user_id."'))";
$sqlSurveyList = sisplet_query($stringSurveyList);
$rowSurveyList = mysqli_fetch_assoc($sqlSurveyList);
# v ajax post vrnemo število anket
echo $rowSurveyList['cnt'];
return;
}
if ($rowa['backup'] > 0)
echo 'index.php?anketa=' . $rowa['backup'] . '&a=arhivi';
else
echo 'index.php';
}
elseif ($_GET['a'] == 'nova_grupa') {
Common::updateEditStamp();
if($anketa > 0){
$sql = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='$anketa'");
$nums = mysqli_num_rows($sql);
$vrstni_red = $nums + 1;
$sql = sisplet_query("INSERT INTO srv_grupa (id, ank_id, naslov, vrstni_red) VALUES ('', '$anketa', '$lang[srv_stran] $vrstni_red', '$vrstni_red')");
$insert_id = mysqli_insert_id($GLOBALS['connect_db']);
// Ce dodamo 4. stran vklopimo progress indicator (pri 3 straneh ali manj je po default izklopljen)
if($vrstni_red == 4){
$sqlP = sisplet_query("UPDATE srv_anketa SET progressbar='1' WHERE id='$anketa'");
}
echo 'index.php?anketa=' . $anketa . '&grupa=' . $insert_id . '&novagrupa=true';
}
}
elseif ($_GET['a'] == 'edit_grupa') {
Common::updateEditStamp();
$sql = sisplet_query("UPDATE srv_grupa SET naslov = '$naslov' WHERE id='$grupa'");
}
elseif ($_GET['a'] == 'save_edit_grupa') {
Common::updateEditStamp();
$sql = sisplet_query("UPDATE srv_grupa SET naslov = '$naslov' WHERE id='$grupa'");
echo '' . $naslov . " ";
$this->SurveyAdmin->showEditPageDiv($grupa, false);
}
elseif ($_GET['a'] == 'save_edit_uporabnost_link') {
Common::updateEditStamp();
SurveySetting::getInstance()->Init($this->anketa);
SurveySetting::getInstance()->setSurveyMiscSetting('uporabnost_link_'.$_POST['grupa'], $_POST['link']);
$sql = sisplet_query("SELECT naslov FROM srv_grupa WHERE id = '$grupa'");
$row = mysqli_fetch_array($sql);
echo '' . $row['naslov'] . " ";
$this->SurveyAdmin->showEditPageDiv($grupa, false);
}
elseif ($_GET['a'] == 'brisi_grupo') {
Common::updateEditStamp();
if($grupa > 0 && $anketa > 0){
$sql = sisplet_query("SELECT id FROM srv_spremenljivka WHERE gru_id='$grupa'");
while ($row = mysqli_fetch_array($sql)) {
$sql1 = sisplet_query("DELETE FROM srv_vrednost WHERE spr_id='$row[id]'");
}
$sql = sisplet_query("DELETE FROM srv_spremenljivka WHERE gru_id='$grupa'");
$sqlOldGrupa = sisplet_query("SELECT vrstni_red FROM srv_grupa WHERE id='$grupa'");
$rowOldGrupa = mysqli_fetch_assoc($sqlOldGrupa);
$sql = sisplet_query("DELETE FROM srv_grupa WHERE id = '$grupa'");
// popravimo vrstni red grup
$sqlUpdateVrestniRed = sisplet_query("UPDATE srv_grupa SET vrstni_red = vrstni_red-1 WHERE id = '$grupa' AND vrstni_red > '".$rowOldGrupa['vrstni_red']."'");
// preverimo ce imamo kaksno grupo
$sql = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='$anketa'");
$nums = mysqli_num_rows($sql);
if ($nums == 0) {
// dodamo eno grupo
$vrstni_red = 1;
$sql = sisplet_query("INSERT INTO srv_grupa (id, ank_id, naslov, vrstni_red) VALUES ('', '$anketa', '$lang[srv_stran] $vrstni_red', '$vrstni_red')");
$insert_id = mysqli_insert_id($GLOBALS['connect_db']);
echo $site_url . 'admin/survey/index.php?anketa=' . $anketa;
die();
}
$this->SurveyAdmin->repareGrupa($anketa);
if ($thisgrupa != $grupa) {
$redirect = '&grupa=' . $thisgrupa;
} else
$redirect = '';
echo $site_url . 'admin/survey/index.php?anketa=' . $anketa . '&grupa=' . $redirect;
die();
}
}
elseif ($_GET['a'] == 'nova_spremenljivka') {
Common::updateEditStamp();
$rowb = SurveyInfo::getInstance()->getSurveyRow();
$this->grupa = $grupa;
if ($rowb['branching'] == 0) { // obicno dodajanje spremenljivke
if ($this->grupa > 0) {
$sql = sisplet_query("SELECT ank_id, vrstni_red FROM srv_grupa WHERE id = '$grupa'");
$row = mysqli_fetch_array($sql);
$this->anketa = $row['ank_id'];
if ($spremenljivka > 0) {
$row3 = Cache::srv_spremenljivka($spremenljivka);
$vrstni_red = $row3['vrstni_red'];
$sql3 = sisplet_query("UPDATE srv_spremenljivka SET vrstni_red = vrstni_red+1 WHERE gru_id = '$grupa' AND vrstni_red >= '$vrstni_red'");
} else {
$sql3 = sisplet_query("SELECT id FROM srv_spremenljivka WHERE gru_id='$grupa'");
$nums = mysqli_num_rows($sql3);
$vrstni_red = $nums +1;
}
$spr_id = $this->SurveyAdmin->nova_spremenljivka($grupa, $row['vrstni_red'], $vrstni_red);
}
} else { // ce mamo branching, je treba dodati tudi v srv_branching
//include_once ('Branching.php');
$Branching = new Branching($this->anketa);
$Branching->spremenljivka_new($spremenljivka);
$Branching->repare_vrstni_red();
}
$this->SurveyAdmin->prestevilci();
$this->SurveyAdmin->vprasanja();
}
elseif ($_GET['a'] == 'nova_spremenljivka_vrivanje') {
Common::updateEditStamp();
$last = substr($spremenljivka, strlen($spremenljivka) - 5, strlen($spremenljivka));
//ugotovimo id grupe kjer se je zgodil drop
if ($last == "_last") {
//dodajanje na konec (popravimo spremenljivko)
$spremenljivka = substr($spremenljivka, 0, strlen($spremenljivka) - 5);
// ni vprasanj, ugotovimo id prve grupe
$sql = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='$this->anketa' ORDER BY vrstni_red LIMIT 1");
$row = mysqli_fetch_array($sql);
$grupa = $row['id'];
} else {
$row = Cache::srv_spremenljivka($spremenljivka);
$grupa = $row['gru_id'];
}
$this->grupa = $grupa;
//ugotovimo vrstni red grupe
$sql = sisplet_query("SELECT ank_id, vrstni_red FROM srv_grupa WHERE id = '$grupa'");
$row = mysqli_fetch_array($sql);
$this->anketa = $row['ank_id'];
//ugotovimo vrstni red vprasanja kamor ga vstavljamo
$row3 = Cache::srv_spremenljivka($spremenljivka);
$vrstni_red = $row3['vrstni_red'];
if ($last == "_last") {
$vrstni_red++;
}
//popravimo vrstni red vprasanj za vstavljenim
$sql3 = sisplet_query("UPDATE srv_spremenljivka SET vrstni_red = vrstni_red+1 WHERE gru_id = '$grupa' AND vrstni_red >= '$vrstni_red'");
//ustvarimo novo vprasanje na pravem mestu
$this->SurveyAdmin->nova_spremenljivka($grupa, $row['vrstni_red'], $vrstni_red);
//nastavimo tudi tip vprasanja ki smo ga draggali
//substring je st. vprasanja (tip)
$type = substr($child, 10);
//textbox vprasanje - ena vrstica
if ($type == "401") {
$type = 4;
}
//textbox vprasanje - 5 vrstic
elseif ($type == "405") {
$sql = sisplet_query("SELECT params FROM srv_spremenljivka WHERE gru_id='$grupa' AND vrstni_red='$vrstni_red'");
$row = mysqli_fetch_array($sql);
Common::updateEditStamp();
// v polje params spremenljivke shranimo spremembo parametra
$newParams = new enkaParameters($row['params']);
$newParams->set("taSize", 5);
$s = sisplet_query("UPDATE srv_spremenljivka SET params='" . $newParams->getString() . "' WHERE gru_id='$grupa' AND vrstni_red='$vrstni_red'");
$type = 4;
}
$sql5 = sisplet_query("UPDATE srv_spremenljivka SET tip='$type' WHERE gru_id='$grupa' AND vrstni_red='$vrstni_red'");
//popravimo size na 1 za število
if ($type == 7 || $type == 21)
$sql5 = sisplet_query("UPDATE srv_spremenljivka SET size='1' WHERE gru_id='$grupa' AND vrstni_red='$vrstni_red'");
$this->SurveyAdmin->prestevilci();
$this->SurveyAdmin->vprasanja();
}
elseif ($_GET['a'] == 'nova_spremenljivka_in_grupa') {
Common::updateEditStamp();
$rowb = SurveyInfo::getInstance()->getSurveyRow();
if ($_POST['grupa'] == 'all') {
// ugotovimo id grupa od spremenljivke
$row = Cache::srv_spremenljivka($spremenljivka);
$this->grupa = $row['gru_id'];
$grupa = $row['gru_id'];
} else {
$this->grupa = $_POST['grupa'];
$grupa = $_POST['grupa'];
}
if ($rowb['branching'] == 0) { // obicno dodajanje spremenljivke
if ($this->grupa > 0) {
$sql = sisplet_query("SELECT ank_id, vrstni_red FROM srv_grupa WHERE id = '$grupa'");
$row = mysqli_fetch_array($sql);
$this->anketa = $row['ank_id'];
if ($spremenljivka > 0) {
$row3 = Cache::srv_spremenljivka($spremenljivka);
$vrstni_red = $row3['vrstni_red'];
$sql3 = sisplet_query("UPDATE srv_spremenljivka SET vrstni_red = vrstni_red+1 WHERE gru_id = '$grupa' AND vrstni_red >= '$vrstni_red'");
} else {
$sql3 = sisplet_query("SELECT id FROM srv_spremenljivka WHERE gru_id='$grupa'");
$nums = mysqli_num_rows($sql3);
$vrstni_red = $nums +1;
}
}
//ustvarimo novo vprasanje na pravem mestu
$spr_id = $this->SurveyAdmin->nova_spremenljivka($grupa, $row['vrstni_red'], $vrstni_red);
} else { // ce mamo branching, je treba dodati tudi v srv_branching
//include_once ('Branching.php');
$Branching = new Branching($this->anketa);
$Branching->spremenljivka_new($spremenljivka);
$Branching->repare_vrstni_red();
}
$this->SurveyAdmin->prestevilci();
if (isset($_POST['full_screen']) && $_POST['full_screen'] == 'true') { // v fullscreenu vrnemo samo id nove spremenljivke
echo $spr_id;
} else { // v normalnem načinu vrenmo html editmode vprašanja
if ($rowb['branching'] == 0)
$movable = ' movable';
else
$movable = '';
// prikažemo vprašanje v edit načinu
echo ' ';
$this->SurveyAdmin->vprasanje_edit($spr_id);
echo '
';
}
}
elseif ($_GET['a'] == 'refresh_grupe') {
$this->SurveyAdmin->grupe();
}
elseif ($_GET['a'] == 'refresh_right_panel') {
global $site_url;
echo $site_url . 'admin/survey/index.php?anketa=' . $anketa . '&grupa='.$grupa;
}
elseif ($_GET['a'] == 'brisi_spremenljivko') {
$this->ajax_brisi_spremenljivko();
}
elseif ($_GET['a'] == 'nova_vrednost') {
Common::updateEditStamp();
$sql = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$spremenljivka' AND vrstni_red>0");
$row = mysqli_fetch_array($sql);
$nums = mysqli_num_rows($sql);
$vrstni_red = $nums +1;
$row1 = Cache::srv_spremenljivka($spremenljivka);
$variable = $vrstni_red; // tole se itak popravi v prestevilci()
// če smo postali polje undecided, rejected inappropriate
$_otherStatus = array (
99,
98,
97
);
$_otherStatusFields = array (
99 => 'undecided',
98 => 'rejected',
97 => 'inappropriate'
);
$_otherStatusDefaults = array (
99 => 'Ne vem',
98 => 'Zavrnil',
97 => 'Neustrezno'
);
if (!in_array($other, $_otherStatus)) { // nismo kreirali polja 99,98,97
if ($other == 1)
$naslov = $lang['srv_other'] . ':';
else
$naslov = '';
// vrednost dodamo v tabelo
$sql = sisplet_query("INSERT INTO srv_vrednost (id, spr_id, naslov, variable, vrstni_red, other) " .
"VALUES ('', '$spremenljivka', '$naslov', '$variable', '$vrstni_red', '$other')");
} else {
// polja 99,98,97 damo v tabelo srv_vrednost smo za spremenljivke tipa: 1,2,3,4,7,8
if (in_array($row1['tip'], array (
1,
2,
3,
4,
7,
8
))) { // za tipe vprašanj 1,2,3 dodamo variablo v tabelo srv_vrednost
// po novem so neopredeljene vrednosti negativne : -99,-98,-97
$_otherVariables = array ( 99=>'-99',98=>'-98',97=>'-97');
$variable = $_otherVariables[$other];
$naslov = $_otherStatusDefaults[$other];
$sql = sisplet_query("INSERT INTO srv_vrednost (id, spr_id, naslov, variable, vrstni_red, other) " .
"VALUES ('', '$spremenljivka', '$naslov', '$variable', '$vrstni_red', '$other')");
}
// spremenimo nastavitev v srv_spremenljvka
if ($row1[$_otherStatusFields[$other]] == 0) {
$_updateState = $_otherStatusFields[$other] . "='1'";
} else {
$_updateState = $_otherStatusFields[$other] . "='0'";
// pobrišemo spremenljivkko če je nastavljena
$sqlDelete = sisplet_query("DELETE FROM srv_vrednost WHERE spr_id = '" . $spremenljivka . "' AND other = '" . $other . "'");
}
// nardimo updejt posameznega polja ( undecided, rejected inappropriate) v tabeli srv_spremenljivka
$sql = sisplet_query("UPDATE srv_spremenljivka SET $_updateState WHERE id='$spremenljivka'");
// enako mormo updejtat kadar pobrišemo vrednost preko gumba -
}
// dodamo vrednosti -4 za novo variablo k že vpisanim odgovorom
// multigridu dodamo vrednost -4
if ($row1['tip'] == 6) {
$sql = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$spremenljivka'");
$sql1 = sisplet_query("SELECT id FROM srv_user WHERE ank_id='$anketa'");
while ($row1 = mysqli_fetch_assoc($sql1)) {
mysqli_data_seek($sql, 0);
while ($row = mysqli_fetch_assoc($sql)) {
$s = sisplet_query("INSERT INTO srv_data_grid".$this->db_table." (spr_id, vre_id, usr_id, grd_id) VALUES ('$spremenljivka', '$row[id]', '$row1[id]', '-4')");
}
}
}
if ($row1['tip'] == 16) { // multicheckbox
$sql = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$spremenljivka'");
$sql1 = sisplet_query("SELECT id FROM srv_user WHERE ank_id='$anketa'");
while ($row1 = mysqli_fetch_assoc($sql1)) {
mysqli_data_seek($sql, 0);
while ($row = mysqli_fetch_assoc($sql)) {
$s = sisplet_query("INSERT INTO srv_data_grid".$this->db_table." (spr_id, vre_id, usr_id, grd_id) VALUES ('$spremenljivka', '$row[id]', '$row1[id]', '-4')");
}
}
}
if ($row1['tip'] == 17) {
$sql = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$spremenljivka'");
$sql1 = sisplet_query("SELECT id FROM srv_user WHERE ank_id='$anketa'");
while ($row1 = mysqli_fetch_assoc($sql1)) {
mysqli_data_seek($sql, 0);
while ($row = mysqli_fetch_assoc($sql)) {
$s = sisplet_query("INSERT INTO srv_data_rating (spr_id, vre_id, usr_id, vrstni_red) VALUES ('$spremenljivka', '$row[id]', '$row1[id]', '-4')");
}
}
}
$this->SurveyAdmin->prestevilci($spremenljivka);
$this->SurveyAdmin->vprasanje_edit($spremenljivka);
}
elseif ($_GET['a'] == 'edit_vrednost') {
Common::updateEditStamp();
$sql = sisplet_query("SELECT variable FROM srv_vrednost WHERE id ='$vrednost'");
$row = mysqli_fetch_array($sql);
if ($row['variable'] != $variable)
$variable_custom = ", variable_custom='1' ";
else
$variable_custom = '';
$sql = sisplet_query("UPDATE srv_vrednost SET naslov = '$naslov', naslov2 ='$naslov2', variable='$variable' $variable_custom WHERE id='$vrednost'");
}
elseif ($_GET['a'] == 'edit_vrednost_size') {
Common::updateEditStamp();
$sql = sisplet_query("UPDATE srv_vrednost SET size = '$size' WHERE id = '$vrednost'");
$this->SurveyAdmin->vprasanje_edit($spremenljivka);
}
elseif ($_GET['a'] == 'edit_vsota') {
Common::updateEditStamp();
$sql = sisplet_query("UPDATE srv_spremenljivka SET vsota = '$vrednost' WHERE id='$spremenljivka'");
}
elseif ($_GET['a'] == 'edit_limit') {
Common::updateEditStamp();
if($vrednost == "")
$vrednost = 0;
if($min == "")
$min = 0;
$sql = sisplet_query("UPDATE srv_spremenljivka SET vsota_limit = '$vrednost', vsota_min = '$min' WHERE id='$spremenljivka'");
}
elseif ($_GET['a'] == 'edit_vsota_omejitve') {
Common::updateEditStamp();
$sql = sisplet_query("UPDATE srv_spremenljivka SET vsota_limittype = '$tip' WHERE id='$spremenljivka'");
$this->SurveyAdmin->display_vsota_omejitve($spremenljivka, $tip);
}
elseif ($_GET['a'] == 'edit_spremenljivka_vsota_reminder') {
Common::updateEditStamp();
$sql = sisplet_query("UPDATE srv_spremenljivka SET vsota_reminder = '$reminder' WHERE id='$spremenljivka'");
}
elseif ($_GET['a'] == 'editor_vrednost') {
$sql = sisplet_query("SELECT naslov, naslov2, variable, spr_id FROM srv_vrednost WHERE id = '$vrednost'");
$row = mysqli_fetch_array($sql);
echo '' . $lang['srv_editirajvrednost'] . '
';
echo '';
}
elseif ($_GET['a'] == 'editor_note') {
$row = Cache::srv_spremenljivka($spremenljivka);
echo '' . $lang['srv_editirajopombo'] . '
';
echo '';
echo '' . $row['info'] . ' ';
echo ' ';
echo ' ';
}
elseif ($_GET['a'] == 'editor_note_save') {
$info = $_POST['content'];
$sqlUpdate = sisplet_query("UPDATE srv_spremenljivka SET info ='" . $info . "' WHERE id = '" . $spremenljivka . "'");
}
elseif ($_GET['a'] == 'brisi_vrednost') {
Common::updateEditStamp();
$sql = sisplet_query("SELECT spr_id, other FROM srv_vrednost WHERE id = '$vrednost'");
$row = mysqli_fetch_array($sql);
$spremenljivka = $row['spr_id'];
$sql = sisplet_query("DELETE FROM srv_vrednost WHERE id='$vrednost'");
// če je other 99,98,97 moramo nastavit ustrezno polje še v srv_spremenljivka na 0
$_otherStatus = array (
99,
98,
97
);
$_otherStatusFields = array (
99 => 'undecided',
98 => 'rejected',
97 => 'inappropriate'
);
if (in_array($row['other'], $_otherStatus))
$sqlUpdate = sisplet_query("UPDATE srv_spremenljivka SET " . $_otherStatusFields[$row['other']] . "=0 WHERE id = '" . $spremenljivka . "'");
$this->SurveyAdmin->repareVrednost($spremenljivka);
$this->SurveyAdmin->prestevilci($spremenljivka);
$this->SurveyAdmin->vprasanje_edit($spremenljivka);
}
elseif ($_GET['a'] == 'edit_gridvrednost') {
Common::updateEditStamp();
$sql = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$spremenljivka' AND vrstni_red='$grid'");
$row = mysqli_fetch_array($sql);
if ($row != FALSE) {
//poiscemo id grida, ki ga zelimo popraviti
$id = $row['id'];
$sql = sisplet_query("UPDATE srv_grid SET naslov = '$naslov' WHERE id='$id' AND spr_id='$spremenljivka'");
//za popravljanje ze obstojecih vprasanj - nastavinmo variablo na isto kot je pozicija grida
if ($row['variable'] == '') {
$sql = sisplet_query("UPDATE srv_grid SET variable = '$grid' WHERE id='$id' AND spr_id='$spremenljivka'");
}
//za popravljanje ze obstojecih vprasanj - nastavinmo vrstni red na isto kot je pozicija grida
if ($row['vrstni_red'] == 0) {
$sql = sisplet_query("UPDATE srv_grid SET vrstni_red = '$grid' WHERE id='$id' AND spr_id='$spremenljivka'");
}
} else {
$sql = sisplet_query("SELECT MAX(id) FROM srv_grid WHERE spr_id='$spremenljivka' ");
$row = mysqli_fetch_array($sql);
//nastavimo id na najvecji v vprasanju
$id = $row['MAX(id)'] + 1;
$sql1 = sisplet_query("INSERT INTO srv_grid (id, spr_id, naslov, vrstni_red, variable) VALUES ('$id', '$spremenljivka', '$naslov', '$grid', '$grid')");
}
}
//editiranje variabel gridov
elseif ($_GET['a'] == 'edit_grids') {
Common::updateEditStamp();
$row = Cache::srv_spremenljivka($spremenljivka);
if ($row['grids_edit'] == 1)
$sql1 = sisplet_query("UPDATE srv_spremenljivka SET grids_edit='0' WHERE id='$spremenljivka'");
else
$sql1 = sisplet_query("UPDATE srv_spremenljivka SET grids_edit='1' WHERE id='$spremenljivka'");
$this->SurveyAdmin->vprasanje_edit($spremenljivka);
}
elseif ($_GET['a'] == 'edit_gridID') {
Common::updateEditStamp();
$sql = sisplet_query("UPDATE srv_grid SET variable = '$grid' WHERE id='$grd_id' AND spr_id='$spremenljivka'");
}
elseif ($_GET['a'] == 'edit_grid_number') {
Common::updateEditStamp();
$sql = sisplet_query("UPDATE srv_spremenljivka SET grids = '$grids' WHERE id='$spremenljivka'");
//dodamo manjkajoce gride v bazo
$this->SurveyAdmin->addMissingGrids($spremenljivka);
$this->SurveyAdmin->vprasanje_edit($spremenljivka);
}
elseif ($_GET['a'] == 'edit_spremenljivka') {
Common::updateEditStamp();
if (strtolower(substr($naslov, 0, 3)) != '' && strtolower(substr($naslov, -4)) != '
' && strrpos($naslov, '') === false) {
//$naslov = '
'.nl2br($naslov).'
';
$naslov = '' . str_replace(NEW_LINE, "
\n", $naslov) . '
';
}
// Počistimo opombo
$info = trim(strip_tags($info));
$sql = sisplet_query("UPDATE srv_spremenljivka SET naslov = '$naslov', info='$info' WHERE id='$spremenljivka'");
if ($_REQUEST['normalmode'] == 1)
$this->SurveyAdmin->vprasanje($spremenljivka);
}
elseif ($_GET['a'] == 'edit_spremenljivka_label') {
Common::updateEditStamp();
$sql = sisplet_query("UPDATE srv_spremenljivka SET naslov = '$naslov' WHERE id='$spremenljivka'");
$this->SurveyAdmin->vprasanje($spremenljivka);
$row = Cache::srv_spremenljivka($spremenljivka);
if ($row['variable'] != $variable) {
$variable_custom = ", variable_custom='1' ";
} else {
$variable_custom = '';
}
}
elseif ($_GET['a'] == 'edit_spremenljivka_variable') {
Common::updateEditStamp();
$row = Cache::srv_spremenljivka($spremenljivka);
if ($row['variable'] != $variable)
$variable_custom = ", variable_custom='1' ";
else
$variable_custom = '';
$sql = sisplet_query("UPDATE srv_spremenljivka SET variable='$variable' $variable_custom WHERE id='$spremenljivka'");
$this->SurveyAdmin->check_spremenljivka_variable($spremenljivka, $variable);
}
elseif ($_GET['a'] == 'edit_spremenljivka_skala') {
Common::updateEditStamp();
# popravimo skalo spremenljivke
# skala - 0 Ordinalna
# skala - 1 Nominalna
if ( isset($skala)) {
$sql = sisplet_query("UPDATE srv_spremenljivka SET skala='".$skala."' WHERE id='$spremenljivka'");
}
}
elseif ($_GET['a'] == 'edit_spremenljivka_tip') {
Common::updateEditStamp();
$row5 = Cache::srv_spremenljivka($spremenljivka);
// pri tipu besedilo* nastavimo privzeto velikost na 1
if ($tip == 21 && ($size == "" || $size== "undefined")) {
$sql = sisplet_query("UPDATE srv_spremenljivka SET size='1' WHERE id='$spremenljivka'");
}
else if ($row5['size'] < 3) { //popravimo velikost v primeru prehoda iz antonucci/number vprasanja
$sql = sisplet_query("UPDATE srv_spremenljivka SET size='3' WHERE id='$spremenljivka'");
}
// kalkulacija ima vedno size 1
if ($tip == 22) {
$sql = sisplet_query("UPDATE srv_spremenljivka SET size='1' WHERE id='$spremenljivka'");
}
if ($size > 0)
$_size = ", size='$size'";
else
$_size = "";
// če smo dobili postali polje undecided, rejected inappropriate
$_otherStatus = array (
99,
98,
97
);
$_otherStatusFields = array (
99 => 'undecided',
98 => 'rejected',
97 => 'inappropriate'
);
if ($undecided && in_array($undecided, $_otherStatus)) {
$_updateState = "";
// updejtamo sistemske variable če jih dobimo z ajaxa
if ($row5[$_otherStatusFields[$undecided]] == 0)
$_updateState .= ", " . $_otherStatusFields[$undecided] . "='1'";
else
$_updateState .= ", " . $_otherStatusFields[$undecided] . "='0'";
}
// nardimo updejt posameznega polja ( undecided, rejected inappropriate) v tabeli srv_spremenljivka
$sql = sisplet_query("UPDATE srv_spremenljivka SET tip = '$tip' $_size $_updateState WHERE id='$spremenljivka'");
// popravimo variable za m.grid in m.checkbox
if ($tip == 6 || $tip == 16 || $tip == 19 || $tip == 20) {
$this->SurveyAdmin->addMissingGrids($spremenljivka);
}
$row = Cache::srv_spremenljivka($spremenljivka);
if (($row['tip'] <= 3 || $row['tip'] == 9 || $row['tip'] == 12 || $row['tip'] == 15 || $row['tip'] == 17 || $row['tip'] == 18) && ($size > 0 || $row5['tip'] != $tip)) {
$sqlp = sisplet_query("SELECT vrstni_red FROM srv_grupa WHERE id='$row[gru_id]'");
$rowp = mysqli_fetch_array($sqlp);
//if ($row['tip'] == 2 || $row['tip'] == 18) {
if ($row['tip'] == 2 || $row['tip'] == 18 || $row['tip'] == 27) {
sisplet_query("UPDATE srv_vrednost SET variable=CONCAT('$row5[variable]', CHAR(vrstni_red+96)) WHERE spr_id='$spremenljivka' AND other <= 1");
} else {
sisplet_query("UPDATE srv_vrednost SET variable=vrstni_red WHERE spr_id='$spremenljivka' AND other <= 1");
}
$sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$spremenljivka' AND other <=1");
$rows = mysqli_num_rows($sql1);
if ($rows < $row['size']) {
for ($i = 1; $i <= $row['size'] - $rows; $i++) {
if ($row['tip'] == 2 || $row['tip'] == 18)
$variable = $row5['variable'] . chr($i + $rows +96);
else
$variable = $i + $rows;
$sql2 = sisplet_query("INSERT INTO srv_vrednost (spr_id, variable, vrstni_red) VALUES ('$spremenljivka', '$variable', '" . ($i + $rows) . "')");
}
$this->SurveyAdmin->repareVrednost($spremenljivka);
}
elseif ($rows > $row['size']) {
$sql = sisplet_query("DELETE FROM srv_vrednost WHERE spr_id='$spremenljivka' AND naslov='' AND vrstni_red > '$row[size]' AND other <= 1");
$this->SurveyAdmin->repareVrednost($spremenljivka);
}
}
else if (($row['tip'] == 6 || $row['tip'] == 16 || $row['tip'] == 19 || $row['tip'] == 20 || $row['tip'] == 18) && $row5['tip'] != $tip) {
sisplet_query("UPDATE srv_vrednost SET variable=CONCAT('$row5[variable]', CHAR(vrstni_red+96)) WHERE spr_id='$spremenljivka' AND variable_custom='0' AND other <= 1");
/* Pri enovnosnih poljih pobri"semo nepotrebne spremenljivke v bazi
* to so:
* -text -> tip = 4
* -label -> tip = 5
* -number -> tip = 7
* -datum -> tip = 8
* */
}
else if ($row['tip'] == 7) { // number
// preverimo če sploh in koliko variable rabimo
$sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$spremenljivka' AND other <=1");
$rows = mysqli_num_rows($sql1);
if ($rows < $row['size']) {
for ($i = 1; $i <= $row['size'] - $rows; $i++) {
if ($row['tip'] == 2)
$variable = $row5['variable'] . chr($i + $rows +96);
else
$variable = $i + $rows;
$sql2 = sisplet_query("INSERT INTO srv_vrednost (spr_id, variable, vrstni_red) VALUES ('$spremenljivka', '$variable', '" . ($i + $rows) . "')");
}
}
}
else if ($row['tip'] == 21) { // besedilo*
// pobrisemo odvecne variable pri preklopu na besedilo*
$sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$spremenljivka'");
$rows = mysqli_num_rows($sql1);
if ($rows > $row['text_kosov'])
$sql2 = sisplet_query("DELETE FROM srv_vrednost WHERE spr_id='$spremenljivka' AND vrstni_red > '$row[text_kosov]'");
}
else if (($row['tip'] == 4 || $row['tip'] == 5 || $row['tip'] == 8) && $row5['tip'] != $tip) {
// $sql = sisplet_query("DELETE FROM srv_vrednost WHERE spr_id='$spremenljivka' AND naslov='' AND vrstni_red > '1'");
// $sql = sisplet_query("DELETE FROM srv_vrednost WHERE spr_id='$spremenljivka' AND other <= 1");
$this->SurveyAdmin->repareVrednost($spremenljivka);
}
if (($row['tip'] == 7 || $row['tip'] == 12 || $row['tip'] == 15) && $row['size'] > 2) {
$sql = sisplet_query("UPDATE srv_spremenljivka SET size=1 WHERE id='$spremenljivka'");
// $sql = sisplet_query("DELETE FROM srv_vrednost WHERE spr_id='$spremenljivka' AND naslov='' AND vrstni_red > '1'");
$this->SurveyAdmin->repareVrednost($spremenljivka);
}
if ($row['tip'] == 9) {
$sql = sisplet_query("UPDATE srv_spremenljivka SET antonucci=1, size=0 WHERE id='$spremenljivka'");
}
if ($row['tip'] == 10 || $row['tip'] == 11 || $row['tip'] == 12 || $row['tip'] == 13 || $row['tip'] == 14 || $row['tip'] == 15) {
$sql = sisplet_query("UPDATE srv_spremenljivka SET podpora=1 WHERE id='$spremenljivka'");
}
//dodajanje page-breakov pri SN-imena, SN-social in SN-povezave
if ($row['tip'] == 9 || $row['tip'] == 10 || $row['tip'] == 13) {
$sql = sisplet_query("UPDATE srv_branching SET pagebreak=1 WHERE element_spr='$spremenljivka' AND ank_id='".$this->anketa."'");
//$sql = sisplet_query("INSERT INTO srv_branching (ank_id, element_spr, vrstni_red, pagebreak) VALUES ('$this->anketa', '$spremenljivka', 0 ,'1') ON DUPLICATE KEY UPDATE pagebreak=1");
$sqlX = sisplet_query("SELECT g.ank_id FROM srv_grupa g, srv_spremenljivka s WHERE s.id='$spremenljivka' AND (g.id=s.gru_id) ");
$rowX = mysqli_fetch_array($sqlX);
$anketa = $rowX['ank_id'];
//include_once ('Branching.php');
$b = new Branching($anketa);
$b->repare_vrstni_red();
$b->trim_grupe();
if ($this->branching == 0) {
$sql = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='$anketa'");
$nums = mysqli_num_rows($sql);
$vrstni_red = $nums + 1;
$sql = sisplet_query("INSERT INTO srv_grupa (id, ank_id, naslov, vrstni_red) VALUES ('', '$anketa', '$lang[srv_stran] $vrstni_red', '$vrstni_red')");
$insert_id = mysqli_insert_id($GLOBALS['connect_db']);
// Ce dodamo 4. stran vklopimo progress indicator (pri 3 straneh ali manj je po default izklopljen)anketa
if($vrstni_red == 4){
$sqlP = sisplet_query("UPDATE srv_anketa SET progressbar='1' WHERE id='$anketa'");
}
}
}
// dodamo -4 multigridu in multicheckboxu
if ( $tip == 2 || $tip == 6 || $tip == 16) {
$sql = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$spremenljivka'");
$sql1 = sisplet_query("SELECT id FROM srv_user WHERE ank_id='$anketa'");
while ($row1 = mysqli_fetch_array($sql1)) {
if ($tip == 2) // checkboxu damo -4 samo en zapis -4 za vse vrednosti
$s = sisplet_query("INSERT INTO srv_data_vrednost".$this->db_table." (spr_id, vre_id, usr_id) VALUES ('$spremenljivka', '-4', '$row1[id]')");
mysqli_data_seek($sql, 0);
while ($row = mysqli_fetch_array($sql)) {
if ($tip == 6)
$s = sisplet_query("INSERT INTO srv_data_grid".$this->db_table." (spr_id, vre_id, usr_id, grd_id) VALUES ('$spremenljivka', '$row[id]', '$row1[id]', '-4')");
if ($tip == 16)
$s = sisplet_query("INSERT INTO srv_data_checkgrid".$this->db_table." (spr_id, vre_id, usr_id, grd_id) VALUES ('$spremenljivka', '$row[id]', '$row1[id]', '-4')");
}
}
}
$this->SurveyAdmin->vprasanje_edit($spremenljivka);
}
elseif ($_GET['a'] == 'edit_spremenljivka_textboxes') {
Common::updateEditStamp();
$s = sisplet_query("UPDATE srv_spremenljivka SET text_kosov='$size' WHERE id='$spremenljivka'");
$rowV = Cache::srv_spremenljivka($spremenljivka);
$sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$spremenljivka' AND other <=1");
$rows = mysqli_num_rows($sql1);
if ($rows < $size) {
for ($i = 1; $i <= $size - $rows; $i++) {
$variable = $rowV['variable'].chr(96 + $i + $rows);
$sql2 = sisplet_query("INSERT INTO srv_vrednost (spr_id, naslov, variable, vrstni_red) VALUES ('$spremenljivka', '', '$variable', '" . ($i + $rows) . "')");
}
$this->SurveyAdmin->repareVrednost($spremenljivka);
} else if ($rows > $size) {
# pobrisemo odvecna polja
$sql = sisplet_query("DELETE FROM srv_vrednost WHERE spr_id='$spremenljivka' AND vrstni_red > '$size'");
}
$this->SurveyAdmin->vprasanje_edit($spremenljivka);
}
elseif ($_GET['a'] == 'edit_spremenljivka_text_orientation') {
Common::updateEditStamp();
$s = sisplet_query("UPDATE srv_spremenljivka SET text_orientation='$orientation' WHERE id='$spremenljivka'");
$this->SurveyAdmin->vprasanje_edit($spremenljivka);
}
elseif ($_GET['a'] == 'edit_spremenljivka_antonucci') {
Common::updateEditStamp();
$s = sisplet_query("UPDATE srv_spremenljivka SET antonucci='$antonucci' WHERE id='$spremenljivka'");
}
elseif ($_GET['a'] == 'edit_spremenljivka_design') {
Common::updateEditStamp();
$s = sisplet_query("UPDATE srv_spremenljivka SET design='$design', cela=2, decimalna=0 WHERE id='$spremenljivka'");
$this->SurveyAdmin->vprasanje_edit($spremenljivka);
}
elseif ($_GET['a'] == 'edit_spremenljivka_ranking_k') {
Common::updateEditStamp();
$s = sisplet_query("UPDATE srv_spremenljivka SET ranking_k='$size' WHERE id='$spremenljivka'");
}
elseif ($_GET['a'] == 'edit_spremenljivka_podpora') {
Common::updateEditStamp();
$s = sisplet_query("UPDATE srv_spremenljivka SET podpora='$podpora' WHERE id='$spremenljivka'");
}
elseif ($_GET['a'] == 'edit_spremenljivka_number') {
Common::updateEditStamp();
$s = sisplet_query("UPDATE srv_spremenljivka SET cela='$cela', decimalna='$decimalna', enota='$enota' WHERE id='$spremenljivka'");
$this->SurveyAdmin->vprasanje_edit($spremenljivka);
}
elseif ($_GET['a'] == 'edit_spremenljivka_param') {
$row = Cache::srv_spremenljivka($spremenljivka);
Common::updateEditStamp();
// v polje params spremenljivke shranimo spremembo parametra
$newParams = new enkaParameters($row['params']);
$newParams->set($paramName, $paramValue);
$s = sisplet_query("UPDATE srv_spremenljivka SET params='" . $newParams->getString() . "' WHERE id='$spremenljivka'");
$this->SurveyAdmin->repareVrednost($spremenljivka);
$this->SurveyAdmin->vprasanje_edit($spremenljivka);
}
elseif ($_GET['a'] == 'spremenljivka_random') {
Common::updateEditStamp();
/** random polje:
* 0 = sort po vrstnem redu
* 1 = sort random
* 2 = sort po abecedi naraščajoče
* 3 = sort po abecedi padajoče
*/
$row = Cache::srv_spremenljivka($spremenljivka);
if ($row['random'] == 3) {
$random = 0;
} else {
$random = $row['random'] + 1;
}
$other = ($random) ? " AND other='0'" : "";
$sql = sisplet_query("UPDATE srv_spremenljivka SET random = '$random' WHERE id='$spremenljivka'");
$sql1 = sisplet_query("UPDATE srv_vrednost SET random = '$random' WHERE spr_id ='$spremenljivka' $other");
$this->SurveyAdmin->vprasanje_edit($spremenljivka);
}
elseif ($_GET['a'] == 'random_vrednost') {
Common::updateEditStamp();
/** random polje:
* 0 = sort po vrstnem redu
* 1 = sort random
* 2 = sort po abecedi naraščajoče
* 3 = sort po abecedi padajoče
*/
$sql = sisplet_query("SELECT random FROM srv_vrednost WHERE id = '$vrednost'");
$row = mysqli_fetch_array($sql);
if ($row['random'] == 3) {
$random = 0;
} else {
$random = $row['random'] + 1;
}
sisplet_query("UPDATE srv_vrednost SET random = '$random' WHERE id = '$vrednost'");
$this->SurveyAdmin->random_vrednost($vrednost);
}
elseif ($_GET['a'] == 'spremenljivka_stat') {
Common::updateEditStamp();
$row = Cache::srv_spremenljivka($spremenljivka);
if ($row['stat'] == 1) {
$stat = 0;
} else {
$stat = 1;
}
$sql = sisplet_query("UPDATE srv_spremenljivka SET stat = '$stat' WHERE id='$spremenljivka'");
$this->SurveyAdmin->spremenljivka_stat($spremenljivka);
}
elseif ($_GET['a'] == 'spremenljivka_orientation') {
Common::updateEditStamp();
$row = Cache::srv_spremenljivka($spremenljivka);
if ($row['orientation'] == 1) {
$orientation = 0;
} else if ($row['orientation'] == 0) {
$orientation = 2;
} else if ($row['orientation'] == 2) {
$orientation = 1;
}
$sql = sisplet_query("UPDATE srv_spremenljivka SET orientation = '$orientation' WHERE id='$spremenljivka'");
$this->SurveyAdmin->spremenljivka_orientation($spremenljivka);
}
elseif ($_GET['a'] == 'spremenljivka_checkbox_hide') {
Common::updateEditStamp();
$row = Cache::srv_spremenljivka($spremenljivka);
if ($row['checkboxhide'] == 1) {
$checkboxhide = 0;
} else {
$checkboxhide = 1;
}
$sql = sisplet_query("UPDATE srv_spremenljivka SET checkboxhide = '$checkboxhide' WHERE id='$spremenljivka'");
$this->SurveyAdmin->spremenljivka_checkbox_hide($spremenljivka);
}
elseif ($_GET['a'] == 'spremenljivka_reminder') {
Common::updateEditStamp();
$row = Cache::srv_spremenljivka($spremenljivka);
if ($row['reminder'] == 0) {
$reminder = 1;
}
elseif ($row['reminder'] == 1) {
$reminder = 2;
} else {
$reminder = 0;
}
$sql = sisplet_query("UPDATE srv_spremenljivka SET reminder = '$reminder' WHERE id='$spremenljivka'");
$this->SurveyAdmin->spremenljivka_reminder($spremenljivka);
}
elseif ($_GET['a'] == 'spremenljivka_sistem') {
Common::updateEditStamp();
$row = Cache::srv_spremenljivka($spremenljivka);
if ($row['sistem'] == 1) {
$sistem = 0;
} else {
$sistem = 1;
}
$sql = sisplet_query("UPDATE srv_spremenljivka SET sistem = '$sistem' WHERE id='$spremenljivka'");
$this->SurveyAdmin->spremenljivka_sistem($spremenljivka);
}
elseif ($_GET['a'] == 'spremenljivka_visible') {
Common::updateEditStamp();
$row = Cache::srv_spremenljivka($spremenljivka);
if ($row['visible'] == 1) {
$visible = 0;
} else {
$visible = 1;
}
$sql = sisplet_query("UPDATE srv_spremenljivka SET visible = '$visible' WHERE id='$spremenljivka'");
$this->SurveyAdmin->spremenljivka_visible($spremenljivka);
}
elseif ($_GET['a'] == 'spremenljivka_textfield') {
Common::updateEditStamp();
$row = Cache::srv_spremenljivka($spremenljivka);
if ($row['textfield'] == 1) {
$textfield = 0;
$label = '';
} else {
$textfield = 1;
$label = $lang['srv_other'] . ':';
}
$sql = sisplet_query("UPDATE srv_spremenljivka SET textfield = '$textfield', textfield_label='$label' WHERE id='$spremenljivka'");
$this->SurveyAdmin->vprasanje_edit($spremenljivka);
}
elseif ($_GET['a'] == 'spremenljivka_timer') {
Common::updateEditStamp();
$sql = sisplet_query("UPDATE srv_spremenljivka SET timer = '$timer' WHERE id='$spremenljivka'");
$this->SurveyAdmin->spremenljivka_timer($spremenljivka);
}
elseif ($_GET['a'] == 'edit_textfield') {
Common::updateEditStamp();
sisplet_query("UPDATE srv_vrednost SET naslov = '$label' WHERE id='$vrednost'");
}
elseif ($_GET['a'] == 'vrstnired_vrednost') {
Common::updateEditStamp();
$exploded = explode('&', $serialize);
$i = 1;
foreach ($exploded AS $key) {
$key = str_replace('spremenljivka_', '', $key);
$explode = explode('[]=', $key);
$sql = sisplet_query("UPDATE srv_vrednost SET vrstni_red = '$i' WHERE id = '$explode[1]'");
$i++;
}
$this->SurveyAdmin->prestevilci(); // TODO, tukaj bi moral biti id spremenljivke
}
elseif ($_GET['a'] == 'vrstnired_vprasanje') {
Common::updateEditStamp();
$exploded = explode('&', $serialize);
if ($_POST['grupa'] != 'all') {
// sortiramo samo v okviru ene strani
$i = 1;
foreach ($exploded AS $key) {
$key = str_replace('vprasanja', '', $key);
$explode = explode('[]=', $key);
$sql = sisplet_query("UPDATE srv_spremenljivka SET vrstni_red = '$i' WHERE id = '$explode[1]'");
$i++;
}
} else {
// da ne updejtamo vseh spremenljivk, popravljamo podatke samo pri "prizadetih" grupah
$moved_spr = str_replace('spremenljivka_', '', $_POST['moved']);
// id stare gurpe
$strGr = "select gru_id FROM srv_spremenljivka where id = '".$moved_spr."'";
$sqlGr = sisplet_query($strGr);
$rowGr = mysqli_fetch_assoc($sqlGr);
$oldPageId = $rowGr['gru_id'];
// id nove grupe
$newPageId = str_replace('fieldset_page_', '', $_POST['topage']);
$grNew = array();
$grOld = array();
// vse psremenljvke ki so v novi gupi
$strGrNew = "select id FROM srv_spremenljivka where gru_id = '".$newPageId."'";
$sqlGrNew = sisplet_query($strGrNew);
while ($rowGrNew = mysqli_fetch_assoc($sqlGrNew)) {
$grNew[$rowGrNew['id']] = $newPageId;
}
// vse spremenljivke ki so v stari grupi
$strGrOld = "select id FROM srv_spremenljivka where gru_id = '".$oldPageId."'";
$sqlGrOld = sisplet_query($strGrOld);
while ($rowGrOld = mysqli_fetch_assoc($sqlGrOld)) {
$grOld[$rowGrOld['id']] = $oldPageId;
}
$serialized = array();
// zloopamo skozi prejeta vprašanja in popravimo grupe
$grupa_test = null;
$vrstni_red = 1;
foreach ($exploded AS $key) {
$key = str_replace('spremenljivka[]=', '', $key);
// ce je $key spremenljivka ki jo premikamo ji dodelimo novo grupo
if ($moved_spr == $key) {
$grupa = $newPageId;
} else {
$grupa = isset($grNew[$key])
? $grNew[$key]
: (isset($grOld[$key])
? $grOld[$key]
: null);
}
if ($grupa_test != $grupa) {
// resetriamo couner
$vrstni_red = 1;
$grupa_test = $grupa;
}
if ($grupa != null) {
$serialized[$key] = array('id'=>$key, 'grupa'=>$grupa, 'vrstni_red'=>$vrstni_red);
$vrstni_red ++;
}
}
// updejtamo serializirane podatke
foreach ( $serialized as $key => $value ) {
$sql = sisplet_query("UPDATE srv_spremenljivka SET gru_id='".$value['grupa']."', vrstni_red = '".$value['vrstni_red']."' WHERE id = '".$value['id']."'");
}
}
$this->SurveyAdmin->prestevilci();
}
elseif ($_GET['a'] == 'vrstnired_vprasanje_forma') {
Common::updateEditStamp();
$exploded = explode('&', $serialize);
$i = 1;
foreach ($exploded AS $key) {
$key = str_replace('vprasanja', '', $key);
$explode = explode('[]=', $key);
$sql = sisplet_query("UPDATE srv_spremenljivka SET vrstni_red = '$i' WHERE id = '$explode[1]'");
$i++;
}
$this->SurveyAdmin->prestevilci();
$this->SurveyAdmin->vprasanja();
}
elseif ($_GET['a'] == 'vrstnired_grupa') {
Common::updateEditStamp();
$exploded = explode('&', $serialize);
$i = 1;
foreach ($exploded AS $key) {
$key = str_replace('grupe', '', $key);
$explode = explode('[]=', $key);
$sql = sisplet_query("UPDATE srv_grupa SET vrstni_red = '$i' WHERE id = '$explode[1]'");
$i++;
}
$this->SurveyAdmin->prestevilci();
}
elseif ($_GET['a'] == 'premakni_vprasanje') {
Common::updateEditStamp();
$row = Cache::srv_spremenljivka($spremenljivka);
$old_grupa = $row['gru_id'];
$sql = sisplet_query("SELECT MAX(vrstni_red) AS max FROM srv_spremenljivka WHERE gru_id='$grupa'");
$row = mysqli_fetch_array($sql);
$vrstni_red = $row['max'] + 1;
$sql = sisplet_query("UPDATE srv_spremenljivka SET gru_id='$grupa', vrstni_red='$vrstni_red' WHERE id='$spremenljivka'");
$this->SurveyAdmin->repareSpremenljivka($old_grupa);
$this->SurveyAdmin->repareSpremenljivka($grupa);
$this->SurveyAdmin->prestevilci();
}
elseif ($_GET['a'] == 'intro_concl_fullscreeen') {
//include_once ('Branching.php');
$Branching = new Branching($this->anketa);
echo ' ';
$Branching->introduction_conclusion($_POST['introconcl'], 1);
echo '
';
}
elseif ($_GET['a'] == 'editmode_spremenljivka') {
$this->grupa = $grupa;
$this->SurveyAdmin->vprasanje_edit($spremenljivka);
}
elseif ($_GET['a'] == 'editmode_spremenljivka_single') {
$Branching = new Branching($this->anketa);
$Branching->display();
}
elseif ($_GET['a'] == 'normalmode_spremenljivka') {
$this->SurveyAdmin->vprasanje($spremenljivka);
}
elseif ($_GET['a'] == 'editmode_grupa') {
if ($_POST['pages'] == "1") {
$this->SurveyAdmin->showEditPageDiv($grupa, true);
} else {
$this->SurveyAdmin->grupa_edit($grupa);
}
}
elseif ($_GET['a'] == 'branch_editmode_grupa') {
$this->SurveyAdmin->branch_grupa_edit($grupa, $spremenljivka);
}
elseif ($_GET['a'] == 'branch_normalmode_grupa') {
$this->SurveyAdmin->branch_normalmode_grupa($grupa, $spremenljivka);
}
elseif ($_GET['a'] == 'normalmode_grupa') {
$sql = sisplet_query("SELECT ank_id FROM srv_grupa WHERE id = '$grupa'");
$row = mysqli_fetch_array($sql);
$this->anketa = $row['ank_id'];
$this->SurveyAdmin->grupa($grupa);
}
elseif ($_GET['a'] == 'copy_spremenljivka') {
$this->SurveyAdmin->clipboard_display($spremenljivka);
}
elseif ($_GET['a'] == 'copy_remove') {
$this->SurveyAdmin->clipboard_display(-1);
}
elseif ($_GET['a'] == 'edit_data_vrednost_ch') {
Common::updateEditStamp();
sisplet_query("DELETE FROM srv_data_vrednost".$this->db_table." WHERE spr_id='$spr_id' AND vre_id='$vre_id' AND usr_id='$usr_id'");
if ($value == 1) {
$s = sisplet_query("INSERT INTO srv_data_vrednost".$this->db_table." (spr_id, vre_id, usr_id) VALUES ('$spr_id', '$vre_id', '$usr_id')");
}
}
elseif ($_GET['a'] == 'edit_data_vrednost') {
Common::updateEditStamp();
sisplet_query("DELETE FROM srv_data_vrednost".$this->db_table." WHERE spr_id='$spr_id' AND usr_id='$usr_id'");
if ($vre_id != 0) {
sisplet_query("INSERT INTO srv_data_vrednost".$this->db_table." (spr_id, vre_id, usr_id) VALUES ('$spr_id', '$vre_id', '$usr_id')");
}
}
elseif ($_GET['a'] == 'edit_data_grid') {
Common::updateEditStamp();
sisplet_query("UPDATE srv_data_grid".$this->db_table." SET grd_id='$grd_id' WHERE spr_id='$spr_id' AND vre_id='$vre_id' AND usr_id='$usr_id'");
}
elseif ($_GET['a'] == 'edit_data_text') {
Common::updateEditStamp();
sisplet_query("DELETE FROM srv_data_text".$this->db_table." WHERE spr_id='$spr_id' AND vre_id='$vre_id' AND usr_id='$usr_id'");
if ($value != '') {
sisplet_query("INSERT INTO srv_data_text".$this->db_table." (spr_id, vre_id, usr_id, text) VALUES ('$spr_id', '$vre_id', '$usr_id', '$value')");
}
}
elseif ($_GET['a'] == 'edit_data_delete') {
Common::updateEditStamp();
sisplet_query("DELETE FROM srv_user WHERE id = '$usr_id'");
}
elseif ($_GET['a'] == 'delete_all') {
Common::updateEditStamp();
$sql = sisplet_query("DELETE FROM srv_user WHERE ank_id = '$this->anketa'");
# pobrišemo še DATA datoteke in HTML -dashboard če obstajajo
global $site_path;
$folder = $site_path . EXPORT_FOLDER.'/';
#pobrišemo header datoteko
if (file_exists($folder.'export_header_'.$this->anketa.'_*.dat')) {
unlink($folder.'export_header_'.$this->anketa.'_*.dat');
}
# pobrišemo data datoteko
if (file_exists($folder.'export_data_'.$this->anketa.'_*.dat')) {
unlink($folder.'export_data_'.$this->anketa.'_*.dat');
}
# pobrišemo dashboard
if (file_exists($folder.'export_dashboard_'.$this->anketa.'_*.html')) {
unlink($folder.'export_dashboard_'.$this->anketa.'_*.html');
}
echo 'index.php?anketa=' . $this->anketa . '&a='.A_COLLECT_DATA;
}
elseif ($_GET['a'] == A_REPORTI) { // ajax funkcije za analizo
switch ($_GET['m']) {
case M_ANALYSIS_STATISTICS :
$options = array ();
$options['startDate'] = (isset ($_POST['startDate'])) ? $_POST['startDate'] : null;
$options['endDate'] = (isset ($_POST['endDate'])) ? $_POST['endDate'] : null;
$options['type'] = (isset ($_POST['type'])) ? $_POST['type'] : null;
//include_once ('Analiza.php');
$analiza = new Analiza($this->anketa, $_GET['m']);
$analiza->displayStats($options);
break;
}
}
elseif ($_GET['a'] == 'analizaDisplayData') { // ajax funkcije za analizo
$podstran = $_POST['podstran'];
SurveyAnalysis::Init($this->anketa);
SurveyAnalysis::Display();
} elseif ($_GET['a'] == 'anketa_active_refresh') {
SurveyInfo :: getInstance()->SurveyInit($anketa);
// vsilimo refresh podatkov
SurveyInfo :: getInstance()->resetSurveyData();
$row = SurveyInfo::getInstance()->getSurveyRow();
# updejtjmo pošiljanje alertov
// Ostanek, kjer se uporablja baza surveycrontab za posiljanje obvestil o poteku
/*SurveyAlert::getInstance()->Init($anketa, $global_user_id);
SurveyAlert::getInstance()->prepareSendExpireAlerts();*/
if ($_POST['folders'] && $_POST['folders'] == 'true') { // če smo na folderjih zlistamo folderje
// osvezimo samo ikonico in ne celotnih map
echo '' .
' '.
' ';
} else {
$this->SurveyAdmin->displayAktivnost();
}
} elseif ($_GET['a'] == 'anketa_show_activation') {
global $global_user_id;
$folders = $_POST['folders'];
# za koliko časa aktiviramo
$mth = 3;
$starts = date("d.m.Y"); // danes
$cd = strtotime($starts);
$expire = date('d.m.Y', mktime(0, 0, 0, date('m', $cd) + $mth, date('d', $cd), date('Y', $cd)));
$row = SurveyInfo::getInstance()->getSurveyRow();
$b = new Branching($this->anketa);
$napake = $b->check_pogoji_output();
# Aktivacijski pop up za hierarhijo
if(SurveyInfo::getInstance()->checkSurveyModule('hierarhija')){
// Anketo zaklenemo
//sisplet_query("UPDATE srv_anketa SET locked='1' WHERE id = '$anketa'");
// Popup
echo '