[Mapbender-commits] r6935 - trunk/mapbender/http/classes

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Sep 23 10:02:14 EDT 2010


Author: christoph
Date: 2010-09-23 14:02:14 +0000 (Thu, 23 Sep 2010)
New Revision: 6935

Modified:
   trunk/mapbender/http/classes/class_wms.php
Log:
Layer authorisation

Modified: trunk/mapbender/http/classes/class_wms.php
===================================================================
--- trunk/mapbender/http/classes/class_wms.php	2010-09-23 14:01:16 UTC (rev 6934)
+++ trunk/mapbender/http/classes/class_wms.php	2010-09-23 14:02:14 UTC (rev 6935)
@@ -217,12 +217,22 @@
 	}
 
 	public function getLayerById ($id) {
+		$adm = new administration();
 		for ($i = 0; $i < count($this->objLayer); $i++) {
 			if (strval($this->objLayer[$i]->layer_uid) === strval($id)) {
-				return $this->objLayer[$i];
+				if ($adm->getLayerPermission(
+							$this->wms_id, 
+							$this->objLayer[$i]->layer_name, 
+							Mapbender::session()->get("mb_user_id")
+				)) {
+					return $this->objLayer[$i];
+				}
+				else {
+					throw new Exception ("Access to layer denied.");
+				}
 			}
 		}
-		return null;
+		throw new Exception ("Layer not found.");
 	}
 
 	public function getLayerByPos ($pos) {
@@ -2787,7 +2797,12 @@
 		$wmsFactory = new UniversalWmsFactory();
 		$wms = $wmsFactory->createFromDb($wmsId);
 		if (!is_null($wms)) {
-			$currentLayer = $wms->getLayerById($this->layer_uid);
+			try {
+				$currentLayer = $wms->getLayerById($this->layer_uid);
+			}
+			catch (Exception $e) {
+				return $children;
+			}
 			for ($i = 0; $i < count($wms->objLayer); $i++) {
 				$l = $wms->objLayer[$i];
 				if ($l->layer_parent === $currentLayer->layer_pos) {
@@ -2805,7 +2820,12 @@
 		$wmsFactory = new UniversalWmsFactory();
 		$wms = $wmsFactory->createFromDb($wmsId);
 		if (!is_null($wms)) {
-			$currentLayer = $wms->getLayerById($this->layer_uid);
+			try {
+				$currentLayer = $wms->getLayerById($this->layer_uid);
+			}
+			catch (Exception $e) {
+				return $parents;
+			}
 			while (!is_null($currentLayer)) {
 				$pos = $currentLayer->layer_parent;
 				$currentLayer = $wms->getLayerByPos($pos);



More information about the Mapbender_commits mailing list