# packages/intrasite-message/www/folder-delete.tcl

ad_page_contract {

  @author richard.hamilton@webteamworks.com
  @creation-date 2005-09-27
  @cvs-id $Id:  Exp $
} {
  folder_id:integer,notnull
}

# Check permissions on the package_id
ad_require_permission [ad_conn package_id] write

set user_id [ad_verify_and_get_user_id]
ad_maybe_redirect_for_registration

# Ensure that the folder belongs to the requesting user.
db_1row folder_owner_p {
    select im_message__folder_owner_p(:folder_id, :user_id) as folder_owner_p
}
    
if { [string is false $folder_owner_p] } { ad_script_abort }

db_exec_plsql delete_folder {
  begin
    intrasite-message.im_folder__del( :folder_id, :user_id );
  end;
}

ad_returnredirect "./"
