9cb21861514df76b30d13df3e0eb10ace6d0ec86 chinhli Sat Jun 15 13:31:38 2013 -0700 ToDo 11002 Jonathan's CRAZ category hack STOOPED. diff --git src/hg/hgUserSuggestion/hgUserSuggestion.c src/hg/hgUserSuggestion/hgUserSuggestion.c index 3f64b67..58e2c98 100644 --- src/hg/hgUserSuggestion/hgUserSuggestion.c +++ src/hg/hgUserSuggestion/hgUserSuggestion.c @@ -122,30 +122,48 @@ if (!*(domain = ++c)) return 0; do { if (*c == '.') { if (c == domain || *(c - 1) == '.') return 0; count++; } if (*c <= ' ' || *c >= 127) return 0; if (strchr(rfc822_specials, *c)) return 0; } while (*++c); return (count >= 1); } +boolean validateCategory(char *category) +/* Validate the Category from the request */ +{ +const char *cat[5]; +cat[0] = "Tracks"; +cat[1] = "Genome Assemblies"; +cat[2] = "Browser Tools"; +cat[3] = "Command-line Utilities"; +cat[4] = "Others"; + +int i; +for(i=0;i<5;i++) +{ + if (strcmp(cat[i], category)==0) return TRUE; +} +return FALSE; +} + /* javascript functions */ void printMainForm() /* Create the main suggestion form */ { hPrintf( "
\n"); hPrintf( "

User Suggestion Form

\n" "

If you have ideas about how we can improve the value of the Genome Browser to your research, " "we'd like to hear from you. Please provide a concise description below. " "A copy of the suggestion will be sent to your email address along with a reference number. " "You may follow up on the status of your request at any time by contacting us and quoting the reference number.

"); hPrintf("

Please note: this form is not the proper place to submit questions regarding browser use or bug reports. Use the links on our contact page instead.

"); hPrintf("

"); @@ -323,30 +341,42 @@ "contacting us and quoting your reference number:

%s

" "A copy of this information has also been sent to you at %s.

", refID, userAddr); hPrintf( "

Click here if you wish to make additional suggestions.

"); hPrintf( "

" "Your suggestion summary:
" "%s
" "Your suggestion details:
" "

%s
" "

", summary, details); } +void printInvalidCategory(char *invalidCategory) +/* display suggestion confirm page */ +{ +hPrintf( + "

Invalid Category.

"); +hPrintf( + "

" + "The category \"%s\" is invalid. Please correct it and " + "submit again.

", + invalidCategory); +} + void printInvalidEmailAddr(char *invalidEmailAddr) /* display suggestion confirm page */ { hPrintf( "

Invalid email address format.

"); hPrintf( "

" "The email address \"%s\" is invalid. Please correct it and " "submit again.

", invalidEmailAddr); } void sendSuggestionBack(char *sName, char *sEmail, char *sCategory, char *sSummary, char *sDetails, char *suggestID) /* send back the suggestion */ { @@ -402,30 +432,38 @@ { /* parameters from hg.cong */ char *filter=filterKeyword(); /* values from cart */ char *sName=cartUsualString(cart,"suggestName",""); char *sEmail=cartUsualString(cart,"suggestEmail",""); char *sCategory=cartUsualString(cart,"suggestCategory",""); char *sSummary=cartUsualString(cart,"suggestSummary",""); char *sDetails=cartUsualString(cart,"suggestDetails",""); char suggestID[512]; safef(suggestID, sizeof(suggestID),"%s %s", sEmail, now()); char subject[512]; safef(subject, sizeof(subject),"%s %s", filter, suggestID); + +/* reject suggestion if category is invalid */ +if (!validateCategory(sCategory)) +{ + printInvalidCategory(sCategory); + return; +} + /* Send back suggestion only with valid user email address */ if (spc_email_isvalid(sEmail) != 0) { /* send back the suggestion */ sendSuggestionBack(sName, sEmail, sCategory, sSummary, sDetails, suggestID); /* send confirmation mail to user */ sendConfirmMail(sEmail,suggestID, sSummary, sDetails); /* display confirmation page */ printSuggestionConfirmed(sSummary, suggestID, sEmail, mailReturnAddr(), sDetails); } else { /* save all field value in cart */ printInvalidEmailAddr(sEmail); } cartRemove(cart, "do.suggestSendMail"); }