--- ../../racktables-prod/inc/functions.php	2013-07-02 15:17:42.000000000 +0200
+++ ./functions.php	2013-07-31 14:45:12.557187967 +0200
@@ -6116,4 +6116,49 @@
 	return FALSE;
 }
 
+
+
+// function getLocationTrail requires location id 
+// and optional: spacer/delimiter 
+// and optional: link - if href link should be create to each location
+// it returns html string with parent location names 
+function getLocationTrail($loc_id, $link = true, $spacer = " : ")
+{
+
+	//build location lookup table:
+        $loc_tree = listCells('location');
+        
+        global $loc_name_tbl;
+        global $loc_parents;
+        
+	//lets do it once and then use it again in next function calls
+        if(count($loc_name_tbl) == 0)
+	{
+	        $loc_name_tbl = array();
+		$loc_parents = array();
+		//populate tables
+		foreach($loc_tree as $loc)
+	        {
+            		$loc_parents[$loc['id']] = $loc['parent_id'];
+		        $loc_name_tbl[$loc['id']] = $loc['name'];
+		}
+	}
+
+	//generate parent location to given location string
+        $name = "";
+        $id=$loc_id;
+        while(isset($id))
+        {
+		if($link)
+			$name = mkA($loc_name_tbl[$id],'location',$id) . $spacer . $name;
+		else
+			$name = $loc_name_tbl[$id] . $spacer . $name;
+                $id = $loc_parents[$id];
+        }
+	$name = substr($name,0,0 - strlen($spacer));
+
+	return $name;
+}
+
+
 ?>
