Index: openacs-4/packages/acs-content-repository/tcl/content-item-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/content-item-procs.tcl,v diff -u -N -r1.7.2.4 -r1.7.2.5 --- openacs-4/packages/acs-content-repository/tcl/content-item-procs.tcl 6 Jan 2005 16:54:54 -0000 1.7.2.4 +++ openacs-4/packages/acs-content-repository/tcl/content-item-procs.tcl 9 Jan 2005 21:59:52 -0000 1.7.2.5 @@ -105,6 +105,9 @@ # and create a revision with all subtype attributes that were # passed in + # since we can't rely on content_item__new to create a revision + # we have to pass is_live to content::revision::new and + # set the live revision there if {[exists_and_not_null title] \ || [exists_and_not_null text] \ || [exists_and_not_null data] \ @@ -116,6 +119,7 @@ -content $text \ -mime_type $mime_type \ -content_type $content_type \ + -is_live $is_live \ -attributes $attributes } @@ -182,22 +186,33 @@ ad_proc -public ::content::item::get { -item_id:required {-revision "live"} - {-attributes ""} + {-array_name "content_item"} } { @author Dave Bauer (dave@thedesignexperience.org) @creation-date 2004-05-28 @param item_id @param revision live, latest, or best (live if it exists, otherwise latest) - @param attributes A list of pairs of additional attributes and their values to get. Each pair is a list of two elements: key => value + @param array_name name of array to upvar content into + @return upvars array_name containing all attributes of the content + type except content + @return returns 0 if item does not exists or 1 if query was sucessful - @return - @error } { - error "not implemented" - + upvar $array_name local_array + if {[lsearch {live latest} $revision] == -1} { + error "content::item::get revision was '${revision}'. It must be 'live' or 'latest'" + } + set content_type [content_type -item_id $item_id] + if {[string equal "" $content_type]} { + # content_type query was unsucessful, item does not exist + return 0 + } + set table_name [db_string get_table_name "select table_name from acs_object_types where object_type=:content_type"] + set table_name "${table_name}x" # get attributes of the content_item use the content_typex view + return [db_0or1row get_item "" -column_array local_array] } ad_proc -public ::content::item::update { @@ -569,7 +584,7 @@ -object_id:required {-relation_tag ""} {-order_n ""} - {-relation_type ""} + {-relation_type "cr_item_rel"} } { @param item_id @param object_id @@ -591,7 +606,7 @@ ad_proc -public content::item::set_live_revision { -revision_id:required - {-publish_status ""} + {-publish_status "ready"} } { @param revision_id @param publish_status Index: openacs-4/packages/acs-content-repository/tcl/content-item-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/content-item-procs.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-content-repository/tcl/content-item-procs.xql 9 Jan 2005 21:59:52 -0000 1.1.2.1 @@ -0,0 +1,26 @@ + + + + + + + + + + + + select cx.*, + ci.live_revision, + ci.latest_revision, + ci.locale, + ci.publish_status, + ci.content_type, + ci.storage_type + from ${table_name} cx, + cr_items ci + where ci.${revision}_revision = cx.revision_id + and ci.item_id = :item_id + + + \ No newline at end of file Index: openacs-4/packages/acs-content-repository/tcl/content-revision-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/content-revision-procs.tcl,v diff -u -N -r1.4.2.1 -r1.4.2.2 --- openacs-4/packages/acs-content-repository/tcl/content-revision-procs.tcl 21 Dec 2004 18:22:33 -0000 1.4.2.1 +++ openacs-4/packages/acs-content-repository/tcl/content-revision-procs.tcl 9 Jan 2005 21:59:52 -0000 1.4.2.2 @@ -26,6 +26,7 @@ {-creation_user} {-creation_ip} {-attributes} + {-is_live "f"} } { Adds a new revision of a content item. If content_type is not passed in, we determine it from the content item. This is needed @@ -75,7 +76,7 @@ } if {![exists_and_not_null content_type]} { - set content_type [item::get_content_type $item_id] + set content_type [::content::item::content_type $item_id] } set attribute_names "" set attribute_values "" @@ -118,7 +119,15 @@ } db_dml insert_revision $query_text } - +ns_log notice " +DB -------------------------------------------------------------------------------- +DB DAVE debugging /var/lib/aolserver/openacs-5-1/packages/acs-content-repository/tcl/content-revision-procs.tcl +DB -------------------------------------------------------------------------------- +DB is_live = '${is_live}' \n +DB revision_id = '${revision_id}'" + if {[string is true $is_live]} { + content::item::set_live_revision -revision_id $revision_id + } return $revision_id } Index: openacs-4/packages/acs-content-repository/tcl/test/content-item-test-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/test/content-item-test-procs.tcl,v diff -u -N -r1.2.2.5 -r1.2.2.6 --- openacs-4/packages/acs-content-repository/tcl/test/content-item-test-procs.tcl 9 Jan 2005 21:01:55 -0000 1.2.2.5 +++ openacs-4/packages/acs-content-repository/tcl/test/content-item-test-procs.tcl 9 Jan 2005 21:59:52 -0000 1.2.2.6 @@ -92,40 +92,32 @@ ] aa_true "Evil_name item created" [expr $evil_item_id == $returned_evil_item_id] - # should be using content::item::get here, but it's not implemented - aa_true "Evil_name item exists" [expr $evil_item_id == \ - [db_string get_item \ - "select item_id from - cr_items where item_id=:evil_item_id and name=:evil_test_name"]] + + aa_true "Evil_name item exists" [expr \ + [content::item::get \ + -item_id $evil_item_id \ + -revision latest \ + -array_name evil_name] == 1] aa_true "Evil_name item's revision exists" \ [expr \ - {![string equal "" \ - [db_string get_revision "select - latest_revision - from cr_items, cr_revisions where latest_revision=revision_id and cr_items.item_id=:evil_item_id" -default ""]]}] + {![string equal "" $evil_name(latest_revision)]}] ######################################################### # delete the evil_name item ######################################################### aa_true "evil_name item deleted" [expr [content::item::delete -item_id $evil_item_id] == 0] + array unset evil_name + aa_true "evil_name item no longer exists" [expr \ + [content::item::get \ + -item_id $evil_item_id \ + -revision "latest" \ + -array_name evil_name] == 0] + aa_true "evil_name item revision does not exist" [expr \ + ![info exists evil(latest_revision)]] - # should be using content::item::get here, but it's not implemented - aa_true "evil_name item no longer exists" [string equal \ - [db_string get_item "select item_id - from cr_items - where item_id=:evil_item_id - and name='$evil_test_name'" -default "no"] "no"] - set evil_item_revision [db_string get_revision "select latest_revision - from cr_items, - cr_revisions - where latest_revision=revision_id - and cr_items.item_id=:evil_item_id" -default "no"] - aa_true "evil_name item revision does not exist" [string equal $evil_item_revision "no"] - - ######################################################### # create a new content type ######################################################### @@ -161,21 +153,17 @@ ######################################################### aa_true "New Type item created" [expr $new_type_item_id == $returned_new_type_item_id] - aa_true "New Type item exists" [expr $new_type_item_id == \ - [db_string get_item \ - "select item_id from - cr_items where item_id=:new_type_item_id and name='test_item_${new_type_item_id}'" -default ""]] + aa_true "New Type item exists" [expr [content::item::get \ + -item_id $new_type_item_id \ + -revision "latest" \ + -array_name new_type_item] == 1] ######################################################### # check that the extended attributes and the revision # exist ######################################################### - aa_true "First item's revision exists" \ - [expr \ - {![string equal "" \ - [db_string get_revision "select - latest_revision - from cr_items, __test_typex where latest_revision=test_id and cr_items.item_id=:new_type_item_id" -default ""]]}] + # this test is obselete since content::item::get uses + # the content type view to retreive the latest revision