Modul za volitve - V DELU
This commit is contained in:
parent
02691e7387
commit
68d6dba0e1
@ -6120,8 +6120,14 @@ class SurveyAdminAjax {
|
||||
$sq->displaySettings();
|
||||
}
|
||||
elseif ($what == 'voting' && $value == '1'){
|
||||
// volitve
|
||||
|
||||
// Volitve
|
||||
$sv = new SurveyVoting($this->anketa);
|
||||
|
||||
// Izvedemo vse potrebno pri vklopu (vklopimo obvescanje, ugasnemo belezenje parapodatkov...)
|
||||
$sv->turnOnVoting();
|
||||
|
||||
// Prikazemo morebitne nastavitve
|
||||
$sv->displaySettings();
|
||||
}
|
||||
elseif ($what == 'advanced_paradata' && $value == '1'){
|
||||
|
@ -3656,6 +3656,9 @@ class SurveyInvitationsNew {
|
||||
global $lang, $site_path, $site_url, $global_user_id, $lastna_instalacija;
|
||||
|
||||
Common::getInstance()->Init($this->sid);
|
||||
|
||||
// Preverimo ce je vklopljen modul za volitve
|
||||
$voting = SurveyInfo::getInstance()->checkSurveyModule('voting');
|
||||
|
||||
if (isset($_POST['rids'])) {
|
||||
|
||||
@ -3764,7 +3767,7 @@ class SurveyInvitationsNew {
|
||||
|
||||
# zakeširamo user_id za datapiping
|
||||
$arryDataPiping = array();
|
||||
$qryDataPiping = sisplet_query("SELECT id,inv_res_id FROM srv_user WHERE ank_id='$this->sid' AND inv_res_id IS NOT NULL");
|
||||
$qryDataPiping = sisplet_query("SELECT id, inv_res_id FROM srv_user WHERE ank_id='$this->sid' AND inv_res_id IS NOT NULL");
|
||||
while (list($dpUid,$dpInvResId) = mysqli_fetch_row($qryDataPiping)) {
|
||||
if ((int)$dpInvResId > 0 && (int)$dpUid > 0) {
|
||||
$arryDataPiping[$dpInvResId] = (int)$dpUid;
|
||||
@ -3952,11 +3955,21 @@ class SurveyInvitationsNew {
|
||||
$strInsertDataText = array();
|
||||
$strInsertDataVrednost = array();
|
||||
|
||||
$_r = sisplet_query("INSERT INTO srv_user
|
||||
(ank_id, email, cookie, pass, last_status, time_insert, inv_res_id)
|
||||
VALUES
|
||||
('".$this->sid."', '".$_user_data['email']."', '".$_user_data['cookie']."', '".$_user_data['password']."', '".$_user_data['status']."', NOW(), '".$_user_data['id']."') ON DUPLICATE KEY UPDATE cookie = '".$_user_data['cookie']."', pass='".$_user_data['password']."'
|
||||
");
|
||||
// Pri volitvah zaradi anonimizacije ignoriramo vse identifikatorje
|
||||
if($voting){
|
||||
$_r = sisplet_query("INSERT INTO srv_user
|
||||
(ank_id, cookie, pass, last_status, time_insert, inv_res_id)
|
||||
VALUES
|
||||
('".$this->sid."', '".$_user_data['cookie']."', '".$_user_data['password']."', '".$_user_data['status']."', NOW(), '".$_user_data['id']."') ON DUPLICATE KEY UPDATE cookie = '".$_user_data['cookie']."', pass='".$_user_data['password']."'
|
||||
");
|
||||
}
|
||||
else{
|
||||
$_r = sisplet_query("INSERT INTO srv_user
|
||||
(ank_id, email, cookie, pass, last_status, time_insert, inv_res_id)
|
||||
VALUES
|
||||
('".$this->sid."', '".$_user_data['email']."', '".$_user_data['cookie']."', '".$_user_data['password']."', '".$_user_data['status']."', NOW(), '".$_user_data['id']."') ON DUPLICATE KEY UPDATE cookie = '".$_user_data['cookie']."', pass='".$_user_data['password']."'
|
||||
");
|
||||
}
|
||||
$usr_id = mysqli_insert_id($GLOBALS['connect_db']);
|
||||
|
||||
if ($usr_id) {
|
||||
@ -3982,17 +3995,22 @@ class SurveyInvitationsNew {
|
||||
// lahko da user že obstaja in je šlo za duplicated keys
|
||||
}
|
||||
|
||||
// vstavimo v srv_data_text
|
||||
if (count($strInsertDataText) > 0) {
|
||||
$strInsert = "INSERT INTO srv_data_text".$this->db_table." (spr_id, vre_id, text, usr_id) VALUES ";
|
||||
$strInsert .= implode(',',$strInsertDataText);
|
||||
sisplet_query($strInsert);
|
||||
}
|
||||
// vstavimo v srv_data_vrednost
|
||||
if (count($strInsertDataVrednost) > 0) {
|
||||
$strInsert = "INSERT INTO srv_data_vrednost".$this->db_table." (spr_id, vre_id, usr_id) VALUES ";
|
||||
$strInsert .= implode(',',$strInsertDataVrednost);
|
||||
sisplet_query($strInsert);
|
||||
|
||||
// Pri volitvah zaradi anonimizacije ne vsatvimo nicesar v sistemske spremenljivke
|
||||
if(!$voting){
|
||||
|
||||
// vstavimo v srv_data_text
|
||||
if (count($strInsertDataText) > 0) {
|
||||
$strInsert = "INSERT INTO srv_data_text".$this->db_table." (spr_id, vre_id, text, usr_id) VALUES ";
|
||||
$strInsert .= implode(',',$strInsertDataText);
|
||||
sisplet_query($strInsert);
|
||||
}
|
||||
// vstavimo v srv_data_vrednost
|
||||
if (count($strInsertDataVrednost) > 0) {
|
||||
$strInsert = "INSERT INTO srv_data_vrednost".$this->db_table." (spr_id, vre_id, usr_id) VALUES ";
|
||||
$strInsert .= implode(',',$strInsertDataVrednost);
|
||||
sisplet_query($strInsert);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5796,22 +5814,39 @@ class SurveyInvitationsNew {
|
||||
// Dodamo vse userje v bazo podatkov kot respondente
|
||||
function add_users_to_database() {
|
||||
|
||||
// Preverimo ce je vklopljen modul za volitve
|
||||
$voting = SurveyInfo::getInstance()->checkSurveyModule('voting');
|
||||
|
||||
# prejeminki besedila
|
||||
$sql_string = "SELECT id,firstname, lastname, email, password, password, cookie, phone, salutation, custom, relation FROM srv_invitations_recipients WHERE ank_id = '".$this->sid."' AND deleted='0' AND sent='0'";
|
||||
$sql_query = sisplet_query($sql_string);
|
||||
$sql_query = sisplet_query("SELECT id, firstname, lastname, email, password, password, cookie, phone, salutation, custom, relation
|
||||
FROM srv_invitations_recipients
|
||||
WHERE ank_id = '".$this->sid."' AND deleted='0' AND sent='0'
|
||||
");
|
||||
|
||||
# polovimo sistemske spremenljivke z vrednostmi
|
||||
$strSistemske = "SELECT s.id, s.naslov, s.variable FROM srv_spremenljivka s, srv_grupa g WHERE s.sistem='1' AND s.gru_id=g.id AND g.ank_id='".$this->sid."' AND variable IN("."'" . implode("','",$this->inv_variables)."') ORDER BY g.vrstni_red, s.vrstni_red";
|
||||
$qrySistemske = sisplet_query($strSistemske);
|
||||
$qrySistemske = sisplet_query("SELECT s.id, s.naslov, s.variable
|
||||
FROM srv_spremenljivka s, srv_grupa g
|
||||
WHERE s.sistem='1' AND s.gru_id=g.id AND g.ank_id='".$this->sid."'
|
||||
AND variable IN("."'" . implode("','",$this->inv_variables)."')
|
||||
ORDER BY g.vrstni_red, s.vrstni_red
|
||||
");
|
||||
|
||||
$sys_vars = array();
|
||||
$sys_vars_ids = array();
|
||||
|
||||
while ($row = mysqli_fetch_assoc($qrySistemske)) {
|
||||
$sys_vars[$row['id']] = array('id'=>$row['id'], 'variable'=>$row['variable'],'naslov'=>$row['naslov']);
|
||||
$sys_vars_ids[] = $row['id'];
|
||||
}
|
||||
$sqlVrednost = sisplet_query("SELECT spr_id, id AS vre_id, vrstni_red, variable FROM srv_vrednost WHERE spr_id IN(".implode(',',$sys_vars_ids).") ORDER BY vrstni_red ASC ");
|
||||
|
||||
$sqlVrednost = sisplet_query("SELECT spr_id, id AS vre_id, vrstni_red, variable
|
||||
FROM srv_vrednost
|
||||
WHERE spr_id IN(".implode(',',$sys_vars_ids).")
|
||||
ORDER BY vrstni_red ASC
|
||||
");
|
||||
while ($row = mysqli_fetch_assoc($sqlVrednost)) {
|
||||
// Ce gre za odnos imamo radio
|
||||
|
||||
// Ce gre za odnos imamo radio
|
||||
if($sys_vars[$row['spr_id']]['variable'] == 'odnos'){
|
||||
if(!isset($sys_vars[$row['spr_id']]['vre_id'][$row['vrstni_red']]))
|
||||
$sys_vars[$row['spr_id']]['vre_id'][$row['variable']] = $row['vre_id'];
|
||||
@ -5837,16 +5872,35 @@ class SurveyInvitationsNew {
|
||||
$strInsertUserbase = array();
|
||||
$strInsertUserstatus = array();
|
||||
foreach ($send_users_data AS $user_data) {
|
||||
$strInsert = "INSERT INTO srv_user (ank_id, email, cookie, pass, last_status, time_insert, inv_res_id) VALUES ('".$this->sid."', '".$user_data['email']."', '".$user_data['cookie']."', '".$user_data['password']."', '".$user_data['status']."', NOW(), '".$user_data['id']."') ON DUPLICATE KEY UPDATE last_status=VALUES(last_status), inv_res_id=VALUES(inv_res_id)";
|
||||
|
||||
sisplet_query($strInsert);
|
||||
$usr_id = mysqli_insert_id($GLOBALS['connect_db']);
|
||||
|
||||
// Pri volitvah zaradi anonimizacije ignoriramo vse identifikatorje
|
||||
if($voting){
|
||||
sisplet_query("INSERT INTO srv_user
|
||||
(ank_id, cookie, pass, last_status, time_insert, inv_res_id)
|
||||
VALUES
|
||||
('".$this->sid."', '".$user_data['cookie']."', '".$user_data['password']."', '".$user_data['status']."', NOW(), '".$user_data['id']."') ON DUPLICATE KEY UPDATE last_status=VALUES(last_status), inv_res_id=VALUES(inv_res_id)
|
||||
");
|
||||
}
|
||||
else{
|
||||
sisplet_query("INSERT INTO srv_user
|
||||
(ank_id, email, cookie, pass, last_status, time_insert, inv_res_id)
|
||||
VALUES
|
||||
('".$this->sid."', '".$user_data['email']."', '".$user_data['cookie']."', '".$user_data['password']."', '".$user_data['status']."', NOW(), '".$user_data['id']."') ON DUPLICATE KEY UPDATE last_status=VALUES(last_status), inv_res_id=VALUES(inv_res_id)
|
||||
");
|
||||
}
|
||||
|
||||
|
||||
|
||||
$usr_id = mysqli_insert_id($GLOBALS['connect_db']);
|
||||
|
||||
if ($usr_id) {
|
||||
# za update v srv_invitations_respondents
|
||||
$send_ok_ids[] = $user_data['id'];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$send_error_ids[] = $user_data;
|
||||
}
|
||||
|
||||
# dodamo še srv_userbase in srv userstatus
|
||||
$strInsertUserbase[] = "('".$usr_id."','0',NOW(),'".$global_user_id."')";
|
||||
$strInsertUserstatus[] = "('".$usr_id."', '0', '0', NOW())";
|
||||
@ -5877,18 +5931,24 @@ class SurveyInvitationsNew {
|
||||
$strInsert .= implode(',',$strInsertUserstatus);
|
||||
sisplet_query($strInsert);
|
||||
}
|
||||
# vstavimo v srv_data_text
|
||||
if (count($strInsertDataText) > 0) {
|
||||
$strInsert = "INSERT INTO srv_data_text".$this->db_table." (spr_id, vre_id, text, usr_id) VALUES ";
|
||||
$strInsert .= implode(',',$strInsertDataText);
|
||||
sisplet_query($strInsert);
|
||||
}
|
||||
# vstavimo v srv_data_vrednost
|
||||
if (count($strInsertDataVrednost) > 0) {
|
||||
$strInsert = "INSERT INTO srv_data_vrednost".$this->db_table." (spr_id, vre_id, usr_id) VALUES ";
|
||||
$strInsert .= implode(',',$strInsertDataVrednost);
|
||||
sisplet_query($strInsert);
|
||||
}
|
||||
|
||||
// Pri volitvah zaradi anonimizacije ne vsatvimo nicesar v sistemske spremenljivke
|
||||
if(!$voting){
|
||||
|
||||
# vstavimo v srv_data_text
|
||||
if (count($strInsertDataText) > 0) {
|
||||
$strInsert = "INSERT INTO srv_data_text".$this->db_table." (spr_id, vre_id, text, usr_id) VALUES ";
|
||||
$strInsert .= implode(',',$strInsertDataText);
|
||||
sisplet_query($strInsert);
|
||||
}
|
||||
# vstavimo v srv_data_vrednost
|
||||
if (count($strInsertDataVrednost) > 0) {
|
||||
$strInsert = "INSERT INTO srv_data_vrednost".$this->db_table." (spr_id, vre_id, usr_id) VALUES ";
|
||||
$strInsert .= implode(',',$strInsertDataVrednost);
|
||||
sisplet_query($strInsert);
|
||||
}
|
||||
}
|
||||
|
||||
sisplet_query("COMMIT");
|
||||
|
||||
# zloopamo skozi prejemnike in personaliziramo sporočila in jih pošljemo
|
||||
@ -5897,19 +5957,13 @@ class SurveyInvitationsNew {
|
||||
# updejtamo userja da mu je bilo poslano
|
||||
if ( count($send_ok_ids) > 0) {
|
||||
|
||||
$sqlString = "UPDATE srv_invitations_recipients SET sent = '1', date_sent = '".$date_sent."' WHERE id IN (".implode(',',$send_ok_ids).")";
|
||||
$sqlQuery = sisplet_query($sqlString);
|
||||
|
||||
if (!$sqlQuery) {
|
||||
$sqlQuery = sisplet_query("UPDATE srv_invitations_recipients SET sent='1', date_sent = '".$date_sent."' WHERE id IN (".implode(',',$send_ok_ids).")");
|
||||
if (!$sqlQuery)
|
||||
$error = mysqli_error($GLOBALS['connect_db']);
|
||||
}
|
||||
|
||||
$sqlString = "UPDATE srv_invitations_recipients SET last_status = '1' WHERE id IN (".implode(',',$send_ok_ids).") AND last_status IN ('0','2')";
|
||||
$sqlQuery = sisplet_query($sqlString);
|
||||
|
||||
if (!$sqlQuery) {
|
||||
$sqlQuery = sisplet_query("UPDATE srv_invitations_recipients SET last_status='1' WHERE id IN (".implode(',',$send_ok_ids).") AND last_status IN ('0','2')");
|
||||
if (!$sqlQuery)
|
||||
$error = mysqli_error($GLOBALS['connect_db']);
|
||||
}
|
||||
}
|
||||
|
||||
$msg = array($lang['srv_inv_activate_respondents']. count($send_ok_ids));
|
||||
|
@ -20,85 +20,43 @@ class SurveyVoting{
|
||||
}
|
||||
|
||||
|
||||
// Izvedemo vse potrebno pri vklopu (vklopimo obvescanje, ugasnemo belezenje parapodatkov...)
|
||||
public function turnOnVoting(){
|
||||
global $lang;
|
||||
|
||||
SurveySetting::getInstance()->Init($this->anketa);
|
||||
|
||||
// Ugasnimo belezenje vseh parapodatkov
|
||||
SurveySetting::getInstance()->setSurveyMiscSetting('survey_ip', '1');
|
||||
SurveySetting::getInstance()->setSurveyMiscSetting('survey_show_ip', '0');
|
||||
SurveySetting::getInstance()->setSurveyMiscSetting('survey_browser', '1');
|
||||
SurveySetting::getInstance()->setSurveyMiscSetting('survey_referal', '1');
|
||||
SurveySetting::getInstance()->setSurveyMiscSetting('survey_date', '1');
|
||||
|
||||
// Vklopimo email vabila
|
||||
sisplet_query("UPDATE srv_anketa SET user_base='1', show_email='0' WHERE id='".$this->anketa."'");
|
||||
sisplet_query("INSERT INTO srv_anketa_module (ank_id, modul) VALUES ('".$this->anketa."', 'email')");
|
||||
}
|
||||
|
||||
// Nastavitve volitev
|
||||
public function displaySettings(){
|
||||
global $lang;
|
||||
|
||||
echo 'Nastavitve volitev';
|
||||
echo '<fieldset><legend>'.$lang['settings'].'</legend>';
|
||||
|
||||
// Posebne opcije in navodile za anketo kviz
|
||||
/*echo '<fieldset><legend>'.$lang['srv_kviz_navodila_1'].'</legend>';
|
||||
echo '<p>'.$lang['srv_kviz_navodila_2'].'</p>';
|
||||
echo '<p>'.$lang['srv_kviz_navodila_3'].'</p>';
|
||||
echo '<p>'.$lang['srv_kviz_navodila_4'].'</p>';
|
||||
echo '<p>'.$lang['srv_kviz_navodila_6'].' '.Help::display('DataPiping').'</p>';
|
||||
echo '<p>'.$lang['srv_kviz_navodila_7'].'</p>';
|
||||
echo '</fieldset>';*/
|
||||
echo '<br>';
|
||||
echo ' <div class="buttonwrapper floatLeft"><a class="ovalbutton ovalbutton_orange" href="index.php?anketa='.$this->anketa.'&a='.A_INVITATIONS.'">'.$lang['srv_inv_nav_email'].'</a></div>';
|
||||
echo '<br><br>';
|
||||
|
||||
|
||||
/*echo '<fieldset><legend>'.$lang['settings'].'</legend>';
|
||||
|
||||
// Pridobimo trenutne nastavitve
|
||||
$settings = $this->getSettings();
|
||||
|
||||
// Prikaz rezultatov v zakljucku
|
||||
echo '<span class="nastavitveSpan1" >'.$lang['srv_quiz_results'].':</span>';
|
||||
echo '<label for="quiz_results_0"><input type="radio" name="quiz_results" id="quiz_results_0" value="0" '.(($settings['results'] == 0) ? ' checked="checked" ' : '').' />'.$lang['no1'].'</label>';
|
||||
echo '<label for="quiz_results_1"><input type="radio" name="quiz_results" id="quiz_results_1" value="1" '.(($settings['results'] == 1) ? ' checked="checked" ' : '').' />'.$lang['yes'].'</label>';
|
||||
|
||||
echo '<br />';
|
||||
|
||||
// Prikaz grafa rezultatov v zakljucku
|
||||
echo '<span class="nastavitveSpan1" >'.$lang['srv_quiz_results_chart'].':</span>';
|
||||
echo '<label for="quiz_results_chart_0"><input type="radio" name="quiz_results_chart" id="quiz_results_chart_0" value="0" '.(($settings['results_chart'] == 0) ? ' checked="checked" ' : '').' />'.$lang['no1'].'</label>';
|
||||
echo '<label for="quiz_results_chart_1"><input type="radio" name="quiz_results_chart" id="quiz_results_chart_1" value="1" '.(($settings['results_chart'] == 1) ? ' checked="checked" ' : '').' />'.$lang['yes'].'</label>';
|
||||
|
||||
echo '<br /><br />';
|
||||
|
||||
echo '</fieldset>';
|
||||
|
||||
|
||||
// Gumb shrani
|
||||
echo '<br class="clr" />';
|
||||
echo '<span class="floatLeft spaceRight"><div class="buttonwrapper"><a class="ovalbutton ovalbutton_orange btn_savesettings" href="#" onclick="quiz_save_settings(); return false;"><span>';
|
||||
echo $lang['edit1337'] . '</span></a></div></span>';
|
||||
echo '<div class="clr"></div>';
|
||||
echo '<div id="success_save"></div>'; */
|
||||
echo '</fieldset>';
|
||||
}
|
||||
|
||||
// Pridobimo trenutne nastavitve kviza za anketo
|
||||
public function getSettings(){
|
||||
// Pridobimo trenutne nastavitve volitev za anketo
|
||||
private function getSettings(){
|
||||
|
||||
$settings = array();
|
||||
|
||||
// Default vrednosti
|
||||
/* $settings['results'] = '1';
|
||||
$settings['results_chart'] = '0';
|
||||
|
||||
$sql = sisplet_query("SELECT * FROM srv_quiz_settings WHERE ank_id='".$this->anketa."'");
|
||||
if(mysqli_num_rows($sql) > 0){
|
||||
$row = mysqli_fetch_array($sql);
|
||||
|
||||
$settings['results'] = $row['results'];
|
||||
$settings['results_chart'] = $row['results_chart'];
|
||||
}*/
|
||||
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
|
||||
public function ajax() {
|
||||
|
||||
if(isset($_GET['a']) && $_GET['a'] == 'save_settings'){
|
||||
|
||||
/*$results = isset($_POST['results']) ? $_POST['results'] : '';
|
||||
$results_chart = isset($_POST['results_chart']) ? $_POST['results_chart'] : '0';
|
||||
|
||||
$sql = sisplet_query("INSERT INTO srv_quiz_settings
|
||||
(ank_id, results, results_chart) VALUES ('".$this->anketa."', '".$results."', '".$results_chart."')
|
||||
ON DUPLICATE KEY UPDATE results='".$results."', results_chart='".$results_chart."'");
|
||||
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1151,15 +1151,13 @@ class InitClass extends Controller
|
||||
$rowu = mysqli_fetch_array($sqlu);
|
||||
|
||||
$sqlu = sisplet_query("SELECT inv_res_id FROM srv_user WHERE id = '" . get('usr_id') . "' AND inv_res_id IS NOT NULL");
|
||||
// ddd(get('usr_id'), "SELECT inv_res_id FROM srv_user WHERE id = '".get('usr_id')."' AND inv_res_id IS NOT NULL");
|
||||
$inv_res_id = null;
|
||||
if (mysqli_num_rows($sqlu) > 0) {
|
||||
//dd('not');
|
||||
# userj je dodan preko novih vabil zato updejtamo status še tam
|
||||
$row_inv_res_id = mysqli_fetch_assoc($sqlu);
|
||||
$inv_res_id = (int)$row_inv_res_id['inv_res_id'];
|
||||
}
|
||||
// ddd($inv_res_id);
|
||||
|
||||
// spremenimo tip
|
||||
if ($status > $rowu['status'] && is_numeric(get('usr_id'))) {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user