$row['starts'],'expire'=>$row['expire']);
}
// dodamo trenutno nastavljeno aktivnost
$activity[] = array('starts'=>$_starts,'expire'=>$_expire);
} else {
// anketa ni aktivna, preberemo samo iz tabele aktivnosti
$str = "SELECT DISTINCT starts, expire FROM srv_activity WHERE sid = '".self::getSurveyId()."'";
$qry = sisplet_query($str);
while ($row = mysqli_fetch_assoc($qry)) {
$activity[] = array('starts'=>$row['starts'],'expire'=>$row['expire']);
}
}
return $activity;
}
static function DisplayInfoBox($showIcons = false) {
global $lang;
global $site_url;
global $global_user_id;
// Ce smo v seznamu anket upostevamo splosni jezik in ne jezik ankete
if(isset($_GET['a']) && $_GET['a'] == 'surveyList_display_info'){
$lang_orig = $lang['id'];
$sql = sisplet_query("SELECT lang FROM users WHERE id = '$global_user_id'");
$row = mysqli_fetch_array($sql);
$lang_admin = $row['lang'];
// Naložimo jezikovno datoteko
if($lang_admin != $lang_orig){
$file = '../../lang/'.$lang_admin.'.php';
include($file);
}
echo '
';
}
echo ''.$lang['srv_status_osnovni'].'
';
// spremenljivk
echo '' . $lang['srv_info_name'] . ':' . self::getSurveyTitle() . '
';
echo '' . $lang['srv_info_type'] . ':' . $lang['srv_vrsta_survey_type_'.self::getSurveyType()] . '
';
echo '' . $lang['srv_info_questions']. ':' .self::getSurveyQuestionCount().'
';
echo '' . $lang['srv_info_variables']. ':' .self::getSurveyVariableCount().'
';
echo '' . $lang['srv_info_answers']. ':' .self::getSurveyAnswersCount().'
';
echo '' . $lang['srv_info_answers_valid']. ':' .self::getSurveyApropriateAnswersCount().'
';
# jezik izpolnjevanja
echo '' . $lang['srv_info_language']. ':'.self::getRespondentLanguage().'
';
echo '' . ($showIcons ? ' ' : '' )
. $lang['srv_info_author']. ':' .self::getSurveyInsertEmail();
if (self::getSurveyInsertDate() && self::getSurveyInsertDate() != "00.00.0000")
echo self::$dateTimeSeperator . self::getSurveyInsertDate();
if (self::getSurveyInsertTime() && self::getSurveyInsertTime() != "00:00:00")
echo self::$dateTimeSeperator . self::getSurveyInsertTime();
echo '
';
echo '' . ($showIcons ? ' ' : '' )
. $lang['srv_info_modify']. ':' .self::getSurveyEditEmail();
if (self::getSurveyEditDate() && self::getSurveyEditDate() != "00.00.0000")
echo self::$dateTimeSeperator . self::getSurveyEditDate() ;
if (self::getSurveyEditTime() && self::getSurveyEditTime() != "00:00:00")
echo self::$dateTimeSeperator . self::getSurveyEditTime();
echo '
';
$dostop = self::getSurveyAccessUsers();
// dostop, Kdo razen avtorja ima dostop
if ($dostop) {
$cnt=0;
foreach ( $dostop as $user) {
if ($cnt==0) {
echo '';
echo ($showIcons ? ' ' : '');
echo $lang['srv_info_access']. ': '.$user['name']." (".$user['email'].")
";
}
else
echo ''.$user['name']." (".$user['email'].')
';
$cnt++;
}
}
// aktivnost
echo '';
echo ($showIcons ? ' ' : '');
echo $lang['srv_info_activity']. ': ';
$activity = self:: getSurveyActivity();
if ( count($activity) > 0 ) {
$prefix = '';
foreach ($activity as $active) {
$_starts = explode('-',$active['starts']);
$_expire = explode('-',$active['expire']);
echo $prefix.$_starts[2].'.'.$_starts[1].'.'.$_starts[0].'-'.$_expire[2].'.'.$_expire[1].'.'.$_expire[0];
$prefix = '; ';
}
} else {
echo $lang['srv_anketa_noactive2'].'!';
}
echo "
";
// prvi / zadnj vnos
if (trim(self::getSurveyFirstEntryDate()) != '') {
echo '';
echo ($showIcons ? ' ' : '');
echo $lang['srv_info_first_entry']. ': ' . self::getSurveyFirstEntryDate() . self::$dateTimeSeperator .self::getSurveyFirstEntryTime() . '
';
}
if (trim(self::getSurveyLastEntryDate()) != '') {
echo '';
echo ($showIcons ? ' ' : '');
echo $lang['srv_info_last_entry']. ': ' . self::getSurveyLastEntryDate() . self::$dateTimeSeperator . self::getSurveyLastEntryTime() . '
';
}
echo '
';
$link = $site_url.'admin/survey/index.php?anketa=' . self::$surveyId.'&a=reporti';
echo ''.$lang['srv_more'].' >>';
// Ce smo v seznamu anket upostevamo splosni jezik in ne jezik ankete
if(isset($_GET['a']) && $_GET['a'] == 'surveyList_display_info'){
// Naložimo originalno jezikovno datoteko
if($lang_admin != $lang_orig){
$file = '../../lang/'.$lang_orig.'.php';
include($file);
}
}
}
static function doVariablesCount($query) {
// zloopamo skozi vprašanja in za vsako vprašan je preberemo št variabel
$cnt= 0;
while ($rowVprasanje = mysqli_fetch_assoc($query)) {
$spr_id= $rowVprasanje['id'];
switch ( $rowVprasanje['tip'] ) { // v odvisnosti od tipa vprašanja pohandlamo podatke
case 1: // radio
case 3: // dropdown
$cnt++; // za sam header
$sqlSrvVred = self::select_sql_vrednost($rowVprasanje['id']);
while ( $rowSrvVred = mysqli_fetch_assoc($sqlSrvVred) ) {
if ($rowSrvVred['other'] == 1)
{
$cnt++; // za text polje
}
}
break;
case 2: // checkbox
case 6: // multigrid
case 18: // vsota
case 17: // ranking
case 21: // text*
// $cnt++; // za sam header
$sqlSrvVred = self::select_sql_vrednost($rowVprasanje['id']);
while ( $rowSrvVred = mysqli_fetch_assoc($sqlSrvVred) ) {
$cnt++; // za vsako variablo
if ($rowSrvVred['other'] == 1) {
$cnt++; // za text polje (polj edrugo še ima tekstovni vnos
}
}
break;
case 4: // text
case 8: // datum
case 7: // number
case 22:// compute
case 25:// kvota
$cnt++;
if ( $rowVprasanje['tip'] == 7 && $rowVprasanje['size'] != 1 ) {
$cnt+=2;
}
break;
case 16: // multicheckbox
case 19: // multitext
case 20: // multinumber
$cnt++; // za sam header
$sqlSrvVred = self::select_sql_vrednost($spr_id);
//gridi s katerimi sestavljamo header (vrstica_grid)
while ( $rowSrvVred = mysqli_fetch_assoc($sqlSrvVred) ) {
//loop cez gride znotraj ene vrstice - ponovimo za vsako vrstico
$sqlSrvGrid = self::select_sql_grid($spr_id);
while ( $colSrvVred = mysqli_fetch_assoc($sqlSrvGrid) ) {
$cnt++;
}
if ($rowSrvVred['other'] == 1) {
$cnt++;
}
}
break;
case 26: // lokacija
if($rowVprasanje['enota'] == 3){
$sqlSrvVred = self::select_sql_vrednost($rowVprasanje['id']);
while ( $rowSrvVred = mysqli_fetch_assoc($sqlSrvVred) ) {
$cnt++; // za vsako variablo
}
}
else
$cnt++; // moja lokacija in multilokacija je 1
break;
case 27: // heatmap
$cnt++; // za koordinate
$sqlSrvVred = self::select_sql_vrednost($rowVprasanje['id']);
while ( $rowSrvVred = mysqli_fetch_assoc($sqlSrvVred) ) { //za morebitna obmocja
$cnt++; // za vsako variablo
if ($rowSrvVred['other'] == 1) {
$cnt++; // za text polje (polj edrugo še ima tekstovni vnos
}
}
break;
} // end switch
} // end while
return $cnt;
}
// pointerji do vrednosti zaradi hitrosti
/**
* @desc vrne sisplet_query za podan spr_id. v bistvu kesramo queryje, ker jih uporabljamo (zlo pogosto) v izpisu
*/
//static private $otherCondition = ' AND other NOT IN (99,98,97,96)';
static private $otherCondition = '';
private static $_select_sql_vrednost = array();
static function select_sql_vrednost ($spr_id) {
if ( isset(self::$_select_sql_vrednost[$spr_id]) ) {
// resetiramo pointer in vrnemo ke�iran query
if (mysqli_num_rows(self::$_select_sql_vrednost[$spr_id]))
mysqli_data_seek(self::$_select_sql_vrednost[$spr_id], 0);
return self::$_select_sql_vrednost[$spr_id];
}
else {
self::$_select_sql_vrednost[$spr_id] = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='".$spr_id."' AND vrstni_red > 0".self::$otherCondition." ORDER BY vrstni_red ASC");
return self::$_select_sql_vrednost[$spr_id];
}
}
/**
* @desc vrne sisplet_query za podan spr_id. v bistvu kesramo queryje, ker jih uporabljamo (zlo pogosto) v izpisu
*/
private static $_select_sql_grid = array();
static function select_sql_grid ($spr_id) {
if ( isset(self::$_select_sql_grid[$spr_id]) ) {
// resetiramo pointer in vrnemo ke�iran query
if (mysqli_num_rows(self::$_select_sql_grid[$spr_id]))
mysqli_data_seek(self::$_select_sql_grid[$spr_id], 0);
return self::$_select_sql_grid[$spr_id];
}
else {
self::$_select_sql_grid[$spr_id] = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='".$spr_id."' ORDER BY vrstni_red");
return self::$_select_sql_grid[$spr_id];
}
}
/**
* vrne URL naslov ankete (lahko je lep :) )
*
*/
static private $surveyLink = array();
static function getSurveyLink ($anketa = false, $uporabnost = true) {
global $site_url;
if ($anketa == false)
$anketa = self::$surveyId;
// V get-u ni vec id ankete ampak string (zaradi zascite, da en more kdorkoli dostopati do vseh anket)
$anketa_string = Common::encryptAnketaID($anketa);
if ( ! isset( self::$surveyLink[$anketa_string] ) ) {
$sqll = sisplet_query("SELECT link FROM srv_nice_links WHERE ank_id = '".$anketa."' ORDER BY id ASC LIMIT 1");
if (mysqli_num_rows($sqll) > 0) {
$rowl = mysqli_fetch_array($sqll);
$link = $site_url . $rowl['link'] ;
}
else {
if (self::checkSurveyModule('uporabnost') && $uporabnost == true) // na redirectih pa v form action ne sme it na uporabnost (ker se odpira znotraj frama)
$link = $site_url.'main/survey/uporabnost.php?anketa=' . $anketa_string ;
else
$link = $site_url.'a/' . $anketa_string ;
}
self::$surveyLink[$anketa_string] = $link;
}
return self::$surveyLink[$anketa_string];
}
static function getRespondentLanguage() {
global $lang;
$lang_resp = SurveyInfo::getSurveyColumn('lang_resp');
if ($lang['id'] <> $lang_resp && $lang_resp > 0) {
$lang_old= $lang;
$file = dirname(__FILE__).'/../../../lang/'.$lang_resp.'.php';
if (file_exists($file)) {
include($file);
$_lang_name = $lang['language'];
$lang = $lang_old;
}
} else {
$_lang_name = $lang['language'];
}
$p = new Prevajanje(self::$surveyId);
$arr = $p->get_all_translation_langs();
$dodatni = '';
foreach ($arr AS $l) {
if ($dodatni != '') $dodatni .= ', ';
$dodatni .= $l;
}
if ($dodatni != '') $_lang_name .= ' ('.$dodatni.')';
return $_lang_name;
}
/**
* Polovimo vse module, ki so vklopljeni na anketi
*/
public static function getSurveyModules($ime = null) {
global $global_user_id;
if (!self::$surveyModules) {
$modules = array();
$userAccess = UserAccess::getInstance($global_user_id);
$sql = sisplet_query("SELECT modul, vrednost FROM srv_anketa_module WHERE ank_id='".self::getSurveyId()."'");
while($row = mysqli_fetch_array($sql)){
$module_availible = true;
// Preverimo, ce je modul omogocen v placljivem paketu
switch($row['modul']){
case 'uporabnost':
if(!$userAccess->checkUserAccess($what='uporabnost'))
$module_availible = false;
break;
case 'quiz':
if(!$userAccess->checkUserAccess($what='kviz'))
$module_availible = false;
break;
case 'voting':
if(!$userAccess->checkUserAccess($what='voting'))
$module_availible = false;
break;
case 'social_network':
if(!$userAccess->checkUserAccess($what='social_network'))
$module_availible = false;
break;
case 'slideshow':
if(!$userAccess->checkUserAccess($what='slideshow'))
$module_availible = false;
break;
case 'phone':
if(!$userAccess->checkUserAccess($what='telephone'))
$module_availible = false;
break;
case 'chat':
if(!$userAccess->checkUserAccess($what='chat'))
$module_availible = false;
break;
case 'panel':
if(!$userAccess->checkUserAccess($what='panel'))
$module_availible = false;
break;
}
// Ce je modul na voljo v paketu, ga dodamo v array
if($module_availible)
$modules[$row['modul']] = $row['vrednost'];
}
self::$surveyModules = $modules;
}
if(!is_null($ime) && isset(self::$surveyModules[$ime]))
return self::$surveyModules[$ime];
elseif(!is_null($ime) && sizeof(self::$surveyModules) == 0)
return 0;
else
return self::$surveyModules;
}
/**
* Preverimo, ce je specificen modul vklopljen na anketi
*/
public static function checkSurveyModule($module, $anketa_id = null) {
global $global_user_id;
if(is_null($anketa_id))
$anketa_id = self::getSurveyId();
if($anketa_id > 0 && $module != ''){
// Preverimo, ce je modul omogocen v placljivem paketu
$userAccess = UserAccess::getInstance($global_user_id);
switch($module){
case 'uporabnost':
if(!$userAccess->checkUserAccess($what='uporabnost'))
return false;
break;
case 'quiz':
if(!$userAccess->checkUserAccess($what='kviz'))
return false;
break;
case 'voting':
if(!$userAccess->checkUserAccess($what='voting'))
return false;
break;
case 'social_network':
if(!$userAccess->checkUserAccess($what='social_network'))
return false;
break;
case 'slideshow':
if(!$userAccess->checkUserAccess($what='slideshow'))
return false;
break;
case 'phone':
if(!$userAccess->checkUserAccess($what='telephone'))
return false;
break;
case 'chat':
if(!$userAccess->checkUserAccess($what='chat'))
return false;
break;
case 'panel':
if(!$userAccess->checkUserAccess($what='panel'))
return false;
break;
}
if (!self::$surveyModules) {
$sql = sisplet_query("SELECT EXISTS (SELECT 1 FROM srv_anketa_module WHERE ank_id='".$anketa_id."' AND modul='".$module."')");
$row = mysqli_fetch_array($sql);
if($row[0] > 0)
return true;
else
return false;
}
else{
if(self::$surveyModules[$module] > 0)
return true;
else
return false;
}
}
else
return false;
}
}
?>