From 2faa766a005f4fc4f1fd48a36185452f77ceb2b9 Mon Sep 17 00:00:00 2001 From: rich Date: Thu, 21 Oct 2004 19:54:28 +0000 Subject: [PATCH] Removed use of the email_notify table (prior to actually removing the table). Emails are now sent to all registered users for a host, unless they opt out of receiving them. --- cocanwiki.sql | 134 +++++++++++++++++++--------------- scripts/admin/edit_emails.ml | 94 ------------------------ scripts/admin/edit_emails_form.ml | 60 --------------- scripts/admin/host.ml | 17 +---- scripts/delete_file.ml | 6 +- scripts/delete_image.ml | 6 +- scripts/edit.ml | 4 +- scripts/edit_page_css.ml | 4 +- scripts/edit_page_title.ml | 4 +- scripts/edit_sitemenu.ml | 6 +- scripts/lib/cocanwiki_emailnotify.ml | 50 ++++++++++--- scripts/restore.ml | 4 +- scripts/upload_file.ml | 6 +- scripts/upload_image.ml | 6 +- templates/admin/edit_emails_form.html | 48 ------------ templates/admin/host.html | 8 -- 16 files changed, 140 insertions(+), 317 deletions(-) delete mode 100644 scripts/admin/edit_emails.ml delete mode 100644 scripts/admin/edit_emails_form.ml delete mode 100644 templates/admin/edit_emails_form.html diff --git a/cocanwiki.sql b/cocanwiki.sql index b9ab1c3..9e657ca 100644 --- a/cocanwiki.sql +++ b/cocanwiki.sql @@ -266,7 +266,8 @@ CREATE TABLE users ( can_manage_site boolean DEFAULT false NOT NULL, can_edit_global_css boolean DEFAULT false NOT NULL, force_password_change boolean DEFAULT false NOT NULL, - can_import_mail boolean DEFAULT false NOT NULL + can_import_mail boolean DEFAULT false NOT NULL, + email_notify boolean DEFAULT true NOT NULL ); @@ -601,7 +602,7 @@ GRANT ALL ON TABLE msg_references TO "www-data"; -- --- TOC entry 61 (OID 536388) +-- TOC entry 63 (OID 536388) -- Name: hostnames_hostid_name_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -609,7 +610,7 @@ CREATE UNIQUE INDEX hostnames_hostid_name_uq ON hostnames USING btree (hostid, n -- --- TOC entry 62 (OID 536389) +-- TOC entry 64 (OID 536389) -- Name: hostnams_name_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -617,7 +618,7 @@ CREATE UNIQUE INDEX hostnams_name_uq ON hostnames USING btree (name); -- --- TOC entry 58 (OID 536419) +-- TOC entry 60 (OID 536419) -- Name: pages_url_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -625,7 +626,7 @@ CREATE UNIQUE INDEX pages_url_uq ON pages USING btree (hostid, url); -- --- TOC entry 63 (OID 536924) +-- TOC entry 65 (OID 536924) -- Name: email_notify_email_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -633,7 +634,7 @@ CREATE UNIQUE INDEX email_notify_email_uq ON email_notify USING btree (hostid, e -- --- TOC entry 64 (OID 540251) +-- TOC entry 66 (OID 540251) -- Name: images_name_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -641,7 +642,7 @@ CREATE UNIQUE INDEX images_name_uq ON images USING btree (hostid, name); -- --- TOC entry 66 (OID 540252) +-- TOC entry 68 (OID 540252) -- Name: files_name_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -649,7 +650,7 @@ CREATE UNIQUE INDEX files_name_uq ON files USING btree (hostid, name); -- --- TOC entry 69 (OID 540831) +-- TOC entry 71 (OID 540831) -- Name: users_name_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -657,7 +658,7 @@ CREATE UNIQUE INDEX users_name_uq ON users USING btree (hostid, name); -- --- TOC entry 68 (OID 540946) +-- TOC entry 70 (OID 540946) -- Name: users_id_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -665,7 +666,7 @@ CREATE UNIQUE INDEX users_id_uq ON users USING btree (hostid, id); -- --- TOC entry 71 (OID 540970) +-- TOC entry 73 (OID 540970) -- Name: sitemenu_ordering_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -673,7 +674,7 @@ CREATE UNIQUE INDEX sitemenu_ordering_uq ON sitemenu USING btree (hostid, orderi -- --- TOC entry 72 (OID 540971) +-- TOC entry 74 (OID 540971) -- Name: sitemenu_url_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -681,7 +682,7 @@ CREATE UNIQUE INDEX sitemenu_url_uq ON sitemenu USING btree (hostid, url); -- --- TOC entry 75 (OID 542626) +-- TOC entry 77 (OID 542626) -- Name: contact_emails_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -689,7 +690,7 @@ CREATE UNIQUE INDEX contact_emails_uq ON contact_emails USING btree (contactid, -- --- TOC entry 76 (OID 543505) +-- TOC entry 78 (OID 543505) -- Name: themes_theme_css_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -697,7 +698,7 @@ CREATE UNIQUE INDEX themes_theme_css_uq ON themes USING btree (theme_css); -- --- TOC entry 77 (OID 543763) +-- TOC entry 79 (OID 543763) -- Name: page_emails_email_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -705,7 +706,7 @@ CREATE UNIQUE INDEX page_emails_email_uq ON page_emails USING btree (hostid, url -- --- TOC entry 78 (OID 543795) +-- TOC entry 80 (OID 543795) -- Name: mailing_lists_email_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -713,7 +714,7 @@ CREATE UNIQUE INDEX mailing_lists_email_uq ON mailing_lists USING btree (hostid, -- --- TOC entry 73 (OID 543880) +-- TOC entry 75 (OID 543880) -- Name: contacts_name_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -721,7 +722,7 @@ CREATE UNIQUE INDEX contacts_name_uq ON contacts USING btree (hostid, name); -- --- TOC entry 79 (OID 544454) +-- TOC entry 81 (OID 544454) -- Name: links_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -729,7 +730,7 @@ CREATE UNIQUE INDEX links_uq ON links USING btree (hostid, from_url, to_url); -- --- TOC entry 80 (OID 547951) +-- TOC entry 82 (OID 547951) -- Name: templates_ext_ord_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -737,7 +738,7 @@ CREATE UNIQUE INDEX templates_ext_ord_uq ON templates USING btree (extension, or -- --- TOC entry 82 (OID 547952) +-- TOC entry 84 (OID 547952) -- Name: templates_title_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -745,7 +746,7 @@ CREATE UNIQUE INDEX templates_title_uq ON templates USING btree (title_regexp); -- --- TOC entry 83 (OID 547953) +-- TOC entry 85 (OID 547953) -- Name: templates_url_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -753,7 +754,7 @@ CREATE UNIQUE INDEX templates_url_uq ON templates USING btree (url_regexp); -- --- TOC entry 84 (OID 551151) +-- TOC entry 86 (OID 551151) -- Name: recently_visited_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -761,7 +762,7 @@ CREATE UNIQUE INDEX recently_visited_uq ON recently_visited USING btree (userid, -- --- TOC entry 85 (OID 552155) +-- TOC entry 87 (OID 552155) -- Name: messages_inet_message_id_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -769,6 +770,22 @@ CREATE UNIQUE INDEX messages_inet_message_id_uq ON messages USING btree (hostid, -- +-- TOC entry 59 (OID 552684) +-- Name: pages_url_ix; Type: INDEX; Schema: public; Owner: rich +-- + +CREATE INDEX pages_url_ix ON pages USING btree (url); + + +-- +-- TOC entry 58 (OID 552685) +-- Name: pages_redirect_ix; Type: INDEX; Schema: public; Owner: rich +-- + +CREATE INDEX pages_redirect_ix ON pages USING btree (redirect); + + +-- -- TOC entry 57 (OID 536012) -- Name: pages_pkey; Type: CONSTRAINT; Schema: public; Owner: rich -- @@ -778,7 +795,7 @@ ALTER TABLE ONLY pages -- --- TOC entry 59 (OID 536027) +-- TOC entry 61 (OID 536027) -- Name: contents_pkey; Type: CONSTRAINT; Schema: public; Owner: rich -- @@ -787,7 +804,7 @@ ALTER TABLE ONLY contents -- --- TOC entry 60 (OID 536377) +-- TOC entry 62 (OID 536377) -- Name: hosts_pkey; Type: CONSTRAINT; Schema: public; Owner: rich -- @@ -796,7 +813,7 @@ ALTER TABLE ONLY hosts -- --- TOC entry 65 (OID 537158) +-- TOC entry 67 (OID 537158) -- Name: images_pkey; Type: CONSTRAINT; Schema: public; Owner: rich -- @@ -805,7 +822,7 @@ ALTER TABLE ONLY images -- --- TOC entry 67 (OID 537173) +-- TOC entry 69 (OID 537173) -- Name: files_pkey; Type: CONSTRAINT; Schema: public; Owner: rich -- @@ -814,7 +831,7 @@ ALTER TABLE ONLY files -- --- TOC entry 70 (OID 540825) +-- TOC entry 72 (OID 540825) -- Name: users_pkey; Type: CONSTRAINT; Schema: public; Owner: rich -- @@ -823,7 +840,7 @@ ALTER TABLE ONLY users -- --- TOC entry 74 (OID 542611) +-- TOC entry 76 (OID 542611) -- Name: contacts_pkey; Type: CONSTRAINT; Schema: public; Owner: rich -- @@ -832,7 +849,7 @@ ALTER TABLE ONLY contacts -- --- TOC entry 81 (OID 547945) +-- TOC entry 83 (OID 547945) -- Name: templates_pkey; Type: CONSTRAINT; Schema: public; Owner: rich -- @@ -841,7 +858,7 @@ ALTER TABLE ONLY templates -- --- TOC entry 86 (OID 551681) +-- TOC entry 88 (OID 551681) -- Name: messages_pkey; Type: CONSTRAINT; Schema: public; Owner: rich -- @@ -850,7 +867,7 @@ ALTER TABLE ONLY messages -- --- TOC entry 91 (OID 536029) +-- TOC entry 93 (OID 536029) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -859,7 +876,7 @@ ALTER TABLE ONLY contents -- --- TOC entry 94 (OID 536384) +-- TOC entry 96 (OID 536384) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -868,7 +885,7 @@ ALTER TABLE ONLY hostnames -- --- TOC entry 92 (OID 536394) +-- TOC entry 94 (OID 536394) -- Name: hosts_hostname_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -877,7 +894,7 @@ ALTER TABLE ONLY hosts -- --- TOC entry 87 (OID 536404) +-- TOC entry 89 (OID 536404) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -886,7 +903,7 @@ ALTER TABLE ONLY pages -- --- TOC entry 95 (OID 536920) +-- TOC entry 97 (OID 536920) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -895,7 +912,7 @@ ALTER TABLE ONLY email_notify -- --- TOC entry 96 (OID 537160) +-- TOC entry 98 (OID 537160) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -904,7 +921,7 @@ ALTER TABLE ONLY images -- --- TOC entry 97 (OID 537175) +-- TOC entry 99 (OID 537175) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -913,7 +930,7 @@ ALTER TABLE ONLY files -- --- TOC entry 88 (OID 539155) +-- TOC entry 90 (OID 539155) -- Name: pages_redirect_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -922,7 +939,7 @@ ALTER TABLE ONLY pages -- --- TOC entry 98 (OID 540827) +-- TOC entry 100 (OID 540827) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -931,7 +948,7 @@ ALTER TABLE ONLY users -- --- TOC entry 99 (OID 540837) +-- TOC entry 101 (OID 540837) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -940,7 +957,7 @@ ALTER TABLE ONLY usercookies -- --- TOC entry 89 (OID 540942) +-- TOC entry 91 (OID 540942) -- Name: $2; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -949,7 +966,7 @@ ALTER TABLE ONLY pages -- --- TOC entry 90 (OID 540947) +-- TOC entry 92 (OID 540947) -- Name: pages_user_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -958,7 +975,7 @@ ALTER TABLE ONLY pages -- --- TOC entry 100 (OID 540966) +-- TOC entry 102 (OID 540966) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -967,7 +984,7 @@ ALTER TABLE ONLY sitemenu -- --- TOC entry 101 (OID 540972) +-- TOC entry 103 (OID 540972) -- Name: sitemenu_url_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -976,7 +993,7 @@ ALTER TABLE ONLY sitemenu -- --- TOC entry 102 (OID 542613) +-- TOC entry 104 (OID 542613) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -985,7 +1002,7 @@ ALTER TABLE ONLY contacts -- --- TOC entry 103 (OID 542622) +-- TOC entry 105 (OID 542622) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -994,7 +1011,7 @@ ALTER TABLE ONLY contact_emails -- --- TOC entry 93 (OID 543506) +-- TOC entry 95 (OID 543506) -- Name: hosts_theme_css_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -1003,7 +1020,7 @@ ALTER TABLE ONLY hosts -- --- TOC entry 104 (OID 543759) +-- TOC entry 106 (OID 543759) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -1012,7 +1029,7 @@ ALTER TABLE ONLY page_emails -- --- TOC entry 105 (OID 543764) +-- TOC entry 107 (OID 543764) -- Name: page_emails_url_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -1021,7 +1038,7 @@ ALTER TABLE ONLY page_emails -- --- TOC entry 106 (OID 543791) +-- TOC entry 108 (OID 543791) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -1030,7 +1047,7 @@ ALTER TABLE ONLY mailing_lists -- --- TOC entry 107 (OID 544450) +-- TOC entry 109 (OID 544450) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -1039,7 +1056,7 @@ ALTER TABLE ONLY links -- --- TOC entry 108 (OID 544455) +-- TOC entry 110 (OID 544455) -- Name: links_from_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -1048,7 +1065,7 @@ ALTER TABLE ONLY links -- --- TOC entry 109 (OID 551129) +-- TOC entry 111 (OID 551129) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -1057,7 +1074,7 @@ ALTER TABLE ONLY recently_visited -- --- TOC entry 110 (OID 551133) +-- TOC entry 112 (OID 551133) -- Name: $2; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -1066,7 +1083,7 @@ ALTER TABLE ONLY recently_visited -- --- TOC entry 111 (OID 551137) +-- TOC entry 113 (OID 551137) -- Name: recently_visited_url_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -1075,7 +1092,7 @@ ALTER TABLE ONLY recently_visited -- --- TOC entry 112 (OID 551141) +-- TOC entry 114 (OID 551141) -- Name: recently_visited_userid_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -1084,7 +1101,7 @@ ALTER TABLE ONLY recently_visited -- --- TOC entry 114 (OID 551690) +-- TOC entry 116 (OID 551690) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -1093,7 +1110,7 @@ ALTER TABLE ONLY msg_references -- --- TOC entry 113 (OID 551694) +-- TOC entry 115 (OID 551694) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -1162,6 +1179,7 @@ SET search_path = public, pg_catalog; COPY themes (theme_css, name, description) FROM stdin; /_css/easyweb.css Merjis Easy Web Marketing This is the easy web marketing stylesheet developed by Merjis Ltd. Please see http://www.merjis.com/ +/_css/basic.css Basic styles only Only the most essential styles. This is a good starting point if you want to completely restyle pages using site-specific CSS. \. diff --git a/scripts/admin/edit_emails.ml b/scripts/admin/edit_emails.ml deleted file mode 100644 index a1d0cc6..0000000 --- a/scripts/admin/edit_emails.ml +++ /dev/null @@ -1,94 +0,0 @@ -(* COCANWIKI - a wiki written in Objective CAML. - * Written by Richard W.M. Jones . - * Copyright (C) 2004 Merjis Ltd. - * $Id: edit_emails.ml,v 1.6 2004/09/23 11:56:47 rich Exp $ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - *) - -open Apache -open Registry -open Cgi -open Printf - -open Cocanwiki -open Cocanwiki_ok -open Cocanwiki_strings - -let split_re = Pcre.regexp "[\\r\\n,;]+" -let email_re = Pcre.regexp "(.*)<(.*)>" - -let run r (q : cgi) (dbh : Dbi.connection) _ host' _ = - let hostid = int_of_string (q#param "hostid") in - - if q#param_true "cancel" then ( - let { hostname = hostname } = host' in - q#redirect ("http://" ^ hostname ^ "/_bin/admin/host.cmo?hostid=" ^ - string_of_int hostid); - return () - ); - - let emails = try q#param "emails" with Not_found -> "" in - - (* It's very hard to verify email addresses. Thus this script - * should not be exposed to untrusted users. - *) - let check_email str = - let name, email = - try - let subs = Pcre.exec ~rex:email_re str in - Pcre.get_substring subs 1, Pcre.get_substring subs 2 - with - Not_found -> - "", str in - - (* Trim whitespace. *) - trim name, trim email - in - - let emails = Pcre.split ~rex:split_re emails in - let emails = List.map check_email emails in - let emails = List.filter ((<>) ("","")) emails in - - (* Update the database. *) - let sth = dbh#prepare_cached - "delete from email_notify where hostid = ?" in - sth#execute [`Int hostid]; - let sth = dbh#prepare_cached "insert into email_notify (hostid, email, name) - values (?, ?, ?)" in - List.iter (fun (name, email) -> - if name = "" then - sth#execute [`Int hostid; `String email; `Null] - else - sth#execute [`Int hostid; `String email; `String name]) - emails; - - (* Commit to the database. *) - dbh#commit (); - - (* Print confirmation page. *) - let buttons = [ - { StdPages.label = "OK"; - StdPages.link = "/_bin/admin/host.cmo"; - StdPages.method_ = None; - StdPages.params = [ "hostid", string_of_int hostid ] } - ] in - - ok ~title:"Saved" ~buttons - q "Email notifications updated." - -let () = - register_script run diff --git a/scripts/admin/edit_emails_form.ml b/scripts/admin/edit_emails_form.ml deleted file mode 100644 index 5dabb2e..0000000 --- a/scripts/admin/edit_emails_form.ml +++ /dev/null @@ -1,60 +0,0 @@ -(* COCANWIKI - a wiki written in Objective CAML. - * Written by Richard W.M. Jones . - * Copyright (C) 2004 Merjis Ltd. - * $Id: edit_emails_form.ml,v 1.5 2004/09/09 12:21:22 rich Exp $ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - *) - -open Apache -open Registry -open Cgi -open Printf - -open Cocanwiki -open Cocanwiki_template - -let template = _get_template "admin/edit_emails_form.html" - -let run r (q : cgi) (dbh : Dbi.connection) _ _ _ = - let hostid = int_of_string (q#param "hostid") in - - template#set "id" (string_of_int hostid); - - let sth = dbh#prepare_cached - "select canonical_hostname from hosts where id = ?" in - sth#execute [`Int hostid]; - - let canonical_hostname = sth#fetch1string () in - template#set "canonical_hostname" canonical_hostname; - - let sth = dbh#prepare_cached - "select email, name from email_notify where hostid = ?" in - sth#execute [`Int hostid]; - - let emails = sth#map (function - [`String email; `Null] -> - email - | [`String email; `String name] -> - sprintf "%s <%s>" name email - | _ -> assert false) in - - template#set "emails" (String.concat "\n" emails); - - q#template template - -let () = - register_script run diff --git a/scripts/admin/host.ml b/scripts/admin/host.ml index 732e5d0..4cec09c 100644 --- a/scripts/admin/host.ml +++ b/scripts/admin/host.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: host.ml,v 1.6 2004/09/09 12:21:22 rich Exp $ + * $Id: host.ml,v 1.7 2004/10/21 19:54:29 rich Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -92,21 +92,6 @@ let run r (q : cgi) (dbh : Dbi.connection) _ _ _ = | _ -> assert false) in template#table "hostnames" table; - (* Pull out any email notifications. *) - let sth = dbh#prepare_cached "select email, name from email_notify - where hostid = ?" in - sth#execute [`Int hostid]; - - let table = sth#map (function - [`String email; `Null] -> - [ "email", Template.VarString email; - "name", Template.VarString "" ] - | [ `String email; `String name] -> - [ "email", Template.VarString email; - "name", Template.VarString name ] - | _ -> assert false) in - template#table "emails" table; - q#template template let () = diff --git a/scripts/delete_file.ml b/scripts/delete_file.ml index fbfacff..9c1ac60 100644 --- a/scripts/delete_file.ml +++ b/scripts/delete_file.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: delete_file.ml,v 1.6 2004/09/09 12:21:22 rich Exp $ + * $Id: delete_file.ml,v 1.7 2004/10/21 19:54:29 rich Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,7 +28,7 @@ open Cocanwiki open Cocanwiki_ok open Cocanwiki_emailnotify -let run r (q : cgi) (dbh : Dbi.connection) hostid { hostname = hostname } _ = +let run r (q : cgi) (dbh : Dbi.connection) hostid { hostname = hostname } user= let id = int_of_string (q#param "id") in if q#param_true "yes" then ( @@ -46,7 +46,7 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid { hostname = hostname } _ = let body = fun () -> "Page: http://" ^ hostname ^ "/_files?deleted=1" in - email_notify ~body ~subject dbh hostid; + email_notify ~body ~subject ~user dbh hostid; (* Done. *) let buttons = [ ok_button "/_files" ] in diff --git a/scripts/delete_image.ml b/scripts/delete_image.ml index dcb4522..5b64357 100644 --- a/scripts/delete_image.ml +++ b/scripts/delete_image.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: delete_image.ml,v 1.6 2004/09/09 12:21:22 rich Exp $ + * $Id: delete_image.ml,v 1.7 2004/10/21 19:54:29 rich Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,7 +28,7 @@ open Cocanwiki open Cocanwiki_ok open Cocanwiki_emailnotify -let run r (q : cgi) (dbh : Dbi.connection) hostid { hostname = hostname } _ = +let run r (q : cgi) (dbh : Dbi.connection) hostid { hostname = hostname } user= let id = int_of_string (q#param "id") in if q#param_true "yes" then ( @@ -46,7 +46,7 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid { hostname = hostname } _ = let body = fun () -> "Page: http://" ^ hostname ^ "/_images?deleted=1" in - email_notify ~body ~subject dbh hostid; + email_notify ~body ~subject ~user dbh hostid; (* Done. *) let buttons = [ ok_button "/_images" ] in ok ~title:"Image deleted" ~buttons diff --git a/scripts/edit.ml b/scripts/edit.ml index 2e4a6cd..af885a1 100644 --- a/scripts/edit.ml +++ b/scripts/edit.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: edit.ml,v 1.20 2004/10/11 14:13:04 rich Exp $ + * $Id: edit.ml,v 1.21 2004/10/21 19:54:29 rich Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -431,7 +431,7 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} user = "Page: http://" ^ hostname ^ "/" ^ url ^ "\n\n" ^ diff in - email_notify ~body ~subject dbh hostid; + email_notify ~body ~subject ~user dbh hostid; (* Redirect back to the URL. *) q#redirect ("http://" ^ hostname ^ "/" ^ url); diff --git a/scripts/edit_page_css.ml b/scripts/edit_page_css.ml index b9f1ecd..22cab69 100644 --- a/scripts/edit_page_css.ml +++ b/scripts/edit_page_css.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: edit_page_css.ml,v 1.12 2004/10/10 16:14:43 rich Exp $ + * $Id: edit_page_css.ml,v 1.13 2004/10/21 19:54:29 rich Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -99,7 +99,7 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} user = "Page: http://" ^ hostname ^ "/" ^ page ^ "\n\n" ^ diff in - email_notify ~subject ~body dbh hostid; + email_notify ~subject ~body ~user dbh hostid; let buttons = [ ok_button ("/" ^ page); { StdPages.label = "Edit stylesheet again"; diff --git a/scripts/edit_page_title.ml b/scripts/edit_page_title.ml index a410d5c..bc51f67 100644 --- a/scripts/edit_page_title.ml +++ b/scripts/edit_page_title.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: edit_page_title.ml,v 1.4 2004/10/10 16:14:43 rich Exp $ + * $Id: edit_page_title.ml,v 1.5 2004/10/21 19:54:29 rich Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -130,7 +130,7 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} user = "Old title: " ^ old_title ^ "\n" ^ "New title: " ^ new_title ^ "\n" in - email_notify ~subject ~body dbh hostid; + email_notify ~subject ~body ~user dbh hostid; let buttons = [ ok_button ("/" ^ page) ] in ok ~title:"Title changed" ~buttons diff --git a/scripts/edit_sitemenu.ml b/scripts/edit_sitemenu.ml index 38cba43..975ee71 100644 --- a/scripts/edit_sitemenu.ml +++ b/scripts/edit_sitemenu.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: edit_sitemenu.ml,v 1.5 2004/09/23 11:56:47 rich Exp $ + * $Id: edit_sitemenu.ml,v 1.6 2004/10/21 19:54:29 rich Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,7 +38,7 @@ open Cocanwiki_strings *) type model_t = (string * string) list (* label, url *) -let run r (q : cgi) (dbh : Dbi.connection) hostid { hostname = hostname } _ = +let run r (q : cgi) (dbh : Dbi.connection) hostid { hostname = hostname } user= let template = get_template dbh hostid "edit_sitemenu.html" in (* Workaround bugs in IE, specifically lack of support for