8025342bcfb5a55261a82fcae1781f915af3f44b
chinhli
  Mon Jun 10 15:01:17 2013 -0700
Bug 11006 hgUserSuggestion CGI need to check proper suggestion setting in hg.conf first.
diff --git src/hg/hgUserSuggestion/hgUserSuggestion.c src/hg/hgUserSuggestion/hgUserSuggestion.c
index b109842..f7b4b3d 100644
--- src/hg/hgUserSuggestion/hgUserSuggestion.c
+++ src/hg/hgUserSuggestion/hgUserSuggestion.c
@@ -11,83 +11,75 @@
 #include "hui.h"
 #include "cart.h"
 #include "hPrint.h"
 #include "dbDb.h"
 #include "web.h"
 #include "hash.h"
 #include "hgConfig.h"
 #include "hgUserSuggestion.h"
 #include "mailViaPipe.h"
 
 /* ---- Global variables. ---- */
 struct cart *cart;	/* The user's ui state. */
 struct hash *oldVars = NULL;
 
 /* ---- Global helper functions ---- */
+void checkHgConfForSuggestion()
+/* Abort if hg.conf has not been set up to accept suggestion */
+{
+if (isEmpty(cfgOption(CFG_SUGGEST_MAILTOADDR)) ||
+    isEmpty(cfgOption(CFG_SUGGEST_MAILFROMADDR)) ||
+    isEmpty(cfgOption(CFG_FILTERKEYWORD))        ||
+    isEmpty(cfgOption(CFG_SUGGEST_MAIL_SIGNATURE)) ||
+    isEmpty(cfgOption(CFG_SUGGEST_MAIL_RETURN_ADDR)) ||
+    isEmpty(cfgOption(CFG_SUGGEST_BROWSER_NAME)))
+    errAbort("This Genome Browser has not been configured to accept suggestion yet. Please contact the browser administrator for more information.");
+}
+
 char *mailToAddr()
 /* Return the address to send suggestion to  */
 {
-if isEmpty(cfgOption(CFG_SUGGEST_MAILTOADDR))
-    return cloneString("NULL_suggest.mailToAddr");
-else
     return cloneString(cfgOption(CFG_SUGGEST_MAILTOADDR));
 }
 
 char *mailFromAddr()
 /* Return the bogus sender address to help filter out spam */
 {
-if isEmpty(cfgOption(CFG_SUGGEST_MAILFROMADDR))
-    return cloneString("NULL_suggest.mailFromAddr");
-else
     return cloneString(cfgOption(CFG_SUGGEST_MAILFROMADDR));
 }
 
 char *filterKeyword()
 /* Return the keyword used to filter out spam  */
 {
-if isEmpty(cfgOption(CFG_FILTERKEYWORD))
-    return cloneString("NULL_suggest.filterKeyword");
-else
     return cloneString(cfgOption(CFG_FILTERKEYWORD));
 }
 
 char *mailSignature()
-/* Return the signature to be used by outbound mail or NULL. Allocd
- * here. */
+/* Return the signature to be used by outbound mail. */
 {
-if isEmpty(cfgOption(CFG_SUGGEST_MAIL_SIGNATURE))
-    return cloneString("NULL_mailSignature");
-else
     return cloneString(cfgOption(CFG_SUGGEST_MAIL_SIGNATURE));
 }
 
 char *mailReturnAddr()
-/* Return the return addr. to be used by outbound mail or NULL. Allocd
- * here. */
+/* Return the return addr. to be used by outbound mail. */
 {
-if isEmpty(cfgOption(CFG_SUGGEST_MAIL_RETURN_ADDR))
-    return cloneString("NULL_mailReturnAddr");
-else
     return cloneString(cfgOption(CFG_SUGGEST_MAIL_RETURN_ADDR));
 }
 
 char *browserName()
 /* Return the browser name like 'UCSC Genome Browser' */
 {
-if isEmpty(cfgOption(CFG_SUGGEST_BROWSER_NAME))
-    return cloneString("NULL_browserName");
-else
     return cloneString(cfgOption(CFG_SUGGEST_BROWSER_NAME));
 }
 
 static char *now()
 /* Return a mysql-formatted time like "2008-05-19 15:33:34". */
 {
 char nowBuf[256];
 time_t curtime;
 curtime = time (NULL); 
 struct tm *theTime = localtime(&curtime);
 strftime(nowBuf, sizeof nowBuf, "%Y-%m-%d %H:%M:%S", theTime);
 return cloneString(nowBuf);
 }
 
 
@@ -349,30 +341,31 @@
 sendSuggestionBack(sName, sEmail, sCategory, sSummary, sDetails, suggestID);
 /* send confirmation mail to user */
 sendConfirmMail(sEmail,suggestID);
 /* display confirmation page */
 printSuggestionConfirmed();
 cartRemove(cart, "do.suggestSendMail");
 }
 
 void doMiddle(struct cart *theCart)
 /* Write header and body of html page. */
 {
 char *db, *organism;
 cart = theCart;
 getDbAndGenome(cart, &db, &organism, oldVars);
 cartWebStart(theCart, db, "User Suggestion");
+checkHgConfForSuggestion();
 if (cartVarExists(cart, "do.suggestSendMail"))
     {
     submitSuggestion();
     cartRemove(cart, "do.suggestSendMail");
     return;
     }
 
 askForSuggest(organism,db);
 cartWebEnd();
 }
 
 /* Null terminated list of CGI Variables we don't want to save
  * permanently. */
 char *excludeVars[] = {"Submit", "submit", "Clear", NULL};