24295958e3a35c027cf4727e43823283d80ae697 larrym Tue Apr 3 12:48:49 2012 -0700 replace use of SUPPORT_EURONODE with geoMirrorEnabled() diff --git src/hg/lib/cart.c src/hg/lib/cart.c index 49ca9c8..6ef9098 100644 --- src/hg/lib/cart.c +++ src/hg/lib/cart.c @@ -10,30 +10,31 @@ #include "hgConfig.h" #include "cart.h" #include "net.h" #include "web.h" #include "hdb.h" #include "jksql.h" #include "jsHelper.h" #include "trashDir.h" #ifndef GBROWSE #include "customFactory.h" #include "googleAnalytics.h" #include "wikiLink.h" #endif /* GBROWSE */ #include "hgMaf.h" #include "hui.h" +#include "geoMirror.h" static char *sessionVar = "hgsid"; /* Name of cgi variable session is stored in. */ static char *positionCgiName = "position"; DbConnector cartDefaultConnector = hConnectCart; DbDisconnect cartDefaultDisconnector = hDisconnectCart; static void hashUpdateDynamicVal(struct hash *hash, char *name, void *val) /* Val is a dynamically allocated (freeMem-able) entity to put * in hash. Override existing hash item with that name if any. * Otherwise make new hash item. */ { struct hashEl *hel = hashLookup(hash, name); if (hel == NULL) hashAdd(hash, name, val); @@ -1334,42 +1335,40 @@ /* Clear cart in database. */ { int hguid = getCookieId(cookieName); int hgsid = getSessionId(); struct sqlConnection *conn = cartDefaultConnector(); clearDbContents(conn, "userDb", hguid); clearDbContents(conn, "sessionDb", hgsid); cartDefaultDisconnector(&conn); } void cartWriteCookie(struct cart *cart, char *cookieName) /* Write out HTTP Set-Cookie statement for cart. */ { printf("Set-Cookie: %s=%u; path=/; domain=%s; expires=%s\r\n", cookieName, cart->userInfo->id, cfgVal("central.domain"), cookieDate()); -#ifdef SUPPORT_EURONODE +if(geoMirrorEnabled()) + { + // This occurs after the user has manually choosen to go back to the original site; we store redirect value into a cookie so we + // can use it in subsequent hgGateway requests before loading the user's cart char *redirect = cgiOptionalString("redirect"); -char *source = cgiOptionalString("source"); -if (redirect && !source) + if (redirect) { - printf("Set-Cookie: redirect=mirror; path=/; domain=%s; expires=%s\r\n", cgiServerName(), cookieDate()); - // DEBUG REMOVE: - fprintf(stderr, "GALT Set-Cookie: redirect=mirror; path=/; domain=%s; expires=%s\r\n", - cfgVal("central.domain"), cookieDate()); - fflush(stderr); + printf("Set-Cookie: redirect=%s; path=/; domain=%s; expires=%s\r\n", redirect, cgiServerName(), cookieDate()); + } } -#endif } struct cart *cartForSession(char *cookieName, char **exclude, struct hash *oldVars) /* This gets the cart without writing any HTTP lines at all to stdout. */ { int hguid = getCookieId(cookieName); int hgsid = getSessionId(); struct cart *cart = cartNew(hguid, hgsid, exclude, oldVars); cartExclude(cart, sessionVar); if (sameOk(cfgOption("signalsHandler"), "on")) /* most cgis call this routine */ initSigHandlers(hDumpStackEnabled()); char *httpProxy = cfgOption("httpProxy"); /* most cgis call this routine */ if (httpProxy) setenv("http_proxy", httpProxy, TRUE); /* net.c cannot see the cart, pass the value through env var */