'6',5=>'5',4=>'4',3=>'3',2=>'2',1=>'^1',0=>'0','null'=>'-1'); # texti za statuse. 6=>'6',5=>'5',4=>'4',3=>'3',2=>'2',1=>'^1',0=>'0',null=>'-1' Pri 1 je ^pomemben, če ne lahko vzame tudi -1
static private $allUserCount = 0; #Koliko je vseh userjev
static private $allValidCount = 0; #Koliko je veljavnih userjev
static private $survayDefaultUstrezni = 2; #privzet ustrezni profil: 2-ustrezni (5,6) 3-končani(6)
static function Init($sid, $uid = null) {
# nastavimo surveyId
self::setSId($sid);
SurveyInfo :: getInstance()->SurveyInit(self::$sid);
# nastavimo userja
self::setGlobalUserId($uid);
if ((int)SurveyInfo :: getInstance()->getSurveyColumn('defValidProfile') == 3) {
self::$survayDefaultUstrezni = 3;
}
# preštejemo userje
$str_all = "SELECT count(*) FROm srv_user WHERE ank_id='".self::$sid."' AND deleted='0' AND preview = '0'";
if (self::$survayDefaultUstrezni == 2) {
$str_valid = "SELECT count(*) FROM srv_user WHERE ank_id='".self::$sid."' AND last_status IN (5,6) AND lurker = 0 AND deleted='0' AND preview = '0' AND testdata='0'";
} else {
$str_valid = "SELECT count(*) FROM srv_user WHERE ank_id='".self::$sid."' AND last_status = '6' AND lurker = 0 AND deleted='0' AND preview = '0' AND testdata='0'";
}
$query_all = sisplet_query($str_all);
$query_valid = sisplet_query($str_valid);
list($all) = mysqli_fetch_row($query_all);
list($valid) = mysqli_fetch_row($query_valid);
self::$allUserCount = $all;
self::$allValidCount = $valid;
SurveyUserSetting :: getInstance()->Init(self::$sid, self::getGlobalUserId());
self :: RefreshData();
}
static function getAllValidCount() {
return self::$allValidCount;
}
static function getAllUserCount() {
return self::$allUserCount;
}
static function RefreshData() {
global $lang;
$lang_admin = SurveyInfo :: getInstance()->getSurveyColumn('lang_admin');
self::$profiles = array();
# dodamo sejo če obstaja
if (isset($_SESSION['statusProfile'])) {
if ( $lang_admin != 1 ) {
$_SESSION['statusProfile']['name'] = $lang['srv_temp_profile'];
}
self::$profiles[$_SESSION['statusProfile']['id']] = $_SESSION['statusProfile'];
}
# preberemo podatke vseh porfilov ki so na voljo in jih dodamo v array
$stringSelect = "SELECT * FROM srv_status_profile WHERE uid='".self::getGlobalUserId()."' OR ank_id = '".self::$sid."' OR (uid = '0' AND `system`=1) ORDER BY id";
$querySelect = sisplet_query($stringSelect);
while ( $rowSelect = mysqli_fetch_assoc($querySelect) ) {
if ( $lang_admin != 1 && $rowSelect['system'] == 1 ) {
# imamo sistemski profil v tujem jeziku popravimo tekste
$rowSelect['name'] = $lang['srv_status_profile_system_'.$rowSelect['id']];
}
self::$profiles[$rowSelect['id']] = $rowSelect;
}
# ker si Vasja skoz nekaj zmišljuje glede imen sistemskih profilov (ki so zaenkrat v bazi) jih ročno prepišemo
# pa še jezikovno tabelo lahko uporabimo, tak da je to boljše
self::$profiles[1]['name'] = $lang['srv_status_profile_system_1'];
self::$profiles[2]['name'] = $lang['srv_status_profile_system_2'];
self::$profiles[3]['name'] = $lang['srv_status_profile_system_3'];
# vsi statusi ni pomembno ali je lurker ali ne
# pri ustreznih ne sme biti lurker in ne testni
self::$profiles[1]['statuslurker'] = 2;
self::$profiles[2]['statuslurker'] = 0;
self::$profiles[3]['statuslurker'] = 0;
self::$profiles[1]['statustestni'] = 2;
self::$profiles[2]['statustestni'] = 0;
self::$profiles[3]['statustestni'] = 0;
// Uporabnost - vedno so vsi vklopljeni po defaultu
self::$profiles[1]['statusnonusable'] = 1;
self::$profiles[2]['statuspartusable'] = 1;
self::$profiles[3]['statususable'] = 1;
# poiscemo privzet profil
#določimo podstran
if (isset($_POST['meta_akcija']) && $_POST['meta_akcija'] != '') {
$_podstran = $_POST['meta_akcija'];
} else if (isset($_POST['podstran']) && $_POST['podstran'] != '') {
$_podstran = $_POST['podstran'];
} else if (isset($_GET['a']) && $_GET['a'] != '') {
$_podstran = $_GET['a'];
} else {
$_podstran = A_COLLECT_DATA;
}
if ( (($_podstran !== A_COLLECT_DATA && $_podstran !== A_COLLECT_DATA_EXPORT && $_podstran !== 'para_graph') || (isset($_GET['b']) && $_GET['b'] == 'export')) && $_podstran !== 'usable_resp' && $_podstran !== 'reminder_tracking') {
$_podstran = A_ANALYSIS;
}
// Pri izvozu podatkov uporabimo isti profil kot pri ostalih podatkih
if ($_podstran == A_COLLECT_DATA_EXPORT) {
$_podstran = A_COLLECT_DATA;
}
# če smo v vpogledu pohandlammo posebej
if (($_podstran == A_COLLECT_DATA && $_GET['m'] == 'quick_edit') || $_POST['podstran'] == 'quick_edit') {
$_podstran = 'vpogled';
}
self::$currentProfileId = SurveyUserSetting :: getInstance()->getSettings('default_status_profile_'.$_podstran);
if (!self::$currentProfileId) {
#self::$currentProfileId = 2;
self::$currentProfileId = self::$survayDefaultUstrezni; # je lahko 2 ali 3
}
# ustrezni je lahko samo če so kakšni ustrezni zapisi v bazi ob pogoju da pa neustrezni obstajajao
if (self::$allValidCount == 0 && self::$allUserCount > 0) {
if (self::$currentProfileId == 2 || self::$currentProfileId == 3 ) {
# privzeto nastavimo na vsi
self::$currentProfileId = 1;
}
}
# ce imamo nastavljen curent pid in profil z tem pid ne obstaja nastavomo na privzet profil
if (self::$currentProfileId != 1) {
if (!isset(self::$profiles[self::$currentProfileId])) {
self::$currentProfileId = 1;
}
}
# ce ne obstajajo podatki za cpid damo error
if (!isset(self::$profiles[self::$currentProfileId])) {
die("Profile data is missing!");
return false;
} else {
return true;
}
}
public static function getSystemDefaultProfile() {
$sysDefProf = self::$survayDefaultUstrezni; # je lahko 2 ali 3
# ustrezni je lahko samo če so kakšni ustrezni zapisi v bazi ob pogoju da pa neustrezni obstajajao
if (self::$allValidCount == 0 && self::$allUserCount > 0) {
if ($sysDefProf == 2 || $sysDefProf == 3 ) {
# privzeto nastavimo na vsi
$sysDefProf = 1;
}
}
return (int)$sysDefProf;
}
public static function getDefaultProfile() {
return self::$currentProfileId;
}
static function DisplayProfile( $pid = null) {
global $lang;
if ($pid == null ) {
$pid = self::$currentProfileId;
}
$popUp = new PopUp();
$popUp->setId('divStatusProfile');
$popUp->setHeaderText($lang['srv_status_settings']);
#vsebino shranimo v buffer
ob_start();
if ( self::$currentProfileId != SSP_DEFAULT_PROFILE ) {
echo '
';
return;
}
static function showColectDataSetting() {
global $lang, $admin_type;
$_sql_string = "SELECT collect_all_status FROM srv_data_files WHERE sid = '".self::$sid."'";
$_sql_qry = sisplet_query($_sql_string);
list($collect_all_status) = mysqli_fetch_row($_sql_qry);
$str_qry_cnt_user = "SELECT count(*) FROM srv_user AS u WHERE u.ank_id = '".self::$sid."'";
$_qry_cnt_user = sisplet_query($str_qry_cnt_user);
list($all_user_cnt) = mysqli_fetch_row($_qry_cnt_user);
#vsebino shranimo v buffer
$content = '';
# kadar imamo uporabnikov več kakor ONLY_VALID_LIMIT (5000) ne dovolimo nastaviti na vse statuse, zato dodamo obvestilo
# le admin lahko nastavi da generira tudi nad 5000 takrat nastavimo collect_all_status = 2
if ($all_user_cnt > ONLY_VALID_LIMIT && (int)$admin_type > 1)
{
$content .= '';
$content .= 'Anketa vsebuje več kakor '.ONLY_VALID_LIMIT.' respondentov, zato je dovoljen prikaz le ustreznih!';
$content .= '
';
$content .= ''.$lang['srv_collect_data_setting_note'] . Help :: display('srv_collect_data_setting').'';
$content .= '';
}
else
{
$content .= ''.$lang['srv_collect_data_setting_note'] . Help :: display('srv_collect_data_setting').'';
$content .= '';
}
$content .= ' ';
$content .= ' ';
$content .= ''.$lang['srv_deleteSurveyDataFile_link'].'';
$popUp = new PopUp();
$popUp->setId('div_data_file');
$popUp -> setHeaderText($lang['srv_file_settings']);
#dodamo vsebino
$popUp -> setContent($content);
#dodamo gumb izberi profil
$button = new PopUpButton($lang['srv_save_profile']);
$button -> setFloat('right')
-> setButtonColor('orange')
-> addAction('onClick','changeColectDataStatus(); return false;');
$popUp->addButton($button);
# dodamo gumb Prekliči
$button = new PopUpCancelButton();
$button -> setFloat('right');
$popUp->addButton($button);
echo $popUp;
}
static function savecollectdatasetting() {
global $admin_type;
// Najprej pobrišemo vse datoteke
$SDF = SurveyDataFile::get_instance();
$SDF->init(self::$sid);
$SDF->clearFiles();
$_collect_all_status = (isset($_POST['collect_all_status']) && (int)$_POST['collect_all_status'] == 1 ) ? '1' : '0';
if ($admin_type == '0' && $_collect_all_status == '1') {
$_collect_all_status = '2';
}
// Ce imamo socialna omrezja, zacasno vedno generiramo samo ustrezne
if(SurveyInfo::getInstance()->checkSurveyModule('social_network')){
$_collect_all_status = '0';
}
// če smo zbrali samo statuse ustrezno, popravimo profile da ni izbran profil vsi statusi
if ((int)$_collect_all_status == 0) {
// Ce smo izbrali drug profil resetiramo še profil profilov na trenutne nastavitve
SurveyUserSetting :: getInstance()->saveSettings('default_profileManager_pid', '0');
SurveyUserSetting :: getInstance()->saveSettings('default_status_profile_data', 2);
SurveyUserSetting :: getInstance()->saveSettings('default_status_profile_analysis', 2);
}
}
static function getProfilesValues()
{
$_sql_string = "SELECT collect_all_status FROM srv_data_files WHERE sid = '".self::$sid."'";
$_sql_qry = sisplet_query($_sql_string);
list($collect_all_status) = mysqli_fetch_row($_sql_qry);
return array('all_status'=>(int)$collect_all_status);
}
static function getActiveProfileUserCount()
{
$pid = self::$currentProfileId;
if ($pid == 1)
{
return (int)self::$allUserCount;
}
else if( $pid == 2)
{
return (int)self::$allValidCount;
}
else
{
# preštejemo userje
$str_all = "SELECT count(*) FROm srv_user WHERE ank_id='".self::$sid."' AND deleted='0' AND preview = '0' ".self::getStatusAsQueryString($pid);
$query_all = sisplet_query($str_all);
list($all) = mysqli_fetch_row($query_all);
return $all;
}
}
static function displayOnlyValidCheckbox(){
global $lang;
$pid = self::$currentProfileId;
$values = self::getProfilesValues();
$collect_all_status = $values['all_status'];
#če ni ustreznih uporabnikov je privzeto vsi
if (self::$allValidCount == 0) {
$pid = 1;
$disabledValid = ' disabled="disabled"';
$disabledGray = ' gray';
} else if (self::$allValidCount > 0 && $collect_all_status == 0) {
if ( $pid == 1 ) {
#$pid = 2;
$pid = self::$survayDefaultUstrezni;
}
$disabledAll = ' disabled="disabled"';
$disabledAllGray = ' gray';
}
echo '';
echo ' ';
if (self::$survayDefaultUstrezni == 2) {
echo '';
} else {
echo '