X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fadmin-inc.php;h=e34b0cf014f0a22421e43f54ca3c6bae1c479fdc;hp=543b67f17c7049b55c96ab984dd08ee0a32a2bec;hb=6a0c39a390c28999679d84a7ae5264363b0054dc;hpb=1c62a6c2a4ed2bb170e0f1888899625e67a27947 diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index 543b67f17c..e34b0cf014 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -16,7 +16,7 @@ * $Author:: $ * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * - * Copyright (c) 2009, 2010 by Mailer Developer Team * + * Copyright (c) 2009 - 2011 by Mailer Developer Team * * For more information visit: http://www.mxchange.org * * * * This program is free software; you can redistribute it and/or modify * @@ -72,8 +72,9 @@ function addAdminAccount ($adminLogin, $passHash, $adminEmail) { // This function will be executed when the admin is not logged in and has submitted his login data function ifAdminLoginDataIsValid ($adminLogin, $adminPassword) { - // First of all, no admin login is found + // First of all, no admin login is found, so the admin hash is null $ret = '404'; + $adminHash = null; // Get admin id from login $adminId = getAdminId($adminLogin); @@ -165,15 +166,12 @@ function doAdminAction () { // Get action value $action = getActionFromModuleWhat(getModule(), $what); - // Define admin login name and id number - $content['login'] = getAdminLogin(getSession('admin_id')); - $content['id'] = getCurrentAdminId(); - - // Preload templates + // Load welcome template if (isExtensionActive('admins')) { - $content['welcome'] = loadTemplate('admin_welcome_admins', true, $content); + // @TODO This and the next getCurrentAdminId() call might be moved into the templates? + $content['welcome'] = loadTemplate('admin_welcome_admins', true, getCurrentAdminId()); } else { - $content['welcome'] = loadTemplate('admin_welcome', true, $content); + $content['welcome'] = loadTemplate('admin_welcome', true, getCurrentAdminId()); } // Load header, footer, render menu @@ -220,11 +218,11 @@ LIMIT 1", // Access denied loadTemplate('admin_menu_failed', false, getMaskedMessage('ADMIN_ACCESS_DENIED', $what)); } else { - // Include file not found! :-( + // Include file not found :-( loadTemplate('admin_menu_failed', false, getMaskedMessage('ADMIN_ACTION_404', $action)); } } else { - // Invalid action/what pair found! + // Invalid action/what pair found loadTemplate('admin_menu_failed', false, getMaskedMessage('ADMIN_ACTION_INVALID', $action . '/' . $what)); } @@ -235,8 +233,22 @@ LIMIT 1", loadTemplate('admin_main_footer', false, $content); } +// Checks wether current admin is allowed to access given action/what combination +// (only one is allowed to be null!) +function isAdminAllowedAccessMenu ($action, $what = null) { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__][$action][$what])) { + // ACL is always 'allow' when no ext-admins is installed + // @TODO This can be rewritten into a filter + $GLOBALS[__FUNCTION__][$action][$what] = ((!isExtensionInstalledAndNewer('admins', '0.2.0')) || (adminsCheckAdminAcl($action, $what))); + } // END - if + + // Return the cached value + return $GLOBALS[__FUNCTION__][$action][$what]; +} + // Adds an admin menu -function addAdminMenu ($action, $what, $return=false) { +function addAdminMenu ($action, $what, $return = false) { // Init variables $SUB = false; $OUT = ''; @@ -261,25 +273,19 @@ ORDER BY $OUT .= '