Author:   Lars Michelsen <[email protected]>
Date:     Sat Oct 27 18:18:48 2012 +0200
Committer:   Lars Michelsen <[email protected]>
Commit-Date: Sat Oct 27 18:18:48 2012 +0200

Added optional variable filterUser to filter the maps on overview maps
listing by another user permissions (only possible if authed user is
allowed to access those maps too)

---

 .f12                                               |   28 +++----------------
 .../core/classes/CoreAuthorisationHandler.php      |    5 +--
 .../core/classes/CoreAuthorisationModMySQL.php     |    5 ++-
 .../core/classes/CoreAuthorisationModSQLite.php    |    5 ++-
 .../core/classes/CoreAuthorisationModule.php       |    4 +-
 share/server/core/classes/GlobalIndexPage.php      |   10 +++++++
 6 files changed, 25 insertions(+), 32 deletions(-)

diff --git a/.f12 b/.f12
index ffd78d4..5f40887 100755
--- a/.f12
+++ b/.f12
@@ -1,43 +1,25 @@
 #!/bin/bash
 
 [ -z $SITE ] && SITE=lancom
-
-cd /d1/nagvis
+which sudo >/dev/null 2>&1 && SUDO=sudo || SUDO=
 
 #
 # Install to /usr/local/nagvis
 #
-sudo ./install.sh -a y -q -r -F -c y \
+$SUDO ./install.sh -a y -q -r -F -c y \
              -W /nagvis -n /usr/local/nagios \
              -i mklivestatus -p /usr/local/nagvis \
              -u www-data -g www-data \
              -w /etc/apache2/conf.d \
              -l unix:/omd/sites/muc/tmp/run/live
-sudo rm -f /etc/apache2/conf.d/nagvis.conf.*
+$SUDO rm -f /etc/apache2/conf.d/nagvis.conf.*
 
 #
 # Install to omd site local/
 #
-sudo su - $SITE -c "[ ! -d /omd/sites/$SITE/nvsrc ] && mkdir 
/omd/sites/$SITE/nvsrc ; \
-rsync --filter='- .git' --filter='- .*.swp' -av /d1/nagvis/ 
/omd/sites/$SITE/nvsrc/ ; \
+$SUDO su - $SITE -c "[ ! -d /omd/sites/$SITE/nvsrc ] && mkdir 
/omd/sites/$SITE/nvsrc ; \
+rsync --filter='- .git' --filter='- .*.swp' -av ./ /omd/sites/$SITE/nvsrc/ ; \
 cd /omd/sites/$SITE/nvsrc/ ; \
 yes y | ./omd_install.sh"
 
-#
-# Install to OMD default version
-#
-
-#sudo rsync -av /d1/nagvis/share/frontend/ 
/opt/omd/versions/default/share/nagvis/htdocs/frontend/
-#[ -f 
/opt/omd/versions/default/share/nagvis/htdocs/frontend/nagvis-js/js/NagVisCompressed.js
 ] \
-#  && sudo rm 
/opt/omd/versions/default/share/nagvis/htdocs/frontend/nagvis-js/js/NagVisCompressed.js
-#[ -f 
/opt/omd/versions/default/share/nagvis/htdocs/frontend/wui/js/WuiCompressed.js 
] \
-#  && sudo rm 
/opt/omd/versions/default/share/nagvis/htdocs/frontend/wui/js/WuiCompressed.js
-#sudo rsync -av /d1/nagvis/share/server/core/ajax_handler.php 
/opt/omd/versions/default/share/nagvis/htdocs/server/core/ajax_handler.php
-#sudo rsync -av /d1/nagvis/share/server/core/classes/ 
/opt/omd/versions/default/share/nagvis/htdocs/server/core/classes/
-#sudo rsync -av /d1/nagvis/share/server/core/functions/ 
/opt/omd/versions/default/share/nagvis/htdocs/server/core/functions/
-#sudo rsync -av /d1/nagvis/share/server/core/defines/matches.php 
/opt/omd/versions/default/share/nagvis/htdocs/server/core/defines/
-##sudo rsync -av /d1/nagvis/share/userfiles/ 
/opt/omd/versions/default/skel/var/nagvis/userfiles/
-##sudo rsync -av /d1/nagvis/share/userfiles/ 
/opt/omd/sites/muc/var/nagvis/userfiles/
-#sudo rsync -av /d1/nagvis/share/userfiles/ 
/omd/sites/muc/share/nagvis/htdocs/userfiles/
-
 exit 0
