Fossil SCM

Add the ability to purge old pending subscriptions from the /subscribers page.

drh 2020-03-27 22:23 trunk
Commit 8c40c38f5e525663dd2ede5e25dbf1c199ea51ceb05e546c0a5c879c95151e86
2 files changed +30 -1 +1 -1
+30 -1
--- src/alerts.c
+++ src/alerts.c
@@ -1955,28 +1955,57 @@
19551955
19561956
/*
19571957
** WEBPAGE: subscribers
19581958
**
19591959
** This page, accessible to administrators only,
1960
-** shows a list of email notification email addresses.
1960
+** shows a list of subscriber email addresses.
19611961
** Clicking on an email takes one to the /alerts page
19621962
** for that email where the delivery settings can be
19631963
** modified.
19641964
*/
19651965
void subscriber_list_page(void){
19661966
Blob sql;
19671967
Stmt q;
19681968
sqlite3_int64 iNow;
1969
+ int nTotal;
1970
+ int nPending;
1971
+ int nDel = 0;
19691972
if( alert_webpages_disabled() ) return;
19701973
login_check_credentials();
19711974
if( !g.perm.Admin ){
19721975
login_needed(0);
19731976
return;
19741977
}
19751978
alert_submenu_common();
19761979
style_submenu_element("Users","setup_ulist");
19771980
style_header("Subscriber List");
1981
+ nTotal = db_int(0, "SELECT count(*) FROM subscriber");
1982
+ nPending = db_int(0, "SELECT count(*) FROM subscriber WHERE NOT sverified");
1983
+ if( nPending>0 && P("purge") && cgi_csrf_safe(0) ){
1984
+ int nNewPending;
1985
+ db_multi_exec(
1986
+ "DELETE FROM subscriber"
1987
+ " WHERE NOT sverified AND mtime<0+strftime('%%s','now','-1 day')"
1988
+ );
1989
+ nNewPending = db_int(0, "SELECT count(*) FROM subscriber"
1990
+ " WHERE NOT sverified");
1991
+ nDel = nPending - nNewPending;
1992
+ nPending = nNewPending;
1993
+ }
1994
+ if( nPending>0 ){
1995
+ @ <h1>%,d(nTotal) Subscribers, %,d(nPending) Pending</h1>
1996
+ if( nDel==0 && 0<db_int(0,"SELECT count(*) FROM subscriber"
1997
+ " WHERE NOT sverified AND mtime<0+strftime('%%s','now','-1 day')")
1998
+ ){
1999
+ style_submenu_element("Purge Pending","subscribers?purge");
2000
+ }
2001
+ }else{
2002
+ @ <h1>%,d(nTotal) Subscribers</h1>
2003
+ }
2004
+ if( nDel>0 ){
2005
+ @ <p>*** %d(nDel) pending subscriptions deleted ***</p>
2006
+ }
19782007
blob_init(&sql, 0, 0);
19792008
blob_append_sql(&sql,
19802009
"SELECT hex(subscriberCode)," /* 0 */
19812010
" semail," /* 1 */
19822011
" ssub," /* 2 */
19832012
--- src/alerts.c
+++ src/alerts.c
@@ -1955,28 +1955,57 @@
1955
1956 /*
1957 ** WEBPAGE: subscribers
1958 **
1959 ** This page, accessible to administrators only,
1960 ** shows a list of email notification email addresses.
1961 ** Clicking on an email takes one to the /alerts page
1962 ** for that email where the delivery settings can be
1963 ** modified.
1964 */
1965 void subscriber_list_page(void){
1966 Blob sql;
1967 Stmt q;
1968 sqlite3_int64 iNow;
 
 
 
1969 if( alert_webpages_disabled() ) return;
1970 login_check_credentials();
1971 if( !g.perm.Admin ){
1972 login_needed(0);
1973 return;
1974 }
1975 alert_submenu_common();
1976 style_submenu_element("Users","setup_ulist");
1977 style_header("Subscriber List");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1978 blob_init(&sql, 0, 0);
1979 blob_append_sql(&sql,
1980 "SELECT hex(subscriberCode)," /* 0 */
1981 " semail," /* 1 */
1982 " ssub," /* 2 */
1983
--- src/alerts.c
+++ src/alerts.c
@@ -1955,28 +1955,57 @@
1955
1956 /*
1957 ** WEBPAGE: subscribers
1958 **
1959 ** This page, accessible to administrators only,
1960 ** shows a list of subscriber email addresses.
1961 ** Clicking on an email takes one to the /alerts page
1962 ** for that email where the delivery settings can be
1963 ** modified.
1964 */
1965 void subscriber_list_page(void){
1966 Blob sql;
1967 Stmt q;
1968 sqlite3_int64 iNow;
1969 int nTotal;
1970 int nPending;
1971 int nDel = 0;
1972 if( alert_webpages_disabled() ) return;
1973 login_check_credentials();
1974 if( !g.perm.Admin ){
1975 login_needed(0);
1976 return;
1977 }
1978 alert_submenu_common();
1979 style_submenu_element("Users","setup_ulist");
1980 style_header("Subscriber List");
1981 nTotal = db_int(0, "SELECT count(*) FROM subscriber");
1982 nPending = db_int(0, "SELECT count(*) FROM subscriber WHERE NOT sverified");
1983 if( nPending>0 && P("purge") && cgi_csrf_safe(0) ){
1984 int nNewPending;
1985 db_multi_exec(
1986 "DELETE FROM subscriber"
1987 " WHERE NOT sverified AND mtime<0+strftime('%%s','now','-1 day')"
1988 );
1989 nNewPending = db_int(0, "SELECT count(*) FROM subscriber"
1990 " WHERE NOT sverified");
1991 nDel = nPending - nNewPending;
1992 nPending = nNewPending;
1993 }
1994 if( nPending>0 ){
1995 @ <h1>%,d(nTotal) Subscribers, %,d(nPending) Pending</h1>
1996 if( nDel==0 && 0<db_int(0,"SELECT count(*) FROM subscriber"
1997 " WHERE NOT sverified AND mtime<0+strftime('%%s','now','-1 day')")
1998 ){
1999 style_submenu_element("Purge Pending","subscribers?purge");
2000 }
2001 }else{
2002 @ <h1>%,d(nTotal) Subscribers</h1>
2003 }
2004 if( nDel>0 ){
2005 @ <p>*** %d(nDel) pending subscriptions deleted ***</p>
2006 }
2007 blob_init(&sql, 0, 0);
2008 blob_append_sql(&sql,
2009 "SELECT hex(subscriberCode)," /* 0 */
2010 " semail," /* 1 */
2011 " ssub," /* 2 */
2012
+1 -1
--- src/stat.c
+++ src/stat.c
@@ -112,11 +112,11 @@
112112
@ <tr><th>Subscribers:</th><td>
113113
}
114114
nSub = db_int(0, "SELECT count(*) FROM subscriber");
115115
nASub = db_int(0, "SELECT count(*) FROM subscriber WHERE sverified"
116116
" AND NOT sdonotcall AND length(ssub)>1");
117
- @ %,d(nASub) active, %,d(nSub-nASub) pending, %,d(nSub) total
117
+ @ %,d(nASub) active, %,d(nSub) total
118118
@ </td></tr>
119119
}
120120
121121
/*
122122
** WEBPAGE: stat
123123
--- src/stat.c
+++ src/stat.c
@@ -112,11 +112,11 @@
112 @ <tr><th>Subscribers:</th><td>
113 }
114 nSub = db_int(0, "SELECT count(*) FROM subscriber");
115 nASub = db_int(0, "SELECT count(*) FROM subscriber WHERE sverified"
116 " AND NOT sdonotcall AND length(ssub)>1");
117 @ %,d(nASub) active, %,d(nSub-nASub) pending, %,d(nSub) total
118 @ </td></tr>
119 }
120
121 /*
122 ** WEBPAGE: stat
123
--- src/stat.c
+++ src/stat.c
@@ -112,11 +112,11 @@
112 @ <tr><th>Subscribers:</th><td>
113 }
114 nSub = db_int(0, "SELECT count(*) FROM subscriber");
115 nASub = db_int(0, "SELECT count(*) FROM subscriber WHERE sverified"
116 " AND NOT sdonotcall AND length(ssub)>1");
117 @ %,d(nASub) active, %,d(nSub) total
118 @ </td></tr>
119 }
120
121 /*
122 ** WEBPAGE: stat
123

Keyboard Shortcuts

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