Fossil SCM
Add the /subscribers page. Fix minor issues. All pages still need improvement.
Commit
e015c10306d40a306c55d5f956df2cac0ad376b7ceb9ed8b37a9282f55869adf
Parent
adf068faebbe64f…
2 files changed
+21
+50
-8
M
src/db.c
+21
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -310,10 +310,31 @@ | ||
| 310 | 310 | db.pAllStmt = pStmt; |
| 311 | 311 | va_end(ap); |
| 312 | 312 | } |
| 313 | 313 | return rc; |
| 314 | 314 | } |
| 315 | + | |
| 316 | +/* Prepare a statement using text placed inside a Blob | |
| 317 | +** using blob_append_sql(). | |
| 318 | +*/ | |
| 319 | +int db_prepare_blob(Stmt *pStmt, Blob *pSql){ | |
| 320 | + int rc; | |
| 321 | + char *zSql; | |
| 322 | + pStmt->sql = *pSql; | |
| 323 | + blob_init(pSql, 0, 0); | |
| 324 | + zSql = blob_sql_text(&pStmt->sql); | |
| 325 | + db.nPrepare++; | |
| 326 | + rc = sqlite3_prepare_v3(g.db, zSql, -1, 0, &pStmt->pStmt, 0); | |
| 327 | + if( rc!=0 ){ | |
| 328 | + db_err("%s\n%s", sqlite3_errmsg(g.db), zSql); | |
| 329 | + } | |
| 330 | + pStmt->pNext = pStmt->pPrev = 0; | |
| 331 | + pStmt->nStep = 0; | |
| 332 | + pStmt->rc = rc; | |
| 333 | + return rc; | |
| 334 | +} | |
| 335 | + | |
| 315 | 336 | |
| 316 | 337 | /* |
| 317 | 338 | ** Return the index of a bind parameter |
| 318 | 339 | */ |
| 319 | 340 | static int paramIdx(Stmt *pStmt, const char *zParamName){ |
| 320 | 341 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -310,10 +310,31 @@ | |
| 310 | db.pAllStmt = pStmt; |
| 311 | va_end(ap); |
| 312 | } |
| 313 | return rc; |
| 314 | } |
| 315 | |
| 316 | /* |
| 317 | ** Return the index of a bind parameter |
| 318 | */ |
| 319 | static int paramIdx(Stmt *pStmt, const char *zParamName){ |
| 320 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -310,10 +310,31 @@ | |
| 310 | db.pAllStmt = pStmt; |
| 311 | va_end(ap); |
| 312 | } |
| 313 | return rc; |
| 314 | } |
| 315 | |
| 316 | /* Prepare a statement using text placed inside a Blob |
| 317 | ** using blob_append_sql(). |
| 318 | */ |
| 319 | int db_prepare_blob(Stmt *pStmt, Blob *pSql){ |
| 320 | int rc; |
| 321 | char *zSql; |
| 322 | pStmt->sql = *pSql; |
| 323 | blob_init(pSql, 0, 0); |
| 324 | zSql = blob_sql_text(&pStmt->sql); |
| 325 | db.nPrepare++; |
| 326 | rc = sqlite3_prepare_v3(g.db, zSql, -1, 0, &pStmt->pStmt, 0); |
| 327 | if( rc!=0 ){ |
| 328 | db_err("%s\n%s", sqlite3_errmsg(g.db), zSql); |
| 329 | } |
| 330 | pStmt->pNext = pStmt->pPrev = 0; |
| 331 | pStmt->nStep = 0; |
| 332 | pStmt->rc = rc; |
| 333 | return rc; |
| 334 | } |
| 335 | |
| 336 | |
| 337 | /* |
| 338 | ** Return the index of a bind parameter |
| 339 | */ |
| 340 | static int paramIdx(Stmt *pStmt, const char *zParamName){ |
| 341 |
+50
-8
| --- src/email.c | ||
| +++ src/email.c | ||
| @@ -113,10 +113,11 @@ | ||
| 113 | 113 | login_needed(0); |
| 114 | 114 | return; |
| 115 | 115 | } |
| 116 | 116 | db_begin_transaction(); |
| 117 | 117 | |
| 118 | + style_submenu_element("Subscriber List", "%R/subscribers"); | |
| 118 | 119 | style_header("Email Notification Setup"); |
| 119 | 120 | @ <form action="%R/setup_email" method="post"><div> |
| 120 | 121 | @ <input type="submit" name="submit" value="Apply Changes" /><hr> |
| 121 | 122 | login_insert_csrf_secret(); |
| 122 | 123 | multiple_choice_attribute("Email Send Method","email-send-method", |
| @@ -661,24 +662,24 @@ | ||
| 661 | 662 | } |
| 662 | 663 | @ </tr> |
| 663 | 664 | } |
| 664 | 665 | @ <tr> |
| 665 | 666 | @ <td class="form_label">Options:</td> |
| 666 | - @ <td><label><input type="checkbox" name="sa" %s(PCK("sa"))>\ | |
| 667 | + @ <td><label><input type="checkbox" name="sa" %s(PCK("sa"))> \ | |
| 667 | 668 | @ Announcements</label><br> |
| 668 | - @ <label><input type="checkbox" name="sc" %s(PCK("sc"))>\ | |
| 669 | + @ <label><input type="checkbox" name="sc" %s(PCK("sc"))> \ | |
| 669 | 670 | @ Check-ins</label><br> |
| 670 | - @ <label><input type="checkbox" name="st" %s(PCK("st"))>\ | |
| 671 | + @ <label><input type="checkbox" name="st" %s(PCK("st"))> \ | |
| 671 | 672 | @ Ticket changes</label><br> |
| 672 | - @ <label><input type="checkbox" name="sw" %s(PCK("sw"))>\ | |
| 673 | + @ <label><input type="checkbox" name="sw" %s(PCK("sw"))> \ | |
| 673 | 674 | @ Wiki</label><br> |
| 674 | - @ <label><input type="checkbox" name="di" %s(PCK("di"))>\ | |
| 675 | + @ <label><input type="checkbox" name="di" %s(PCK("di"))> \ | |
| 675 | 676 | @ Daily digest only</label><br> |
| 676 | 677 | if( g.perm.Admin ){ |
| 677 | - @ <label><input type="checkbox" name="vi" %s(PCK("vi"))>\ | |
| 678 | + @ <label><input type="checkbox" name="vi" %s(PCK("vi"))> \ | |
| 678 | 679 | @ Verified</label><br> |
| 679 | - @ <label><input type="checkbox" name="dnc" %s(PCK("dnc"))>\ | |
| 680 | + @ <label><input type="checkbox" name="dnc" %s(PCK("dnc"))> \ | |
| 680 | 681 | @ Do not call</label><br> |
| 681 | 682 | } |
| 682 | 683 | @ </td> |
| 683 | 684 | @ </tr> |
| 684 | 685 | @ <tr> |
| @@ -860,11 +861,11 @@ | ||
| 860 | 861 | @ Wiki</label><br> |
| 861 | 862 | @ <label><input type="checkbox" name="sdigest" %s(sdigest?"checked":"")>\ |
| 862 | 863 | @ Daily digest only</label><br> |
| 863 | 864 | if( g.perm.Admin ){ |
| 864 | 865 | @ <label><input type="checkbox" name="sdonotcall" \ |
| 865 | - @ %s(sdonotcall?"checked":"")>Do not call</label><br> | |
| 866 | + @ %s(sdonotcall?"checked":"")> Do not call</label><br> | |
| 866 | 867 | @ <label><input type="checkbox" name="sverified" \ |
| 867 | 868 | @ %s(sverified?"checked":"")>\ |
| 868 | 869 | @ Verified</label><br> |
| 869 | 870 | } |
| 870 | 871 | @ <label><input type="checkbox" name="dodelete"> |
| @@ -880,8 +881,49 @@ | ||
| 880 | 881 | @ <input type="submit" name="delete" value="Unsubscribe"> |
| 881 | 882 | @ </tr> |
| 882 | 883 | @ </table> |
| 883 | 884 | @ </form> |
| 884 | 885 | fossil_free(zErr); |
| 886 | + db_finalize(&q); | |
| 887 | + style_footer(); | |
| 888 | +} | |
| 889 | + | |
| 890 | +/* | |
| 891 | +** WEBPAGE: subscribers | |
| 892 | +** | |
| 893 | +** This page, accessible to administrators only, | |
| 894 | +** shows a list of email notification email addresses with | |
| 895 | +** links to facilities for editing. | |
| 896 | +*/ | |
| 897 | +void subscriber_list_page(void){ | |
| 898 | + Blob sql; | |
| 899 | + Stmt q; | |
| 900 | + login_check_credentials(); | |
| 901 | + if( !g.perm.Admin ){ | |
| 902 | + fossil_redirect_home(); | |
| 903 | + return; | |
| 904 | + } | |
| 905 | + style_header("Subscriber List"); | |
| 906 | + blob_init(&sql, 0, 0); | |
| 907 | + blob_append_sql(&sql, | |
| 908 | + "SELECT hex(subscriberCode)," | |
| 909 | + " semail," | |
| 910 | + " ssub," | |
| 911 | + " suname," | |
| 912 | + " sverified" | |
| 913 | + " FROM subscriber" | |
| 914 | + ); | |
| 915 | + db_prepare_blob(&q, &sql); | |
| 916 | + @ <table> | |
| 917 | + while( db_step(&q)==SQLITE_ROW ){ | |
| 918 | + @ <tr> | |
| 919 | + @ <td><a href='%R/alerts/%s(db_column_text(&q,0))'>\ | |
| 920 | + @ %h(db_column_text(&q,1))</a></td> | |
| 921 | + @ <td>%h(db_column_text(&q,3))</td> | |
| 922 | + @ <td>%h(db_column_text(&q,4))</td> | |
| 923 | + @ <td>%s(db_column_int(&q,5)?"":"unverified")</td> | |
| 924 | + @ </tr> | |
| 925 | + } | |
| 926 | + @ </table> | |
| 885 | 927 | db_finalize(&q); |
| 886 | 928 | style_footer(); |
| 887 | 929 | } |
| 888 | 930 |
| --- src/email.c | |
| +++ src/email.c | |
| @@ -113,10 +113,11 @@ | |
| 113 | login_needed(0); |
| 114 | return; |
| 115 | } |
| 116 | db_begin_transaction(); |
| 117 | |
| 118 | style_header("Email Notification Setup"); |
| 119 | @ <form action="%R/setup_email" method="post"><div> |
| 120 | @ <input type="submit" name="submit" value="Apply Changes" /><hr> |
| 121 | login_insert_csrf_secret(); |
| 122 | multiple_choice_attribute("Email Send Method","email-send-method", |
| @@ -661,24 +662,24 @@ | |
| 661 | } |
| 662 | @ </tr> |
| 663 | } |
| 664 | @ <tr> |
| 665 | @ <td class="form_label">Options:</td> |
| 666 | @ <td><label><input type="checkbox" name="sa" %s(PCK("sa"))>\ |
| 667 | @ Announcements</label><br> |
| 668 | @ <label><input type="checkbox" name="sc" %s(PCK("sc"))>\ |
| 669 | @ Check-ins</label><br> |
| 670 | @ <label><input type="checkbox" name="st" %s(PCK("st"))>\ |
| 671 | @ Ticket changes</label><br> |
| 672 | @ <label><input type="checkbox" name="sw" %s(PCK("sw"))>\ |
| 673 | @ Wiki</label><br> |
| 674 | @ <label><input type="checkbox" name="di" %s(PCK("di"))>\ |
| 675 | @ Daily digest only</label><br> |
| 676 | if( g.perm.Admin ){ |
| 677 | @ <label><input type="checkbox" name="vi" %s(PCK("vi"))>\ |
| 678 | @ Verified</label><br> |
| 679 | @ <label><input type="checkbox" name="dnc" %s(PCK("dnc"))>\ |
| 680 | @ Do not call</label><br> |
| 681 | } |
| 682 | @ </td> |
| 683 | @ </tr> |
| 684 | @ <tr> |
| @@ -860,11 +861,11 @@ | |
| 860 | @ Wiki</label><br> |
| 861 | @ <label><input type="checkbox" name="sdigest" %s(sdigest?"checked":"")>\ |
| 862 | @ Daily digest only</label><br> |
| 863 | if( g.perm.Admin ){ |
| 864 | @ <label><input type="checkbox" name="sdonotcall" \ |
| 865 | @ %s(sdonotcall?"checked":"")>Do not call</label><br> |
| 866 | @ <label><input type="checkbox" name="sverified" \ |
| 867 | @ %s(sverified?"checked":"")>\ |
| 868 | @ Verified</label><br> |
| 869 | } |
| 870 | @ <label><input type="checkbox" name="dodelete"> |
| @@ -880,8 +881,49 @@ | |
| 880 | @ <input type="submit" name="delete" value="Unsubscribe"> |
| 881 | @ </tr> |
| 882 | @ </table> |
| 883 | @ </form> |
| 884 | fossil_free(zErr); |
| 885 | db_finalize(&q); |
| 886 | style_footer(); |
| 887 | } |
| 888 |
| --- src/email.c | |
| +++ src/email.c | |
| @@ -113,10 +113,11 @@ | |
| 113 | login_needed(0); |
| 114 | return; |
| 115 | } |
| 116 | db_begin_transaction(); |
| 117 | |
| 118 | style_submenu_element("Subscriber List", "%R/subscribers"); |
| 119 | style_header("Email Notification Setup"); |
| 120 | @ <form action="%R/setup_email" method="post"><div> |
| 121 | @ <input type="submit" name="submit" value="Apply Changes" /><hr> |
| 122 | login_insert_csrf_secret(); |
| 123 | multiple_choice_attribute("Email Send Method","email-send-method", |
| @@ -661,24 +662,24 @@ | |
| 662 | } |
| 663 | @ </tr> |
| 664 | } |
| 665 | @ <tr> |
| 666 | @ <td class="form_label">Options:</td> |
| 667 | @ <td><label><input type="checkbox" name="sa" %s(PCK("sa"))> \ |
| 668 | @ Announcements</label><br> |
| 669 | @ <label><input type="checkbox" name="sc" %s(PCK("sc"))> \ |
| 670 | @ Check-ins</label><br> |
| 671 | @ <label><input type="checkbox" name="st" %s(PCK("st"))> \ |
| 672 | @ Ticket changes</label><br> |
| 673 | @ <label><input type="checkbox" name="sw" %s(PCK("sw"))> \ |
| 674 | @ Wiki</label><br> |
| 675 | @ <label><input type="checkbox" name="di" %s(PCK("di"))> \ |
| 676 | @ Daily digest only</label><br> |
| 677 | if( g.perm.Admin ){ |
| 678 | @ <label><input type="checkbox" name="vi" %s(PCK("vi"))> \ |
| 679 | @ Verified</label><br> |
| 680 | @ <label><input type="checkbox" name="dnc" %s(PCK("dnc"))> \ |
| 681 | @ Do not call</label><br> |
| 682 | } |
| 683 | @ </td> |
| 684 | @ </tr> |
| 685 | @ <tr> |
| @@ -860,11 +861,11 @@ | |
| 861 | @ Wiki</label><br> |
| 862 | @ <label><input type="checkbox" name="sdigest" %s(sdigest?"checked":"")>\ |
| 863 | @ Daily digest only</label><br> |
| 864 | if( g.perm.Admin ){ |
| 865 | @ <label><input type="checkbox" name="sdonotcall" \ |
| 866 | @ %s(sdonotcall?"checked":"")> Do not call</label><br> |
| 867 | @ <label><input type="checkbox" name="sverified" \ |
| 868 | @ %s(sverified?"checked":"")>\ |
| 869 | @ Verified</label><br> |
| 870 | } |
| 871 | @ <label><input type="checkbox" name="dodelete"> |
| @@ -880,8 +881,49 @@ | |
| 881 | @ <input type="submit" name="delete" value="Unsubscribe"> |
| 882 | @ </tr> |
| 883 | @ </table> |
| 884 | @ </form> |
| 885 | fossil_free(zErr); |
| 886 | db_finalize(&q); |
| 887 | style_footer(); |
| 888 | } |
| 889 | |
| 890 | /* |
| 891 | ** WEBPAGE: subscribers |
| 892 | ** |
| 893 | ** This page, accessible to administrators only, |
| 894 | ** shows a list of email notification email addresses with |
| 895 | ** links to facilities for editing. |
| 896 | */ |
| 897 | void subscriber_list_page(void){ |
| 898 | Blob sql; |
| 899 | Stmt q; |
| 900 | login_check_credentials(); |
| 901 | if( !g.perm.Admin ){ |
| 902 | fossil_redirect_home(); |
| 903 | return; |
| 904 | } |
| 905 | style_header("Subscriber List"); |
| 906 | blob_init(&sql, 0, 0); |
| 907 | blob_append_sql(&sql, |
| 908 | "SELECT hex(subscriberCode)," |
| 909 | " semail," |
| 910 | " ssub," |
| 911 | " suname," |
| 912 | " sverified" |
| 913 | " FROM subscriber" |
| 914 | ); |
| 915 | db_prepare_blob(&q, &sql); |
| 916 | @ <table> |
| 917 | while( db_step(&q)==SQLITE_ROW ){ |
| 918 | @ <tr> |
| 919 | @ <td><a href='%R/alerts/%s(db_column_text(&q,0))'>\ |
| 920 | @ %h(db_column_text(&q,1))</a></td> |
| 921 | @ <td>%h(db_column_text(&q,3))</td> |
| 922 | @ <td>%h(db_column_text(&q,4))</td> |
| 923 | @ <td>%s(db_column_int(&q,5)?"":"unverified")</td> |
| 924 | @ </tr> |
| 925 | } |
| 926 | @ </table> |
| 927 | db_finalize(&q); |
| 928 | style_footer(); |
| 929 | } |
| 930 |