Fossil SCM
Enhancements to administrator access to the subscriber list.
Commit
b7b877ef4928572c63029857d5c5ea3634cbeab34988e93d08fe0fafa0d34049
Parent
e45cfde7aa17ab6…
1 file changed
+36
-14
+36
-14
| --- src/email.c | ||
| +++ src/email.c | ||
| @@ -1096,10 +1096,12 @@ | ||
| 1096 | 1096 | int sdigest, sdonotcall, sverified; |
| 1097 | 1097 | const char *ssub; |
| 1098 | 1098 | const char *semail; |
| 1099 | 1099 | const char *smip; |
| 1100 | 1100 | const char *suname; |
| 1101 | + char *smtime; | |
| 1102 | + char *sctime; | |
| 1101 | 1103 | int eErr = 0; |
| 1102 | 1104 | char *zErr = 0; |
| 1103 | 1105 | |
| 1104 | 1106 | if( email_webpages_disabled() ) return; |
| 1105 | 1107 | login_check_credentials(); |
| @@ -1171,17 +1173,19 @@ | ||
| 1171 | 1173 | return; |
| 1172 | 1174 | } |
| 1173 | 1175 | } |
| 1174 | 1176 | db_prepare(&q, |
| 1175 | 1177 | "SELECT" |
| 1176 | - " semail," | |
| 1177 | - " sverified," | |
| 1178 | - " sdonotcall," | |
| 1179 | - " sdigest," | |
| 1180 | - " ssub," | |
| 1181 | - " smip," | |
| 1182 | - " suname" | |
| 1178 | + " semail," /* 0 */ | |
| 1179 | + " sverified," /* 1 */ | |
| 1180 | + " sdonotcall," /* 2 */ | |
| 1181 | + " sdigest," /* 3 */ | |
| 1182 | + " ssub," /* 4 */ | |
| 1183 | + " smip," /* 5 */ | |
| 1184 | + " suname," /* 6 */ | |
| 1185 | + " datetime(smtime)," /* 7 */ | |
| 1186 | + " datetime(sctime)" /* 8 */ | |
| 1183 | 1187 | " FROM subscriber WHERE subscriberCode=hextoblob(%Q)", zName); |
| 1184 | 1188 | if( db_step(&q)!=SQLITE_ROW ){ |
| 1185 | 1189 | db_finalize(&q); |
| 1186 | 1190 | cgi_redirect("subscribe"); |
| 1187 | 1191 | return; |
| @@ -1196,10 +1200,12 @@ | ||
| 1196 | 1200 | sc = strchr(ssub,'c')!=0; |
| 1197 | 1201 | st = strchr(ssub,'t')!=0; |
| 1198 | 1202 | sw = strchr(ssub,'w')!=0; |
| 1199 | 1203 | smip = db_column_text(&q, 5); |
| 1200 | 1204 | suname = db_column_text(&q, 6); |
| 1205 | + smtime = db_column_text(&q, 7); | |
| 1206 | + sctime = db_column_text(&q, 8); | |
| 1201 | 1207 | if( !g.perm.Admin && !sverified ){ |
| 1202 | 1208 | db_multi_exec( |
| 1203 | 1209 | "UPDATE subscriber SET sverified=1 WHERE subscriberCode=hextoblob(%Q)", |
| 1204 | 1210 | zName); |
| 1205 | 1211 | @ <h1>Your email alert subscription has been verified!</h1> |
| @@ -1216,10 +1222,18 @@ | ||
| 1216 | 1222 | @ <tr> |
| 1217 | 1223 | @ <td class="form_label">Email Address:</td> |
| 1218 | 1224 | @ <td>%h(semail)</td> |
| 1219 | 1225 | @ </tr> |
| 1220 | 1226 | if( g.perm.Admin ){ |
| 1227 | + @ <tr> | |
| 1228 | + @ <td class='form_label'>Created:</td> | |
| 1229 | + @ <td>%h(sctime)</td> | |
| 1230 | + @ </tr> | |
| 1231 | + @ <tr> | |
| 1232 | + @ <td class='form_label'>Last Modified:</td> | |
| 1233 | + @ <td>%h(smtime)</td> | |
| 1234 | + @ </tr> | |
| 1221 | 1235 | @ <tr> |
| 1222 | 1236 | @ <td class='form_label'>IP Address:</td> |
| 1223 | 1237 | @ <td>%h(smip)</td> |
| 1224 | 1238 | @ </tr> |
| 1225 | 1239 | @ <tr> |
| @@ -1429,10 +1443,11 @@ | ||
| 1429 | 1443 | ** modified. |
| 1430 | 1444 | */ |
| 1431 | 1445 | void subscriber_list_page(void){ |
| 1432 | 1446 | Blob sql; |
| 1433 | 1447 | Stmt q; |
| 1448 | + double rNow; | |
| 1434 | 1449 | if( email_webpages_disabled() ) return; |
| 1435 | 1450 | login_check_credentials(); |
| 1436 | 1451 | if( !g.perm.Admin ){ |
| 1437 | 1452 | fossil_redirect_home(); |
| 1438 | 1453 | return; |
| @@ -1439,35 +1454,43 @@ | ||
| 1439 | 1454 | } |
| 1440 | 1455 | email_submenu_common(); |
| 1441 | 1456 | style_header("Subscriber List"); |
| 1442 | 1457 | blob_init(&sql, 0, 0); |
| 1443 | 1458 | blob_append_sql(&sql, |
| 1444 | - "SELECT hex(subscriberCode)," | |
| 1445 | - " semail," | |
| 1446 | - " ssub," | |
| 1447 | - " suname," | |
| 1448 | - " sverified," | |
| 1449 | - " sdigest" | |
| 1459 | + "SELECT hex(subscriberCode)," /* 0 */ | |
| 1460 | + " semail," /* 1 */ | |
| 1461 | + " ssub," /* 2 */ | |
| 1462 | + " suname," /* 3 */ | |
| 1463 | + " sverified," /* 4 */ | |
| 1464 | + " sdigest," /* 5 */ | |
| 1465 | + " date(sctime)," /* 6 */ | |
| 1466 | + " smtime" /* 7 */ | |
| 1450 | 1467 | " FROM subscriber" |
| 1451 | 1468 | ); |
| 1452 | 1469 | db_prepare_blob(&q, &sql); |
| 1470 | + rNow = db_double(0.0,"SELECT julianday('now')"); | |
| 1453 | 1471 | @ <table border="1"> |
| 1454 | 1472 | @ <tr> |
| 1455 | 1473 | @ <th>Email |
| 1456 | 1474 | @ <th>Events |
| 1457 | 1475 | @ <th>Digest-Only? |
| 1458 | 1476 | @ <th>User |
| 1459 | 1477 | @ <th>Verified? |
| 1478 | + @ <th>Last change | |
| 1479 | + @ <th>Created | |
| 1460 | 1480 | @ </tr> |
| 1461 | 1481 | while( db_step(&q)==SQLITE_ROW ){ |
| 1482 | + double rAge = rNow - db_column_double(&q, 7); | |
| 1462 | 1483 | @ <tr> |
| 1463 | 1484 | @ <td><a href='%R/alerts/%s(db_column_text(&q,0))'>\ |
| 1464 | 1485 | @ %h(db_column_text(&q,1))</a></td> |
| 1465 | 1486 | @ <td>%h(db_column_text(&q,2))</td> |
| 1466 | 1487 | @ <td>%s(db_column_int(&q,5)?"digest":"")</td> |
| 1467 | 1488 | @ <td>%h(db_column_text(&q,3))</td> |
| 1468 | 1489 | @ <td>%s(db_column_int(&q,4)?"yes":"pending")</td> |
| 1490 | + @ <td>%z(human_readable_age(rAge)) ago</td> | |
| 1491 | + @ <td>%h(db_column_text(&q,6))</td> | |
| 1469 | 1492 | @ </tr> |
| 1470 | 1493 | } |
| 1471 | 1494 | @ </table> |
| 1472 | 1495 | db_finalize(&q); |
| 1473 | 1496 | style_footer(); |
| @@ -1779,11 +1802,10 @@ | ||
| 1779 | 1802 | return; |
| 1780 | 1803 | } |
| 1781 | 1804 | db_begin_transaction(); |
| 1782 | 1805 | if( !email_tables_exist() ) goto autoexec_done; |
| 1783 | 1806 | if( !db_get_boolean("email-autoexec",0) ) goto autoexec_done; |
| 1784 | - if( !db_exists("SELECT 1 FROM pending_alert") ) goto autoexec_done; | |
| 1785 | 1807 | email_send_alerts(0); |
| 1786 | 1808 | iJulianDay = db_int(0, "SELECT julianday('now')"); |
| 1787 | 1809 | if( iJulianDay>db_get_int("email-last-digest",0) ){ |
| 1788 | 1810 | if( db_transaction_nesting_depth()!=1 ){ |
| 1789 | 1811 | fossil_warning("Transaction nesting error prior to digest processing"); |
| 1790 | 1812 |
| --- src/email.c | |
| +++ src/email.c | |
| @@ -1096,10 +1096,12 @@ | |
| 1096 | int sdigest, sdonotcall, sverified; |
| 1097 | const char *ssub; |
| 1098 | const char *semail; |
| 1099 | const char *smip; |
| 1100 | const char *suname; |
| 1101 | int eErr = 0; |
| 1102 | char *zErr = 0; |
| 1103 | |
| 1104 | if( email_webpages_disabled() ) return; |
| 1105 | login_check_credentials(); |
| @@ -1171,17 +1173,19 @@ | |
| 1171 | return; |
| 1172 | } |
| 1173 | } |
| 1174 | db_prepare(&q, |
| 1175 | "SELECT" |
| 1176 | " semail," |
| 1177 | " sverified," |
| 1178 | " sdonotcall," |
| 1179 | " sdigest," |
| 1180 | " ssub," |
| 1181 | " smip," |
| 1182 | " suname" |
| 1183 | " FROM subscriber WHERE subscriberCode=hextoblob(%Q)", zName); |
| 1184 | if( db_step(&q)!=SQLITE_ROW ){ |
| 1185 | db_finalize(&q); |
| 1186 | cgi_redirect("subscribe"); |
| 1187 | return; |
| @@ -1196,10 +1200,12 @@ | |
| 1196 | sc = strchr(ssub,'c')!=0; |
| 1197 | st = strchr(ssub,'t')!=0; |
| 1198 | sw = strchr(ssub,'w')!=0; |
| 1199 | smip = db_column_text(&q, 5); |
| 1200 | suname = db_column_text(&q, 6); |
| 1201 | if( !g.perm.Admin && !sverified ){ |
| 1202 | db_multi_exec( |
| 1203 | "UPDATE subscriber SET sverified=1 WHERE subscriberCode=hextoblob(%Q)", |
| 1204 | zName); |
| 1205 | @ <h1>Your email alert subscription has been verified!</h1> |
| @@ -1216,10 +1222,18 @@ | |
| 1216 | @ <tr> |
| 1217 | @ <td class="form_label">Email Address:</td> |
| 1218 | @ <td>%h(semail)</td> |
| 1219 | @ </tr> |
| 1220 | if( g.perm.Admin ){ |
| 1221 | @ <tr> |
| 1222 | @ <td class='form_label'>IP Address:</td> |
| 1223 | @ <td>%h(smip)</td> |
| 1224 | @ </tr> |
| 1225 | @ <tr> |
| @@ -1429,10 +1443,11 @@ | |
| 1429 | ** modified. |
| 1430 | */ |
| 1431 | void subscriber_list_page(void){ |
| 1432 | Blob sql; |
| 1433 | Stmt q; |
| 1434 | if( email_webpages_disabled() ) return; |
| 1435 | login_check_credentials(); |
| 1436 | if( !g.perm.Admin ){ |
| 1437 | fossil_redirect_home(); |
| 1438 | return; |
| @@ -1439,35 +1454,43 @@ | |
| 1439 | } |
| 1440 | email_submenu_common(); |
| 1441 | style_header("Subscriber List"); |
| 1442 | blob_init(&sql, 0, 0); |
| 1443 | blob_append_sql(&sql, |
| 1444 | "SELECT hex(subscriberCode)," |
| 1445 | " semail," |
| 1446 | " ssub," |
| 1447 | " suname," |
| 1448 | " sverified," |
| 1449 | " sdigest" |
| 1450 | " FROM subscriber" |
| 1451 | ); |
| 1452 | db_prepare_blob(&q, &sql); |
| 1453 | @ <table border="1"> |
| 1454 | @ <tr> |
| 1455 | @ <th>Email |
| 1456 | @ <th>Events |
| 1457 | @ <th>Digest-Only? |
| 1458 | @ <th>User |
| 1459 | @ <th>Verified? |
| 1460 | @ </tr> |
| 1461 | while( db_step(&q)==SQLITE_ROW ){ |
| 1462 | @ <tr> |
| 1463 | @ <td><a href='%R/alerts/%s(db_column_text(&q,0))'>\ |
| 1464 | @ %h(db_column_text(&q,1))</a></td> |
| 1465 | @ <td>%h(db_column_text(&q,2))</td> |
| 1466 | @ <td>%s(db_column_int(&q,5)?"digest":"")</td> |
| 1467 | @ <td>%h(db_column_text(&q,3))</td> |
| 1468 | @ <td>%s(db_column_int(&q,4)?"yes":"pending")</td> |
| 1469 | @ </tr> |
| 1470 | } |
| 1471 | @ </table> |
| 1472 | db_finalize(&q); |
| 1473 | style_footer(); |
| @@ -1779,11 +1802,10 @@ | |
| 1779 | return; |
| 1780 | } |
| 1781 | db_begin_transaction(); |
| 1782 | if( !email_tables_exist() ) goto autoexec_done; |
| 1783 | if( !db_get_boolean("email-autoexec",0) ) goto autoexec_done; |
| 1784 | if( !db_exists("SELECT 1 FROM pending_alert") ) goto autoexec_done; |
| 1785 | email_send_alerts(0); |
| 1786 | iJulianDay = db_int(0, "SELECT julianday('now')"); |
| 1787 | if( iJulianDay>db_get_int("email-last-digest",0) ){ |
| 1788 | if( db_transaction_nesting_depth()!=1 ){ |
| 1789 | fossil_warning("Transaction nesting error prior to digest processing"); |
| 1790 |
| --- src/email.c | |
| +++ src/email.c | |
| @@ -1096,10 +1096,12 @@ | |
| 1096 | int sdigest, sdonotcall, sverified; |
| 1097 | const char *ssub; |
| 1098 | const char *semail; |
| 1099 | const char *smip; |
| 1100 | const char *suname; |
| 1101 | char *smtime; |
| 1102 | char *sctime; |
| 1103 | int eErr = 0; |
| 1104 | char *zErr = 0; |
| 1105 | |
| 1106 | if( email_webpages_disabled() ) return; |
| 1107 | login_check_credentials(); |
| @@ -1171,17 +1173,19 @@ | |
| 1173 | return; |
| 1174 | } |
| 1175 | } |
| 1176 | db_prepare(&q, |
| 1177 | "SELECT" |
| 1178 | " semail," /* 0 */ |
| 1179 | " sverified," /* 1 */ |
| 1180 | " sdonotcall," /* 2 */ |
| 1181 | " sdigest," /* 3 */ |
| 1182 | " ssub," /* 4 */ |
| 1183 | " smip," /* 5 */ |
| 1184 | " suname," /* 6 */ |
| 1185 | " datetime(smtime)," /* 7 */ |
| 1186 | " datetime(sctime)" /* 8 */ |
| 1187 | " FROM subscriber WHERE subscriberCode=hextoblob(%Q)", zName); |
| 1188 | if( db_step(&q)!=SQLITE_ROW ){ |
| 1189 | db_finalize(&q); |
| 1190 | cgi_redirect("subscribe"); |
| 1191 | return; |
| @@ -1196,10 +1200,12 @@ | |
| 1200 | sc = strchr(ssub,'c')!=0; |
| 1201 | st = strchr(ssub,'t')!=0; |
| 1202 | sw = strchr(ssub,'w')!=0; |
| 1203 | smip = db_column_text(&q, 5); |
| 1204 | suname = db_column_text(&q, 6); |
| 1205 | smtime = db_column_text(&q, 7); |
| 1206 | sctime = db_column_text(&q, 8); |
| 1207 | if( !g.perm.Admin && !sverified ){ |
| 1208 | db_multi_exec( |
| 1209 | "UPDATE subscriber SET sverified=1 WHERE subscriberCode=hextoblob(%Q)", |
| 1210 | zName); |
| 1211 | @ <h1>Your email alert subscription has been verified!</h1> |
| @@ -1216,10 +1222,18 @@ | |
| 1222 | @ <tr> |
| 1223 | @ <td class="form_label">Email Address:</td> |
| 1224 | @ <td>%h(semail)</td> |
| 1225 | @ </tr> |
| 1226 | if( g.perm.Admin ){ |
| 1227 | @ <tr> |
| 1228 | @ <td class='form_label'>Created:</td> |
| 1229 | @ <td>%h(sctime)</td> |
| 1230 | @ </tr> |
| 1231 | @ <tr> |
| 1232 | @ <td class='form_label'>Last Modified:</td> |
| 1233 | @ <td>%h(smtime)</td> |
| 1234 | @ </tr> |
| 1235 | @ <tr> |
| 1236 | @ <td class='form_label'>IP Address:</td> |
| 1237 | @ <td>%h(smip)</td> |
| 1238 | @ </tr> |
| 1239 | @ <tr> |
| @@ -1429,10 +1443,11 @@ | |
| 1443 | ** modified. |
| 1444 | */ |
| 1445 | void subscriber_list_page(void){ |
| 1446 | Blob sql; |
| 1447 | Stmt q; |
| 1448 | double rNow; |
| 1449 | if( email_webpages_disabled() ) return; |
| 1450 | login_check_credentials(); |
| 1451 | if( !g.perm.Admin ){ |
| 1452 | fossil_redirect_home(); |
| 1453 | return; |
| @@ -1439,35 +1454,43 @@ | |
| 1454 | } |
| 1455 | email_submenu_common(); |
| 1456 | style_header("Subscriber List"); |
| 1457 | blob_init(&sql, 0, 0); |
| 1458 | blob_append_sql(&sql, |
| 1459 | "SELECT hex(subscriberCode)," /* 0 */ |
| 1460 | " semail," /* 1 */ |
| 1461 | " ssub," /* 2 */ |
| 1462 | " suname," /* 3 */ |
| 1463 | " sverified," /* 4 */ |
| 1464 | " sdigest," /* 5 */ |
| 1465 | " date(sctime)," /* 6 */ |
| 1466 | " smtime" /* 7 */ |
| 1467 | " FROM subscriber" |
| 1468 | ); |
| 1469 | db_prepare_blob(&q, &sql); |
| 1470 | rNow = db_double(0.0,"SELECT julianday('now')"); |
| 1471 | @ <table border="1"> |
| 1472 | @ <tr> |
| 1473 | @ <th>Email |
| 1474 | @ <th>Events |
| 1475 | @ <th>Digest-Only? |
| 1476 | @ <th>User |
| 1477 | @ <th>Verified? |
| 1478 | @ <th>Last change |
| 1479 | @ <th>Created |
| 1480 | @ </tr> |
| 1481 | while( db_step(&q)==SQLITE_ROW ){ |
| 1482 | double rAge = rNow - db_column_double(&q, 7); |
| 1483 | @ <tr> |
| 1484 | @ <td><a href='%R/alerts/%s(db_column_text(&q,0))'>\ |
| 1485 | @ %h(db_column_text(&q,1))</a></td> |
| 1486 | @ <td>%h(db_column_text(&q,2))</td> |
| 1487 | @ <td>%s(db_column_int(&q,5)?"digest":"")</td> |
| 1488 | @ <td>%h(db_column_text(&q,3))</td> |
| 1489 | @ <td>%s(db_column_int(&q,4)?"yes":"pending")</td> |
| 1490 | @ <td>%z(human_readable_age(rAge)) ago</td> |
| 1491 | @ <td>%h(db_column_text(&q,6))</td> |
| 1492 | @ </tr> |
| 1493 | } |
| 1494 | @ </table> |
| 1495 | db_finalize(&q); |
| 1496 | style_footer(); |
| @@ -1779,11 +1802,10 @@ | |
| 1802 | return; |
| 1803 | } |
| 1804 | db_begin_transaction(); |
| 1805 | if( !email_tables_exist() ) goto autoexec_done; |
| 1806 | if( !db_get_boolean("email-autoexec",0) ) goto autoexec_done; |
| 1807 | email_send_alerts(0); |
| 1808 | iJulianDay = db_int(0, "SELECT julianday('now')"); |
| 1809 | if( iJulianDay>db_get_int("email-last-digest",0) ){ |
| 1810 | if( db_transaction_nesting_depth()!=1 ){ |
| 1811 | fossil_warning("Transaction nesting error prior to digest processing"); |
| 1812 |