0 ) { self::$user_setting = mysqli_fetch_assoc($sqlUserSetting); self::$inited=true; return true; } else { // uporabnik se nima svojih nastavitev. preberemo iz sistemskih // TODO //zaenkrat kar direkt nastavimo privzete nastavitve self::$user_setting['icons_always_on'] = 0; self::$user_setting['full_screen_edit'] = 0; self::$user_setting['autoActiveSurvey'] = 0; self::$user_setting['lockSurvey'] = 1; self::$user_setting['activeComments'] = 0; self::$user_setting['showIntro'] = 1; self::$user_setting['showConcl'] = 1; self::$user_setting['showSurveyTitle'] = 1; self::$inited=true; return true; } } else { return false; } } } static function getUserId() { return self::$userId; } static function getUserSetting($what) { return self::$user_setting[$what] ?? null; } /** @desc ponastavi nastavitev in shrani v bazo * */ static function setUserSetting($what, $value) { if (isset($what) && isset($value)) { self::$changed[$what] = $value; self::$user_setting[$what] = $value; } else return false; } /** @desc v bazi popravimo vse spremenjene zapise zapis * */ static function saveUserSetting() { if (self::$inited && is_countable(self::$changed) && count(self::$changed) > 0 ) { $str_insert_fields = 'usr_id'; $str_insert_values = "'".self::$userId."'"; $str_update_text = ''; $str_update_prefix = ''; foreach (self::$changed as $what => $value) { if (isset(self::$user_setting[$what])) { $str_insert_fields .= ', '.$what; $str_insert_values .= ", '".self::$user_setting[$what]."'"; $str_update_text .= $str_update_prefix . $what."='".self::$user_setting[$what]."'"; $str_update_prefix = ', '; } unset(self::$changed[$what]); } // sestavimo mysql insert string $insertString = 'INSERT INTO srv_user_setting ('.$str_insert_fields.') VALUES ('.$str_insert_values.') ON DUPLICATE KEY UPDATE '.$str_update_text; self::$changed = array(); $insert = sisplet_query($insertString); return mysqli_affected_rows($GLOBALS['connect_db']); } else { // manjkajo podatki za vpis v bazo return false; } } } ?>