Warning: Reason support is experimental. We are looking for beta-tester and contributors.

Module Os_group

module Os_group : sig..end

Groups of users. Groups are sets of users. Groups and group members are saved in database. Groups are used by OS for example to restrict access to pages or server functions.

exception No_such_group

Exception raised when no there is no group corresponding to the request (for example wrong ID or name).

type id = Os_types.Group.id

Type alias to Os_types.Group.id to allow to use Os_group.id.

type t = Os_types.Group.t  = {
  id: id;  name: string;  desc: string option;}

Type alias to Os_types.Group.t to allow to use Os_group.t.

val id_of_group : Os_types.Group.t -> Os_types.Group.id

id_of_group group returns the group ID.

val name_of_group : Os_types.Group.t -> string

name_of_group group returns the group name.

val desc_of_group : Os_types.Group.t -> string option

desc_of_group group returns the group description.

val create : ?description:string -> string -> Os_types.Group.t Lwt.t

create ~description name creates a new group in the database and returns it as a record of type Os_types.Group.t.

val group_of_name : string -> Os_types.Group.t Lwt.t

Overwrites the function group_of_name of Os_db.Group and use the get function of the cache module.

val add_user_in_group : 
  group:Os_types.Group.t -> userid:Os_types.User.id -> unit Lwt.t

add_user_in_group ~group ~userid adds the user with ID userid to group.

val remove_user_in_group : 
  group:Os_types.Group.t -> userid:Os_types.User.id -> unit Lwt.t

remove_user_in_group ~group ~userid removes the user with ID userid from group.

val in_group : 
  ?dbh:Os_db.PGOCaml.pa_pg_data Os_db.PGOCaml.t ->
  group:Os_types.Group.t ->
  userid:Os_types.User.id -> unit -> bool Lwt.t

in_group ~group ~userid returns true if the user with ID userid is in group.

val all : unit -> Os_types.Group.t list Lwt.t

all () returns all the groups of the database.