diff --git a/src/admin/index.php b/src/admin/index.php index 53cff38..c9db17f 100644 --- a/src/admin/index.php +++ b/src/admin/index.php @@ -56,57 +56,143 @@ InitFilterHelpers(); // Helpers for frontend filtering! IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' ); // --- BEGIN Custom Code - if ( isset($_SESSION['SESSION_ISADMIN']) && $_SESSION['SESSION_ISADMIN'] == 1 ) +{ $content['EditAllowed'] = true; + $content['DISABLE_GLOBALEDIT_FORMCONTROL'] = ""; +} else +{ $content['EditAllowed'] = false; + $content['DISABLE_GLOBALEDIT_FORMCONTROL'] = "disabled"; +} + +// --- First thing to do is to check the op get parameter! +// Check for changes first | Abort if Edit is not allowed +if ( isset($_GET['op']) && isset($_GET['value']) ) +{ + if ( $_GET['op'] == "enableuserops" ) + { + $iNewVal = intval($_GET['value']); + if ( $iNewVal == 1 ) + $USERCFG['UserOverwriteOptions'] = 1; + else + $USERCFG['UserOverwriteOptions'] = 0; + + // Enable User Options! + WriteConfigValue( "UserOverwriteOptions", false, $content['SESSION_USERID'] ); + } +} +// --- + +// --- Check if user wants to overwrite +$UserOverwriteOptions = GetConfigSetting("UserOverwriteOptions", 0, CFGLEVEL_USER); +if ( $UserOverwriteOptions == 1 ) +{ + $content['ENABLEUSEROPTIONS'] = true; +} +else +{ + $content['ENABLEUSEROPTIONS'] = false; + + +} +// --- // Check for changes first | Abort if Edit is not allowed -if ( isset($_POST['op']) && $content['EditAllowed'] ) +if ( isset($_POST['op']) ) { if ( $_POST['op'] == "edit" ) { - // Language needs special treatment - if ( isset ($_POST['ViewDefaultLanguage']) ) - { - $tmpvar = DB_RemoveBadChars($_POST['ViewDefaultLanguage']); - if ( VerifyLanguage($tmpvar) ) - $content['ViewDefaultLanguage'] = $tmpvar; + // Do if User is ADMIN + if ( $content['EditAllowed'] ) + { + // Language needs special treatment + if ( isset ($_POST['ViewDefaultLanguage']) ) + { + $tmpvar = DB_RemoveBadChars($_POST['ViewDefaultLanguage']); + if ( VerifyLanguage($tmpvar) ) + $content['ViewDefaultLanguage'] = $tmpvar; + } + + // Read default theme + if ( isset ($_POST['ViewDefaultTheme']) ) { $content['ViewDefaultTheme'] = $_POST['ViewDefaultTheme']; } + + // Read default VIEW | Check if View exists as well! + if ( isset ($_POST['DefaultViewsID']) && isset($content['Views'][$_POST['DefaultViewsID']] )) { $content['DefaultViewsID'] = $_POST['DefaultViewsID']; } + + // Read default SOURCES | Check if Source exists as well! + if ( isset ($_POST['DefaultSourceID']) && isset($content['Sources'][$_POST['DefaultSourceID']] )) { $content['DefaultSourceID'] = $_POST['DefaultSourceID']; } + + // Read checkboxes + if ( isset ($_POST['ViewUseTodayYesterday']) ) { $content['ViewUseTodayYesterday'] = 1; } else { $content['ViewUseTodayYesterday'] = 0; } + if ( isset ($_POST['ViewEnableDetailPopups']) ) { $content['ViewEnableDetailPopups'] = 1; } else { $content['ViewEnableDetailPopups'] = 0; } + if ( isset ($_POST['EnableIPAddressResolve']) ) { $content['EnableIPAddressResolve'] = 1; } else { $content['EnableIPAddressResolve'] = 0; } + if ( isset ($_POST['MiscShowDebugMsg']) ) { $content['MiscShowDebugMsg'] = 1; } else { $content['MiscShowDebugMsg'] = 0; } + if ( isset ($_POST['MiscShowDebugGridCounter']) ) { $content['MiscShowDebugGridCounter'] = 1; } else { $content['MiscShowDebugGridCounter'] = 0; } + if ( isset ($_POST['MiscShowPageRenderStats']) ) { $content['MiscShowPageRenderStats'] = 1; } else { $content['MiscShowPageRenderStats'] = 0; } + if ( isset ($_POST['MiscEnableGzipCompression']) ) { $content['MiscEnableGzipCompression'] = 1; } else { $content['MiscEnableGzipCompression'] = 0; } + if ( isset ($_POST['DebugUserLogin']) ) { $content['DebugUserLogin'] = 1; } else { $content['DebugUserLogin'] = 0; } + if ( isset ($_POST['SuppressDuplicatedMessages']) ) { $content['SuppressDuplicatedMessages'] = 1; } else { $content['SuppressDuplicatedMessages'] = 0; } + + // Read Text number fields + if ( isset ($_POST['ViewMessageCharacterLimit']) && is_numeric($_POST['ViewMessageCharacterLimit']) ) { $content['ViewMessageCharacterLimit'] = $_POST['ViewMessageCharacterLimit']; } + if ( isset ($_POST['ViewEntriesPerPage']) && is_numeric($_POST['ViewEntriesPerPage']) ) { $content['ViewEntriesPerPage'] = $_POST['ViewEntriesPerPage']; } + if ( isset ($_POST['ViewEnableAutoReloadSeconds']) && is_numeric($_POST['ViewEnableAutoReloadSeconds']) ) { $content['ViewEnableAutoReloadSeconds'] = $_POST['ViewEnableAutoReloadSeconds']; } + + // Read Text fields + if ( isset ($_POST['PrependTitle']) ) { $content['PrependTitle'] = $_POST['PrependTitle']; } + if ( isset ($_POST['SearchCustomButtonCaption']) ) { $content['SearchCustomButtonCaption'] = $_POST['SearchCustomButtonCaption']; } + if ( isset ($_POST['SearchCustomButtonSearch']) ) { $content['SearchCustomButtonSearch'] = $_POST['SearchCustomButtonSearch']; } + + // Save configuration variables now + SaveGeneralSettingsIntoDB(); } + + // Do if User wants extra options + if ( $content['ENABLEUSEROPTIONS'] ) + { + // Language needs special treatment + if ( isset ($_POST['User_ViewDefaultLanguage']) ) + { + $tmpvar = DB_RemoveBadChars($_POST['User_ViewDefaultLanguage']); + if ( VerifyLanguage($tmpvar) ) + $USERCFG['ViewDefaultLanguage'] = $tmpvar; + } - // Read default theme - if ( isset ($_POST['ViewDefaultTheme']) ) { $content['ViewDefaultTheme'] = $_POST['ViewDefaultTheme']; } + // Read default theme + if ( isset ($_POST['User_ViewDefaultTheme']) ) { $USERCFG['ViewDefaultTheme'] = $_POST['User_ViewDefaultTheme']; } - // Read default VIEW | Check if View exists as well! - if ( isset ($_POST['DefaultViewsID']) && isset($content['Views'][$_POST['DefaultViewsID']] )) { $content['DefaultViewsID'] = $_POST['DefaultViewsID']; } + // Read default VIEW | Check if View exists as well! + if ( isset ($_POST['User_DefaultViewsID']) && isset($content['Views'][$_POST['User_DefaultViewsID']] )) { $USERCFG['DefaultViewsID'] = $_POST['User_DefaultViewsID']; } - // Read default SOURCES | Check if Source exists as well! - if ( isset ($_POST['DefaultSourceID']) && isset($content['Sources'][$_POST['DefaultSourceID']] )) { $content['DefaultSourceID'] = $_POST['DefaultSourceID']; } + // Read default SOURCES | Check if Source exists as well! + if ( isset ($_POST['User_DefaultSourceID']) && isset($content['Sources'][$_POST['User_DefaultSourceID']] )) { $USERCFG['DefaultSourceID'] = $_POST['User_DefaultSourceID']; } - // Read checkboxes - if ( isset ($_POST['ViewUseTodayYesterday']) ) { $content['ViewUseTodayYesterday'] = 1; } else { $content['ViewUseTodayYesterday'] = 0; } - if ( isset ($_POST['ViewEnableDetailPopups']) ) { $content['ViewEnableDetailPopups'] = 1; } else { $content['ViewEnableDetailPopups'] = 0; } - if ( isset ($_POST['EnableIPAddressResolve']) ) { $content['EnableIPAddressResolve'] = 1; } else { $content['EnableIPAddressResolve'] = 0; } - if ( isset ($_POST['MiscShowDebugMsg']) ) { $content['MiscShowDebugMsg'] = 1; } else { $content['MiscShowDebugMsg'] = 0; } - if ( isset ($_POST['MiscShowDebugGridCounter']) ) { $content['MiscShowDebugGridCounter'] = 1; } else { $content['MiscShowDebugGridCounter'] = 0; } - if ( isset ($_POST['MiscShowPageRenderStats']) ) { $content['MiscShowPageRenderStats'] = 1; } else { $content['MiscShowPageRenderStats'] = 0; } - if ( isset ($_POST['MiscEnableGzipCompression']) ) { $content['MiscEnableGzipCompression'] = 1; } else { $content['MiscEnableGzipCompression'] = 0; } - if ( isset ($_POST['DebugUserLogin']) ) { $content['DebugUserLogin'] = 1; } else { $content['DebugUserLogin'] = 0; } - if ( isset ($_POST['SuppressDuplicatedMessages']) ) { $content['SuppressDuplicatedMessages'] = 1; } else { $content['SuppressDuplicatedMessages'] = 0; } + // Read checkboxes + if ( isset ($_POST['User_ViewUseTodayYesterday']) ) { $USERCFG['ViewUseTodayYesterday'] = 1; } else { $USERCFG['ViewUseTodayYesterday'] = 0; } + if ( isset ($_POST['User_ViewEnableDetailPopups']) ) { $USERCFG['ViewEnableDetailPopups'] = 1; } else { $USERCFG['ViewEnableDetailPopups'] = 0; } + if ( isset ($_POST['User_EnableIPAddressResolve']) ) { $USERCFG['EnableIPAddressResolve'] = 1; } else { $USERCFG['EnableIPAddressResolve'] = 0; } + if ( isset ($_POST['User_MiscShowDebugMsg']) ) { $USERCFG['MiscShowDebugMsg'] = 1; } else { $USERCFG['MiscShowDebugMsg'] = 0; } + if ( isset ($_POST['User_MiscShowDebugGridCounter']) ) { $USERCFG['MiscShowDebugGridCounter'] = 1; } else { $USERCFG['MiscShowDebugGridCounter'] = 0; } + if ( isset ($_POST['User_MiscShowPageRenderStats']) ) { $USERCFG['MiscShowPageRenderStats'] = 1; } else { $USERCFG['MiscShowPageRenderStats'] = 0; } + if ( isset ($_POST['User_MiscEnableGzipCompression']) ) { $USERCFG['MiscEnableGzipCompression'] = 1; } else { $USERCFG['MiscEnableGzipCompression'] = 0; } +// DISABLED FOR USER! if ( isset ($_POST['User_DebugUserLogin']) ) { $USERCFG['DebugUserLogin'] = 1; } else { $USERCFG['DebugUserLogin'] = 0; } + if ( isset ($_POST['User_SuppressDuplicatedMessages']) ) { $USERCFG['SuppressDuplicatedMessages'] = 1; } else { $USERCFG['SuppressDuplicatedMessages'] = 0; } - // Read Text number fields - if ( isset ($_POST['ViewMessageCharacterLimit']) && is_numeric($_POST['ViewMessageCharacterLimit']) ) { $content['ViewMessageCharacterLimit'] = $_POST['ViewMessageCharacterLimit']; } - if ( isset ($_POST['ViewEntriesPerPage']) && is_numeric($_POST['ViewEntriesPerPage']) ) { $content['ViewEntriesPerPage'] = $_POST['ViewEntriesPerPage']; } - if ( isset ($_POST['ViewEnableAutoReloadSeconds']) && is_numeric($_POST['ViewEnableAutoReloadSeconds']) ) { $content['ViewEnableAutoReloadSeconds'] = $_POST['ViewEnableAutoReloadSeconds']; } + // Read Text number fields + if ( isset ($_POST['User_ViewMessageCharacterLimit']) && is_numeric($_POST['User_ViewMessageCharacterLimit']) ) { $USERCFG['ViewMessageCharacterLimit'] = $_POST['User_ViewMessageCharacterLimit']; } + if ( isset ($_POST['User_ViewEntriesPerPage']) && is_numeric($_POST['User_ViewEntriesPerPage']) ) { $USERCFG['ViewEntriesPerPage'] = $_POST['User_ViewEntriesPerPage']; } + if ( isset ($_POST['User_ViewEnableAutoReloadSeconds']) && is_numeric($_POST['User_ViewEnableAutoReloadSeconds']) ) { $USERCFG['ViewEnableAutoReloadSeconds'] = $_POST['User_ViewEnableAutoReloadSeconds']; } - // Read Text fields - if ( isset ($_POST['PrependTitle']) ) { $content['PrependTitle'] = $_POST['PrependTitle']; } - if ( isset ($_POST['SearchCustomButtonCaption']) ) { $content['SearchCustomButtonCaption'] = $_POST['SearchCustomButtonCaption']; } - if ( isset ($_POST['SearchCustomButtonSearch']) ) { $content['SearchCustomButtonSearch'] = $_POST['SearchCustomButtonSearch']; } + // Read Text fields + if ( isset ($_POST['User_PrependTitle']) ) { $USERCFG['PrependTitle'] = $_POST['User_PrependTitle']; } + if ( isset ($_POST['User_SearchCustomButtonCaption']) ) { $USERCFG['SearchCustomButtonCaption'] = $_POST['User_SearchCustomButtonCaption']; } + if ( isset ($_POST['User_SearchCustomButtonSearch']) ) { $USERCFG['SearchCustomButtonSearch'] = $_POST['User_SearchCustomButtonSearch']; } - // Save configuration variables now - SaveGeneralSettingsIntoDB(); + // Save configuration variables now + SaveUserGeneralSettingsIntoDB(); + } // Do a redirect RedirectResult( $content['LN_GEN_SUCCESSFULLYSAVED'], "index.php" ); @@ -141,18 +227,95 @@ foreach ( $content['VIEWS'] as $myView ) // --- // --- Init for DefaultSource field! -// copy Views Array +// copy Sources Array $content['SOURCES'] = $content['Sources']; if ( !isset($content['DefaultSourceID']) ) { $content['DefaultSourceID'] = ''; } -foreach ( $content['SOURCES'] as $myView ) +foreach ( $content['SOURCES'] as $mySource ) { - if ( $myView['ID'] == $content['DefaultSourceID'] ) - $content['SOURCES'][ $myView['ID'] ]['selected'] = "selected"; + if ( $mySource['ID'] == $content['DefaultSourceID'] ) + $content['SOURCES'][ $mySource['ID'] ]['selected'] = "selected"; else - $content['SOURCES'][ $myView['ID'] ]['selected'] = ""; + $content['SOURCES'][ $mySource['ID'] ]['selected'] = ""; } // --- +// Do if User wants extra options +if ( $content['ENABLEUSEROPTIONS'] ) +{ + // Set checkbox States + if ( GetConfigSetting('ViewUseTodayYesterday', $content['ViewUseTodayYesterday'], CFGLEVEL_USER) == 1) { $content['User_ViewUseTodayYesterday_checked'] = "checked"; } else { $content['User_ViewUseTodayYesterday_checked'] = ""; } + if ( GetConfigSetting('ViewEnableDetailPopups', $content['ViewEnableDetailPopups'], CFGLEVEL_USER) == 1) { $content['User_ViewEnableDetailPopups_checked'] = "checked"; } else { $content['User_ViewEnableDetailPopups_checked'] = ""; } + if ( GetConfigSetting('EnableIPAddressResolve', $content['EnableIPAddressResolve'], CFGLEVEL_USER) == 1) { $content['User_EnableIPAddressResolve_checked'] = "checked"; } else { $content['User_EnableIPAddressResolve_checked'] = ""; } + + if ( GetConfigSetting('MiscShowDebugMsg', $content['MiscShowDebugMsg'], CFGLEVEL_USER) == 1) { $content['User_MiscShowDebugMsg_checked'] = "checked"; } else { $content['User_MiscShowDebugMsg_checked'] = ""; } + if ( GetConfigSetting('MiscShowDebugGridCounter', $content['MiscShowDebugGridCounter'], CFGLEVEL_USER) == 1) { $content['User_MiscShowDebugGridCounter_checked'] = "checked"; } else { $content['User_MiscShowDebugGridCounter_checked'] = ""; } + if ( GetConfigSetting('MiscShowPageRenderStats', $content['MiscShowPageRenderStats'], CFGLEVEL_USER) == 1) { $content['User_MiscShowPageRenderStats_checked'] = "checked"; } else { $content['User_MiscShowPageRenderStats_checked'] = ""; } + if ( GetConfigSetting('MiscEnableGzipCompression', $content['MiscEnableGzipCompression'], CFGLEVEL_USER) == 1) { $content['User_MiscEnableGzipCompression_checked'] = "checked"; } else { $content['User_MiscEnableGzipCompression_checked'] = ""; } + if ( GetConfigSetting('SuppressDuplicatedMessages', $content['SuppressDuplicatedMessages'], CFGLEVEL_USER) == 1) { $content['User_SuppressDuplicatedMessages_checked'] = "checked"; } else { $content['User_SuppressDuplicatedMessages_checked'] = ""; } + // --- + + // --- Set TextFields! + $content['User_PrependTitle'] = GetConfigSetting('PrependTitle', $content['PrependTitle'], CFGLEVEL_USER); + $content['User_ViewMessageCharacterLimit'] = GetConfigSetting('ViewMessageCharacterLimit', $content['ViewMessageCharacterLimit'], CFGLEVEL_USER); + $content['User_ViewEntriesPerPage'] = GetConfigSetting('ViewEntriesPerPage', $content['ViewEntriesPerPage'], CFGLEVEL_USER); + $content['User_ViewEnableAutoReloadSeconds'] = GetConfigSetting('ViewEnableAutoReloadSeconds', $content['ViewEnableAutoReloadSeconds'], CFGLEVEL_USER); + $content['User_SearchCustomButtonCaption'] = GetConfigSetting('SearchCustomButtonCaption', $content['SearchCustomButtonCaption'], CFGLEVEL_USER); + $content['User_SearchCustomButtonSearch'] = GetConfigSetting('SearchCustomButtonSearch', $content['SearchCustomButtonSearch'], CFGLEVEL_USER); + // --- + + // --- Init for ViewDefaultTheme field! + // copy STYLES Array + $content['USER_STYLES'] = $content['STYLES']; + $userStyleID = GetConfigSetting('ViewDefaultTheme', $content['ViewDefaultTheme'], CFGLEVEL_USER); + foreach ( $content['USER_STYLES'] as &$myStyle ) + { + if ( $myStyle['StyleName'] == $userStyleID ) + $myStyle['selected'] = "selected"; + else + $myStyle['selected'] = ""; + } + // --- + + // --- Init for ViewDefaultLanguage field! + // copy LANGUAGES Array + $content['USER_LANGUAGES'] = $content['LANGUAGES']; + $userLangID = GetConfigSetting('ViewDefaultLanguage', $content['ViewDefaultLanguage'], CFGLEVEL_USER); + foreach ( $content['USER_LANGUAGES'] as &$myLang ) + { + if ( $myLang['langcode'] == $userLangID ) + $myLang['selected'] = "selected"; + else + $myLang['selected'] = ""; + } + // --- + + // --- Init for DefaultView field! + // copy Views Array + $content['USER_VIEWS'] = $content['Views']; + $userViewID = GetConfigSetting('DefaultViewsID', $content['DefaultViewsID'], CFGLEVEL_USER); + foreach ( $content['USER_VIEWS'] as &$myView ) + { + if ( $myView['ID'] == $userViewID ) + $myView['selected'] = "selected"; + else + $myView['selected'] = ""; + } + // --- + + // --- Init for DefaultSource field! + // copy Sources Array + $content['USER_SOURCES'] = $content['Sources']; + $userSourceID = GetConfigSetting('DefaultViewsID', $content['DefaultViewsID'], CFGLEVEL_USER); + foreach ( $content['USER_SOURCES'] as &$mySource ) + { + if ( $mySource['ID'] == $userSourceID ) + $mySource['selected'] = "selected"; + else + $mySource['selected'] = ""; + } + // --- +} + // --- BEGIN CREATE TITLE $content['TITLE'] = InitPageTitle(); $content['TITLE'] .= " :: " . $content['LN_ADMINMENU_GENOPT']; diff --git a/src/include/functions_common.php b/src/include/functions_common.php index bb0a209..85b5cc9 100644 --- a/src/include/functions_common.php +++ b/src/include/functions_common.php @@ -146,9 +146,6 @@ function InitPhpLogCon() // Init UserDB related stuff! InitUserSystemPhpLogCon(); - // Moved here, because we do not need if GZIP needs to be enabled before the config is loaded! - InitRuntimeInformations(); - // Establish DB Connection if ( GetConfigSetting("UserDBEnabled", false) ) DB_Connect(); @@ -156,6 +153,9 @@ function InitPhpLogCon() // Now load the Page configuration values InitConfigurationValues(); + // Moved here, because we do not need if GZIP needs to be enabled before the config is loaded! + InitRuntimeInformations(); + // Now Create Themes List because we haven't the config before! CreateThemesList(); @@ -376,8 +376,6 @@ function InitRuntimeInformations() { global $content; - // TODO| maybe not needed! - // Enable GZIP Compression if enabled! if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && GetConfigSetting("MiscEnableGzipCompression", 1, CFGLEVEL_USER) == 1 ) { @@ -445,7 +443,8 @@ function InitFrontEndVariables() $content['MENU_SOURCE_PDO'] = $content['BASEPATH'] . "images/icons/data_gear.png"; $content['MENU_MAXIMIZE'] = $content['BASEPATH'] . "images/icons/table_selection_all.png"; $content['MENU_NORMAL'] = $content['BASEPATH'] . "images/icons/table_selection_block.png"; - + $content['MENU_USEROPTIONS'] = $content['BASEPATH'] . "images/icons/businessman_preferences.png"; + $content['MENU_PAGER_BEGIN'] = $content['BASEPATH'] . "images/icons/media_beginning.png"; $content['MENU_PAGER_PREVIOUS'] = $content['BASEPATH'] . "images/icons/media_rewind.png"; $content['MENU_PAGER_NEXT'] = $content['BASEPATH'] . "images/icons/media_fast_forward.png"; @@ -500,7 +499,7 @@ function InitConfigurationValues() if ( $result ) { - $rows = DB_GetAllRows($result, true, true); + $rows = DB_GetAllRows($result, true); // Read results from DB and overwrite in $CFG Array! if ( isset($rows ) ) { @@ -704,7 +703,7 @@ function InitPageTitle() { global $content, $currentSourceID; - $tmpTitle = GetConfigSetting("PrependTitle", ""); + $tmpTitle = GetConfigSetting("PrependTitle", "", CFGLEVEL_USER); if ( strlen($tmpTitle) > 0 ) $szReturn = $tmpTitle . " :: "; else @@ -1079,15 +1078,51 @@ function SaveGeneralSettingsIntoDB() WriteConfigValue( "DefaultSourceID", true ); } +function SaveUserGeneralSettingsIntoDB() +{ + global $content; + + WriteConfigValue( "ViewDefaultLanguage", false, $content['SESSION_USERID']); + WriteConfigValue( "ViewDefaultTheme", false, $content['SESSION_USERID'] ); + + WriteConfigValue( "ViewUseTodayYesterday", false, $content['SESSION_USERID'] ); + WriteConfigValue( "ViewEnableDetailPopups", false, $content['SESSION_USERID'] ); + WriteConfigValue( "EnableIPAddressResolve", false, $content['SESSION_USERID'] ); + WriteConfigValue( "MiscShowDebugMsg", false, $content['SESSION_USERID'] ); + WriteConfigValue( "MiscShowDebugGridCounter", false, $content['SESSION_USERID'] ); + WriteConfigValue( "MiscShowPageRenderStats", false, $content['SESSION_USERID'] ); + WriteConfigValue( "MiscEnableGzipCompression", false, $content['SESSION_USERID'] ); + WriteConfigValue( "SuppressDuplicatedMessages", false, $content['SESSION_USERID'] ); + + WriteConfigValue( "ViewMessageCharacterLimit", false, $content['SESSION_USERID'] ); + WriteConfigValue( "ViewEntriesPerPage", false, $content['SESSION_USERID'] ); + WriteConfigValue( "ViewEnableAutoReloadSeconds", false, $content['SESSION_USERID'] ); + + WriteConfigValue( "PrependTitle", false, $content['SESSION_USERID'] ); + WriteConfigValue( "SearchCustomButtonCaption", false, $content['SESSION_USERID'] ); + WriteConfigValue( "SearchCustomButtonSearch", false, $content['SESSION_USERID'] ); + + // Extra Fields + WriteConfigValue( "DefaultViewsID", false, $content['SESSION_USERID'] ); + WriteConfigValue( "DefaultSourceID", false, $content['SESSION_USERID'] ); +} + + function GetConfigSetting($szSettingName, $szDefaultValue = "", $DesiredConfigLevel = CFGLEVEL_GLOBAL) { - global $content, $CFG; + global $content, $CFG, $USERCFG; if ( isset($CFG['UserDBEnabled']) && $CFG['UserDBEnabled'] ) { if ( $DesiredConfigLevel == CFGLEVEL_USER ) { - // TODO! + // only use user settings if desired by the user + if ( isset($USERCFG['UserOverwriteOptions']) && $USERCFG['UserOverwriteOptions'] == 1 ) + { + // return user specific setting if available + if ( isset($USERCFG[$szSettingName]) ) + return $USERCFG[$szSettingName]; + } } } diff --git a/src/include/functions_db.php b/src/include/functions_db.php index 5b4a383..2bb2c17 100644 --- a/src/include/functions_db.php +++ b/src/include/functions_db.php @@ -320,38 +320,77 @@ function WriteConfigValue($szPropName, $is_global = true, $userid = false, $grou return; // --- - // !!! TODO HANDLE USER AND GROUP FIELDS! - - if ( isset($content[$szPropName]) ) + if ( $is_global ) { - // Copy value for DB and check for BadDB Chars! - $szDbValue = PrepareValueForDB( $content[$szPropName] ); - } - else - { - // Set empty in this case - $szDbValue = ""; - $content[$szPropName] = ""; - } + if ( isset($content[$szPropName]) ) + { + // Copy value for DB and check for BadDB Chars! + $szDbValue = PrepareValueForDB( $content[$szPropName] ); + } + else + { + // Set empty in this case + $szDbValue = ""; + $content[$szPropName] = ""; + } - // Copy to $CFG array as well - $CFG[$szPropName] = $content[$szPropName]; - - // Check if we need to INSERT or UPDATE - $result = DB_Query("SELECT propname FROM " . DB_CONFIG . " WHERE propname = '" . $szPropName . "' AND is_global = " . $is_global); - $rows = DB_GetAllRows($result, true); - if ( !isset($rows) ) - { - // New Entry - $result = DB_Query("INSERT INTO " . DB_CONFIG . " (propname, propvalue, is_global) VALUES ( '" . $szPropName . "', '" . $szDbValue . "', " . $is_global . ")"); - DB_FreeQuery($result); + // Copy to $CFG array as well + $CFG[$szPropName] = $content[$szPropName]; + + // Check if we need to INSERT or UPDATE + $result = DB_Query("SELECT propname FROM " . DB_CONFIG . " WHERE propname = '" . $szPropName . "' AND is_global = " . $is_global); + $rows = DB_GetAllRows($result, true); + if ( !isset($rows) ) + { + // New Entry + $result = DB_Query("INSERT INTO " . DB_CONFIG . " (propname, propvalue, is_global) VALUES ( '" . $szPropName . "', '" . $szDbValue . "', " . $is_global . ")"); + DB_FreeQuery($result); + } + else + { + // Update Entry + $result = DB_Query("UPDATE " . DB_CONFIG . " SET propvalue = '" . $szDbValue . "' WHERE propname = '" . $szPropName . "' AND is_global = " . $is_global); + DB_FreeQuery($result); + } } - else + else if ( $userid != false ) { - // Update Entry - $result = DB_Query("UPDATE " . DB_CONFIG . " SET propvalue = '" . $szDbValue . "' WHERE propname = '" . $szPropName . "' AND is_global = " . $is_global); - DB_FreeQuery($result); + global $USERCFG; + + if ( isset($USERCFG[$szPropName]) ) + { + // Copy value for DB and check for BadDB Chars! + $szDbValue = PrepareValueForDB( $USERCFG[$szPropName] ); + } + else + { + // Set empty in this case + $szDbValue = ""; + $USERCFG[$szPropName] = ""; + } + + // Check if we need to INSERT or UPDATE + $result = DB_Query("SELECT propname FROM " . DB_CONFIG . " WHERE propname = '" . $szPropName . "' AND userid = " . $userid); + $rows = DB_GetAllRows($result, true); + if ( !isset($rows) ) + { + // New Entry + $result = DB_Query("INSERT INTO " . DB_CONFIG . " (propname, propvalue, userid) VALUES ( '" . $szPropName . "', '" . $szDbValue . "', " . $userid . ")"); + DB_FreeQuery($result); + } + else + { + // Update Entry + $result = DB_Query("UPDATE " . DB_CONFIG . " SET propvalue = '" . $szDbValue . "' WHERE propname = '" . $szPropName . "' AND userid = " . $userid); + DB_FreeQuery($result); + } + } + else if ( $groupid != false ) + DieWithFriendlyErrorMsg( "Critical Error occured in WriteConfigValue, writing GROUP specific properties is not supported yet!" ); + + + } function GetSingleDBEntryOnly( $myqry ) diff --git a/src/include/functions_users.php b/src/include/functions_users.php index ab801e4..7597760 100644 --- a/src/include/functions_users.php +++ b/src/include/functions_users.php @@ -52,7 +52,7 @@ $content['IS_USERSYSTEMENABLED'] = true; // --- BEGIN Usermanagement Function --- function InitUserSession() { - global $content; + global $USERCFG, $content; // --- Hide donate Button if not on Admin Page if ( !defined('IS_ADMINPAGE') ) @@ -77,6 +77,26 @@ function InitUserSession() $content['SESSION_ISADMIN'] = $_SESSION['SESSION_ISADMIN']; if ( isset($_SESSION['SESSION_GROUPIDS']) ) $content['SESSION_GROUPIDS'] = $_SESSION['SESSION_GROUPIDS']; + + // --- Now we obtain user specific general settings from the DB for the user! + $result = DB_Query("SELECT * FROM " . DB_CONFIG . " WHERE userid = " . $content['SESSION_USERID']); + if ( $result ) + { + $rows = DB_GetAllRows($result, true); + // Read results from DB and overwrite in $CFG Array! + if ( isset($rows ) ) + { + for($i = 0; $i < count($rows); $i++) + { + // Store and overwrite settings from the user here! + $USERCFG[ $rows[$i]['propname'] ] = $rows[$i]['propvalue']; +// $content[ $rows[$i]['propname'] ] = $rows[$i]['propvalue']; + } + } + } + else // Critical ERROR HERE! + DieWithFriendlyErrorMsg( "Critical Error occured while trying to access the database in table '" . DB_CONFIG . "'" ); + // --- // Successfully logged in return true; diff --git a/src/lang/en/admin.php b/src/lang/en/admin.php index 115e7ad..4822fa0 100644 --- a/src/lang/en/admin.php +++ b/src/lang/en/admin.php @@ -78,6 +78,12 @@ $content['LN_GEN_ACCESSDENIED'] = "Access denied to this function"; $content['LN_GEN_DEFVIEWS'] = "Default selected view"; $content['LN_GEN_DEFSOURCE'] = "Default selected source"; $content['LN_GEN_SUPPRESSDUPMSG'] = "Suppress duplicated messages"; + $content['LN_GEN_OPTIONNAME'] = "Option name"; + $content['LN_GEN_GLOBALVALUE'] = "Global value"; + $content['LN_GEN_PERSONALVALUE'] = "Personal (User)value"; + $content['LN_GEN_DISABLEUSEROPTIONS'] = "Click here to disable personal options"; + $content['LN_GEN_ENABLEUSEROPTIONS'] = "Click here to enable personal options"; + // User Center $content['LN_USER_CENTER'] = "User Options"; diff --git a/src/templates/admin/admin_index.html b/src/templates/admin/admin_index.html index 1fc7f04..34807c2 100644 --- a/src/templates/admin/admin_index.html +++ b/src/templates/admin/admin_index.html @@ -5,132 +5,223 @@