From 8f95b1ac0361fab0f5b12762b01e81ffe1cbab99 Mon Sep 17 00:00:00 2001 From: rich Date: Sat, 9 Oct 2004 09:52:10 +0000 Subject: [PATCH] Fixed the cancel button on the edit page. --- scripts/edit.ml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/scripts/edit.ml b/scripts/edit.ml index 3edce8c..016b0bb 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.16 2004/10/09 09:41:38 rich Exp $ + * $Id: edit.ml,v 1.17 2004/10/09 09:52: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 @@ -633,10 +633,20 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} user = in let cancel id = - let sth = dbh#prepare_cached "select url from pages - where hostid = ? and id = ?" in - sth#execute [`Int hostid; `Int id]; - let url = sth#fetch1string () in + let url = + if id <> 0 then ( + let sth = dbh#prepare_cached "select url from pages + where hostid = ? and id = ?" in + sth#execute [`Int hostid; `Int id]; + sth#fetch1string () + ) else if q#param "pt_type" = "page" then + q#param "pt_value" + else + (* Create a new page, but the user hits the cancel button. Because + * we didn't save where they came from, we now have nowhere to + * go. So we redirect to the home page. XXX + *) + "" in q#redirect ("http://" ^ hostname ^ "/" ^ url); return () -- 1.8.3.1