From 318a62028282b1c486f6ea8f18ec89084fa456ed Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Fri, 27 Mar 2015 13:40:41 +0100 Subject: [PATCH] Added support for Admin Users to edit ALL sources in sources admin --- src/admin/sources.php | 24 ++++++++++++++++-------- src/include/functions_config.php | 31 ++++++++++++++++++++++--------- src/lang/de/admin.php | 1 + src/lang/en/admin.php | 1 + 4 files changed, 40 insertions(+), 17 deletions(-) diff --git a/src/admin/sources.php b/src/admin/sources.php index 3b16669..b2e4ed0 100644 --- a/src/admin/sources.php +++ b/src/admin/sources.php @@ -44,13 +44,6 @@ include($gl_root_path . 'include/functions_filters.php'); define('IS_ADMINPAGE', true); $content['IS_ADMINPAGE'] = true; InitPhpLogCon(); -InitSourceConfigs(); -InitFrontEndDefaults(); // Only in WebFrontEnd -InitFilterHelpers(); // Helpers for frontend filtering! - -// Init admin langauge file now! -IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' ); -// --- // --- Deny if User is READONLY! if ( !isset($_SESSION['SESSION_ISREADONLY']) || $_SESSION['SESSION_ISREADONLY'] == 1 ) @@ -69,6 +62,21 @@ if ( !isset($_SESSION['SESSION_ISREADONLY']) || $_SESSION['SESSION_ISREADONLY'] } // --- +// --- Special Case for ADMIN Users, they should see ALL sources in admin panel! +if ( GetConfigSetting("UserDBEnabled", false) && + isset($_SESSION['SESSION_ISADMIN']) && + $_SESSION['SESSION_ISADMIN'] == 1 ) + LoadSourcesFromDatabase(true); +// --- + +InitSourceConfigs(); +InitFrontEndDefaults(); // Only in WebFrontEnd +InitFilterHelpers(); // Helpers for frontend filtering! + +// Init admin langauge file now! +IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' ); +// --- + // --- BEGIN Custom Code // --- Set Helpervariable for non-ADMIN users @@ -895,7 +903,7 @@ if ( !isset($_POST['op']) && !isset($_GET['op']) ) if ( $mySource['userid'] != null ) { $mySource['SourcesAssignedToImage'] = $content["MENU_ADMINUSERS"]; - $mySource['SourcesAssignedToText'] = $content["LN_GEN_USERONLY"]; + $mySource['SourcesAssignedToText'] = GetAndReplaceLangStr( $content["LN_GEN_USERONLYNAME"], $mySource['username'] ); } else if ( $mySource['groupid'] != null ) { diff --git a/src/include/functions_config.php b/src/include/functions_config.php index f581b81..a4ab29a 100644 --- a/src/include/functions_config.php +++ b/src/include/functions_config.php @@ -1000,22 +1000,35 @@ function LoadViewsFromDatabase() } } -function LoadSourcesFromDatabase() +function LoadSourcesFromDatabase($ForceloadAllSources = false) { // Needed to make global global $CFG, $content; // --- Create SQL Query // Create Where for USERID - if ( isset($content['SESSION_LOGGEDIN']) && $content['SESSION_LOGGEDIN'] ) - $szWhereUser = " OR `" . DB_SOURCES . "`.userid = " . $content['SESSION_USERID'] . " "; - else + $szWhereNoUserOrGroups = " WHERE (`" . DB_SOURCES . "`.userid IS NULL AND `" . DB_SOURCES . "`.groupid IS NULL) "; + if ( $ForceloadAllSources ) + { + // Remove any WHERE stuff and show ALL sources + $szWhereNoUserOrGroups = ""; $szWhereUser = ""; - - if ( isset($content['SESSION_GROUPIDS']) ) - $szGroupWhere = " OR `" . DB_SOURCES . "`.groupid IN (" . $content['SESSION_GROUPIDS'] . ")"; - else $szGroupWhere = ""; + } + else + { + if ( isset($content['SESSION_LOGGEDIN']) && $content['SESSION_LOGGEDIN'] ) + $szWhereUser = " OR `" . DB_SOURCES . "`.userid = " . $content['SESSION_USERID'] . " "; + else + $szWhereUser = ""; + + if ( isset($content['SESSION_GROUPIDS']) ) + $szGroupWhere = " OR `" . DB_SOURCES . "`.groupid IN (" . $content['SESSION_GROUPIDS'] . ")"; + else + $szGroupWhere = ""; + } + + // Create SQL Query $sqlquery = " SELECT " . DB_SOURCES . ".*, " . DB_USERS . ".username, " . @@ -1023,7 +1036,7 @@ function LoadSourcesFromDatabase() " FROM `" . DB_SOURCES . "`" . " LEFT OUTER JOIN (`" . DB_USERS . "`) ON (`" . DB_SOURCES . "`.userid=`" . DB_USERS . "`.ID ) " . " LEFT OUTER JOIN (`" . DB_GROUPS . "`) ON (`" . DB_SOURCES . "`.groupid=`" . DB_GROUPS . "`.ID ) " . - " WHERE (`" . DB_SOURCES . "`.userid IS NULL AND `" . DB_SOURCES . "`.groupid IS NULL) " . + $szWhereNoUserOrGroups . $szWhereUser . $szGroupWhere . " ORDER BY `" . DB_SOURCES . "`.userid, `" . DB_SOURCES . "`.groupid, `" . DB_SOURCES . "`.Name"; diff --git a/src/lang/de/admin.php b/src/lang/de/admin.php index bb08a92..d36f391 100644 --- a/src/lang/de/admin.php +++ b/src/lang/de/admin.php @@ -48,6 +48,7 @@ $content['LN_DELETENO'] = "Nein"; $content['LN_GEN_ACTIONS'] = "Mögliche Aktionen"; $content['LN_ADMIN_SEND'] = "Änderungen speichern"; $content['LN_GEN_USERONLY'] = "Nur Benutzer"; +$content['LN_GEN_USERONLYNAME'] = "Benutzer '%1'"; $content['LN_GEN_GROUPONLY'] = "Nur Gruppen"; $content['LN_GEN_GLOBAL'] = "Global"; $content['LN_GEN_USERONLY_LONG'] = "Eigene Einstellungen
(Nur für Ihren Benutzer)"; diff --git a/src/lang/en/admin.php b/src/lang/en/admin.php index ef55fd8..b62fcb2 100644 --- a/src/lang/en/admin.php +++ b/src/lang/en/admin.php @@ -48,6 +48,7 @@ $content['LN_DELETENO'] = "No"; $content['LN_GEN_ACTIONS'] = "Available Actions"; $content['LN_ADMIN_SEND'] = "Send changes"; $content['LN_GEN_USERONLY'] = "User only"; +$content['LN_GEN_USERONLYNAME'] = "User '%1'"; $content['LN_GEN_GROUPONLY'] = "Group only"; $content['LN_GEN_GLOBAL'] = "Global"; $content['LN_GEN_USERONLY_LONG'] = "For me only
(Only available to your user)";