4a12b8e105ea5b518de2c1ce33c1b94e3df09a2e
hiram
  Mon Jun 25 10:56:10 2012 -0700
make the wiki track read only be an option in hg.conf
diff --git src/hg/lib/wikiTrack.c src/hg/lib/wikiTrack.c
index d074dd1..6852a33 100644
--- src/hg/lib/wikiTrack.c
+++ src/hg/lib/wikiTrack.c
@@ -312,30 +312,36 @@
 
 #ifdef NOT
 static void savePosInTextBox(char *chrom, int start, int end)
 /* Save basic position/database info in text box and hidden var. 
    Positions becomes chrom:start-end*/
 {
 char position[128];
 char *newPos;
 snprintf(position, 128, "%s:%d-%d", chrom, start, end);
 newPos = addCommasToPos(position);
 cgiMakeTextVar("getDnaPos", newPos, strlen(newPos) + 2);
 cgiContinueHiddenVar("db");
 }
 #endif
 
+boolean wikiTrackReadOnly()
+/* return TRUE if wiki track is in Read-Only mode, default answer is FALSE */
+{
+return cfgOptionBooleanDefault(CFG_WIKI_TRACK_READ_ONLY, FALSE);
+}
+
 boolean wikiTrackEnabled(char *database, char **wikiUserName)
 /*determine if wikiTrack can be used, and is this user logged into the wiki ?*/
 {
 static boolean done = FALSE;
 static boolean status = FALSE;
 static boolean wikiUp = TRUE;
 static char *userName = NULL;
 
 /* do not repeat this query */
 if (done)
     {
     if (wikiUserName)
 	*wikiUserName = userName;  /* returning name indicates logged in */
     return status;
     }
@@ -384,49 +390,51 @@
 	    struct errCatch *errCatch = errCatchNew();
 	    if (errCatchStart(errCatch))
 		{
 		page = fetchEditPage(TEST_EMAIL_VERIFIED);
 		}
 	    errCatchEnd(errCatch);
 	    if (errCatch->gotError) // we think it is supposed to be there
 		{
 		wikiUp = FALSE;		// but it will not respond
 		}
 	    errCatchFree(&errCatch);
 	    char *loginExpired = NULL;
 	    if (page)
 		loginExpired = stringIn(LOGIN_EXPIRED, page->fullText);
 	    if (loginExpired == NULL)
-		userName = NULL; /* read-only mode enforced 2012-06-22
-                                  * otherwise we would set wikiUser here
-                                  * to save result for next time */
+                {
+                if (wikiTrackReadOnly())
+                    userName = NULL; /* read-only mode 2012-06-25 */
+                else
+                    userName = wikiUser;
+                }
 	}
     /* see if table exists, create it if it is not yet there */
     struct sqlConnection *wikiConn = wikiConnect();
     if (! sqlTableExists(wikiConn,WIKI_TRACK_TABLE))
 	{
 	char *query = wikiTrackGetCreateSql(WIKI_TRACK_TABLE);
 	sqlUpdate(wikiConn, query);
 	freeMem(query);
 	}
     wikiDisconnect(&wikiConn);
     if (wikiUp)
 	status = TRUE; /* system is enabled */
     }
 if (wikiUserName)
-    *wikiUserName = NULL;  /* read-only mode enforced 2012-06-22
-                            * otherwise we would return userName here */
+    *wikiUserName = userName;  /* returning name indicates logged in */
 
 return status;
 }
 
 /* from hg/lib/wikiTrack.sql */
 static char *createString =
 "CREATE TABLE %s (\n"
     "bin smallint unsigned not null,\n"
     "chrom varchar(255) not null,\n"
     "chromStart int unsigned not null,\n"
     "chromEnd int unsigned not null,\n"
     "name varchar(255) not null,\n"
     "score int unsigned not null,\n"
     "strand char(1) not null,\n"
     "db varchar(36) not null,\n"