Fossil SCM
When deleting a subscription, also provide the opportunity to delete the corresponding user. When deleting a user, always also delete subscriptions associated with that user.
Commit
b6b5a7dc6246b2c7b416264a9c147a558d457d91c00de52fdd937c0c0426da3f
Parent
590a8fcac60f6cd…
2 files changed
+20
-5
+5
+20
-5
| --- src/alerts.c | ||
| +++ src/alerts.c | ||
| @@ -1561,24 +1561,39 @@ | ||
| 1561 | 1561 | ** Either shutdown or completely delete a subscription entry given |
| 1562 | 1562 | ** by the hex value zName. Then paint a webpage that explains that |
| 1563 | 1563 | ** the entry has been removed. |
| 1564 | 1564 | */ |
| 1565 | 1565 | static void alert_unsubscribe(int sid){ |
| 1566 | - char *zEmail; | |
| 1567 | - zEmail = db_text(0, "SELECT semail FROM subscriber" | |
| 1568 | - " WHERE subscriberId=%d", sid); | |
| 1566 | + const char *zEmail = 0; | |
| 1567 | + const char *zLogin = 0; | |
| 1568 | + int uid = 0; | |
| 1569 | + Stmt q; | |
| 1570 | + db_prepare(&q, "SELECT semail, suname FROM subscriber" | |
| 1571 | + " WHERE subscriberId=%d", sid); | |
| 1572 | + if( db_step(&q)==SQLITE_ROW ){ | |
| 1573 | + zEmail = db_column_text(&q, 0); | |
| 1574 | + zLogin = db_column_text(&q, 1); | |
| 1575 | + uid = db_int(0, "SELECT uid FROM user WHERE login=%Q", zLogin); | |
| 1576 | + } | |
| 1569 | 1577 | if( zEmail==0 ){ |
| 1570 | 1578 | style_header("Unsubscribe Fail"); |
| 1571 | 1579 | @ <p>Unable to locate a subscriber with the requested key</p> |
| 1572 | 1580 | }else{ |
| 1581 | + | |
| 1573 | 1582 | db_multi_exec( |
| 1574 | 1583 | "DELETE FROM subscriber WHERE subscriberId=%d", sid |
| 1575 | 1584 | ); |
| 1576 | 1585 | style_header("Unsubscribed"); |
| 1577 | - @ <p>The "%h(zEmail)" email address has been delisted. | |
| 1578 | - @ All traces of that email address have been removed</p> | |
| 1586 | + @ <p>The "%h(zEmail)" email address has been unsubscribed and the | |
| 1587 | + @ corresponding row in the subscriber table has been deleted.<p> | |
| 1588 | + if( uid && g.perm.Admin ){ | |
| 1589 | + @ <p>You may also want to | |
| 1590 | + @ <a href="%R/setup_uedit?id=%d(uid)">edit or delete | |
| 1591 | + @ the corresponding user "%h(zLogin)"</a></p> | |
| 1592 | + } | |
| 1579 | 1593 | } |
| 1594 | + db_finalize(&q); | |
| 1580 | 1595 | style_footer(); |
| 1581 | 1596 | return; |
| 1582 | 1597 | } |
| 1583 | 1598 | |
| 1584 | 1599 | /* |
| 1585 | 1600 |
| --- src/alerts.c | |
| +++ src/alerts.c | |
| @@ -1561,24 +1561,39 @@ | |
| 1561 | ** Either shutdown or completely delete a subscription entry given |
| 1562 | ** by the hex value zName. Then paint a webpage that explains that |
| 1563 | ** the entry has been removed. |
| 1564 | */ |
| 1565 | static void alert_unsubscribe(int sid){ |
| 1566 | char *zEmail; |
| 1567 | zEmail = db_text(0, "SELECT semail FROM subscriber" |
| 1568 | " WHERE subscriberId=%d", sid); |
| 1569 | if( zEmail==0 ){ |
| 1570 | style_header("Unsubscribe Fail"); |
| 1571 | @ <p>Unable to locate a subscriber with the requested key</p> |
| 1572 | }else{ |
| 1573 | db_multi_exec( |
| 1574 | "DELETE FROM subscriber WHERE subscriberId=%d", sid |
| 1575 | ); |
| 1576 | style_header("Unsubscribed"); |
| 1577 | @ <p>The "%h(zEmail)" email address has been delisted. |
| 1578 | @ All traces of that email address have been removed</p> |
| 1579 | } |
| 1580 | style_footer(); |
| 1581 | return; |
| 1582 | } |
| 1583 | |
| 1584 | /* |
| 1585 |
| --- src/alerts.c | |
| +++ src/alerts.c | |
| @@ -1561,24 +1561,39 @@ | |
| 1561 | ** Either shutdown or completely delete a subscription entry given |
| 1562 | ** by the hex value zName. Then paint a webpage that explains that |
| 1563 | ** the entry has been removed. |
| 1564 | */ |
| 1565 | static void alert_unsubscribe(int sid){ |
| 1566 | const char *zEmail = 0; |
| 1567 | const char *zLogin = 0; |
| 1568 | int uid = 0; |
| 1569 | Stmt q; |
| 1570 | db_prepare(&q, "SELECT semail, suname FROM subscriber" |
| 1571 | " WHERE subscriberId=%d", sid); |
| 1572 | if( db_step(&q)==SQLITE_ROW ){ |
| 1573 | zEmail = db_column_text(&q, 0); |
| 1574 | zLogin = db_column_text(&q, 1); |
| 1575 | uid = db_int(0, "SELECT uid FROM user WHERE login=%Q", zLogin); |
| 1576 | } |
| 1577 | if( zEmail==0 ){ |
| 1578 | style_header("Unsubscribe Fail"); |
| 1579 | @ <p>Unable to locate a subscriber with the requested key</p> |
| 1580 | }else{ |
| 1581 | |
| 1582 | db_multi_exec( |
| 1583 | "DELETE FROM subscriber WHERE subscriberId=%d", sid |
| 1584 | ); |
| 1585 | style_header("Unsubscribed"); |
| 1586 | @ <p>The "%h(zEmail)" email address has been unsubscribed and the |
| 1587 | @ corresponding row in the subscriber table has been deleted.<p> |
| 1588 | if( uid && g.perm.Admin ){ |
| 1589 | @ <p>You may also want to |
| 1590 | @ <a href="%R/setup_uedit?id=%d(uid)">edit or delete |
| 1591 | @ the corresponding user "%h(zLogin)"</a></p> |
| 1592 | } |
| 1593 | } |
| 1594 | db_finalize(&q); |
| 1595 | style_footer(); |
| 1596 | return; |
| 1597 | } |
| 1598 | |
| 1599 | /* |
| 1600 |
+5
| --- src/setupuser.c | ||
| +++ src/setupuser.c | ||
| @@ -316,10 +316,15 @@ | ||
| 316 | 316 | if( P("delete") && cgi_csrf_safe(1) ){ |
| 317 | 317 | int n; |
| 318 | 318 | if( P("verifydelete") ){ |
| 319 | 319 | /* Verified delete user request */ |
| 320 | 320 | db_unprotect(PROTECT_USER); |
| 321 | + if( db_table_exists("repository","subscriber") ){ | |
| 322 | + /* Also delete any subscriptions associated with this user */ | |
| 323 | + db_multi_exec("DELETE FROM subscriber WHERE suname=" | |
| 324 | + "(SELECT login FROM user WHERE uid=%d)", uid); | |
| 325 | + } | |
| 321 | 326 | db_multi_exec("DELETE FROM user WHERE uid=%d", uid); |
| 322 | 327 | db_protect_pop(); |
| 323 | 328 | moderation_disapprove_for_missing_users(); |
| 324 | 329 | admin_log("Deleted user [%s] (uid %d).", |
| 325 | 330 | PD("login","???")/*safe-for-%s*/, uid); |
| 326 | 331 |
| --- src/setupuser.c | |
| +++ src/setupuser.c | |
| @@ -316,10 +316,15 @@ | |
| 316 | if( P("delete") && cgi_csrf_safe(1) ){ |
| 317 | int n; |
| 318 | if( P("verifydelete") ){ |
| 319 | /* Verified delete user request */ |
| 320 | db_unprotect(PROTECT_USER); |
| 321 | db_multi_exec("DELETE FROM user WHERE uid=%d", uid); |
| 322 | db_protect_pop(); |
| 323 | moderation_disapprove_for_missing_users(); |
| 324 | admin_log("Deleted user [%s] (uid %d).", |
| 325 | PD("login","???")/*safe-for-%s*/, uid); |
| 326 |
| --- src/setupuser.c | |
| +++ src/setupuser.c | |
| @@ -316,10 +316,15 @@ | |
| 316 | if( P("delete") && cgi_csrf_safe(1) ){ |
| 317 | int n; |
| 318 | if( P("verifydelete") ){ |
| 319 | /* Verified delete user request */ |
| 320 | db_unprotect(PROTECT_USER); |
| 321 | if( db_table_exists("repository","subscriber") ){ |
| 322 | /* Also delete any subscriptions associated with this user */ |
| 323 | db_multi_exec("DELETE FROM subscriber WHERE suname=" |
| 324 | "(SELECT login FROM user WHERE uid=%d)", uid); |
| 325 | } |
| 326 | db_multi_exec("DELETE FROM user WHERE uid=%d", uid); |
| 327 | db_protect_pop(); |
| 328 | moderation_disapprove_for_missing_users(); |
| 329 | admin_log("Deleted user [%s] (uid %d).", |
| 330 | PD("login","???")/*safe-for-%s*/, uid); |
| 331 |