Fossil SCM
Enhance the /announce page so that it provides an option to send a message to all forum moderators.
Commit
84d854c6d1268da03b642b2182a8c59f4316378d9688d98543409b5e28354120
Parent
ea4ccfdc2df9d0b…
1 file changed
+30
-7
+30
-7
| --- src/alerts.c | ||
| +++ src/alerts.c | ||
| @@ -2641,10 +2641,11 @@ | ||
| 2641 | 2641 | char *zErr; |
| 2642 | 2642 | const char *zTo = PT("to"); |
| 2643 | 2643 | char *zSubject = PT("subject"); |
| 2644 | 2644 | int bAll = PB("all"); |
| 2645 | 2645 | int bAA = PB("aa"); |
| 2646 | + int bMods = PB("mods"); | |
| 2646 | 2647 | const char *zSub = db_get("email-subname", "[Fossil Repo]"); |
| 2647 | 2648 | int bTest2 = fossil_strcmp(P("name"),"test2")==0; |
| 2648 | 2649 | Blob hdr, body; |
| 2649 | 2650 | blob_init(&body, 0, 0); |
| 2650 | 2651 | blob_init(&hdr, 0, 0); |
| @@ -2652,17 +2653,29 @@ | ||
| 2652 | 2653 | pSender = alert_sender_new(bTest2 ? "blob" : 0, 0); |
| 2653 | 2654 | if( zTo[0] ){ |
| 2654 | 2655 | blob_appendf(&hdr, "To: <%s>\r\nSubject: %s %s\r\n", zTo, zSub, zSubject); |
| 2655 | 2656 | alert_send(pSender, &hdr, &body, 0); |
| 2656 | 2657 | } |
| 2657 | - if( bAll || bAA ){ | |
| 2658 | + if( bAll || bAA || bMods ){ | |
| 2658 | 2659 | Stmt q; |
| 2659 | 2660 | int nUsed = blob_size(&body); |
| 2660 | 2661 | const char *zURL = db_get("email-url",0); |
| 2661 | - db_prepare(&q, "SELECT semail, hex(subscriberCode) FROM subscriber " | |
| 2662 | - " WHERE sverified AND NOT sdonotcall %s", | |
| 2663 | - bAll ? "" : " AND ssub LIKE '%a%'"); | |
| 2662 | + if( bAll ){ | |
| 2663 | + db_prepare(&q, "SELECT semail, hex(subscriberCode) FROM subscriber " | |
| 2664 | + " WHERE sverified AND NOT sdonotcall"); | |
| 2665 | + }else if( bAA ){ | |
| 2666 | + db_prepare(&q, "SELECT semail, hex(subscriberCode) FROM subscriber " | |
| 2667 | + " WHERE sverified AND NOT sdonotcall" | |
| 2668 | + " AND ssub LIKE '%%a%%'"); | |
| 2669 | + }else if( bMods ){ | |
| 2670 | + db_prepare(&q, | |
| 2671 | + "SELECT semail, hex(subscriberCode)" | |
| 2672 | + " FROM subscriber, user " | |
| 2673 | + " WHERE sverified AND NOT sdonotcall" | |
| 2674 | + " AND suname=login" | |
| 2675 | + " AND fullcap(cap) GLOB '*5*'"); | |
| 2676 | + } | |
| 2664 | 2677 | while( db_step(&q)==SQLITE_ROW ){ |
| 2665 | 2678 | const char *zCode = db_column_text(&q, 1); |
| 2666 | 2679 | zTo = db_column_text(&q, 0); |
| 2667 | 2680 | blob_truncate(&hdr, 0); |
| 2668 | 2681 | blob_appendf(&hdr, "To: <%s>\r\nSubject: %s %s\r\n", zTo, zSub, zSubject); |
| @@ -2719,11 +2732,12 @@ | ||
| 2719 | 2732 | @ <p>The following error was reported by the system: |
| 2720 | 2733 | @ <blockquote><pre> |
| 2721 | 2734 | @ %h(zErr) |
| 2722 | 2735 | @ </pre></blockquote> |
| 2723 | 2736 | }else{ |
| 2724 | - @ <p>The announcement has been sent.</p> | |
| 2737 | + @ <p>The announcement has been sent. | |
| 2738 | + @ <a href="%h(PD("REQUEST_URI","/"))">Send another</a></p> | |
| 2725 | 2739 | } |
| 2726 | 2740 | style_footer(); |
| 2727 | 2741 | return; |
| 2728 | 2742 | } else if( !alert_enabled() ){ |
| 2729 | 2743 | style_header("Cannot Send Announcement"); |
| @@ -2737,21 +2751,26 @@ | ||
| 2737 | 2751 | @ <form method="POST"> |
| 2738 | 2752 | @ <table class="subscribe"> |
| 2739 | 2753 | if( g.perm.Admin ){ |
| 2740 | 2754 | int aa = PB("aa"); |
| 2741 | 2755 | int all = PB("all"); |
| 2756 | + int aMod = PB("mods"); | |
| 2742 | 2757 | const char *aack = aa ? "checked" : ""; |
| 2743 | 2758 | const char *allck = all ? "checked" : ""; |
| 2759 | + const char *modck = aMod ? "checked" : ""; | |
| 2744 | 2760 | @ <tr> |
| 2745 | 2761 | @ <td class="form_label">To:</td> |
| 2746 | 2762 | @ <td><input type="text" name="to" value="%h(PT("to"))" size="30"><br> |
| 2747 | 2763 | @ <label><input type="checkbox" name="aa" %s(aack)> \ |
| 2748 | 2764 | @ All "announcement" subscribers</label> \ |
| 2749 | 2765 | @ <a href="%R/subscribers?only=a" target="_blank">(list)</a><br> |
| 2750 | 2766 | @ <label><input type="checkbox" name="all" %s(allck)> \ |
| 2751 | 2767 | @ All subscribers</label> \ |
| 2752 | - @ <a href="%R/subscribers" target="_blank">(list)</a><br></td> | |
| 2768 | + @ <a href="%R/subscribers" target="_blank">(list)</a><br> | |
| 2769 | + @ <label><input type="checkbox" name="mods" %s(modck)> \ | |
| 2770 | + @ All moderators</label> \ | |
| 2771 | + @ <a href="%R/setup_ulist?with=5" target="_blank">(list)</a><br></td> | |
| 2753 | 2772 | @ </tr> |
| 2754 | 2773 | } |
| 2755 | 2774 | @ <tr> |
| 2756 | 2775 | @ <td class="form_label">Subject:</td> |
| 2757 | 2776 | @ <td><input type="text" name="subject" value="%h(PT("subject"))"\ |
| @@ -2762,11 +2781,15 @@ | ||
| 2762 | 2781 | @ <td><textarea name="msg" cols="80" rows="10" wrap="virtual">\ |
| 2763 | 2782 | @ %h(PT("msg"))</textarea> |
| 2764 | 2783 | @ </tr> |
| 2765 | 2784 | @ <tr> |
| 2766 | 2785 | @ <td></td> |
| 2767 | - @ <td><input type="submit" name="submit" value="Send Message"> | |
| 2786 | + if( fossil_strcmp(P("name"),"test2")==0 ){ | |
| 2787 | + @ <td><input type="submit" name="submit" value="Dry Run"> | |
| 2788 | + }else{ | |
| 2789 | + @ <td><input type="submit" name="submit" value="Send Message"> | |
| 2790 | + } | |
| 2768 | 2791 | @ </tr> |
| 2769 | 2792 | @ </table> |
| 2770 | 2793 | @ </form> |
| 2771 | 2794 | style_footer(); |
| 2772 | 2795 | } |
| 2773 | 2796 |
| --- src/alerts.c | |
| +++ src/alerts.c | |
| @@ -2641,10 +2641,11 @@ | |
| 2641 | char *zErr; |
| 2642 | const char *zTo = PT("to"); |
| 2643 | char *zSubject = PT("subject"); |
| 2644 | int bAll = PB("all"); |
| 2645 | int bAA = PB("aa"); |
| 2646 | const char *zSub = db_get("email-subname", "[Fossil Repo]"); |
| 2647 | int bTest2 = fossil_strcmp(P("name"),"test2")==0; |
| 2648 | Blob hdr, body; |
| 2649 | blob_init(&body, 0, 0); |
| 2650 | blob_init(&hdr, 0, 0); |
| @@ -2652,17 +2653,29 @@ | |
| 2652 | pSender = alert_sender_new(bTest2 ? "blob" : 0, 0); |
| 2653 | if( zTo[0] ){ |
| 2654 | blob_appendf(&hdr, "To: <%s>\r\nSubject: %s %s\r\n", zTo, zSub, zSubject); |
| 2655 | alert_send(pSender, &hdr, &body, 0); |
| 2656 | } |
| 2657 | if( bAll || bAA ){ |
| 2658 | Stmt q; |
| 2659 | int nUsed = blob_size(&body); |
| 2660 | const char *zURL = db_get("email-url",0); |
| 2661 | db_prepare(&q, "SELECT semail, hex(subscriberCode) FROM subscriber " |
| 2662 | " WHERE sverified AND NOT sdonotcall %s", |
| 2663 | bAll ? "" : " AND ssub LIKE '%a%'"); |
| 2664 | while( db_step(&q)==SQLITE_ROW ){ |
| 2665 | const char *zCode = db_column_text(&q, 1); |
| 2666 | zTo = db_column_text(&q, 0); |
| 2667 | blob_truncate(&hdr, 0); |
| 2668 | blob_appendf(&hdr, "To: <%s>\r\nSubject: %s %s\r\n", zTo, zSub, zSubject); |
| @@ -2719,11 +2732,12 @@ | |
| 2719 | @ <p>The following error was reported by the system: |
| 2720 | @ <blockquote><pre> |
| 2721 | @ %h(zErr) |
| 2722 | @ </pre></blockquote> |
| 2723 | }else{ |
| 2724 | @ <p>The announcement has been sent.</p> |
| 2725 | } |
| 2726 | style_footer(); |
| 2727 | return; |
| 2728 | } else if( !alert_enabled() ){ |
| 2729 | style_header("Cannot Send Announcement"); |
| @@ -2737,21 +2751,26 @@ | |
| 2737 | @ <form method="POST"> |
| 2738 | @ <table class="subscribe"> |
| 2739 | if( g.perm.Admin ){ |
| 2740 | int aa = PB("aa"); |
| 2741 | int all = PB("all"); |
| 2742 | const char *aack = aa ? "checked" : ""; |
| 2743 | const char *allck = all ? "checked" : ""; |
| 2744 | @ <tr> |
| 2745 | @ <td class="form_label">To:</td> |
| 2746 | @ <td><input type="text" name="to" value="%h(PT("to"))" size="30"><br> |
| 2747 | @ <label><input type="checkbox" name="aa" %s(aack)> \ |
| 2748 | @ All "announcement" subscribers</label> \ |
| 2749 | @ <a href="%R/subscribers?only=a" target="_blank">(list)</a><br> |
| 2750 | @ <label><input type="checkbox" name="all" %s(allck)> \ |
| 2751 | @ All subscribers</label> \ |
| 2752 | @ <a href="%R/subscribers" target="_blank">(list)</a><br></td> |
| 2753 | @ </tr> |
| 2754 | } |
| 2755 | @ <tr> |
| 2756 | @ <td class="form_label">Subject:</td> |
| 2757 | @ <td><input type="text" name="subject" value="%h(PT("subject"))"\ |
| @@ -2762,11 +2781,15 @@ | |
| 2762 | @ <td><textarea name="msg" cols="80" rows="10" wrap="virtual">\ |
| 2763 | @ %h(PT("msg"))</textarea> |
| 2764 | @ </tr> |
| 2765 | @ <tr> |
| 2766 | @ <td></td> |
| 2767 | @ <td><input type="submit" name="submit" value="Send Message"> |
| 2768 | @ </tr> |
| 2769 | @ </table> |
| 2770 | @ </form> |
| 2771 | style_footer(); |
| 2772 | } |
| 2773 |
| --- src/alerts.c | |
| +++ src/alerts.c | |
| @@ -2641,10 +2641,11 @@ | |
| 2641 | char *zErr; |
| 2642 | const char *zTo = PT("to"); |
| 2643 | char *zSubject = PT("subject"); |
| 2644 | int bAll = PB("all"); |
| 2645 | int bAA = PB("aa"); |
| 2646 | int bMods = PB("mods"); |
| 2647 | const char *zSub = db_get("email-subname", "[Fossil Repo]"); |
| 2648 | int bTest2 = fossil_strcmp(P("name"),"test2")==0; |
| 2649 | Blob hdr, body; |
| 2650 | blob_init(&body, 0, 0); |
| 2651 | blob_init(&hdr, 0, 0); |
| @@ -2652,17 +2653,29 @@ | |
| 2653 | pSender = alert_sender_new(bTest2 ? "blob" : 0, 0); |
| 2654 | if( zTo[0] ){ |
| 2655 | blob_appendf(&hdr, "To: <%s>\r\nSubject: %s %s\r\n", zTo, zSub, zSubject); |
| 2656 | alert_send(pSender, &hdr, &body, 0); |
| 2657 | } |
| 2658 | if( bAll || bAA || bMods ){ |
| 2659 | Stmt q; |
| 2660 | int nUsed = blob_size(&body); |
| 2661 | const char *zURL = db_get("email-url",0); |
| 2662 | if( bAll ){ |
| 2663 | db_prepare(&q, "SELECT semail, hex(subscriberCode) FROM subscriber " |
| 2664 | " WHERE sverified AND NOT sdonotcall"); |
| 2665 | }else if( bAA ){ |
| 2666 | db_prepare(&q, "SELECT semail, hex(subscriberCode) FROM subscriber " |
| 2667 | " WHERE sverified AND NOT sdonotcall" |
| 2668 | " AND ssub LIKE '%%a%%'"); |
| 2669 | }else if( bMods ){ |
| 2670 | db_prepare(&q, |
| 2671 | "SELECT semail, hex(subscriberCode)" |
| 2672 | " FROM subscriber, user " |
| 2673 | " WHERE sverified AND NOT sdonotcall" |
| 2674 | " AND suname=login" |
| 2675 | " AND fullcap(cap) GLOB '*5*'"); |
| 2676 | } |
| 2677 | while( db_step(&q)==SQLITE_ROW ){ |
| 2678 | const char *zCode = db_column_text(&q, 1); |
| 2679 | zTo = db_column_text(&q, 0); |
| 2680 | blob_truncate(&hdr, 0); |
| 2681 | blob_appendf(&hdr, "To: <%s>\r\nSubject: %s %s\r\n", zTo, zSub, zSubject); |
| @@ -2719,11 +2732,12 @@ | |
| 2732 | @ <p>The following error was reported by the system: |
| 2733 | @ <blockquote><pre> |
| 2734 | @ %h(zErr) |
| 2735 | @ </pre></blockquote> |
| 2736 | }else{ |
| 2737 | @ <p>The announcement has been sent. |
| 2738 | @ <a href="%h(PD("REQUEST_URI","/"))">Send another</a></p> |
| 2739 | } |
| 2740 | style_footer(); |
| 2741 | return; |
| 2742 | } else if( !alert_enabled() ){ |
| 2743 | style_header("Cannot Send Announcement"); |
| @@ -2737,21 +2751,26 @@ | |
| 2751 | @ <form method="POST"> |
| 2752 | @ <table class="subscribe"> |
| 2753 | if( g.perm.Admin ){ |
| 2754 | int aa = PB("aa"); |
| 2755 | int all = PB("all"); |
| 2756 | int aMod = PB("mods"); |
| 2757 | const char *aack = aa ? "checked" : ""; |
| 2758 | const char *allck = all ? "checked" : ""; |
| 2759 | const char *modck = aMod ? "checked" : ""; |
| 2760 | @ <tr> |
| 2761 | @ <td class="form_label">To:</td> |
| 2762 | @ <td><input type="text" name="to" value="%h(PT("to"))" size="30"><br> |
| 2763 | @ <label><input type="checkbox" name="aa" %s(aack)> \ |
| 2764 | @ All "announcement" subscribers</label> \ |
| 2765 | @ <a href="%R/subscribers?only=a" target="_blank">(list)</a><br> |
| 2766 | @ <label><input type="checkbox" name="all" %s(allck)> \ |
| 2767 | @ All subscribers</label> \ |
| 2768 | @ <a href="%R/subscribers" target="_blank">(list)</a><br> |
| 2769 | @ <label><input type="checkbox" name="mods" %s(modck)> \ |
| 2770 | @ All moderators</label> \ |
| 2771 | @ <a href="%R/setup_ulist?with=5" target="_blank">(list)</a><br></td> |
| 2772 | @ </tr> |
| 2773 | } |
| 2774 | @ <tr> |
| 2775 | @ <td class="form_label">Subject:</td> |
| 2776 | @ <td><input type="text" name="subject" value="%h(PT("subject"))"\ |
| @@ -2762,11 +2781,15 @@ | |
| 2781 | @ <td><textarea name="msg" cols="80" rows="10" wrap="virtual">\ |
| 2782 | @ %h(PT("msg"))</textarea> |
| 2783 | @ </tr> |
| 2784 | @ <tr> |
| 2785 | @ <td></td> |
| 2786 | if( fossil_strcmp(P("name"),"test2")==0 ){ |
| 2787 | @ <td><input type="submit" name="submit" value="Dry Run"> |
| 2788 | }else{ |
| 2789 | @ <td><input type="submit" name="submit" value="Send Message"> |
| 2790 | } |
| 2791 | @ </tr> |
| 2792 | @ </table> |
| 2793 | @ </form> |
| 2794 | style_footer(); |
| 2795 | } |
| 2796 |