Module: nagvis
Branch: master
Commit: abac6da1b62536abb9743980bda0a70632ac4a3b
URL:    
http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=abac6da1b62536abb9743980bda0a70632ac4a3b

Author: Lars Michelsen <[email protected]>
Date:   Wed Oct 21 22:52:39 2009 +0200

Fixed FrontendAutoMap module name; Fixed initial permissions for guest user; 
Overview page items are now controlled by new AA mchanism

---

 ...ontendModAutomap.php => FrontendModAutoMap.php} |    0
 share/frontend/nagvis-js/index.php                 |    2 +-
 share/server/core/classes/CoreAuthModSQLite.php    |   16 +++++++
 share/server/core/classes/CoreModOverview.php      |   32 ++++++---------
 share/server/core/classes/GlobalIndexPage.php      |   42 +++++++++++---------
 5 files changed, 52 insertions(+), 40 deletions(-)

diff --git a/share/frontend/nagvis-js/classes/FrontendModAutomap.php 
b/share/frontend/nagvis-js/classes/FrontendModAutoMap.php
similarity index 100%
rename from share/frontend/nagvis-js/classes/FrontendModAutomap.php
rename to share/frontend/nagvis-js/classes/FrontendModAutoMap.php
diff --git a/share/frontend/nagvis-js/index.php 
b/share/frontend/nagvis-js/index.php
index cf2fe37..163d3f7 100644
--- a/share/frontend/nagvis-js/index.php
+++ b/share/frontend/nagvis-js/index.php
@@ -97,7 +97,7 @@ $MHANDLER->regModule('Info');
 $MHANDLER->regModule('Auth');
 $MHANDLER->regModule('Map');
 $MHANDLER->regModule('Url');
-$MHANDLER->regModule('Automap');
+$MHANDLER->regModule('AutoMap');
 $MHANDLER->regModule('Overview');
 $MHANDLER->regModule('Rotation');
 
