X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=scripts%2Frename_page.ml;h=a1d287c80fec89df4414850fa7aa803d76b6dfc9;hb=cd059731a60fd3d4dcf426430ad26ff227b91910;hp=32cfff86438195d248106f54689b6cee36730fa0;hpb=e828b148d6338765d7f5ca8f10567d5d9ef00548;p=cocanwiki.git diff --git a/scripts/rename_page.ml b/scripts/rename_page.ml index 32cfff8..a1d287c 100644 --- a/scripts/rename_page.ml +++ b/scripts/rename_page.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: rename_page.ml,v 1.3 2005/11/24 14:54:12 rich Exp $ + * $Id: rename_page.ml,v 1.5 2006/03/28 16:24:08 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 @@ -30,7 +30,7 @@ open Cocanwiki_pages open Cocanwiki_strings open Cocanwiki_emailnotify -let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} user = +let run r (q : cgi) dbh hostid {hostname = hostname} user = let page = q#param "page" in (* Cancelled? *) @@ -49,11 +49,10 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} user = ); (* Get the old title. *) - let sth = dbh#prepare_cached "select title from pages - where hostid = ? and url = ?" in - sth#execute [`Int hostid; `String page]; - - let old_title = sth#fetch1string () in + let old_title = List.hd ( + PGSQL (dbh) "select title from pages + where hostid = $hostid and url = $page" + ) in (* Generate URL for the new title. *) let new_page = @@ -82,9 +81,9 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} user = let old_model = load_page dbh hostid ~url:page () in let new_model = new_page_with_title new_title in let new_model = { new_model with description = old_model.description; - contents = old_model.contents } in - let old_model = { old_model with redirect = new_page } in - save_page dbh hostid ~user ~r old_model; + contents_ = old_model.contents_ } in + let old_model = { old_model with redirect = Some new_page } in + ignore (save_page dbh hostid ~user ~r old_model); try ignore (save_page dbh hostid ~user ~r new_model) @@ -100,7 +99,7 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} user = ); (* Finish off XXX *) - dbh#commit (); + PGOCaml.commit dbh; (* Email notification. *) let subject = "Page " ^ page ^ " has been renamed" in