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.1 -r1.2
--- openacs-4/contrib/packages/bcms/sql/postgresql/bcms-create.sql 14 May 2003 15:34:18 -0000 1.1
+++ openacs-4/contrib/packages/bcms/sql/postgresql/bcms-create.sql 4 Aug 2003 11:19:46 -0000 1.2
@@ -3,28 +3,29 @@
--
-- @author
-- @create-date 10 Aug 2002
--- @cvs-id $Id
+-- @cvs-id $Id$
--
-- creates bcms content types
+-- TODO look into if we need to define the extra content types
+
-- this content type are just for convinience, bcms_page are the text pages, bcms_file are binary files
-- bcms_images are for images
-select content_type__create_type ('bcms_page', 'content_revision', 'BCMS Page', 'BCMS Pages', 'cr_bcms_pages', 'page_id', null);
-select content_type__create_type ('bcms_file', 'content_revision', 'BCMS File', 'BCMS Files', 'cr_bcms_files', 'file_id', null);
--- select content_type__create_type ('bcms_images', 'image', 'BCMS Image', 'BCMS Images', 'cr_bcms_image', 'image_id', null);
+--select content_type__create_type ('bcms_page', 'content_revision', 'BCMS Page', 'BCMS Pages', 'cr_bcms_pages', 'page_id', null);
+--select content_type__create_type ('bcms_file', 'content_revision', 'BCMS File', 'BCMS Files', 'cr_bcms_files', 'file_id', null);
-- bcms_links are external links... href values
-select content_type__create_type ('bcms_link', 'content_revision', 'BCMS Link', 'BCMS Links', 'cr_bcms_links', 'link_id', null);
+--select content_type__create_type ('bcms_link', 'content_revision', 'BCMS Link', 'BCMS Links', 'cr_bcms_links', 'link_id', null);
-- bcms_nav nav links are used to build the navigation
-select acs_object_type__create_type ('bcms_navlink', 'BCMS Navigation Link', 'BCMS Navigation Links', 'content_item', 'cr_bcms_navlinks', 'navlink_id', null, 'f', null, null);
-select acs_attribute__create_attribute ('bcms_navlink', 'nav_object_id', 'integer', 'Navigation Object ID', 'Navigation Object IDs', null, null, null, 1, 1, null, 'type_specific', 'f');
-select acs_attribute__create_attribute ('bcms_navlink', 'sort_key', 'integer', 'Sort Key', 'Sort Keys', null, null, null, 1, 1, null, 'type_specific', 'f');
+--select acs_object_type__create_type ('bcms_navlink', 'BCMS Navigation Link', 'BCMS Navigation Links', 'content_item', 'cr_bcms_navlinks', 'navlink_id', null, 'f', null, null);
+--select acs_attribute__create_attribute ('bcms_navlink', 'nav_object_id', 'integer', 'Navigation Object ID', 'Navigation Object IDs', null, null, null, 1, 1, null, 'type_specific', 'f');
+--select acs_attribute__create_attribute ('bcms_navlink', 'sort_key', 'integer', 'Sort Key', 'Sort Keys', null, null, null, 1, 1, null, 'type_specific', 'f');
-- create the relations, bcms_page may relate to another page, file, image
-select content_type__register_relation_type ('bcms_page', 'bcms_page', 'pages', '0', null);
-select content_type__register_relation_type ('bcms_page', 'bcms_file', 'files', '0', null);
-select content_type__register_relation_type ('bcms_page', 'image', 'images', '0', null);
+--select content_type__register_relation_type ('bcms_page', 'bcms_page', 'pages', '0', null);
+--select content_type__register_relation_type ('bcms_page', 'bcms_file', 'files', '0', null);
+--select content_type__register_relation_type ('bcms_page', 'image', 'images', '0', null);
create or replace function bcms__get_title(integer, varchar)
returns varchar as '
@@ -47,15 +48,15 @@
-- lets get the revision_id of what we are interested in
-- live or latest
- if p_revision = ''live_revision'' then
+ if p_revision = ''live'' then
select r.title into v_title
from cr_items i, cr_revisions r
where i.parent_id = p_item_id
and i.name = ''index''
and r.revision_id = i.live_revision;
return v_title;
end if;
- if p_revision = ''latest_revision'' then
+ if p_revision = ''latest'' then
select r.title into v_title
from cr_items i, cr_revisions r
where i.parent_id = p_item_id
@@ -70,14 +71,14 @@
-- lets get the revision_id of what we are interested in
-- live or latest
- if p_revision = ''live_revision'' then
+ if p_revision = ''live'' then
select r.title into v_title
from cr_items i, cr_revisions r
where i.item_id = p_item_id
and r.revision_id = i.live_revision;
return v_title;
end if;
- if p_revision = ''latest_revision'' then
+ if p_revision = ''latest'' then
select r.title into v_title
from cr_items i, cr_revisions r
where i.item_id = p_item_id
@@ -89,7 +90,129 @@
end;
' language 'plpgsql';
+
+-- patched function
+create or replace function content_item__delete (integer)
+returns integer as '
+declare
+ delete__item_id alias for $1;
+ -- v_wf_cases_val record;
+ v_symlink_val record;
+ v_revision_val record;
+ v_rel_val record;
+begin
+ -- Removed this as having workflow stuff in the CR is just plain wrong.
+ -- DanW, Aug 25th, 2001.
+ -- raise NOTICE ''Deleting associated workflows...'';
+ -- 1) delete all workflow cases associated with this item
+ -- for v_wf_cases_val in select
+ -- case_id
+ -- from
+ -- wf_cases
+ -- where
+ -- object_id = delete__item_id
+ -- LOOP
+ -- PERFORM workflow_case__delete(v_wf_cases_val.case_id);
+ -- end loop;
-
+ raise NOTICE ''Deleting symlinks...'';
+ -- 2) delete all symlinks to this item
+ for v_symlink_val in select
+ symlink_id
+ from
+ cr_symlinks
+ where
+ target_id = delete__item_id
+ LOOP
+ PERFORM content_symlink__delete(v_symlink_val.symlink_id);
+ end loop;
+
+ raise NOTICE ''Unscheduling item...'';
+ delete from cr_release_periods
+ where item_id = delete__item_id;
+
+ raise NOTICE ''Deleting associated revisions...'';
+ -- 3) delete all revisions of this item
+ delete from cr_item_publish_audit
+ where item_id = delete__item_id;
+
+ for v_revision_val in select
+ revision_id
+ from
+ cr_revisions
+ where
+ item_id = delete__item_id
+ LOOP
+ PERFORM acs_object__delete(v_revision_val.revision_id);
+ end loop;
+
+ raise NOTICE ''Deleting associated item templates...'';
+ -- 4) unregister all templates to this item
+ delete from cr_item_template_map
+ where item_id = delete__item_id;
+
+ raise NOTICE ''Deleting item relationships...'';
+ -- Delete all relations on this item
+ for v_rel_val in select
+ rel_id
+ from
+ cr_item_rels
+ where
+ item_id = delete__item_id
+ or
+ related_object_id = delete__item_id
+ LOOP
+ PERFORM acs_rel__delete(v_rel_val.rel_id);
+ end loop;
+
+ raise NOTICE ''Deleting child relationships...'';
+ for v_rel_val in select
+ rel_id
+ from
+ cr_child_rels
+ where
+ child_id = delete__item_id
+ LOOP
+ PERFORM acs_rel__delete(v_rel_val.rel_id);
+ end loop;
+
+ raise NOTICE ''Deleting parent relationships...'';
+ for v_rel_val in select
+ rel_id, child_id
+ from
+ cr_child_rels
+ where
+ parent_id = delete__item_id
+ LOOP
+ PERFORM acs_rel__delete(v_rel_val.rel_id);
+ PERFORM content_item__delete(v_rel_val.child_id);
+ end loop;
+
+ raise NOTICE ''Deleting associated permissions...'';
+ -- 5) delete associated permissions
+ delete from acs_permissions
+ where object_id = delete__item_id;
+
+ raise NOTICE ''Deleting keyword associations...'';
+ -- 6) delete keyword associations
+ delete from cr_item_keyword_map
+ where item_id = delete__item_id;
+
+ raise NOTICE ''Deleting associated comments...'';
+ -- 7) delete associated comments
+ PERFORM journal_entry__delete_for_object(delete__item_id);
+
+ -- context_id debugging loop
+ --for v_error_val in c_error_cur loop
+ -- raise NOTICE ''ID='' || v_error_val.object_id || '' TYPE=''
+ -- || v_error_val.object_type);
+ --end loop;
+
+ raise NOTICE ''Deleting content item...'';
+ delete from cr_items where item_id = delete__item_id;
+ PERFORM acs_object__delete(delete__item_id);
+
+ return 0;
+end;' language 'plpgsql';
Index: openacs-4/contrib/packages/bcms/tcl/bcms-folder-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms/tcl/bcms-folder-procs-postgresql.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/bcms/tcl/bcms-folder-procs-postgresql.xql 14 May 2003 15:34:59 -0000 1.1
+++ openacs-4/contrib/packages/bcms/tcl/bcms-folder-procs-postgresql.xql 4 Aug 2003 11:19:46 -0000 1.2
@@ -4,72 +4,61 @@
postgresql7.2
-
-
- select content_item__get_root_folder(null);
-
-
+
+
+ select content_item__get_root_folder(null);
+
+
-
-
- select f.folder_id, i.name, f.label, f.has_child_folders, tree_level(i.tree_sortkey) as level,
- tree_level(p.tree_sortkey) as parent_level
- $addtnl_select
- from cr_items i, cr_folders f,
- (select tree_sortkey from cr_items where item_id = :parent_id) p
- where f.folder_id = i.item_id
- and tree_ancestor_p(p.tree_sortkey, i.tree_sortkey)
- $addtnl_where
- order by i.tree_sortkey
-
-
+
+
+ select f.folder_id,
+ i.name,
+ i.parent_id,
+ f.label,
+ f.has_child_folders,
+ f.has_child_symlinks,
+ f.package_id
+ from cr_items i, cr_folders f
+ where f.folder_id = i.item_id
+ and i.parent_id = :parent_id
+ order by i.tree_sortkey
+
+
-
-
- select a.item_id as folder_id, o.name, f.label, f.has_child_folders, tree_level(a.tree_sortkey_trail) as level,
- tree_level(parent_sortkey) as parent_level
- $addtnl_select
- from cr_items o, cr_folders f,
- (select tree_ancestor_keys(i.tree_sortkey) as tree_sortkey_trail, p.tree_sortkey as parent_sortkey, i.item_id, i.tree_sortkey
- from cr_items i,
- (select tree_sortkey from cr_items where item_id = :parent_id) p
- where tree_ancestor_p(p.tree_sortkey, i.tree_sortkey)
- and content_type = 'content_folder'
- $addtnl_where) a
- where o.item_id = f.folder_id
- and o.tree_sortkey = a.tree_sortkey_trail
- and tree_ancestor_p(parent_sortkey, o.tree_sortkey)
- order by a.tree_sortkey
-
-
+
+
+ select f.folder_id,
+ i.name,
+ i.parent_id,
+ f.label,
+ f.has_child_folders,
+ f.has_child_symlinks,
+ f.package_id,
+ tree_level(i.tree_sortkey) as level,
+ tree_level(p.tree_sortkey) as parent_level,
+ :prepend_path || content_item__get_path(f.folder_id, p.item_id) as path
+ from cr_items i, cr_folders f,
+ (select item_id, tree_sortkey from cr_items where item_id = :parent_id) p
+ where
+ f.folder_id = i.item_id
+ and i.tree_sortkey between p.tree_sortkey and tree_right(p.tree_sortkey)
+ and i.item_id <> p.item_id
+ order by i.tree_sortkey
+
+
-
-
- select content_folder__new(:name, :folder_label, :description, :parent_id)
+
+
+ select content_folder__new(:name, :folder_label, :description, :parent_id)
+
+
-
-
+
+
+ select content_folder__delete(:folder_id)
+
+
-
-
- select content_folder__delete(:folder_id)
-
-
-
-
-
-
-
-
- select label as folder_name, folder_id, tree_level(i.tree_sortkey) as level,
- tree_level(a.tree_sortkey) as parent_level
- from cr_folders f, cr_items i,
- (select tree_sortkey from cr_items where item_id = :bcms_parent_folder) a
- where i.item_id = f.folder_id
- and tree_ancestor_p(a.tree_sortkey, i.tree_sortkey)
-
-
-
-
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.1 -r1.2
--- openacs-4/contrib/packages/bcms/tcl/bcms-folder-procs.tcl 14 May 2003 15:34:59 -0000 1.1
+++ openacs-4/contrib/packages/bcms/tcl/bcms-folder-procs.tcl 4 Aug 2003 11:19:46 -0000 1.2
@@ -9,16 +9,19 @@
namespace eval bcms::folder {}
-# for possible contribution
+
ad_proc -public bcms::folder::get_cr_root_folder {} {
Gets the CR Pages root, this is helpful as BCMS will always
- create its root from there. returns the folder_id of cr_folder's Pages root
+ create its root from there.
+
+ @return the folder_id of cr_folder's Pages root
} {
return [db_string get_cr_root_folder "SQL"]
}
+
ad_proc -public bcms::folder::get_bcms_root_folder {} {
- returns the BCMS folder_id based from the current package instance
+ @return the BCMS folder_id based from the current package instance
if it is not setup properly it returns 0
} {
set bcms_root_folder [parameter::get -parameter root_folder_id -default 0]
@@ -30,16 +33,22 @@
}
}
-# for possible contribution - maybe we move this on CR's api
+
ad_proc -public bcms::folder::create_folder {
{-name:required}
{-folder_label:required}
{-parent_id:required}
{-description ""}
} {
- creates a new folder in cr_folders a basic tcl wrapper
- for content_folder__new
- returns the folder_id that was created
+ creates a new folder in cr_folders
+
+ @param name name or url of the folder
+ @param folder_label the label used for the folder, this is the human readable title of
+ the folder
+ @param parent_id the folder_id of which this folder will become a subfolder
+ @param description a description for this folder
+
+ @return the folder_id that was created
} {
set folder_id [db_exec_plsql create_folder "SQL"]
ns_log notice "bcms::folder::create_folder created folder $folder_id"
@@ -51,8 +60,11 @@
ad_proc -public bcms::folder::delete_folder {
{-folder_id:required}
} {
- deletes a cr_folder based from the folder_id, a tcl wrapper
- for content_folder__delete, if its unable to delete the folder
+ deletes a cr_folder based from the folder_id
+
+ @param folder_id of folder you wish to delete
+
+ @return 1 if its able to delete the folder otherwise
it returns 0
} {
# TODO: test of we are catching the error message
@@ -72,7 +84,12 @@
{-label}
{-parent_id}
} {
- edits the folder
+ set/edits the folder properties.
+
+ @param folder_id folder_id of the folder you wish to edit
+ @param name edit the name of the folder
+ @param label edit the label of the folder
+ @param parent_id edit or basically move this folder to another folder
} {
set update_list [list]
@@ -99,9 +116,13 @@
ad_proc -public bcms::folder::get_folder {
{-folder_id:required}
} {
- the the properties of a folder
- which are parent_id, name, label, description, has_child_folders,
- has_child_symlinks, package_id
+ gets the properties of a folder
+
+ @param folder_id you wish to get
+
+ @return an array with the following elments:
+ parent_id, name, label, description, has_child_folders, has_child_symlinks, package_id
+ if no folder is found a blank array is returned
} {
if {[db_0or1row get_1folder "SQL" -column_array one_folder]} {
return [array get one_folder]
@@ -111,127 +132,96 @@
}
+# TODO: to be removed not a general proc
ad_proc -public bcms::folder::get_image_folder { } {
returns the folder_id of the image folder of this bcms instance
} {
array set one_item [bcms::item::get_item_by_url -root_id [get_bcms_root_folder] -url images -resolve_index false]
return $one_item(item_id)
}
+# TODO: to be removed not a general proc
ad_proc -public bcms::folder::get_file_folder { } {
returns the folder_id of the file folder of this bcms instance
} {
array set one_item [bcms::item::get_item_by_url -root_id [get_bcms_root_folder] -url files -resolve_index false]
return $one_item(item_id)
}
+# TODO: to be removed not a general proc
ad_proc -public bcms::folder::get_page_folder { } {
returns the folder_id of the page folder of this bcms instance
} {
array set one_item [bcms::item::get_item_by_url -root_id [get_bcms_root_folder] -url pages -resolve_index false]
return $one_item(item_id)
}
-# TODO: remove level_diff similar to bcms::item::list_items
+
ad_proc -public bcms::folder::list_folders {
{-parent_id}
- {-level_diff 1}
- {-multirow_name}
+ {-multirow_name bcms_list_folders}
{-return_list:boolean false}
} {
returns a listing of the content folder under the parent_id, if
no parent_id is provided the bcms root folder is used as the parent_id
- returns this columns: folder_id, name, label, has_child_folders, level and parent_level
+ @param parent_id lists the folders underneath this folder_id
+ @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
- if -return_list is used it returns a list of ns_sets otherwise it
- returns a multirow uses the multirow_name if given
-
- -with_path return the relative path of items to the parent_id, adds path columns
- that is returns
+ @return this columns: folder_id, name, parent_id, label, has_child_folders,
+ has_child_symlinks, package_id
} {
- # initialize the addtionals we will use
- set addtnl_where_list [list]
- set addtnl_select_list [list]
if ![info exists parent_id] {
# if the parent_id does not exists then start from the root
set parent_id [get_bcms_root_folder]
}
- # TODO: make use of db_map...
- # check to see how deep we want to go
- if {$level_diff != 0} {
- lappend addtnl_where_list ":level_diff >= tree_level(i.tree_sortkey) - tree_level(p.tree_sortkey)"
- }
-
- # construct the additionals
- if {[llength $addtnl_where_list] > 0} {
- set addtnl_where "and [join $addtnl_where_list " and "]"
- } else {
- set addtnl_where ""
- }
- if {[llength $addtnl_select_list] > 0} {
- set addtnl_select ", [join $addtnl_select_list ", "]"
- } else {
- set addtnl_select ""
- }
-
if $return_list_p {
# return a list of lists
return [db_list_of_ns_sets get_cr_folders "SQL"]
} else {
# make a multirow
- if ![info exists multirow_name] { set multirow_name bcms_list_folders }
db_multirow $multirow_name get_cr_folders "SQL"
}
}
ad_proc -public bcms::folder::tree_folders {
{-parent_id}
- {-level_diff 0}
- {-multirow_name}
+ {-prepend_path "./"}
+ {-multirow_name bcms_list_folders}
{-return_list:boolean false}
} {
- similar to list_folders but also gives additional rows with ancestors, similar to item_lists_and_ancestors
+ similar to list_folders but also gives the subfolders underneath it
+ gives some more addtional columns
- returns the following columns: folder_id, name, label, has_child_folders, level and parent_level
+ @param parent_id gets the subfolder underneath this folder_id
+ @param prepend_path you can add a string to prepend the path column
+ @param multirow_name you can supply your own multirow name
+ @param return_list if supplied it returns a list of ns_sets otherwise it
+ returns a multirow uses the multirow_name if given
+ @return this columns: folder_id, name, parent_id, label, has_child_folders,
+ has_child_symlinks, package_id, level, parent_level, path
+
} {
- # initialize the addtionals we will use
- set addtnl_where_list [list]
- set addtnl_select_list [list]
+ #TODO we may need to optimze getting the path, we are currently using
+ #content_item__get_path (which is not that fast)
+
if ![info exists parent_id] {
# if the parent_id does not exists then start from the root
set parent_id [get_bcms_root_folder]
}
- # TODO: make use of db_map...
- # check to see how deep we want to go
- if {$level_diff != 0} {
- lappend addtnl_where_list ":level_diff >= tree_level(i.tree_sortkey) - tree_level(p.tree_sortkey)"
- }
-
- # construct the additionals
- if {[llength $addtnl_where_list] > 0} {
- set addtnl_where "and [join $addtnl_where_list " and "]"
- } else {
- set addtnl_where ""
- }
- if {[llength $addtnl_select_list] > 0} {
- set addtnl_select ", [join $addtnl_select_list ", "]"
- } else {
- set addtnl_select ""
- }
-
if $return_list_p {
# return a list of lists
return [db_list_of_ns_sets get_cr_folders "SQL"]
} else {
# make a multirow
- if ![info exists multirow_name] { set multirow_name bcms_list_folders }
db_multirow $multirow_name get_cr_folders "SQL"
}
Index: openacs-4/contrib/packages/bcms/tcl/bcms-item-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms/tcl/bcms-item-procs-postgresql.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/bcms/tcl/bcms-item-procs-postgresql.xql 14 May 2003 15:34:59 -0000 1.1
+++ openacs-4/contrib/packages/bcms/tcl/bcms-item-procs-postgresql.xql 4 Aug 2003 11:19:46 -0000 1.2
@@ -3,58 +3,81 @@
postgresql7.2
-
-
- select content_item__new (
- :item_name, -- name
- integer :parent_id, -- parent_id for some reason PG gets confused on this param, explicit typecasting was needed
- null, -- item_id
- null, -- locale
- now(), -- creation_date
- :creation_user_id, -- creation_user
- :parent_id, -- context_id
- :creation_ip, -- creation_ip
- 'content_revision', -- item_subtype
- :content_type, -- content_type
- null, -- title
- null, -- description
- null, -- mime_type
- null, -- nls_language
- null, -- data
- :storage_type -- storage_type
- )
+
+
+ select content_item__new (
+ :item_name, -- name
+ integer :parent_id, -- parent_id for some reason PG gets confused on this param, explicit typecasting was needed
+ null, -- item_id
+ null, -- locale
+ now(), -- creation_date
+ :creation_user_id, -- creation_user
+ :parent_id, -- context_id
+ :creation_ip, -- creation_ip
+ 'content_revision', -- item_subtype
+ :content_type, -- content_type
+ null, -- title
+ null, -- description
+ null, -- mime_type
+ null, -- nls_language
+ null, -- data
+ :storage_type -- storage_type
+ )
-
-
+
+
-
-
+
+
select content_item__move(:item_id, :parent_id)
-
-
+
+
-
-
- select i.item_id, i.name, i.live_revision, i.latest_revision, i.publish_status,
- i.content_type, i.storage_type,
- tree_level(i.tree_sortkey) as level,
- tree_level(p.tree_sortkey) as parent_level
- $addtnl_select
- from cr_items i, (select tree_sortkey from cr_items where item_id = :parent_id) p
- $addtnl_from
- where
- tree_ancestor_p(p.tree_sortkey,i.tree_sortkey)
- $addtnl_where
- order by i.tree_sortkey
-
-
+
+
+ select i.item_id,
+ i.name,
+ i.live_revision,
+ i.latest_revision,
+ i.publish_status,
+ i.content_type,
+ i.storage_type,
+ i.tree_sortkey
+ $addtnl_select
+ from cr_items i
+ $addtnl_from
+ where
+ i.parent_id = :parent_id
+ $addtnl_where
-
-
+ union
+
+ select i.item_id,
+ i.name,
+ i.live_revision,
+ i.latest_revision,
+ i.publish_status,
+ i.content_type,
+ i.storage_type,
+ i.tree_sortkey,
+ f.label as title,
+ f.description
+ $addtnl_select_folder
+ from cr_items i, cr_folders f
+ where
+ i.parent_id = :parent_id
+ and i.item_id = f.folder_id
+
+ order by tree_sortkey
+
+
+
+
+
select a.item_id, o.name, o.live_revision, o.latest_revision, o.publish_status,
o.content_type, o.storage_type,
- tree_level(o.tree_sortkey) as level,
- tree_level(parent_sortkey) as parent_level
+ tree_level(o.tree_sortkey) as level,
+ tree_level(parent_sortkey) as parent_level
$addtnl_select
from cr_items o,
(select tree_ancestor_keys(i.tree_sortkey) as tree_sortkey_trail, p.tree_sortkey as parent_sortkey, i.item_id, i.tree_sortkey
@@ -69,8 +92,8 @@
o.tree_sortkey = tree_sortkey_trail
and tree_ancestor_p(parent_sortkey, o.tree_sortkey)
order by a.tree_sortkey
-
-
+
+
@@ -82,16 +105,16 @@
where ir.item_id = :item_id
and ir.related_object_id = i.item_id
and ir.relation_tag = :relation_tag
- $addtnl_where
+ $addtnl_where
order by order_n
-
-
- select content_item__delete(:item_id)
-
-
+
+
+ select content_item__delete(:item_id)
+
+
@@ -133,16 +156,16 @@
-
-
- select name, parent_id, storage_type, content_type, storage_type, publish_status,
- revision_id, title, content, description, publish_date, mime_type
- from cr_items i, cr_revisions r where
- i.item_id = r.item_id
- and i.item_id = :item_id
- and content_item__get_best_revision(:item_id) = r.revision_id
-
-
+
+
+ select name, parent_id, storage_type, content_type, storage_type, publish_status,
+ revision_id, title, content, description, publish_date, mime_type
+ from cr_items i, cr_revisions r where
+ i.item_id = r.item_id
+ and i.item_id = :item_id
+ and content_item__get_best_revision(:item_id) = r.revision_id
+
+
@@ -153,11 +176,11 @@
-
-
- select content_item__get_id(:url, :root_id, :resolve_index);
-
-
+
+
+ select content_item__get_id(:url, :root_id, :resolve_index);
+
+
@@ -187,6 +210,20 @@
+
+
+ select i.item_id, :prepend_path || content_item__get_path(i.item_id, r.item_id) as path,
+ case when i.content_type = 'content_folder' then content_folder__get_label(i.item_id) else bcms__get_title(i.item_id, 'latest') end as title
+ from cr_items i,
+ (select tree_sortkey, item_id from cr_items where item_id = :root_id) r,
+ (select tree_ancestor_keys(tree_sortkey) as tree_sortkey from cr_items where item_id = :item_id) p
+ where
+ i.tree_sortkey = p.tree_sortkey
+ and i.tree_sortkey > r.tree_sortkey
+ order by i.tree_sortkey
+
+
+
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.1 -r1.2
--- openacs-4/contrib/packages/bcms/tcl/bcms-item-procs.tcl 14 May 2003 15:34:59 -0000 1.1
+++ openacs-4/contrib/packages/bcms/tcl/bcms-item-procs.tcl 4 Aug 2003 11:19:46 -0000 1.2
@@ -12,28 +12,43 @@
# for possible contribution
ad_proc -public bcms::item::get_content_type {
- -item_id:required
+ {-item_id:required}
} {
returns the content type of a particular item_id
+
+ @param item_id you wish to know what content type
+
+ @returns the content type of an item
} {
array set one_item [get_item -item_id $item_id]
return $one_item(content_type)
}
-ad_proc -public bcms::item::create_item {
+
+ad_proc -private bcms::item::create_item {
{-item_name:required}
{-parent_id:required}
{-content_type "content_revision"}
{-storage_type "text"}
- {-creation_user_id ""}
- {-creation_ip ""}
+ {-creation_user_id}
+ {-creation_ip}
} {
This proc only creates the content item but not the revision.
Normally you would like couple this with create_revision or
your own custom create_revision.
- Returns the item_id that was created
+ @param item_name the name or url that will be used for the content item
+ @param parent_id the parent_id which the page will be under, normally this is a folder
+ @param content_type content type of the item to be created
+ @param storage_type where to store the item, valid values are: text, file and lob (lob support not yet implemented)
+ @param creation_user_id user_id creating this item
+ @param creation_user_ip ip address which this item is created
+
+ @returns the item_id that was created
} {
+ 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_item "SQL"]
ns_log notice "bcms::item::create_item created new item $item_id"
return $item_id
@@ -44,13 +59,23 @@
{-target_id:required}
{-name:required}
{-label:required}
- {-creation_user_id ""}
- {-creation_ip ""}
+ {-creation_user_id}
+ {-creation_ip}
} {
creates a symlink to the content item target_id
- returns the item_id of the new link
+ @param parent_id the item which will hold the symlink, normally the destination folder
+ @param target_id link to which item_id, the source
+ @param name name of the link
+ @param label label or title of the link
+ @param creation_user_id user_id creating this item
+ @param creation_user_ip ip address which this item is created
+
+ @returns the item_id of the new link
} {
+ 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_link "SQL"]
ns_log notice "bcms::item::create_link created new link $item_id to $target_id"
return $item_id
@@ -62,6 +87,10 @@
{-parent_id}
} {
edits the content item's name or folder/parent_id
+
+ @param item_id id of item to edit
+ @param name if supplied it will edit the name
+ @param parent_id if supplied it will move the item to the new parent
} {
if [info exists name] {
@@ -75,82 +104,68 @@
ad_proc -public bcms::item::delete_item {
- {-item_id:required}
+ -item_id:required
} {
nukes out the content item.
+ This also deletes the all the revision of the content item
- returns 0 if successful.
+ @param item_id of the item to be deleted
- This also deletes the all the revision of the content item
+ @returns 0 if successful.
} {
- db_transaction {
- # use db_foreach because we may have multiple revisions
- db_foreach delete_all_revisions "SQL" {}
- return [db_exec_plsql delete_item "SQL"]
- }
-
+ return [db_exec_plsql delete_item "SQL"]
}
-# TODO: refactor this code so we the view cr_XXXx instead of cr_items and cr_revisions.
-# remove the depth, lets just use the list_tree
+
ad_proc -public bcms::item::list_items {
- {-parent_id:required}
- {-revision}
- {-content_type}
- {-level_diff 1}
- {-multirow_name}
+ -parent_id:required
+ {-revision latest}
+ {-content_type content_revision}
+ {-multirow_name bcms_list_items}
{-return_list:boolean false}
+ {-additional_columns [list]}
} {
Gets all content item under the parent_id
- upvars a bcms_list_items variable to the adp level that
- contains rows of content items below the parent_id
+ @param parent_id id of the which contents you wish to list, normally a folder
+ @param revision returns items that have live or latest revision under the parent_id
+ @param content_type
+ @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
+ @param additional_columns to be returned with the results
+
+ @returns rows of content items below the parent_id
with the following columns:
item_id, name, live_revision, latest_revision, publish_status,
- content_type, storage_type, level, parent_level
+ content_type, storage_type, tree_sortkey, title, description
- Since multirow is not easy to pass around procs I have decided just add a return_list switch.
- This will return a list of ns_sets.
-
- -revision will only returns items that have live or latest revision under the parent_id
- if this is used additional info are returned such as revision_id, title, description, publish_date
-
- -level_diff if present will only returns items that is level_diff >= level - parent_level.
- That means "-level_diff 1" will only return the current child of the parent_id.
- if its not present then we return all childrens
- DO NOT USE THIS ANYMORE, use tree_items instead.
-
-
} {
+ # TODO: make use of db_map...
+
# initialize the addtionals we will use
set addtnl_where_list [list]
- set addtnl_select_list [list]
+ set addtnl_select_list $additional_columns
# if additional revision data must be returned, set the additional columns here
- # for revisions. we need to make use of db_map
- if [info exists revision] {
- lappend addtnl_select_list r.revision_id r.title r.description r.publish_date
- set addtnl_from ", cr_revisions r"
- switch -exact $revision {
- latest { lappend addtnl_where_list "i.latest_revision = r.revision_id" }
- live { lappend addtnl_where_list "i.live_revision = r.revision_id" }
- default {
- # abort the proc
- ns_log notice "bcms: revision requested not valid"
- return
- }
+ # for revisions.
+
+ # lets get the view for the content type
+ db_1row get_table_name "SQL"
+ set addtnl_from ", ${table_name}x r"
+
+ switch -exact $revision {
+ latest { lappend addtnl_where_list "i.latest_revision = r.revision_id" }
+ live { lappend addtnl_where_list "i.live_revision = r.revision_id" }
+ default {
+ # abort the proc
+ ns_log notice "bcms: revision requested not valid"
+ error "revision requested not valid"
+ return
}
- } else {
- set addtnl_from ""
}
- # TODO: make use of db_map...
- # check to see how deep we want to go
- if {$level_diff != 0} {
- lappend addtnl_where_list ":level_diff >= tree_level(i.tree_sortkey) - tree_level(p.tree_sortkey)"
- }
-
# pick a particular content type
if [info exists content_type] {
lappend addtnl_where_list "content_type = :content_type"
@@ -163,17 +178,19 @@
set addtnl_where ""
}
if {[llength $addtnl_select_list] > 0} {
+ set addtnl_select_folder ", null as [join $addtnl_select_list ", null as "]"
+ set addtnl_select_list [linsert $addtnl_select_list 0 r.title r.description]
set addtnl_select ", [join $addtnl_select_list ", "]"
} else {
set addtnl_select ""
+ set addtnl_select_folder ""
}
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 get_items "SQL"]
} else {
# make a multirow, it is likely that this proc is not being called from another proc
- if ![info exists multirow_name] { set multirow_name bcms_list_items }
db_multirow $multirow_name get_items "SQL"
}
@@ -308,10 +325,19 @@
ad_proc -public bcms::item::get_item_by_url {
{-root_id:required}
{-url:required}
- {-resolve_index true}
{-revision}
+ {-resolve_index:boolean false}
} {
- get the content item details. Returns an array that contains the following
+ get the content item details based from the url.
+
+ @param root_id starting from which url to resolve the item
+ @param url the url which we would like to resolve
+ @param revision if "-revision live" or "-revision lastest" is given then additional
+ properties are returned
+ @param resolve_index return the item_id of the index content item on a content_folder
+ rather than the content_folder's item_id
+
+ @returns an array that contains the following
item_id, name, parent_id, live_revision, latest_revision, publish_status, content_type
and storage_type
@@ -321,14 +347,11 @@
revision_id, title, content, description, publish_date, mime_type
- -resolve_index is to return the item_id of the index content item on a content_folder
- rather than the content_folder's item_id
-
if it returns a single element array that means no item exists so using
[array size yourarray] > 0 should check if such item does exists
- [array size yourarray] > 1 should check if a revision was retrieved. item exists
- but revision does not exists
+ [array size yourarray] > 1 should check if a live revision was retrieved. item exists
+ but no live revision
Be careful in checking [array size yourarray] inside a loop, you must unset the array first.
array unset yourarray.
@@ -353,7 +376,13 @@
{-item_id:required}
{-revision}
} {
- get the content item details. Returns an array that contains the following
+ get the content item details.
+
+ @param item_id id of the item you want to get properties
+ @param revision if "-revision live" or "-revision lastest" is given then additional
+ properties are returned
+
+ @returns an array that contains the following
name, parent_id, live_revision, latest_revision, publish_status, content_type
and storage_type
@@ -404,6 +433,7 @@
}
}
+# TODO move this out, this is too specific
ad_proc -public bcms::item::list_pages {
{-parent_id:required}
{-revision latest}
@@ -445,6 +475,7 @@
}
+# TODO move this out, this is too specific
ad_proc -public bcms::item::list_images {
{-parent_id:required}
{-live_items:boolean false}
@@ -465,6 +496,7 @@
}
+# TODO move this out, this is too specific
ad_proc -public bcms::item::list_files {
{-parent_id:required}
{-live_items:boolean false}
@@ -566,3 +598,31 @@
}
+ad_proc -public bcms::item::get_item_path {
+ {-item_id:required}
+ {-root_id}
+ {-prepend_path ''}
+ {-multirow_name bcms_item_path}
+ {-return_list:boolean false}
+} {
+ returns a path from the root_id to the item_id.
+
+ @param item_id build the path to this item
+ @param root_id build the path from this folder, if not supplied it use the current bcms root
+ @param prepend_path you can add a string to prepend the path column
+ @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 following attributes item_id, path, title
+} {
+ if ![info exists root_id] {
+ # if the parent_id does not exists then start from the root
+ set root_id [bcms::folder::get_bcms_root_folder]
+ }
+
+ if {$return_list_p} {
+ return [db_list_of_ns_sets get_item_path "SQL"]
+ } else {
+ db_multirow $multirow_name get_item_path "SQL"
+ }
+}
Index: openacs-4/contrib/packages/bcms/tcl/bcms-item-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms/tcl/bcms-item-procs.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/bcms/tcl/bcms-item-procs.xql 14 May 2003 15:34:59 -0000 1.1
+++ openacs-4/contrib/packages/bcms/tcl/bcms-item-procs.xql 4 Aug 2003 11:19:46 -0000 1.2
@@ -26,18 +26,10 @@
-
+
+
+ select table_name from acs_object_types where object_type = :content_type
+
+
-
-
- select i.item_id, i.live_revision, i.latest_revision,
- i.content_type, i.storage_type, i.publish_status
- $addtnl_select
- from cr_items i $addtnl_from
- where i.parent_id = :parent_id
- and i.name = :name
- $addtnl_where
-
-
-
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.1 -r1.2
--- openacs-4/contrib/packages/bcms/tcl/bcms-procs.tcl 14 May 2003 15:34:59 -0000 1.1
+++ openacs-4/contrib/packages/bcms/tcl/bcms-procs.tcl 4 Aug 2003 11:19:46 -0000 1.2
@@ -132,3 +132,44 @@
return 0
}
}
+
+
+ad_proc -public bcms::create_page {
+ {-page_name:required}
+ {-folder_id:required}
+ {-mime_type "text/plain"}
+ {-title:required}
+ {-description ""}
+ {-page_body ""}
+ {-creation_user_id}
+ {-creation_user_ip}
+} {
+ creates a new page and its first revision
+
+ @param page_name name of the page which will be used for the url
+ @param folder_id the folder_id which the page will be under
+ @param mime_type mime_type of the page
+ @param title title of the page
+ @param description description of the page
+ @param page_body the contents of a page
+ @param creation_user_id user_id creating this page
+ @param creation_user_ip ip address which this page is created
+
+ @returns the page_id of the newly created page
+} {
+ 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] }
+
+ db_transaction {
+ set page_id [bcms::item::create_item -item_name $page_name -parent_id $folder_id -content_type content_revision \
+ -storage_type text -creation_user_id $creation_user_id -creation_ip $creation_ip]
+
+ set revision_id [bcms::revision::add_revision -item_id $page_id \
+ -title $title -content $page_body -description $description \
+ -mime_type $mime_type \
+ -creation_user_id $creation_user_id -creation_ip $creation_ip]
+ }
+
+ return $page_id
+
+}
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.1 -r1.2
--- openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs-postgresql.xql 14 May 2003 15:34:59 -0000 1.1
+++ openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs-postgresql.xql 4 Aug 2003 11:19:46 -0000 1.2
@@ -30,7 +30,7 @@
-
+
select x.revision_id, 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
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.1 -r1.2
--- openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs.tcl 14 May 2003 15:34:59 -0000 1.1
+++ openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs.tcl 4 Aug 2003 11:19:46 -0000 1.2
@@ -13,7 +13,7 @@
namespace eval bcms::revision {}
-ad_proc -private bcms::revision::add_revision {
+ad_proc -public bcms::revision::add_revision {
{-item_id:required}
{-title:required}
{-content_type}
@@ -41,7 +41,7 @@
}
-ad_proc -private bcms::revision::upload_file_revision {
+ad_proc -public bcms::revision::upload_file_revision {
{-item_id:required}
{-revision_id}
{-title ""}
@@ -100,7 +100,7 @@
}
-ad_proc -public bcms::revision::revision_list {
+ad_proc -public bcms::revision::list_revisions {
{-item_id:required}
{-content_type "content_revision"}
{-return_list:boolean false}
Index: openacs-4/contrib/packages/bcms/tcl/bcms-widget-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms/tcl/bcms-widget-procs.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/bcms/tcl/bcms-widget-procs.tcl 14 May 2003 15:34:59 -0000 1.1
+++ openacs-4/contrib/packages/bcms/tcl/bcms-widget-procs.tcl 4 Aug 2003 11:19:46 -0000 1.2
@@ -15,6 +15,8 @@
-display_columns:required
{-prefix " "}
} {
+ @depracated use patched bcms::widget::extract_values
+
creates a list for use of ad_form's option_list. Gets a list of ns_sets.
-value_column is the column that will be used the html value
@@ -107,3 +109,51 @@
return $option_list
}
+
+
+ad_proc -public bcms::widget::extract_values {
+ -list_of_ns_sets:required
+ -keys_to_extract:required
+} {
+ Gets the values of list_of_ns_sets and creates a list of list
+ {{value1 value2 ... valueX} {value1 value2 ... valueX}}
+
+ @param -list_of_ns_sets a list of ns_sets normally created from db_list_of_ns_sets
+ @param -keys_to_extract a list of keys, the value of the key present in the list
+ will be returned on the results
+
+} {
+
+ set result_list [list]
+
+ foreach set $list_of_ns_sets {
+ set inner_list [list]
+ foreach key $keys_to_extract {
+ lappend inner_list [ns_set get $set $key]
+ }
+ lappend result_list $inner_list
+ }
+
+ return $result_list
+
+}
+
+
+ad_proc -public bcms::widget::item_context {
+ -item_id:required
+ {-append_list {}}
+} {
+ creates a list based the folder it resides that can be used as context or trail.
+
+ @param item_id id of which item to get a context
+
+ @returns a list in {{url label} {url label}} format
+} {
+
+ set root_url [ad_conn package_url]
+ set root_id [bcms::folder::get_bcms_root_folder]
+
+ return [bcms::widget::extract_values -list_of_ns_sets \
+ [bcms::item::get_item_path -item_id $item_id -root_id $root_id -prepend_path "$root_url" -return_list] \
+ -keys_to_extract {path title}]
+}