Index: openacs-4/packages/acs-content-repository/tcl/content-folder-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/content-folder-procs.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/acs-content-repository/tcl/content-folder-procs.tcl 7 Dec 2004 06:23:28 -0000 1.5 +++ openacs-4/packages/acs-content-repository/tcl/content-folder-procs.tcl 21 Jan 2005 14:25:07 -0000 1.6 @@ -21,7 +21,7 @@ {-description ""} {-creation_user ""} {-creation_ip ""} - {-creation_date ""} + -creation_date {-context_id ""} {-package_id ""} } { @@ -59,9 +59,12 @@ # FIXME or should this use package instantiate object which is a # little smarter set var_list [list] - foreach var [list folder_id name label description parent_id context_id package_id creation_date] { + foreach var [list folder_id name label description parent_id context_id package_id] { lappend var_list [list $var [set $var]] } + if {[exists_and_not_null creation_date]} { + lappend var_list [list creation_date $creation_date] + } set folder_id [package_instantiate_object \ -creation_user $creation_user \ -creation_ip $creation_ip \ 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 -r1.8 -r1.9 --- openacs-4/packages/acs-content-repository/tcl/content-item-procs.tcl 6 Jan 2005 16:53:57 -0000 1.8 +++ openacs-4/packages/acs-content-repository/tcl/content-item-procs.tcl 21 Jan 2005 14:25:07 -0000 1.9 @@ -32,7 +32,7 @@ {-storage_type "file"} {-attributes ""} } { - @author Dave Bauer (dave@etthedesignexperience.org) + @author Dave Bauer (dave@thedesignexperience.org) @creation-date 2004-05-28 Create a new content item This proc creates versioned content @@ -54,9 +54,14 @@ @param creation_date - defaults to current date and time @param storage_type - file, lob, or text (postgresql only) @param locale - + @param title - title of content_revision to be created + @param description of content_revision to be created + @param text - text of content revision to be created + @param attributes - A list of lists ofpairs of additional attributes and + their values to pass to the constructor. Each pair is a list of two + elements: key => value such as + [list [list attribute value] [list attribute value]] - @param attributes - A list of pairs of additional attributes and their values to pass to the constructor. Each pair is a list of two elements: key => value - @return item_id of the new content item @see content::symlink::new content::extlink::new content::folder::new @@ -73,29 +78,48 @@ [list creation_ip $creation_ip ] \ [list item_subtype $item_subtype ] \ [list content_type $content_type ] \ - [list title $title ] \ - [list description $description ] \ [list mime_type $mime_type ] \ [list nls_language $nls_language ] \ - [list text $text ] \ - [list data $data ] \ [list relation_tag $relation_tag ] \ [list is_live $is_live ] \ [list storage_type $storage_type] + # we don't pass title, text, or data to content_item__new + # because the magic revision creation of the pl/sql proc does + # not create a proper subtype of content revision, also it + # can't set attributes of an extended type + # the content type is not the object type of the cr_item so we pass in # the cr_item subtype here and content_type as part of # var_list - ns_log Debug " -DB -------------------------------------------------------------------------------- -DB DAVE debugging /var/lib/aolserver/ctk/packages/acs-content-repository/tcl/content-item-procs.tcl -DB -------------------------------------------------------------------------------- -DB var_list = '${var_list}' -DB --------------------------------------------------------------------------------" + set item_id [package_exec_plsql \ -var_list $var_list \ content_item new] + # if we have attributes we pass in everything + # 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] \ + || [llength $attributes]} { + content::revision::new \ + -item_id $item_id \ + -title $title \ + -description $description \ + -content $text \ + -mime_type $mime_type \ + -content_type $content_type \ + -is_live $is_live \ + -attributes $attributes + } + return $item_id + } ad_proc -public ::content::item::delete { @@ -156,62 +180,34 @@ ad_proc -public ::content::item::get { -item_id:required - {-array "content_item"} {-revision "live"} - {-revision_id ""} - {-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 } { - upvar $array content_item - - array set content_item {} - if {![string equal "" $item_id]} { - item::get -item_id $item_id -array item - } else { - db_1row get_item_from_revision_id "select * from cr_items where item_id=(select item_id from cr_revisions where revision_id=:revision_id)" -column_array item + upvar $array_name local_array + if {[lsearch {live latest} $revision] == -1} { + error "content::item::get revision was '${revision}'. It must be 'live' or 'latest'" } - if {[array size item] < 1} { + 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 } - - acs_object_type::get -object_type $item(content_type) -array object_type - - set revision_id 0 - if {[string equal $revision "live"] && ![empty_string_p $item(live_revision)]} { - set revision_id $item(live_revision) - } elseif {[string equal $revision "best"]} { - if {![empty_string_p $item(live_revision)]} { - set revision_id $item(live_revision) - } else { - set revision_id $item(latest_revision) - } - } elseif {[string equal $revision "latest"]} { - set revision_id $item(latest_revision) - } - - if {!$revision_id} { - return 0 - } - - # content array will be set by item::get_conrent_revision - item::get_revision_content $revision_id - - set content_item_list [array get item] - append content_item_list " [array get content]" - - array set content_item $content_item_list - - return 1 + 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 { @@ -581,7 +577,7 @@ ad_proc -public content::item::relate { -item_id:required -object_id:required - {-relation_tag "generic"} + {-relation_tag ""} {-order_n ""} {-relation_type "cr_item_rel"} } { @@ -605,7 +601,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-keyword-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/content-keyword-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-content-repository/tcl/content-keyword-procs.tcl 7 Dec 2004 06:58:56 -0000 1.3 +++ openacs-4/packages/acs-content-repository/tcl/content-keyword-procs.tcl 21 Jan 2005 14:25:07 -0000 1.4 @@ -157,10 +157,10 @@ {-description ""} {-parent_id ""} {-keyword_id ""} - {-creation_date ""} + -creation_date {-creation_user ""} {-creation_ip ""} - {-object_type ""} + -object_type } { @param heading @param description @@ -173,16 +173,21 @@ @return keyword_id of created keyword } { - return [package_exec_plsql -var_list [list \ + set var_list [list \ [list heading $heading ] \ [list description $description ] \ [list parent_id $parent_id ] \ [list keyword_id $keyword_id ] \ - [list creation_date $creation_date ] \ [list creation_user $creation_user ] \ [list creation_ip $creation_ip ] \ - [list object_type $object_type ] \ - ] content_keyword new] + ] + if {[exists_and_not_null creation_date]} { + lappend var_list [list creation_date $creation_date ] + } + if {[exists_and_not_null object_type]} { + lappend var_list [list object_type $object_type ] + } + return [package_exec_plsql -var_list $var_list content_keyword new] } 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 -r1.4 -r1.5 --- openacs-4/packages/acs-content-repository/tcl/content-revision-procs.tcl 7 Dec 2004 08:09:35 -0000 1.4 +++ openacs-4/packages/acs-content-repository/tcl/content-revision-procs.tcl 21 Jan 2005 14:25:07 -0000 1.5 @@ -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 @@ -59,7 +60,10 @@ @param creation_ip - @param attributes + @param attributes A list of lists of pairs of additional attributes and + their values to pass to the constructor. Each pair is a list of two + elements: key => value such as + [list [list attribute value] [list attribute value]] @return @@ -75,7 +79,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 $item_id] } set attribute_names "" set attribute_values "" @@ -93,14 +97,13 @@ } } foreach attribute_pair $attributes { - set attribute_name [lindex $attribute_pair 0] - set attribute_value [lindex $attribute_pair 1] + foreach {attribute_name attribute_value} $attribute_pair {break} if {[lsearch $valid_attributes $attribute_name] > -1} { + # first add the column name to the list + append attribute_names ", ${attribute_name}" # create local variable to use for binding - set $attribute_name $attribute_value - append attribute_names ", ${attribute_name}" append attribute_values ", :${attribute_name}" } } @@ -118,7 +121,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/content-symlink-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/content-symlink-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-content-repository/tcl/content-symlink-procs.tcl 7 Dec 2004 08:28:20 -0000 1.3 +++ openacs-4/packages/acs-content-repository/tcl/content-symlink-procs.tcl 21 Jan 2005 14:25:07 -0000 1.4 @@ -62,7 +62,7 @@ -target_id:required -parent_id:required {-symlink_id ""} - {-creation_date ""} + -creation_date {-creation_user ""} {-creation_ip ""} } { @@ -77,16 +77,19 @@ @return NUMBER(38) } { - return [package_exec_plsql -var_list [list \ + set var_list [list \ [list name $name ] \ [list label $label ] \ [list target_id $target_id ] \ [list parent_id $parent_id ] \ [list symlink_id $symlink_id ] \ - [list creation_date $creation_date ] \ [list creation_user $creation_user ] \ [list creation_ip $creation_ip ] \ - ] content_symlink new] + ] + if {[exists_and_not_null creation_date]} { + lappend var_list [list creation_date $creation_date ] + } + return [package_exec_plsql -var_list $var_list content_symlink new] } Index: openacs-4/packages/acs-content-repository/tcl/content-type-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/content-type-procs.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/acs-content-repository/tcl/content-type-procs.tcl 14 Dec 2004 15:51:17 -0000 1.6 +++ openacs-4/packages/acs-content-repository/tcl/content-type-procs.tcl 21 Jan 2005 14:25:07 -0000 1.7 @@ -20,7 +20,7 @@ -pretty_name:required -pretty_plural:required {-table_name ""} - {-id_column ""} + -id_column:required {-name_method ""} } { @param content_type @@ -76,7 +76,8 @@ @param pretty_plural @param sort_order @param default_value - @param column_spec + @param column_spec Specification for column to pass to the + database. Not optional if the column does not already exist in the table. @return attribute_id for created attribute } { Index: openacs-4/packages/acs-content-repository/tcl/filter-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/filter-procs-oracle.xql,v diff -u -r1.8 -r1.9 --- openacs-4/packages/acs-content-repository/tcl/filter-procs-oracle.xql 5 Jun 2004 14:08:37 -0000 1.8 +++ openacs-4/packages/acs-content-repository/tcl/filter-procs-oracle.xql 21 Jan 2005 14:25:07 -0000 1.9 @@ -65,7 +65,7 @@ from cr_items where - item_id = content_item.get_id(:url, :content_root, :resolve_index) + item_id = content_item.get_id(:url, :content_root) Index: openacs-4/packages/acs-content-repository/tcl/filter-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/filter-procs-postgresql.xql,v diff -u -r1.10 -r1.11 --- openacs-4/packages/acs-content-repository/tcl/filter-procs-postgresql.xql 5 Jun 2004 14:08:37 -0000 1.10 +++ openacs-4/packages/acs-content-repository/tcl/filter-procs-postgresql.xql 21 Jan 2005 14:25:07 -0000 1.11 @@ -49,7 +49,7 @@ from cr_items where - item_id = content_item__get_id(:url, :content_root, :resolve_index) + item_id = content_item__get_id(:url, :content_root, 'f')