Index: openacs-4/contrib/packages/bcms/sql/postgresql/bcms-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms/sql/postgresql/bcms-create.sql,v diff -u -r1.7 -r1.8 --- openacs-4/contrib/packages/bcms/sql/postgresql/bcms-create.sql 9 Oct 2003 09:57:17 -0000 1.7 +++ openacs-4/contrib/packages/bcms/sql/postgresql/bcms-create.sql 27 Oct 2003 10:09:10 -0000 1.8 @@ -341,3 +341,94 @@ return child_id; end;' language 'plpgsql'; + +-- patched, there is a big problem when this function is called many times in a short time. +create or replace function content_item__get_path (integer,integer) +returns varchar as ' +declare + get_path__item_id alias for $1; + get_path__root_folder_id alias for $2; -- default null + v_count integer; + v_resolved_root_id integer; + v_path text default ''''; + v_rec record; +begin + + -- check that the item exists + select count(*) into v_count from cr_items where item_id = get_path__item_id; + + if v_count = 0 then + raise EXCEPTION ''-20000: Invalid item ID: %'', get_path__item_id; + end if; + + -- begin walking down the path to the item (from the repository root) + + -- if the root folder is not null then prepare for a relative path + + if get_path__root_folder_id is not null then + + -- if root_folder_id is a symlink, resolve it (child items will point + -- to the actual folder, not the symlink) + + v_resolved_root_id := content_symlink__resolve(get_path__root_folder_id); + + -- check to see if the item is under or out side the root_id + PERFORM 1 from cr_items i, + (select tree_sortkey from cr_items where item_id = v_resolved_root_id) a + where tree_ancestor_p(a.tree_sortkey, i.tree_sortkey) and i.item_id = get_path__item_id; + + if NOT FOUND then + -- if not found then we need to go up the folder and append ../ until we have common ancestor + + for v_rec in select i1.name, i1.parent_id, tree_level(i1.tree_sortkey) as tree_level + from cr_items i1, (select tree_ancestor_keys(tree_sortkey) as tree_sortkey from cr_items where item_id = v_resolved_root_id) i2, + (select tree_sortkey from cr_items where item_id = get_path__item_id) i3 + where + i1.parent_id <> 0 + and i2.tree_sortkey = i1.tree_sortkey + and not tree_ancestor_p(i2.tree_sortkey, i3.tree_sortkey) + order by tree_level desc + LOOP + v_path := v_path || ''../''; + end loop; + -- lets now assign the new root_id to be the last parent_id on the loop + v_resolved_root_id := v_rec.parent_id; + + end if; + + -- go downwards the tree and append the name and / + for v_rec in select i1.name, i1.item_id, tree_level(i1.tree_sortkey) as tree_level + from cr_items i1, (select tree_sortkey from cr_items where item_id = v_resolved_root_id) i2, + (select tree_ancestor_keys(tree_sortkey) as tree_sortkey from cr_items where item_id = get_path__item_id) i3 + where + i1.tree_sortkey = i3.tree_sortkey + and i1.tree_sortkey > i2.tree_sortkey + order by tree_level + LOOP + v_path := v_path || v_rec.name; + if v_rec.item_id <> get_path__item_id then + -- put a / if we are still going down + v_path := v_path || ''/''; + end if; + end loop; + + else + + -- this is an absolute path so prepend a ''/'' + -- loop over the absolute path + + for v_rec in select i2.name, tree_level(i2.tree_sortkey) as tree_level + from cr_items i1, cr_items i2 + where i2.parent_id <> 0 + and i1.item_id = get_path__item_id + and i1.tree_sortkey between i2.tree_sortkey and tree_right(i2.tree_sortkey) + order by tree_level + LOOP + v_path := v_path || ''/'' || v_rec.name; + end loop; + + end if; + + return v_path; + +end;' language 'plpgsql'; Index: openacs-4/contrib/packages/bcms/tcl/bcms-folder-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms/tcl/bcms-folder-procs.tcl,v diff -u -r1.9 -r1.10 --- openacs-4/contrib/packages/bcms/tcl/bcms-folder-procs.tcl 14 Oct 2003 13:58:56 -0000 1.9 +++ openacs-4/contrib/packages/bcms/tcl/bcms-folder-procs.tcl 27 Oct 2003 10:09:10 -0000 1.10 @@ -5,6 +5,7 @@ @author Jun Yamog @creation-date 10 Aug 2002 @cvs-id $Id$ + @cvs-id $Id$ } namespace eval bcms::folder {} Index: openacs-4/contrib/packages/bcms/tcl/bcms-item-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms/tcl/bcms-item-procs.tcl,v diff -u -r1.7 -r1.8 --- openacs-4/contrib/packages/bcms/tcl/bcms-item-procs.tcl 14 Oct 2003 14:58:31 -0000 1.7 +++ openacs-4/contrib/packages/bcms/tcl/bcms-item-procs.tcl 27 Oct 2003 10:09:10 -0000 1.8 @@ -587,41 +587,61 @@ ad_proc -public bcms::item::format_string_as_url { {-url:required} + {-truncate 10} } { trim the string to format as url } { set url [string trim $url] - regsub -all " " $url "" url + regsub -all " " $url "" url regsub -all {([^a-zA-Z0-9])} $url "" url - return $url + + + return [string range [string tolower $url] 0 $truncate] } ad_proc -public bcms::item::is_item_duplicate_p { {-url:required} {-root_id:required} + {-item_id 0} } { checks if given url is a duplicate - returns 1 if duplicate - 0 if not + + @param url url to check + @param root_id where to start traversing the url + @param item_id id of the item being checked + + @return 1 if duplicate 0 if not } { - array set item_tester [bcms::item::get_item_by_url -url $url -root_id $root_id ] - return [array size item_tester] + set duplicate_p 0 + array set existing_item [bcms::item::get_item_by_url -url $url -root_id $root_id] + + if {([array size existing_item] > 0)} { + if {($existing_item(item_id) != $item_id)} { + set duplicate_p 1 + } + } + + return $duplicate_p } ad_proc -public bcms::item::item_url_duplicate_test { {-url:required} {-root_id:required} - {-count:required} + {-count 10} } { this eliminates the chance of having dupplicate pages it checks if url exists, if it does it then pads a 1 after url } { set ctr 0 - while { ([bcms::item::is_item_duplicate_p -url $url -root_id $root_id] > 0) && ($ctr < $count) } { - set url "${url}1" - set ctr [expr $ctr + 1] + while { ([bcms::item::is_item_duplicate_p -url $url -root_id $root_id] > 0) && ($ctr <= $count) } { + set url "${url}1" + set ctr [expr $ctr + 1] } - return $url + if {$ctr > $count} { + error "too many duplicate names/url on this folder. + either increase the count param or pass in more unique name/url" + } + return $url } Index: openacs-4/contrib/packages/bcms/tcl/bcms-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms/tcl/bcms-procs.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/contrib/packages/bcms/tcl/bcms-procs.tcl 5 Oct 2003 12:28:03 -0000 1.4 +++ openacs-4/contrib/packages/bcms/tcl/bcms-procs.tcl 27 Oct 2003 10:09:10 -0000 1.5 @@ -215,3 +215,58 @@ return $file_id } + +ad_proc -public bcms::parse_properties { + {-properties:required} + {-return_format:required} + {-uplevel_level 1} +} { + parses properties returns strings to be used for insert or update sql strings + + @param properites a list of properties / columns to insert format: {property value ... property value} + {property:noquote value} will directly use what is in value + @param return_format either "insert_values", "insert_columns" or "update" + @param uplevel_level if you need to set the quoted vars to another level use this to set the proper uplevel +} { + + # create the properties + set properties_list {} + set values_list {} + foreach one_property $properties { + set property [lindex $one_property 0] + set value [lrange $one_property 1 [llength $one_property]] + if {[regexp {(.+):noquote$} $property match property]} { + #if noquote then use what is in the value + lappend values_list $value + } else { + lappend values_list :__$property + upvar $uplevel_level "__$property" localvar + set localvar $value + } + lappend properties_list $property + } + + switch -exact $return_format { + insert_values { + set insert_values "[join $values_list ","]" + return $insert_values + } + insert_columns { + set insert_columns "[join $properties_list ","]" + return $insert_columns + } + update { + set index 0 + set update_list {} + foreach one_property $properties_list { + lappend update_list "$one_property = [lindex $values_list $index]" + incr index + } + set update_string "[join $update_list ", "]" + return $update_string + } + default { + error "invalid return_format" + } + } +} Index: openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs-postgresql.xql,v diff -u -r1.4 -r1.5 --- openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs-postgresql.xql 9 Oct 2003 09:57:17 -0000 1.4 +++ openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs-postgresql.xql 27 Oct 2003 10:09:10 -0000 1.5 @@ -33,10 +33,11 @@ select x.revision_id, x.name, x.title, x.description, p.first_names, p.last_name, - to_char(x.creation_date,'HH:MI AM MM/DD/YYYY') as creation_date, l.live_revision_id + to_char(x.last_modified,'HH:MI AM MM/DD/YYYY') as creation_date, l.live_revision_id from ${table_name}x x, persons p, (select content_item__get_live_revision(:item_id) as live_revision_id) l where x.creation_user = p.person_id - and x.item_id = :item_id; + and x.item_id = :item_id + order by x.last_modified desc; 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 -r1.7 -r1.8 --- openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs.tcl 9 Oct 2003 09:57:17 -0000 1.7 +++ openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs.tcl 27 Oct 2003 10:09:10 -0000 1.8 @@ -36,25 +36,19 @@ @param creation_user_id user_id creating this item @param creation_user_ip ip address which this item is created @param additional_properites a list of additional properties / columns to insert format: {property value ... property value} + {property:noquote value} will directly use what is value @returns revision_id of newly created 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] } - # create the additional properties - set addtnl_properties "" - set addtnl_values "" - set addtnl_properties_list {} - set addtnl_values_list {} - if {[exists_and_not_null additional_properties]} { - foreach {property value} $additional_properties { - lappend addtnl_properties_list $property - lappend addtnl_values_list :__$property - set __$property $value - } - set addtnl_properties ",[join $addtnl_properties_list ","]" - set addtnl_values ",[join $addtnl_values_list ","]" + if {[info exists additional_properties]} { + set addtnl_properties ", [bcms::parse_properties -properties $additional_properties -return_format insert_columns]" + set addtnl_values ", [bcms::parse_properties -properties $additional_properties -return_format insert_values]" + } else { + set addtnl_properties "" + set addtnl_values "" } if ![info exists content_type] { @@ -96,7 +90,7 @@ @param creation_user_id user_id creating this item @param creation_user_ip ip address which this item is created @param additional_properites a list of additional properties / columns to insert format: {property value ... property value} - + {property:noquote value} will directly use what is value } { 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] } @@ -114,22 +108,16 @@ } # check the mime type if it does not exists insert it if ![db_0or1row check_mime "SQL"] { + set file_extension [string range [file extension $upload_filename] 1 last] db_dml new_mime_type "SQL" } - # create the additional properties - set addtnl_properties "" - set addtnl_values "" - set addtnl_properties_list {} - set addtnl_values_list {} - if {[exists_and_not_null additional_properties]} { - foreach {property value} $additional_properties { - lappend addtnl_properties_list $property - lappend addtnl_values_list :__$property - set __$property $value - } - set addtnl_properties ",[join $addtnl_properties_list ","]" - set addtnl_values ",[join $addtnl_values_list ","]" + if {[info exists additional_properties]} { + set addtnl_properties ", [bcms::parse_properties -properties $additional_properties -return_format insert_columns]" + set addtnl_values ", [bcms::parse_properties -properties $additional_properties -return_format insert_values]" + } else { + set addtnl_properties "" + set addtnl_values "" } db_transaction { Index: openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs.xql,v diff -u -r1.4 -r1.5 --- openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs.xql 5 Oct 2003 12:28:03 -0000 1.4 +++ openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs.xql 27 Oct 2003 10:09:10 -0000 1.5 @@ -45,7 +45,7 @@ - select i.item_id, i.name, r.title, r.description, r.content, + select i.item_id, i.name, i.parent_id, r.title, r.description, r.content, i.content_type, i.publish_status, i.live_revision, i.latest_revision, i.storage_type $addtnl_select from cr_revisions r, cr_items i $addtnl_from where r.revision_id = :revision_id Fisheye: Tag 1.3 refers to a dead (removed) revision in file `openacs-4/contrib/packages/bcms/www/folder-create.adp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/contrib/packages/bcms/www/folder-create.tcl'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.3 refers to a dead (removed) revision in file `openacs-4/contrib/packages/bcms/www/folder-delete.adp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/contrib/packages/bcms/www/folder-delete.tcl'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/contrib/packages/bcms/www/index-postgresql.xql'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/contrib/packages/bcms/www/index.adp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/contrib/packages/bcms/www/index.tcl'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/contrib/packages/bcms/www/index.xql'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/contrib/packages/bcms/www/item-delete.tcl'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.3 refers to a dead (removed) revision in file `openacs-4/contrib/packages/bcms/www/item-list.adp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/contrib/packages/bcms/www/item-list.tcl'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.3 refers to a dead (removed) revision in file `openacs-4/contrib/packages/bcms/www/item-one.adp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/contrib/packages/bcms/www/item-one.tcl'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/contrib/packages/bcms/www/render.tcl'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/contrib/packages/bcms/www/revision-delete.tcl'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/contrib/packages/bcms/www/revision-list.adp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/contrib/packages/bcms/www/revision-list.tcl'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.3 refers to a dead (removed) revision in file `openacs-4/contrib/packages/bcms/www/revision-one.adp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/contrib/packages/bcms/www/revision-one.tcl'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/contrib/packages/bcms/www/revision-set-status.tcl'. Fisheye: No comparison available. Pass `N' to diff?