| | @@ -93,10 +93,29 @@ |
| 93 | 93 | if( !db_table_exists("repository", "subscriber") ){ |
| 94 | 94 | db_multi_exec(zEmailInit/*works-like:""*/); |
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | +/* |
| 99 | +** Return true if email alerts are active. |
| 100 | +*/ |
| 101 | +int email_enabled(void){ |
| 102 | + if( !db_table_exists("repository", "subscriber") ) return 0; |
| 103 | + if( fossil_strcmp(db_get("email-send-method","off"),"off")==0 ) return 0; |
| 104 | + return 1; |
| 105 | +} |
| 106 | + |
| 107 | +/* |
| 108 | +** Insert a "Subscriber List" submenu link if the current user |
| 109 | +** is an administrator. |
| 110 | +*/ |
| 111 | +void email_subscriber_list_link(void){ |
| 112 | + if( g.perm.Admin ){ |
| 113 | + style_submenu_element("Subscriber List","%R/subscribers"); |
| 114 | + } |
| 115 | +} |
| 116 | + |
| 98 | 117 | |
| 99 | 118 | /* |
| 100 | 119 | ** WEBPAGE: setup_email |
| 101 | 120 | ** |
| 102 | 121 | ** Administrative page for configuring and controlling email notification |
| | @@ -113,52 +132,52 @@ |
| 113 | 132 | login_needed(0); |
| 114 | 133 | return; |
| 115 | 134 | } |
| 116 | 135 | db_begin_transaction(); |
| 117 | 136 | |
| 118 | | - style_submenu_element("Subscriber List", "%R/subscribers"); |
| 137 | + email_subscriber_list_link(); |
| 119 | 138 | style_header("Email Notification Setup"); |
| 120 | 139 | @ <form action="%R/setup_email" method="post"><div> |
| 121 | 140 | @ <input type="submit" name="submit" value="Apply Changes" /><hr> |
| 122 | 141 | login_insert_csrf_secret(); |
| 123 | | - multiple_choice_attribute("Email Send Method","email-send-method", |
| 124 | | - "esm", "off", count(azSendMethods)/2, azSendMethods); |
| 142 | + multiple_choice_attribute("Email Send Method", "email-send-method", "esm", |
| 143 | + "off", count(azSendMethods)/2, azSendMethods); |
| 125 | 144 | @ <p>How to send email. The "Pipe to a command" |
| 126 | 145 | @ method is the usual choice in production. |
| 127 | 146 | @ (Property: "email-send-method")</p> |
| 128 | 147 | @ <hr> |
| 129 | | - entry_attribute("Command To Pipe Email To", 80, "esc", |
| 130 | | - "email-send-command", "sendmail -t", 0); |
| 148 | + entry_attribute("Command To Pipe Email To", 80, "email-send-command", |
| 149 | + "ecmd", "sendmail -t", 0); |
| 131 | 150 | @ <p>When the send method is "pipe to a command", this is the command |
| 132 | 151 | @ that is run. Email messages are piped into the standard input of this |
| 133 | 152 | @ command. The command is expected to extract the sender address, |
| 134 | 153 | @ recepient addresses, and subject from the header of the piped email |
| 135 | 154 | @ text. (Property: "email-send-command")</p> |
| 136 | 155 | |
| 137 | | - entry_attribute("Database In Which To Store Email", 60, "esdb", |
| 138 | | - "email-send-db", "", 0); |
| 156 | + entry_attribute("Database In Which To Store Email", 60, "email-send-db", |
| 157 | + "esdb", "", 0); |
| 139 | 158 | @ <p>When the send method is "store in a databaes", each email message is |
| 140 | 159 | @ stored in an SQLite database file with the name given here. |
| 141 | 160 | @ (Property: "email-send-db")</p> |
| 142 | 161 | |
| 143 | | - entry_attribute("Directory In Which To Store Email", 60, "esdir", |
| 144 | | - "email-send-dir", "", 0); |
| 162 | + entry_attribute("Directory In Which To Store Email", 60, "email-send-dir", |
| 163 | + "esdir", "", 0); |
| 145 | 164 | @ <p>When the send method is "store in a directory", each email message is |
| 146 | 165 | @ stored as a separate file in the directory shown here. |
| 147 | 166 | @ (Property: "email-send-dir")</p> |
| 148 | 167 | @ <hr> |
| 149 | 168 | |
| 150 | | - entry_attribute("\"From\" email address", 40, "ef", |
| 151 | | - "email-self", "", 0); |
| 169 | + entry_attribute("\"From\" email address", 40, "email-self", |
| 170 | + "eself", "", 0); |
| 152 | 171 | @ <p>This is the email from which email notifications are sent. The |
| 153 | 172 | @ system administrator should arrange for emails sent to this address |
| 154 | 173 | @ to be handed off to the "fossil email incoming" command so that Fossil |
| 155 | 174 | @ can handle bounces. (Property: "email-self")</p> |
| 156 | 175 | @ <hr> |
| 157 | 176 | |
| 158 | | - entry_attribute("Administrator email address", 40, "ea", |
| 159 | | - "email-admin", "", 0); |
| 177 | + entry_attribute("Administrator email address", 40, "email-admin", |
| 178 | + "eadmin", "", 0); |
| 160 | 179 | @ <p>This is the email for the human administrator for the system. |
| 161 | 180 | @ Abuse and trouble reports are send here. |
| 162 | 181 | @ (Property: "email-admin")</p> |
| 163 | 182 | @ <hr> |
| 164 | 183 | @ <p><input type="submit" name="submit" value="Apply Changes" /></p> |
| | @@ -566,13 +585,14 @@ |
| 566 | 585 | && db_exists("SELECT 1 FROM subscriber WHERE suname=%Q",g.zLogin) |
| 567 | 586 | ){ |
| 568 | 587 | /* This person is already signed up for email alerts. Jump |
| 569 | 588 | ** to the screen that lets them edit their alert preferences. |
| 570 | 589 | */ |
| 571 | | - cgi_redirect("%R/alerts"); |
| 590 | + cgi_redirectf("%R/alerts"); |
| 572 | 591 | return; |
| 573 | 592 | } |
| 593 | + email_subscriber_list_link(); |
| 574 | 594 | needCaptcha = !login_is_individual(); |
| 575 | 595 | if( P("submit") |
| 576 | 596 | && cgi_csrf_safe(1) |
| 577 | 597 | && subscribe_error_check(&eErr,&zErr,needCaptcha) |
| 578 | 598 | ){ |
| | @@ -682,11 +702,16 @@ |
| 682 | 702 | } |
| 683 | 703 | @ </td> |
| 684 | 704 | @ </tr> |
| 685 | 705 | @ <tr> |
| 686 | 706 | @ <td></td> |
| 687 | | - @ <td><input type="submit" name="submit" value="Submit"></td> |
| 707 | + if( needCaptcha && !email_enabled() ){ |
| 708 | + @ <td><input type="submit" name="submit" value="Submit" disabled> |
| 709 | + @ (Email current disabled)</td> |
| 710 | + }else{ |
| 711 | + @ <td><input type="submit" name="submit" value="Submit"></td> |
| 712 | + } |
| 688 | 713 | @ </tr> |
| 689 | 714 | @ </table> |
| 690 | 715 | if( needCaptcha ){ |
| 691 | 716 | @ <div class="captcha"><table class="captcha"><tr><td><pre> |
| 692 | 717 | @ %h(zCaptcha) |
| | @@ -739,10 +764,11 @@ |
| 739 | 764 | } |
| 740 | 765 | if( zName==0 || !validate16(zName, -1) ){ |
| 741 | 766 | cgi_redirect("subscribe"); |
| 742 | 767 | return; |
| 743 | 768 | } |
| 769 | + email_subscriber_list_link(); |
| 744 | 770 | if( P("submit")!=0 && cgi_csrf_safe(1) ){ |
| 745 | 771 | int sdonotcall = PB("sdonotcall"); |
| 746 | 772 | int sdigest = PB("sdigest"); |
| 747 | 773 | char ssub[10]; |
| 748 | 774 | int nsub = 0; |
| | @@ -907,23 +933,32 @@ |
| 907 | 933 | blob_append_sql(&sql, |
| 908 | 934 | "SELECT hex(subscriberCode)," |
| 909 | 935 | " semail," |
| 910 | 936 | " ssub," |
| 911 | 937 | " suname," |
| 912 | | - " sverified" |
| 938 | + " sverified," |
| 939 | + " sdigest" |
| 913 | 940 | " FROM subscriber" |
| 914 | 941 | ); |
| 915 | 942 | db_prepare_blob(&q, &sql); |
| 916 | | - @ <table> |
| 943 | + @ <table border="1"> |
| 944 | + @ <tr> |
| 945 | + @ <th>Email |
| 946 | + @ <th>Events |
| 947 | + @ <th>Digest-Only? |
| 948 | + @ <th>User |
| 949 | + @ <th>Verified? |
| 950 | + @ </tr> |
| 917 | 951 | while( db_step(&q)==SQLITE_ROW ){ |
| 918 | 952 | @ <tr> |
| 919 | 953 | @ <td><a href='%R/alerts/%s(db_column_text(&q,0))'>\ |
| 920 | 954 | @ %h(db_column_text(&q,1))</a></td> |
| 955 | + @ <td>%h(db_column_text(&q,2))</td> |
| 956 | + @ <td>%s(db_column_int(&q,5)?"digest":"")</td> |
| 921 | 957 | @ <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> |
| 958 | + @ <td>%s(db_column_int(&q,4)?"yes":"pending")</td> |
| 924 | 959 | @ </tr> |
| 925 | 960 | } |
| 926 | 961 | @ </table> |
| 927 | 962 | db_finalize(&q); |
| 928 | 963 | style_footer(); |
| 929 | 964 | } |
| 930 | 965 | |