--- ganglia-web/edit_optional_graphs.php	2011-03-09 10:00:58.000000000 +0100
+++ /home/jeffrey/svn/ganglia/branch/web2/edit_optional_graphs.php	2011-03-09 10:15:18.000000000 +0100
@@ -7,6 +7,13 @@
 require_once('./conf.php');
 
 $hostname = $_GET['hostname'];
+$clustername = $_GET['clustername'];
+
+if ( $hostname != "" ) {
+    $filename = "/host_" . $hostname . ".json";
+} else if ( $clustername != "" ) {
+    $filename = "/cluster_" . $clustername . ".json";
+}
 
 $default_reports = array("included_reports" => array(), "excluded_reports" => array());
 $default_file = $conf['conf_dir'] . "/default.json";
@@ -14,10 +21,10 @@
   $default_reports = array_merge($default_reports,json_decode(file_get_contents($default_file), TRUE));
 }
 
-$host_file = $conf['conf_dir'] . "/host_" . $hostname . ".json";
+$file = $conf['conf_dir'] . $filename;
 $override_reports = array("included_reports" => array(), "excluded_reports" => array());
-if ( is_file($host_file) ) {
-  $override_reports = array_merge($override_reports, json_decode(file_get_contents($host_file), TRUE));
+if ( is_file($file) ) {
+  $override_reports = array_merge($override_reports, json_decode(file_get_contents($file), TRUE));
 }
 
 if ( isset($_GET['action']) ) {
@@ -27,79 +34,79 @@
     $report_name = str_replace("\"", "", $report_name); 
 
     switch ( $selection ) {
-	case "included":
-	  # Check if report is already included by default
-	  if ( !in_array($report_name, $default_reports["included_reports"] ) ) {
-	    $reports["included_reports"][] = $report_name;
-	  }
-	  break;
-	case "excluded":
-	  if ( !in_array($report_name, $default_reports["excluded_reports"] ) ) {
-	    $reports["excluded_reports"][] = $report_name;
-	  }
-	  break;
+    case "included":
+      # Check if report is already included by default
+      if ( !in_array($report_name, $default_reports["included_reports"] ) ) {
+        $reports["included_reports"][] = $report_name;
+      }
+      break;
+    case "excluded":
+      if ( !in_array($report_name, $default_reports["excluded_reports"] ) ) {
+        $reports["excluded_reports"][] = $report_name;
+      }
+      break;
     }
   }
 
   if ( is_array($reports) ) {
     $json = json_encode($reports);
-    $host_file = $conf['conf_dir'] . "/host_" . $hostname . ".json";
-    if ( file_put_contents($host_file, $json) === FALSE ) {
+    $file = $conf['conf_dir'] . $filename;
+    if ( file_put_contents($file, $json) === FALSE ) {
   ?>
-	<div class="ui-widget">
-			  <div class="ui-state-error ui-corner-all" style="padding: 0 .7em;"> 
-				  <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span> 
-				  <strong>Alert:</strong> Can't write to file <?php print $host_file; ?>. Perhaps permissions are wrong.</p>
-			  </div>
-	</div>
+    <div class="ui-widget">
+              <div class="ui-state-error ui-corner-all" style="padding: 0 .7em;"> 
+                  <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span> 
+                  <strong>Alert:</strong> Can't write to file <?php print $file; ?>. Perhaps permissions are wrong.</p>
+              </div>
+    </div>
   <?php
     } else {
   ?>
       <div class="ui-widget">
-			  <div class="ui-state-default ui-corner-all" style="padding: 0 .7em;"> 
-				  <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span> 
-				  Change written successfully.</p>
-			  </div>
-	</div>
+              <div class="ui-state-default ui-corner-all" style="padding: 0 .7em;"> 
+                  <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span> 
+                  Change written successfully.</p>
+              </div>
+    </div>
   <?php
     }
 
   } else {
 
     // Remove file if it already exists since there are no overrides
-    if ( is_file($host_file) ) {
-      if ( unlink($host_file) !== FALSE ) {
+    if ( is_file($file) ) {
+      if ( unlink($file) !== FALSE ) {
   ?>
       <div class="ui-widget">
-			  <div class="ui-state-default ui-corner-all" style="padding: 0 .7em;"> 
-				  <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span> 
-				  Change written successfully.</p>
-			  </div>
-	</div>
+              <div class="ui-state-default ui-corner-all" style="padding: 0 .7em;"> 
+                  <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span> 
+                  Change written successfully.</p>
+              </div>
+    </div>
   <?php
       } else {
   ?>
-	<div class="ui-widget">
-			  <div class="ui-state-error ui-corner-all" style="padding: 0 .7em;"> 
-				  <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span> 
-				  <strong>Alert:</strong> Can't write to file <?php print $host_file; ?>. Perhaps permissions are wrong.</p>
-			  </div>
-	</div>
+    <div class="ui-widget">
+              <div class="ui-state-error ui-corner-all" style="padding: 0 .7em;"> 
+                  <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span> 
+                  <strong>Alert:</strong> Can't write to file <?php print $file; ?>. Perhaps permissions are wrong.</p>
+              </div>
+    </div>
   <?php
       }
 
     } else {
   ?>
       <div class="ui-widget">
-			  <div class="ui-state-default ui-corner-all" style="padding: 0 .7em;"> 
-				  <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span> 
-				  Change written successfully.</p>
-			  </div>
-	</div>
+              <div class="ui-state-default ui-corner-all" style="padding: 0 .7em;"> 
+                  <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span> 
+                  Change written successfully.</p>
+              </div>
+    </div>
   <?php
 
 
-    } // end of if ( is_file($host_file) ) {
+    } // end of if ( is_file($file) ) {
 
   } // end of if ( is_array($reports)
 
@@ -109,6 +116,7 @@
 
 <form id=edit_optional_reports_form>
 <input type=hidden name=hostname value=<?php print $_GET['hostname']; ?>>
+<input type=hidden name=clustername value=<?php print $_GET['clustername']; ?>>
 <input type=hidden name=action value=change>
 <table border=1 width=90%>
 <style>
@@ -118,7 +126,8 @@
 </style>
 <?php
 
-print "<h4>Hostname: " . $hostname . "</h4><br>";
+print "<h4>Hostname: " . $hostname . "</h4>";
+print "<h4>Clustername: " . $clustername . "</h4>";
 ?>
 <?php
 function create_radio_button($variable_name, $variable_value = "ignored") {
@@ -149,7 +158,7 @@
 
     while (false !== ($file = readdir($handle))) {
       if ( preg_match("/(.*)(_report)\.(" . $report_suffix .")/", $file, $out) ) {
-	if ( ! in_array($out[1] . "_report", $available_reports) )
+        if ( ! in_array($out[1] . "_report", $available_reports) )
           $available_reports[] = $out[1] . "_report";
       }
     }
@@ -189,4 +198,4 @@
 
 } // if ( isset($_GET['action') )
 
-?>
\ No newline at end of file
+?>
