Init(self::$sid, self::getGlobalUserId());
if (self::$inited == false) {
self::$inited = self :: RefreshData();
}
}
static function RefreshData() {
# preberemo podatke vseh porfilov ki so na voljo in jih dodamo v array
$stringSelect = "SELECT * FROM srv_status_casi WHERE uid = '".self::getGlobalUserId()."' OR (uid = '0' AND `system` =1) ORDER BY id";
$querySelect = sisplet_query($stringSelect);
while ( $rowSelect = mysqli_fetch_assoc($querySelect) ) {
self::$profiles[$rowSelect['id']] = $rowSelect;
}
# poiscemo privzet profil
self::$currentProfileId = SurveyUserSetting :: getInstance()->getSettings('default_status_casi');
if (!self::$currentProfileId || self::$currentProfileId == 1)
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;
self::setDefaultProfileId(self::$currentProfileId);
}
}
# ce ne obstajajo podatki za cpid damo error
if (!isset(self::$profiles[self::$currentProfileId])) {
die("Profile data is missing!");
return false;
} else {
return true;
}
}
static function DisplayProfile( $pid = null) {
global $lang;
if ($pid == null ) {
$pid = self::$currentProfileId;
}
echo '
';
self :: DisplayProfileOptions($pid);
echo '
';
echo '';
echo '
';
self :: DisplayProfileData($pid);
echo '
';
echo '
';
echo '
';
// cover Div
echo '
'."\n";
// div za shranjevanje novega profila
echo ''."\n";
/*
// div za preimenovanje
echo ''."\n";
*/
// div za brisanje
echo ''."\n";
}
static function DisplayProfileData($pid) {
global $lang;
$curentProfileData = self :: $profiles[$pid];
// echo 'help?'.'
';
echo '';
echo '
'."\n";
echo '' . $lang['srv_missing_profile_title4'] . ' '."\n";
echo ''."\n";
echo ' '."\n";
echo '
'."\n";
}
static function DisplayProfileOptions($pid) {
global $lang;
echo '';
foreach ( self::$profiles as $key => $profile ) {
echo '
' . $profile['name'] . '
';
}
echo '
';
echo '';
echo '';
}
/** getProfiles
*
*/
static function getProfiles() {
return self::$profiles;
}
/** setSurveyId
*
*/
static function setSId($surveyId) {
self::$sid = $surveyId;
}
/** setGlobalUserId
*
*/
static function setGlobalUserId($uid = null) {
if ($uid == null) {
global $global_user_id;
self::$uid = $global_user_id;
} else {
self::$uid = $uid;
}
}
/** getGlobalUserId
*
*/
static function getGlobalUserId() {
return self::$uid;
}
static function getCurentProfileId() {
return self::$currentProfileId;
}
/**
*
* @param unknown_type $pid
*/
static function setCurentProfileId($pid) {
if ($pid < 1)
$pid = 1;
return self::$currentProfileId = $pid;
}
static function setDefaultProfileId($pid) {
if (!$pid)
$pid = 1;
SurveyUserSetting :: getInstance()->saveSettings('default_status_casi', $pid);
self::$currentProfileId = $pid;
return true;
}
static function getStatusAsArrayString() {
$mpds = self::getStatusArray(self::$currentProfileId);
$result = array();
if ($mpds) {
foreach ( self::$appropriateStatus as $index) {
if (isset($mpds['status'.$index]) && $mpds['status'.$index] == 1)
$result[$index] = $index;
}
foreach ( self::$unAppropriateStatus as $index) {
if (isset($mpds['status'.$index]) && $mpds['status'.$index] == 1)
$result[$index] = $index;
}
foreach ( self::$unKnownStatus as $index) {
if (isset($mpds['status'.$index]) && $mpds['status'.$index] == 1)
$result[$index] = $index;
}
if (isset($mpds['statuslurker']) && $mpds['statuslurker'] == 1)
$result['lurker'] = 'lurker';
}
return $result;
}
static function getStatusArray($pid) {
$mpd = self::$profiles[$pid];
return $mpd;
}
/** Shranimo v obstoječ profil
*
* @param unknown_type $pid
* @param unknown_type $name
* @param unknown_type $status
*/
static function saveProfile($pid,$status) {
$insert_id = 0;
if (isset($pid) && $pid != null && isset($status) && $status != null) {
if ($pid == 1) { # ce mamo privzet profil ga ne shranjujemo
return 1;
}
# imamo podatke, updejtamo profil v bazi
$statusi = explode(',',$status);
if (count(self::$allStatus) > 0 ) {
$updateString = "UPDATE srv_status_casi SET ";
$prefix = '';
foreach (self::$allStatus as $_status) {
$updateString .= $prefix . 'status'.$_status. ' = '.(in_array((string)$_status,$statusi) ? '1' : '0');
$prefix =', ';
}
$updateString .= " WHERE id = '".$pid."'";
}
$queryUpdate = sisplet_query($updateString)
or die(mysqli_error($GLOBALS['connect_db']));
return $pid;
}
}
/** Shranimo kot nov profil
*
* @param unknown_type $pid
* @param unknown_type $name
* @param unknown_type $status
*/
static function saveNewProfile($pid,$name,$status) {
$insert_id = 0;
if (isset($pid) && $pid != null && isset($name) && $name != null && isset($status) && $status != null) {
# imamo podatke, vstavimo nov profil v bazo
#id uid name system statusnull status0 status1 status2 status3 status4 status5 status6
$statusi = explode(',',$status);
$str_lbl = '';
$str_vle = '';
foreach ($statusi as $_status) {
$str_lbl .= ', status'.$_status;
$str_vle .= ', 1';
}
$insertString = "INSERT INTO srv_status_casi (uid,name,system".$str_lbl.") VALUES ('".self::getGlobalUserId()."', '".$name."', 0".$str_vle.")";
$queryInsert = sisplet_query($insertString)
or die(mysqli_error($GLOBALS['connect_db']));
$insert_id = mysqli_insert_id($GLOBALS['connect_db']);
}
return $insert_id;
}
static function Delete($pid) {
if ($pid != 1) {
$sqlDelete = sisplet_query("DELETE FROM srv_status_casi WHERE id = '$pid' AND `system` != '1'");
print_r("DELETE FROM srv_status_casi WHERE id = '$pid' AND `system` != '1'");
}
}
}
?>