diff --git a/share/server/core/classes/CoreAuthModSQLite.php 
b/share/server/core/classes/CoreAuthModSQLite.php
index 36df871..2d52d99 100644
--- a/share/server/core/classes/CoreAuthModSQLite.php
+++ b/share/server/core/classes/CoreAuthModSQLite.php
@@ -90,6 +90,13 @@ class CoreAuthModSQLite extends CoreAuthModule {
                $this->DB->query('INSERT INTO perms (permId, mod, act, obj) 
VALUES (22, \'Map\', \'getMapObjects\', \'demo-server\')');
                $this->DB->query('INSERT INTO perms (permId, mod, act, obj) 
VALUES (23, \'Map\', \'getObjectStates\', \'demo-server\')');
                
+               $this->DB->query('INSERT INTO perms (permId, mod, act, obj) 
VALUES (24, \'Rotation\', \'view\', \'demo\')');
+               
+               $this->DB->query('INSERT INTO perms (permId, mod, act, obj) 
VALUES (25, \'AutoMap\', \'view\', \'__automap\')');
+               $this->DB->query('INSERT INTO perms (permId, mod, act, obj) 
VALUES (26, \'AutoMap\', \'getAutomapProperties\', \'__automap\')');
+               $this->DB->query('INSERT INTO perms (permId, mod, act, obj) 
VALUES (27, \'AutoMap\', \'getAutomapObjects\', \'__automap\')');
+               $this->DB->query('INSERT INTO perms (permId, mod, act, obj) 
VALUES (28, \'AutoMap\', \'getObjectStates\', \'__automap\')');
+               
                // nagiosadmin => Administrators
                $this->DB->query('INSERT INTO users2roles (userId, roleId) 
VALUES (1, 1)');
                
@@ -130,6 +137,15 @@ class CoreAuthModSQLite extends CoreAuthModule {
                $this->DB->query('INSERT INTO roles2perms (roleId, permId) 
VALUES (2, 21)');
                $this->DB->query('INSERT INTO roles2perms (roleId, permId) 
VALUES (2, 22)');
                $this->DB->query('INSERT INTO roles2perms (roleId, permId) 
VALUES (2, 23)');
+               
+               // Users => Allowed to view the demo rotation
+               $this->DB->query('INSERT INTO roles2perms (roleId, permId) 
VALUES (2, 24)');
+               
+               // Users => Allowed to view the __automap automap
+               $this->DB->query('INSERT INTO roles2perms (roleId, permId) 
VALUES (2, 25)');
+               $this->DB->query('INSERT INTO roles2perms (roleId, permId) 
VALUES (2, 26)');
+               $this->DB->query('INSERT INTO roles2perms (roleId, permId) 
VALUES (2, 27)');
+               $this->DB->query('INSERT INTO roles2perms (roleId, permId) 
VALUES (2, 28)');
        }
        
        private function checkUserExists() {
diff --git a/share/server/core/classes/CoreModOverview.php 
b/share/server/core/classes/CoreModOverview.php
index 8b78bd5..76ae355 100644
--- a/share/server/core/classes/CoreModOverview.php
+++ b/share/server/core/classes/CoreModOverview.php
@@ -26,6 +26,8 @@
  * @author Lars Michelsen <[email protected]>
  */
 class CoreModOverview extends CoreModule {
+       private $BACKEND = null;
+       private $OVERVIEW = null;
        
        public function __construct(GlobalCore $CORE) {
                $this->CORE = $CORE;
@@ -42,6 +44,12 @@ class CoreModOverview extends CoreModule {
                $sReturn = '';
                
                if($this->offersAction($this->sAction)) {
+                       
+                       // Initialize backends
+                       $this->BACKEND = new GlobalBackendMgmt($this->CORE);
+                       
+                       $this->OVERVIEW = new GlobalIndexPage($this->CORE, 
$this->BACKEND, $this->AUTHORISATION);
+                       
                        switch($this->sAction) {
                                case 'getOverviewProperties':
                                        $sReturn = 
$this->getOverviewProperties();
@@ -62,35 +70,19 @@ class CoreModOverview extends CoreModule {
        }
        
        private function getOverviewProperties() {
-               // Initialize backends
-               $BACKEND = new GlobalBackendMgmt($this->CORE);
-               
-               $OVERVIEW = new GlobalIndexPage($this->CORE, $BACKEND);
-               return $OVERVIEW->parseIndexPropertiesJson();
+               return $this->OVERVIEW->parseIndexPropertiesJson();
        }
        
        private function getOverviewMaps() {
-               // Initialize backends
-               $BACKEND = new GlobalBackendMgmt($this->CORE);
-               
-               $OVERVIEW = new GlobalIndexPage($this->CORE, $BACKEND);
-               return $OVERVIEW->parseMapsJson();
+               return $this->OVERVIEW->parseMapsJson();
        }
        
        private function getOverviewAutomaps() {
-               // Initialize backends
-               $BACKEND = new GlobalBackendMgmt($this->CORE);
-               
-               $OVERVIEW = new GlobalIndexPage($this->CORE, $BACKEND);
-               return $OVERVIEW->parseAutomapsJson();
+               return $this->OVERVIEW->parseAutomapsJson();
        }
        
        private function getOverviewRotations() {
-               // Initialize backends
-               $BACKEND = new GlobalBackendMgmt($this->CORE);
-               
-               $OVERVIEW = new GlobalIndexPage($this->CORE, $BACKEND);
-               return $OVERVIEW->parseRotationsJson();
+               return $this->OVERVIEW->parseRotationsJson();
        }
 }
 ?>
diff --git a/share/server/core/classes/GlobalIndexPage.php 
b/share/server/core/classes/GlobalIndexPage.php
index ed0fade..e678c59 100644
--- a/share/server/core/classes/GlobalIndexPage.php
+++ b/share/server/core/classes/GlobalIndexPage.php
@@ -28,6 +28,7 @@
 class GlobalIndexPage {
        private $CORE;
        private $BACKEND;
+       private $AUTHORISATION = null;
        
        private $htmlBase;
        
@@ -39,9 +40,10 @@ class GlobalIndexPage {
         * @param       GlobalBackendMgmt       $BACKEND
         * @author      Lars Michelsen <[email protected]>
         */
-       public function __construct($CORE, $BACKEND) {
+       public function __construct(GlobalCore $CORE, GlobalBackendMgmt 
$BACKEND, CoreAuthorisationHandler $AUTHORISATION) {
                $this->CORE = $CORE;
                $this->BACKEND = $BACKEND;
+               $this->AUTHORISATION = $AUTHORISATION;
                
                $this->htmlBase = 
$this->CORE->MAINCFG->getValue('paths','htmlbase');
        }
@@ -97,8 +99,8 @@ class GlobalIndexPage {
                                // Get the icon of the map
                                $MAP->MAPOBJ->fetchIcon();
                                
-                               // Check if the user is permitted to view this 
map
-                               
if($MAPCFG->checkPermissions($MAPCFG->getValue('global',0, 
'allowed_user'),FALSE)) {
+                               // Check if the user is permitted to view this 
rotation
+                               if($this->AUTHORISATION->isPermitted('AutoMap', 
'view', $mapName)) {
                                        if($MAP->MAPOBJ->checkMaintenance(0)) {
                                                $class = '';
                                                $url = '';
@@ -161,7 +163,6 @@ class GlobalIndexPage {
         */
        public function parseMapsJson() {
                $aMaps = Array();
-               
 
                // Only display the rotation list when enabled
                if($this->CORE->MAINCFG->getValue('index','showmaps') == 1) {
@@ -190,7 +191,7 @@ class GlobalIndexPage {
                                        $MAP->MAPOBJ->fetchIcon();
                                        
                                        // Check if the user is permitted to 
view this map
-                                       
if($MAPCFG->checkPermissions($MAPCFG->getValue('global',0, 
'allowed_user'),FALSE)) {
+                                       
if($this->AUTHORISATION->isPermitted('Map', 'view', $mapName)) {
                                                
if($MAP->MAPOBJ->checkMaintenance(0)) {
                                                        $class = '';
                                                        $url = '';
@@ -262,21 +263,24 @@ class GlobalIndexPage {
                        $aRotationPools = 
$this->CORE->getDefinedRotationPools();
                        if(count($aRotationPools) > 0) {
                                foreach($aRotationPools AS $poolName) {
-                                       $ROTATION = new 
CoreRotation($this->CORE, $poolName);
-                                       
-                                       $aSteps = Array();
-                                       
-                                       // Parse the code for the step list
-                                       $iNum = $ROTATION->getNumSteps();
-                                       for($i = 0; $i < $iNum; $i++) {
-                                               $aSteps[] = Array('name' => 
$ROTATION->getStepLabelById($i),
-                                                                 'url' => 
$ROTATION->getStepUrlById($i));
+                                       // Check if the user is permitted to 
view this rotation
+                                       
if($this->AUTHORISATION->isPermitted('Rotation', 'view', $poolName)) {
+                                               $ROTATION = new 
CoreRotation($this->CORE, $poolName);
+                                               
+                                               $aSteps = Array();
+                                               
+                                               // Parse the code for the step 
list
+                                               $iNum = 
$ROTATION->getNumSteps();
+                                               for($i = 0; $i < $iNum; $i++) {
+                                                       $aSteps[] = 
Array('name' => $ROTATION->getStepLabelById($i),
+                                                                         'url' 
=> $ROTATION->getStepUrlById($i));
+                                               }
+                                               
+                                               $aRotations[] = Array('name' => 
$poolName,
+                                                                     'url' => 
$ROTATION->getStepUrlById(0),
+                                                                     
'num_steps' => $ROTATION->getNumSteps(),
+                                                                               
                                            'steps' => $aSteps);
                                        }
-                                       
-                                       $aRotations[] = Array('name' => 
$poolName,
-                                                             'url' => 
$ROTATION->getStepUrlById(0),
-                                                             'num_steps' => 
$ROTATION->getNumSteps(),
-                                                                               
                                    'steps' => $aSteps);
                                }
                        }
                }


------------------------------------------------------------------------------
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

Reply via email to