X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=scripts%2Fedit_user.ml;h=fb1da46389a92561c3bbb998be0e104627b82213;hb=232d52d33fe530971f81b57bbc8b024fb259c4fd;hp=f549c0d70fa2b2b55d977a388e473c6eafe31226;hpb=b90e3f4f9f352bd21d797d08729540e77b9ce72f;p=cocanwiki.git diff --git a/scripts/edit_user.ml b/scripts/edit_user.ml index f549c0d..fb1da46 100644 --- a/scripts/edit_user.ml +++ b/scripts/edit_user.ml @@ -1,7 +1,22 @@ -(* COCANWIKI scripts. +(* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: edit_user.ml,v 1.1 2004/09/08 12:45:38 rich Exp $ + * $Id: edit_user.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 @@ -13,7 +28,7 @@ open Cocanwiki open Cocanwiki_strings open Cocanwiki_ok -let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) self = +let run r (q : cgi) (dbh : Dbi.connection) hostid _ self = let userid = int_of_string (q#param "userid") in (* Get the user's original name. If we're going to change the @@ -30,7 +45,7 @@ let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) self = if name = "" then ( error ~back_button:true ~title:"Bad username" q "The username you gave is empty."; - raise CgiExit + return () ); (* Check it's not a duplicate, then change it. *) @@ -42,7 +57,7 @@ let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) self = sth#fetch1 (); error ~back_button:true ~title:"Username already taken" q ("That username has already been taken by another user."); - raise CgiExit + return () with Not_found -> ()); @@ -57,6 +72,9 @@ let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) self = let can_edit = q#param_true "can_edit" in let can_manage_users = q#param_true "can_manage_users" in + let can_manage_contacts = q#param_true "can_manage_contacts" in + let can_manage_site = q#param_true "can_manage_site" in + let can_edit_global_css = q#param_true "can_edit_global_css" in (* Trying to remove manage users permission from self? *) (match can_manage_users, self with @@ -65,13 +83,18 @@ let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) self = q ("You tried to remove 'Manage users' permission from yourself. "^ "You can't do this. You'll have to do it from another "^ "user account."); - raise CgiExit + return () | _ -> ()); let sth = dbh#prepare_cached "update users set email = ?, - can_edit = ?, can_manage_users = ? + can_edit = ?, can_manage_users = ?, + can_manage_contacts = ?, + can_manage_site = ?, + can_edit_global_css = ? where hostid = ? and id = ?" in sth#execute [email; `Bool can_edit; `Bool can_manage_users; + `Bool can_manage_contacts; `Bool can_manage_site; + `Bool can_edit_global_css; `Int hostid; `Int userid]; (* Finish up. *)