Fossil SCM
Add the ability to purge old pending subscriptions from the /subscribers page.
Commit
8c40c38f5e525663dd2ede5e25dbf1c199ea51ceb05e546c0a5c879c95151e86
Parent
ce4bece94608e13…
2 files changed
+30
-1
+1
-1
+30
-1
| --- src/alerts.c | ||
| +++ src/alerts.c | ||
| @@ -1955,28 +1955,57 @@ | ||
| 1955 | 1955 | |
| 1956 | 1956 | /* |
| 1957 | 1957 | ** WEBPAGE: subscribers |
| 1958 | 1958 | ** |
| 1959 | 1959 | ** This page, accessible to administrators only, |
| 1960 | -** shows a list of email notification email addresses. | |
| 1960 | +** shows a list of subscriber email addresses. | |
| 1961 | 1961 | ** Clicking on an email takes one to the /alerts page |
| 1962 | 1962 | ** for that email where the delivery settings can be |
| 1963 | 1963 | ** modified. |
| 1964 | 1964 | */ |
| 1965 | 1965 | void subscriber_list_page(void){ |
| 1966 | 1966 | Blob sql; |
| 1967 | 1967 | Stmt q; |
| 1968 | 1968 | sqlite3_int64 iNow; |
| 1969 | + int nTotal; | |
| 1970 | + int nPending; | |
| 1971 | + int nDel = 0; | |
| 1969 | 1972 | if( alert_webpages_disabled() ) return; |
| 1970 | 1973 | login_check_credentials(); |
| 1971 | 1974 | if( !g.perm.Admin ){ |
| 1972 | 1975 | login_needed(0); |
| 1973 | 1976 | return; |
| 1974 | 1977 | } |
| 1975 | 1978 | alert_submenu_common(); |
| 1976 | 1979 | style_submenu_element("Users","setup_ulist"); |
| 1977 | 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 | + } | |
| 1978 | 2007 | blob_init(&sql, 0, 0); |
| 1979 | 2008 | blob_append_sql(&sql, |
| 1980 | 2009 | "SELECT hex(subscriberCode)," /* 0 */ |
| 1981 | 2010 | " semail," /* 1 */ |
| 1982 | 2011 | " ssub," /* 2 */ |
| 1983 | 2012 |
| --- 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 @@ | ||
| 112 | 112 | @ <tr><th>Subscribers:</th><td> |
| 113 | 113 | } |
| 114 | 114 | nSub = db_int(0, "SELECT count(*) FROM subscriber"); |
| 115 | 115 | nASub = db_int(0, "SELECT count(*) FROM subscriber WHERE sverified" |
| 116 | 116 | " 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 | |
| 118 | 118 | @ </td></tr> |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /* |
| 122 | 122 | ** WEBPAGE: stat |
| 123 | 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-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 |