BIG, experimental patch.
[cocanwiki.git] / scripts / cocanwiki.ml
index 981379f..7114c2c 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: cocanwiki.ml,v 1.14 2004/10/04 15:19:56 rich Exp $
+ * $Id: cocanwiki.ml,v 1.17 2004/10/11 14:13:04 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
@@ -46,7 +46,7 @@ type host_t = { hostname : string;
  *   register_script ~restrict:[CanEdit ; CanManageUsers] run
  *)
 type permissions_t = CanView | CanEdit | CanManageUsers | CanManageContacts
-                  | CanManageSite | CanEditGlobalCSS
+                  | CanManageSite | CanEditGlobalCSS | CanImportMail
 
 (* The "user object". *)
 type user_t = Anonymous                        (* Not logged in. *)
@@ -65,6 +65,7 @@ let can_manage_users host = test_permission host CanManageUsers
 let can_manage_contacts host = test_permission host CanManageContacts
 let can_manage_site host = test_permission host CanManageSite
 let can_edit_global_css host = test_permission host CanEditGlobalCSS
+let can_import_mail host = test_permission host CanImportMail
 
 (* Our wrapper around the standard [register_script] function.
  *
@@ -150,7 +151,7 @@ let register_script ?(restrict = []) ?(anonymous = true) run =
             dbh#prepare_cached
               "select u.id, u.name, u.can_edit, u.can_manage_users,
                        u.can_manage_contacts, u.can_manage_site,
-                       u.can_edit_global_css
+                       u.can_edit_global_css, u.can_import_mail
                   from usercookies uc, users u
                  where uc.cookie = ? and uc.userid = u.id and u.hostid = ?" in
           sth#execute [`String cookie; `Int hostid];
@@ -158,7 +159,7 @@ let register_script ?(restrict = []) ?(anonymous = true) run =
                [ `Int userid; `String name;
                  `Bool can_edit; `Bool can_manage_users;
                  `Bool can_manage_contacts; `Bool can_manage_site;
-                 `Bool can_edit_global_css ] ->
+                 `Bool can_edit_global_css; `Bool can_import_mail ] ->
                  (* Every logged in user can view. *)
                  let perms = [CanView] in
                  let perms =
@@ -176,6 +177,9 @@ let register_script ?(restrict = []) ?(anonymous = true) run =
                  let perms =
                    if can_edit_global_css then CanEditGlobalCSS :: perms
                    else perms in
+                 let perms =
+                   if can_import_mail then CanImportMail :: perms
+                   else perms in
                  User (userid, name, perms)
              | _ -> assert false)
         with
@@ -218,3 +222,10 @@ let linkname_of_sectionname str =
     if not (isalnum str.[i]) then str.[i] <- '_'
   done;
   str
+
+(* List of extensions currently registered. *)
+type extension_t = Dbi.connection -> int -> string -> string
+let extensions = ref ([] : (string * extension_t) list)
+
+(* Maximum degree of redirection. *)
+let max_redirect = 4