Index: openacs-4/contrib/packages/bcms/tcl/bcms-template-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms/tcl/bcms-template-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/contrib/packages/bcms/tcl/bcms-template-procs.tcl 14 May 2003 15:34:59 -0000 1.1 +++ openacs-4/contrib/packages/bcms/tcl/bcms-template-procs.tcl 27 Aug 2003 17:23:27 -0000 1.2 @@ -8,19 +8,77 @@ ad_proc -public bcms::template::create_template { {-template_name:required} - {-parent_id} - {-creation_user_id ""} - {-creation_ip ""} + {-parent_id:required} + {-creation_user_id} + {-creation_ip} } { This proc creates a template and returns the item_id of the new template } { - if ![info exists parent_id] { - set parent_id [get_bcds_root_folder] - } + if {![info exists creation_user_id]} { set creation_user_id [ad_conn user_id] } + if {![info exists creation_ip]} { set creation_ip [ad_conn peeraddr] } + set item_id [db_exec_plsql create_template "SQL"] return $item_id } +ad_proc -public bcms::template::add_template { + {-template_id:required} + {-title:required} + {-description ""} + {-content ""} + {-creation_user_id} + {-creation_ip} +} { + adds a template revision +} { + if {![info exists creation_user_id]} { set creation_user_id [ad_conn user_id] } + if {![info exists creation_ip]} { set creation_ip [ad_conn peeraddr] } + + set revision_id [db_exec_plsql add_template "SQL"] + return $revision_id +} + +ad_proc -public bcms::template::list_templates { + {-parent_id:required} + {-revision latest} + {-multirow_name bcms_list_templates} + {-return_list:boolean} +} { + list the template under a folder, since templates a bit different we can't use + the general item::list_items call + + @param parent_id id of the which contents you wish to list, normally a folder + @param multirow_name you can supply your own multirow name + @param return_list if supplied a list of ns_sets otherwise it + returns a multirow uses the multirow_name if given + + @returns rows of content items below the parent_id + with the following columns: + + template_id, name, live_revision, latest_revision, publish_status, content_type, storage_type, tree_sortkey, + title, description + +} { + + if {[string equal $revision "latest"]} { + set revision "i.latest_revision" + } elseif {[string equal $revision "live"]} { + set revision "i.live_revision" + } else { + error "invalid revision value, valid values are live or latest" + } + + if {$return_list_p} { + # return a list of lists since its not easy to pass multirow from proc to proc + return [db_list_of_ns_sets list_templates "SQL"] + } else { + # make a multirow, it is likely that this proc is not being called from another proc + db_multirow $multirow_name list_templates "SQL" + } + +} + + ad_proc -public bcms::template::delete_template { {-template_id:required} } {