Added support for Admin Users to edit ALL sources in sources admin

This commit is contained in:
Andre Lorbach 2015-03-27 13:40:41 +01:00
parent a783655c35
commit 318a620282
4 changed files with 40 additions and 17 deletions

View File

@ -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 )
{

View File

@ -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";

View File

@ -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 <br>(Nur für Ihren Benutzer)";

View File

@ -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 <br>(Only available to your user)";