Module: nagvis Branch: master Commit: 7afaffd6a453adf91d4e08dd2305f79faf536cfd URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=7afaffd6a453adf91d4e08dd2305f79faf536cfd
Author: Lars Michelsen <[email protected]> Date: Thu Oct 22 21:11:20 2009 +0200 AA information are now available in the GlobalCore and can be used everywhere in the NagVis code --- .../nagvis-js/classes/GlobalHeaderMenu.php | 4 +- share/frontend/nagvis-js/index.php | 3 ++ share/server/core/classes/GlobalCore.php | 30 ++++++++++++++++++++ share/server/core/classes/GlobalMapCfg.php | 22 -------------- share/server/core/classes/objects/NagVisMapObj.php | 2 +- 5 files changed, 36 insertions(+), 25 deletions(-) diff --git a/share/frontend/nagvis-js/classes/GlobalHeaderMenu.php b/share/frontend/nagvis-js/classes/GlobalHeaderMenu.php index f8309cb..27d3195 100644 --- a/share/frontend/nagvis-js/classes/GlobalHeaderMenu.php +++ b/share/frontend/nagvis-js/classes/GlobalHeaderMenu.php @@ -111,7 +111,7 @@ class GlobalHeaderMenu { if($MAPCFG1->getValue('global', 0, 'show_in_lists') == 1) { // Only proceed permited objects - if($MAPCFG1->checkPermissions($MAPCFG1->getValue('global',0, 'allowed_user'), FALSE)) { + if($this->CORE->getAuthorization() !== null && $this->CORE->getAuthorization()->isPermitted('Map', 'view', $mapName)) { $sReplaceObj = str_replace('[map_name]',$MAPCFG1->getName(), $matchReturn1[1][0]); $sReplaceObj = str_replace('[map_alias]',$MAPCFG1->getValue('global', '0', 'alias'), $sReplaceObj); @@ -136,7 +136,7 @@ class GlobalHeaderMenu { if($MAPCFG1->getValue('global',0, 'show_in_lists') == 1 && ($mapName != '__automap' || ($mapName == '__automap' && $this->CORE->getMainCfg()->getValue('automap', 'showinlists')))) { // Only proceed permited objects - if($MAPCFG1->checkPermissions($MAPCFG1->getValue('global',0, 'allowed_user'),FALSE)) { + if($this->CORE->getAuthorization() !== null && $this->CORE->getAuthorization()->isPermitted('AutoMap', 'view', $mapName)) { $sReplaceObj = str_replace('[map_name]', 'automap='.$MAPCFG1->getName(), $matchReturn1[1][0]); $sReplaceObj = str_replace('[map_alias]', $MAPCFG1->getValue('global', '0', 'alias'), $sReplaceObj); diff --git a/share/frontend/nagvis-js/index.php b/share/frontend/nagvis-js/index.php index 3294139..25350b2 100644 --- a/share/frontend/nagvis-js/index.php +++ b/share/frontend/nagvis-js/index.php @@ -83,6 +83,9 @@ if($AUTH->isAuthenticated()) { $AUTHORISATION = null; } +// Make the AA information available to whole NagVis for permission checks +$CORE->setAA($AUTH, $AUTHORISATION); + /* * Module handling 1: Choose modules */ diff --git a/share/server/core/classes/GlobalCore.php b/share/server/core/classes/GlobalCore.php index 64f37e4..f5515a7 100644 --- a/share/server/core/classes/GlobalCore.php +++ b/share/server/core/classes/GlobalCore.php @@ -30,6 +30,8 @@ class GlobalCore { private static $MAINCFG = null; private static $LANG = null; + private static $AUTHENTICATION = null; + private static $AUTHORIZATION = null; private static $instance = null; private $iconsetTypeCache = Array(); @@ -78,6 +80,34 @@ class GlobalCore { } /** + * Setter for AA + * + * @author Lars Michelsen <[email protected]> + */ + public static function setAA(CoreAuthHandler $A1, CoreAuthorisationHandler $A2 = null) { + self::$AUTHENTICATION = $A1; + self::$AUTHORIZATION = $A2; + } + + /** + * Getter function for AUTHORIZATION + * + * @author Lars Michelsen <[email protected]> + */ + public static function getAuthorization() { + return self::$AUTHORIZATION; + } + + /** + * Getter function for AUTHENTICATION + * + * @author Lars Michelsen <[email protected]> + */ + public static function getAuthentication() { + return self::$AUTHENTICATION; + } + + /** * Static method for getting the instance * * @author Lars Michelsen <[email protected]> diff --git a/share/server/core/classes/GlobalMapCfg.php b/share/server/core/classes/GlobalMapCfg.php index 771f358..bb9a629 100644 --- a/share/server/core/classes/GlobalMapCfg.php +++ b/share/server/core/classes/GlobalMapCfg.php @@ -1701,27 +1701,5 @@ class GlobalMapCfg { public function getAlias() { return $this->getValue('global', 0, 'alias'); } - - /** - * PUBLIC checkPermissions() - * - * Checks for valid Permissions - * - * @param String $allowed - * @param Boolean $printErr - * @return Boolean Is Check Successful? - * @author Lars Michelsen <[email protected]> - */ - public function checkPermissions($allowed,$printErr) { - if(isset($allowed) && !in_array('EVERYONE', $allowed) && !in_array($this->CORE->getMainCfg()->getRuntimeValue('user'), $allowed)) { - if($printErr) { - new GlobalMessage('ERROR', $this->CORE->getLang()->getText('permissionDenied', Array('USER' => $this->CORE->getMainCfg()->getRuntimeValue('user')))); - } - return FALSE; - } else { - return TRUE; - } - return TRUE; - } } ?> diff --git a/share/server/core/classes/objects/NagVisMapObj.php b/share/server/core/classes/objects/NagVisMapObj.php index 788ebb7..e392a86 100644 --- a/share/server/core/classes/objects/NagVisMapObj.php +++ b/share/server/core/classes/objects/NagVisMapObj.php @@ -405,7 +405,7 @@ class NagVisMapObj extends NagVisStatefulObject { */ private function checkLoop($OBJ) { // Check for valid permissions - if($OBJ->MAPCFG->checkPermissions($OBJ->MAPCFG->getValue('global',0, 'allowed_user'), FALSE)) { + if($this->CORE->getAuthorization() !== null && $this->CORE->getAuthorization()->isPermitted('Map', 'view', $OBJ->getName())) { // Loop all objects on the child map to find out if there is a link back // to this map (loop) // ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Nagvis-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nagvis-checkins
