eb712f3c5bc68c3875bebcd554ea523c26461c82 angie Wed Aug 18 13:17:15 2010 -0700 Added support for new trackDb setting 'tableBrowser off' which prevents hgTables from displaying a track (if related tables need to be excluded from All Tables, they go after 'off', space-sep. diff --git src/hg/hgTables/mainPage.c src/hg/hgTables/mainPage.c index 9f684cb..9c0048d 100644 --- src/hg/hgTables/mainPage.c +++ src/hg/hgTables/mainPage.c @@ -232,27 +232,52 @@ return string; } +static void hashAddSlName(struct hash *hash, char *key, char *val) +/* If key is already in hash, add an slName for val to the head of the list; + * otherwise just store key -> slName for val. */ +{ +struct slName *sln = slNameNew(val); +struct hashEl *hel = hashLookup(hash, key); +if (hel == NULL) + hashAdd(hash, key, sln); +else + slAddHead(&(hel->val), sln); +} + static struct hash *accessControlInit(char *db, struct sqlConnection *conn) /* Return a hash associating restricted table/track names in the given db/conn - * with virtual hosts, or NULL if there is no tableAccessControl table. */ + * with virtual hosts, or NULL if there is no tableAccessControl table and no + * forbiddenTrackList (see getFullTrackList). */ { struct hash *acHash = NULL; if (sqlTableExists(conn, "tableAccessControl")) { struct sqlResult *sr = NULL; char **row = NULL; - acHash = newHash(8); + acHash = newHash(0); sr = sqlGetResult(conn, "select name,host from tableAccessControl"); while ((row = sqlNextRow(sr)) != NULL) + hashAddSlName(acHash, row[0], chopAtFirstDot(row[1])); + sqlFreeResult(&sr); + } +if (forbiddenTrackList != NULL) { - struct slName *sln = slNameNew(chopAtFirstDot(row[1])); - struct hashEl *hel = hashLookup(acHash, row[0]); - if (hel == NULL) - hashAdd(acHash, row[0], sln); - else - slAddHead(&(hel->val), sln); + if (acHash == NULL) + acHash = newHash(0); + struct trackDb *tdb; + for (tdb = forbiddenTrackList; tdb != NULL; tdb = tdb->next) + { + char *tbOff = trackDbSetting(tdb, "tableBrowser"); + if (isEmpty(tbOff)) + errAbort("bug: tdb for %s is in forbiddenTrackList without 'tableBrowser off' setting", + tdb->track); + hashAddSlName(acHash, tdb->table, "-"); + // skip "off" and look for additional table names: + nextWord(&tbOff); + char *tbl; + while ((tbl = nextWord(&tbOff)) != NULL) + hashAddSlName(acHash, tbl, "-"); } - sqlFreeResult(&sr); } return acHash; }