e77dcca9b1bffc335f2843c8cfce67119b3d039d
braney
  Wed Nov 30 16:25:50 2011 -0800
allow specifying different names for the hubPublic and hubStatus tables (#6162)
diff --git src/hg/hgHubConnect/hgHubConnect.c src/hg/hgHubConnect/hgHubConnect.c
index 974226f..b67b64f 100644
--- src/hg/hgHubConnect/hgHubConnect.c
+++ src/hg/hgHubConnect/hgHubConnect.c
@@ -206,37 +206,36 @@
 
     ourCellStart();
     printf(
     "<input name=\"hubDisconnectButton\""
 	"onClick=\"document.disconnectHubForm.elements['hubId'].value='%d';"
 	    "document.disconnectHubForm.submit();return true;\" "
 	    "class=\"hubField\" type=\"button\" value=\"X\">"
 	    , hub->id);
     ourCellEnd();
     }
 
 printf("</TR></tbody></TABLE>\n");
 printf("</div>");
 }
 
-void hgHubConnectPublic()
+static boolean outputPublicTable(struct sqlConnection *conn, char *publicTable)
 /* Put up the list of public hubs and other controls for the page. */
 {
-struct sqlConnection *conn = hConnectCentral();
 char query[512];
 safef(query, sizeof(query), "select hubUrl,shortLabel,longLabel,dbList from %s", 
-	hubPublicTableName); 
+	publicTable); 
 struct sqlResult *sr = sqlGetResult(conn, query);
 char **row;
 
 boolean gotAnyRows = FALSE;
 while ((row = sqlNextRow(sr)) != NULL)
     {
     char *url = row[0], *shortLabel = row[1], *longLabel = row[2], 
     	  *dbList = row[3];
     if (gotAnyRows)
 	webPrintLinkTableNewRow();
     else
 	{
 	/* output header */
 	printf("<div id=\"publicHubs\" class=\"hubList\"> \n");
 	printf("<table id=\"publicHubsTable\"> "
@@ -285,39 +284,48 @@
     if (isEmpty(errorMessage))
 	ourPrintCell(longLabel);
     else
 	printf("<TD><span class=\"hubError\">ERROR: %s </span>"
 	    "<a href=\"../goldenPath/help/hgTrackHubHelp.html#Debug\">Debug</a></TD>", 
 	    errorMessage);
 
     ourPrintCell(removeLastComma(dbList));
     ourPrintCell(url);
     }
 sqlFreeResult(&sr);
 
 if (gotAnyRows)
     {
     printf("</TR></tbody></TABLE>\n");
+    printf("</div>");
     }
-else
+return gotAnyRows;
+}
+
+
+void hgHubConnectPublic()
+/* Put up the list of public hubs and other controls for the page. */
+{
+struct sqlConnection *conn = hConnectCentral();
+char *publicTable = cfgOptionEnvDefault("HGDB_HUB_PUBLIC_TABLE", 
+	"hubPublicTableName", defaultHubPublicTableName);
+if (!(sqlTableExists(conn, publicTable) && outputPublicTable(conn, publicTable) ))
     {
     printf("<div id=\"publicHubs\" class=\"hubList\"> \n");
     printf("No Public Track Hubs for this genome assembly<BR>");
-    }
-
 printf("</div>");
-
+    }
 hDisconnectCentral(&conn);
 }
 
 static void tryHubOpen(unsigned id)
 /* try to open hub, leaks trackHub structure */
 {
 /* try opening this again to reset error */
 struct sqlConnection *conn = hConnectCentral();
 struct errCatch *errCatch = errCatchNew();
 struct hubConnectStatus *hub = NULL;
 if (errCatchStart(errCatch))
     hub = hubConnectStatusForId(conn, id);
 errCatchEnd(errCatch);
 if (errCatch->gotError)
     hubUpdateStatus( errCatch->message->string, NULL);