diff --git a/share/server/core/classes/CoreAuthorisationHandler.php 
b/share/server/core/classes/CoreAuthorisationHandler.php
index 0c5b757..2eec045 100644
--- a/share/server/core/classes/CoreAuthorisationHandler.php
+++ b/share/server/core/classes/CoreAuthorisationHandler.php
@@ -205,9 +205,8 @@ class CoreAuthorisationHandler {
         return $this->MOD->updateRolePerms($roleId, $perms);
     }
 
-    public function parsePermissions() {
-        $this->aPermissions = $this->MOD->parsePermissions();
-
+    public function parsePermissions($sUsername = null) {
+        $this->aPermissions = $this->MOD->parsePermissions($sUsername);
         return $this->aPermissions;
     }
 
diff --git a/share/server/core/classes/CoreAuthorisationModMySQL.php 
b/share/server/core/classes/CoreAuthorisationModMySQL.php
index cda92e0..d6eaded 100644
--- a/share/server/core/classes/CoreAuthorisationModMySQL.php
+++ b/share/server/core/classes/CoreAuthorisationModMySQL.php
@@ -193,11 +193,12 @@ class CoreAuthorisationModMySQL extends 
CoreAuthorisationModule {
         return $this->checkRoleExists($name);
     }
 
-    public function parsePermissions() {
+    public function parsePermissions($sUsername = null) {
         global $AUTH;
         $aPerms = Array();
 
-        $sUsername = $AUTH->getUser();
+        if($sUsername === null)
+            $sUsername = $AUTH->getUser();
 
         // Only handle known users
         $userId = $this->getUserId($sUsername);
diff --git a/share/server/core/classes/CoreAuthorisationModSQLite.php 
b/share/server/core/classes/CoreAuthorisationModSQLite.php
index c8686d2..680e6de 100644
--- a/share/server/core/classes/CoreAuthorisationModSQLite.php
+++ b/share/server/core/classes/CoreAuthorisationModSQLite.php
@@ -206,11 +206,12 @@ class CoreAuthorisationModSQLite extends 
CoreAuthorisationModule {
         }
     }
 
-    public function parsePermissions() {
+    public function parsePermissions($sUsername = null) {
         global $AUTH;
         $aPerms = Array();
 
-        $sUsername = $AUTH->getUser();
+        if($sUsername === null)
+            $sUsername = $AUTH->getUser();
 
         // Only handle known users
         $userId = $this->getUserId($sUsername);
diff --git a/share/server/core/classes/CoreAuthorisationModule.php 
b/share/server/core/classes/CoreAuthorisationModule.php
index 58d7ebf..917bf96 100644
--- a/share/server/core/classes/CoreAuthorisationModule.php
+++ b/share/server/core/classes/CoreAuthorisationModule.php
@@ -29,6 +29,6 @@
  * @author Lars Michelsen <[email protected]>
  */
 abstract class CoreAuthorisationModule {
-    abstract public function parsePermissions();
+    abstract public function parsePermissions($sUsername = null);
 }
-?>
\ No newline at end of file
+?>
diff --git a/share/server/core/classes/GlobalIndexPage.php 
b/share/server/core/classes/GlobalIndexPage.php
index ad64825..b783ea2 100644
--- a/share/server/core/classes/GlobalIndexPage.php
+++ b/share/server/core/classes/GlobalIndexPage.php
@@ -48,6 +48,16 @@ class GlobalIndexPage {
         if(!$AUTHORISATION->isPermitted('Map', 'view', $mapName))
             return null;
 
+        // If the parameter filterUser is set, filter the maps by the username
+        // given in this parameter. This is a mechanism to be authed as generic
+        // user but see the maps of another user.
+        if(isset($_GET['filterUser']) && $_GET['filterUser'] != '') {
+            $AUTHORISATION2 = new CoreAuthorisationHandler();
+            $AUTHORISATION2->parsePermissions($_GET['filterUser']);
+            if(!$AUTHORISATION2->isPermitted('Map', 'view', $mapName))
+                return null;
+        }
+
         $map = Array('object_id' => $objectId);
 
         $MAPCFG = new NagVisMapCfg($this->CORE, $mapName);


------------------------------------------------------------------------------
WINDOWS 8 is here. 
Millions of people.  Your app in 30 days.
Visit The Windows 8 Center at Sourceforge for all your go to resources.
http://windows8center.sourceforge.net/
join-generation-app-and-make-money-coding-fast/
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to