Fossil SCM

Add the /subscribers page. Fix minor issues. All pages still need improvement.

drh 2018-06-21 21:02 UTC email-alerts
Commit e015c10306d40a306c55d5f956df2cac0ad376b7ceb9ed8b37a9282f55869adf
2 files changed +21 +50 -8
+21
--- src/db.c
+++ src/db.c
@@ -310,10 +310,31 @@
310310
db.pAllStmt = pStmt;
311311
va_end(ap);
312312
}
313313
return rc;
314314
}
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
+
315336
316337
/*
317338
** Return the index of a bind parameter
318339
*/
319340
static int paramIdx(Stmt *pStmt, const char *zParamName){
320341
--- 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 @@
113113
login_needed(0);
114114
return;
115115
}
116116
db_begin_transaction();
117117
118
+ style_submenu_element("Subscriber List", "%R/subscribers");
118119
style_header("Email Notification Setup");
119120
@ <form action="%R/setup_email" method="post"><div>
120121
@ <input type="submit" name="submit" value="Apply Changes" /><hr>
121122
login_insert_csrf_secret();
122123
multiple_choice_attribute("Email Send Method","email-send-method",
@@ -661,24 +662,24 @@
661662
}
662663
@ </tr>
663664
}
664665
@ <tr>
665666
@ <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"))> \
667668
@ Announcements</label><br>
668
- @ <label><input type="checkbox" name="sc" %s(PCK("sc"))>\
669
+ @ <label><input type="checkbox" name="sc" %s(PCK("sc"))> \
669670
@ Check-ins</label><br>
670
- @ <label><input type="checkbox" name="st" %s(PCK("st"))>\
671
+ @ <label><input type="checkbox" name="st" %s(PCK("st"))> \
671672
@ Ticket changes</label><br>
672
- @ <label><input type="checkbox" name="sw" %s(PCK("sw"))>\
673
+ @ <label><input type="checkbox" name="sw" %s(PCK("sw"))> \
673674
@ Wiki</label><br>
674
- @ <label><input type="checkbox" name="di" %s(PCK("di"))>\
675
+ @ <label><input type="checkbox" name="di" %s(PCK("di"))> \
675676
@ Daily digest only</label><br>
676677
if( g.perm.Admin ){
677
- @ <label><input type="checkbox" name="vi" %s(PCK("vi"))>\
678
+ @ <label><input type="checkbox" name="vi" %s(PCK("vi"))> \
678679
@ Verified</label><br>
679
- @ <label><input type="checkbox" name="dnc" %s(PCK("dnc"))>\
680
+ @ <label><input type="checkbox" name="dnc" %s(PCK("dnc"))> \
680681
@ Do not call</label><br>
681682
}
682683
@ </td>
683684
@ </tr>
684685
@ <tr>
@@ -860,11 +861,11 @@
860861
@ Wiki</label><br>
861862
@ <label><input type="checkbox" name="sdigest" %s(sdigest?"checked":"")>\
862863
@ Daily digest only</label><br>
863864
if( g.perm.Admin ){
864865
@ <label><input type="checkbox" name="sdonotcall" \
865
- @ %s(sdonotcall?"checked":"")>Do not call</label><br>
866
+ @ %s(sdonotcall?"checked":"")> Do not call</label><br>
866867
@ <label><input type="checkbox" name="sverified" \
867868
@ %s(sverified?"checked":"")>\
868869
@ Verified</label><br>
869870
}
870871
@ <label><input type="checkbox" name="dodelete">
@@ -880,8 +881,49 @@
880881
@ <input type="submit" name="delete" value="Unsubscribe">
881882
@ </tr>
882883
@ </table>
883884
@ </form>
884885
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>
885927
db_finalize(&q);
886928
style_footer();
887929
}
888930
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button