Removed the diff_sidebyside preference for now. It had a really
[cocanwiki.git] / scripts / invite_user.ml
index bca130f..2895d78 100644 (file)
@@ -1,7 +1,7 @@
 (* COCANWIKI - a wiki written in Objective CAML.
  * Written by Richard W.M. Jones <rich@merjis.com>.
  * Copyright (C) 2004 Merjis Ltd.
- * $Id: invite_user.ml,v 1.2 2004/10/23 15:00:15 rich Exp $
+ * $Id: invite_user.ml,v 1.3 2004/10/30 10:16:10 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
@@ -44,24 +44,17 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} user =
     return ()
   );
 
-  let userid, username = match user with
-      User (userid, username, _) -> userid, username
+  let userid, username, email = match user with
+      User (userid, username, _, prefs) -> userid, username, prefs.email
     | _ -> assert false in
 
   let subject = username ^ " has invited you to join " ^ hostname in
 
-  (* Get user's own email address, which will be the return address
-   * for the email.
-   *)
-  let sth = dbh#prepare_cached "select email from users
-                                 where hostid = ? and id = ?" in
-  sth#execute [`Int hostid; `Int userid];
-
+  (* Get a suitable return address for the email. *)
   let from =
-    match sth#fetch1 () with
-       [ `String email ] -> email
-      | [ `Null ] -> "service@merjis.com"
-      | _ -> assert false in
+    match email with
+      | Some email -> email
+      | None -> "service@merjis.com" in
 
   (* Add user accounts for these new users.  For users who are already
    * registered, we'll send reminder emails.