Index: openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs.tcl,v diff -u -N -r1.15 -r1.16 --- openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs.tcl 6 Nov 2003 15:33:20 -0000 1.15 +++ openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs.tcl 12 Nov 2003 17:05:06 -0000 1.16 @@ -59,7 +59,7 @@ db_transaction { set revision_id [bcms::get_next_objectid] - db_dml insert_revision "SQL" + db_dml insert_revision {} } ns_log notice "bcms::revision::add_revision created new revision $revision_id" @@ -136,19 +136,30 @@ ad_proc -public bcms::revision::list_revisions { {-item_id:required} - {-content_type "content_revision"} {-return_list:boolean false} {-multirow_name} } { - returns a multirow of revision_id of the content item. Together with the - title, live_revision_id, creation_date, description and creation user's first_names and last_name + gets the revisions of a content item + + @param item_id content item where to get the different revisions + @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 the revisions of a content item. with the following data: + revision_id, title, live_revision_id, creation_date, description and creation user's first_names and last_name } { + # TODO: content_type is passed not sure if if need to, + # maybe can pass in additional_columns and then make use to return + # other columns + set content_type "content_revision" + set table_name [bcms::get_table_name -object_type $content_type] if $return_list_p { - return [db_list_of_ns_sets get_revisions "SQL"] + return [db_list_of_ns_sets get_revisions {}] } else { if ![info exists multirow_name] { set multirow_name bcms_revision_list } - db_multirow $multirow_name get_revisions "SQL" + db_multirow $multirow_name get_revisions {} } } @@ -171,7 +182,7 @@ # lets determine the content type and query from that view if {[info exists additional_properties]} { - if {[db_0or1row get_1revision "SQL" -column_array one_revision]} { + if {[db_0or1row get_1revision {} -column_array one_revision]} { set content_type [bcms::item::get_content_type -item_id $one_revision(item_id)] set table_name [bcms::get_table_name -object_type $content_type] @@ -183,7 +194,7 @@ } } - if {[db_0or1row get_1revision "SQL" -column_array one_revision]} { + if {[db_0or1row get_1revision {} -column_array one_revision]} { return [array get one_revision] } else { return 0 @@ -200,6 +211,13 @@ {-mime_type} } { Edit a revision's title, description, mime type, content and binary content + + @param revision_id revision which to edit + @param title set to this title + @param description set to this description + @param content set to this content + @param upload_file set to this file + @param mime_type set to this mime_type } { set update_list [list] @@ -239,7 +257,7 @@ } } set update_string [join $update_list ","] - db_dml update_revision "SQL" + db_dml update_revision {} } } @@ -252,10 +270,14 @@ 2 or more revisions. Will not delete if there is only one revision. You can try bcms::item::delete_item if you want to remove an item. + + @param revision_id id of the revision to delete + + @returns 1 if the deletion is successful, 0 if not. } { - set revision_count [db_string get_revision_count "SQL"] + set revision_count [db_string get_revision_count {}] if {$revision_count > 1} { - db_exec_plsql delete_revision "SQL" + db_exec_plsql delete_revision {} return 1 } else { return 0 @@ -269,11 +291,20 @@ } { sets a revision to live or production, normally the query to know what to publish is the revision that is set to live + + @param revision_id revision id to change the status + @param status the the status to this value, currently accepted are live and production } { switch -exact $status { - "live" {db_exec_plsql set_live "SQL"} - "production" {db_exec_plsql unset_live "SQL"} + "live" {db_exec_plsql set_live {}} + "production" {db_exec_plsql unset_live {}} + default { + # abort the proc + ns_log debug "bcms: revision status is unknown" + error "setting to a unknown status" + return + } } } @@ -296,6 +327,6 @@ 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] } - return [db_exec_plsql copy_revision "SQL"] + return [db_exec_plsql copy_revision {}] }