Index: openacs-4/contrib/packages/resource-list/resource-list.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/resource-list/resource-list.info,v diff -u -r1.1 -r1.2 --- openacs-4/contrib/packages/resource-list/resource-list.info 30 Nov 2003 02:15:48 -0000 1.1 +++ openacs-4/contrib/packages/resource-list/resource-list.info 2 Mar 2004 21:32:31 -0000 1.2 @@ -7,9 +7,10 @@ f f - + Jade Rubick Keeps track of a list of resources, under different categories. + 2004-03-02 Stop Abuse For Everyone Index: openacs-4/contrib/packages/resource-list/sql/postgresql/resource-list-functions-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/resource-list/sql/postgresql/resource-list-functions-create.sql,v diff -u -r1.2 -r1.3 --- openacs-4/contrib/packages/resource-list/sql/postgresql/resource-list-functions-create.sql 20 Feb 2004 01:11:52 -0000 1.2 +++ openacs-4/contrib/packages/resource-list/sql/postgresql/resource-list-functions-create.sql 2 Mar 2004 21:32:32 -0000 1.3 @@ -1,7 +1,9 @@ -- -- packages/resource-list/sql/postgresql/resource-list-functions-create.sql -- --- @author jade@bread.com, ncarroll@ee.usyd.edu.au +-- @author jade@bread.com +-- Initial code taken from ncarroll@ee.usyd.edu.au who in turn took it from +-- file-storage I believe -- @creation-date 2003-05-15 -- @cvs-id $Id$ -- @@ -20,30 +22,30 @@ create or replace function rl_resource__new_root_folder (integer) returns integer as ' declare - p_package_id alias for $1; + p_package_id alias for $1; - v_folder_id cr_folders.folder_id%TYPE; - v_folder_name cr_items.name%TYPE; + v_folder_id cr_folders.folder_id%TYPE; + v_folder_name cr_items.name%TYPE; begin raise notice ''in new root folder''; - -- Set the folder name - v_folder_name := rl_resource__new_name (p_package_id); + -- Set the folder name + v_folder_name := rl_resource__new_name (p_package_id); - v_folder_id := content_folder__new ( - v_folder_name, -- name - ''Resources'', -- label - ''Resources Repository'', -- description - 0 -- parent_id - ); + v_folder_id := content_folder__new ( + v_folder_name, -- name + ''Resources'', -- label + ''Resources Repository'', -- description + p_package_id -- parent_id + ); - -- Register the standard content types + -- Register the standard content types PERFORM content_folder__register_content_type ( v_folder_id, -- folder_id ''rl_resource'', -- content_type ''f'' -- include_subtypes - ); + ); -- there is no facility in the API for adding in the package_id, -- so we have to do it ourselves @@ -52,9 +54,9 @@ set package_id = p_package_id where folder_id = v_folder_id; - -- TODO: Handle Permissions here for this folder. + -- TODO: Handle Permissions here for this folder. - return v_folder_id; + return v_folder_id; end;' language 'plpgsql'; @@ -67,32 +69,32 @@ create or replace function rl_resource__get_root_folder (integer, boolean) returns integer as ' declare - p_package_id alias for $1; + p_package_id alias for $1; p_create_if_not_present_p alias for $2; - v_folder_id cr_folders.folder_id%TYPE; - v_count integer; + v_folder_id cr_folders.folder_id%TYPE; + v_count integer; begin -- raise notice ''in get root folder p_create_if_not_present_p = %'',p_create_if_not_present_p; - select count(*) into v_count - from cr_folders - where package_id = p_package_id; + select count(*) into v_count + from cr_folders + where package_id = p_package_id; -- raise notice ''count is % for package_id %'', v_count, p_package_id; - if v_count > 1 then + if v_count > 1 then raise exception ''More than one repository for this application instance''; - elsif v_count = 1 then + elsif v_count = 1 then select folder_id into v_folder_id from cr_folders where package_id = p_package_id; - else + else if p_create_if_not_present_p = true then - -- Must be a new instance. Create a new root folder. + -- Must be a new instance. Create a new root folder. raise notice ''creating a new root repository folder''; - v_folder_id := rl_resource__new_root_folder(p_package_id); + v_folder_id := rl_resource__new_root_folder(p_package_id); else -- raise notice ''setting to null''; v_folder_id := null; @@ -101,98 +103,98 @@ -- raise notice ''v_folder_id is %'', v_folder_id; - return v_folder_id; + return v_folder_id; end; ' language 'plpgsql'; -- Create a resource item. create or replace function rl_resource__new_item ( - integer, -- resource_item_id - varchar, -- resource_name - varchar, -- description - timestamptz, -- creation_date - integer, -- creation_user - varchar, -- creation_ip - integer -- package_id + integer, -- resource_item_id + varchar, -- resource_name + varchar, -- description + timestamptz, -- creation_date + integer, -- creation_user + varchar, -- creation_ip + integer -- package_id ) returns integer as ' declare - p_resource_item_id alias for $1; - p_resource_name alias for $2; - p_description alias for $3; - p_creation_date alias for $4; - p_creation_user alias for $5; - p_creation_ip alias for $6; - p_package_id alias for $7; + p_resource_item_id alias for $1; + p_resource_name alias for $2; + p_description alias for $3; + p_creation_date alias for $4; + p_creation_user alias for $5; + p_creation_ip alias for $6; + p_package_id alias for $7; - v_item_id cr_items.item_id%TYPE; - v_revision_id cr_revisions.revision_id%TYPE; - v_id cr_items.item_id%TYPE; - v_resource_item_id integer; - v_resource_number cr_items.item_id%TYPE; - v_parent_id cr_items.parent_id%TYPE; + v_item_id cr_items.item_id%TYPE; + v_revision_id cr_revisions.revision_id%TYPE; + v_id cr_items.item_id%TYPE; + v_resource_item_id integer; + v_resource_number cr_items.item_id%TYPE; + v_parent_id cr_items.parent_id%TYPE; begin - select acs_object_id_seq.nextval into v_id from dual; + select acs_object_id_seq.nextval into v_id from dual; - v_parent_id := rl_resource__get_root_folder (p_package_id, ''t''); + v_parent_id := rl_resource__get_root_folder (p_package_id, ''true''); -- raise notice ''v_parent_id (%) p_parent_id (%)'', v_parent_id, p_parent_id; - v_item_id := content_item__new ( - v_id::varchar, -- name - v_parent_id, -- parent_id - v_id, -- item_id - null, -- locale - now(), -- creation_date - p_creation_user, -- creation_user - v_parent_id, -- context_id - p_creation_ip, -- creation_ip - ''content_item'', -- item_subtype - ''rl_resource'', -- content_type - p_resource_name, -- title - p_description, -- description - ''text/plain'', -- mime_type - null, -- nls_language - null -- data - ); + v_item_id := content_item__new ( + v_id::varchar, -- name + v_parent_id, -- parent_id + v_id, -- item_id + null, -- locale + now(), -- creation_date + p_creation_user, -- creation_user + v_parent_id, -- context_id + p_creation_ip, -- creation_ip + ''content_item'', -- item_subtype + ''rl_resource'', -- content_type + p_resource_name, -- title + p_description, -- description + ''text/plain'', -- mime_type + null, -- nls_language + null -- data + ); - v_revision_id := content_revision__new ( - p_resource_name, -- title - p_description, -- description - now(), -- publish_date - ''text/plain'', -- mime_type - NULL, -- nls_language - NULL, -- data - v_item_id, -- item_id - NULL, -- revision_id - now(), -- creation_date - p_creation_user, -- creation_user - p_creation_ip -- creation_ip - ); + v_revision_id := content_revision__new ( + p_resource_name, -- title + p_description, -- description + now(), -- publish_date + ''text/plain'', -- mime_type + NULL, -- nls_language + NULL, -- data + v_item_id, -- item_id + NULL, -- revision_id + now(), -- creation_date + p_creation_user, -- creation_user + p_creation_ip -- creation_ip + ); - PERFORM content_item__set_live_revision (v_revision_id); + PERFORM content_item__set_live_revision (v_revision_id); -- select nextval(''rl_resources_number_seq.nextval'') into v_resource_number from dual; - insert into rl_resources ( - resource_item_id, resource_number, approved_p) - values ( - v_item_id, v_id, ''f''); + insert into rl_resources ( + resource_item_id, resource_number, approved_p) + values ( + v_item_id, v_id, ''f''); - insert into rl_resources_revisions ( - resource_revision_id) - values ( + insert into rl_resources_revisions ( + resource_revision_id) + values ( v_revision_id); - PERFORM acs_permission__grant_permission( - v_revision_id, - p_creation_user, - ''admin'' - ); + PERFORM acs_permission__grant_permission( + v_revision_id, + p_creation_user, + ''admin'' + ); - return v_revision_id; + return v_revision_id; end;' language 'plpgsql'; @@ -203,19 +205,19 @@ create or replace function rl_resource__delete_item (integer) returns integer as ' declare - p_resource_item_id alias for $1; + p_resource_item_id alias for $1; begin raise NOTICE ''Deleting rl_resource...''; - delete from acs_permissions - where object_id = p_resource_item_id; + delete from acs_permissions + where object_id = p_resource_item_id; delete from rl_resource_category_map where resource_item_id = p_resource_item_id; delete from rl_resources_revisions where resource_revision_id in (select revision_id from cr_revisions where item_id = p_resource_item_id); - delete from rl_resources - where resource_item_id = p_resource_item_id; + delete from rl_resources + where resource_item_id = p_resource_item_id; PERFORM content_item__delete(p_resource_item_id); return 0; @@ -225,57 +227,57 @@ select define_function_args('rl_resource__new_revision', 'resource_item_id, resource_name, description, creation_date, creation_user, creation_ip, package_id'); create or replace function rl_resource__new_revision ( - integer, -- resource_item_id - varchar, -- resource_name - varchar, -- description - timestamptz, -- creation_date - integer, -- creation_user - varchar, -- creation_ip + integer, -- resource_item_id + varchar, -- resource_name + varchar, -- description + timestamptz, -- creation_date + integer, -- creation_user + varchar, -- creation_ip integer -- package_id ) returns integer as ' declare - p_resource_item_id alias for $1; - p_resource_name alias for $2; - p_description alias for $3; - p_creation_date alias for $4; - p_creation_user alias for $5; - p_creation_ip alias for $6; - p_package_id alias for $7; + p_resource_item_id alias for $1; + p_resource_name alias for $2; + p_description alias for $3; + p_creation_date alias for $4; + p_creation_user alias for $5; + p_creation_ip alias for $6; + p_package_id alias for $7; - v_revision_id cr_revisions.revision_id%TYPE; + v_revision_id cr_revisions.revision_id%TYPE; begin -- the item_id is the resource_id - v_revision_id := content_revision__new ( - p_resource_name, -- title - p_description, -- description - now(), -- publish_date - ''text/plain'', -- mime_type - NULL, -- nls_language - NULL, -- data - p_resource_item_id, -- item_id - NULL, -- revision_id - now(), -- creation_date - p_creation_user, -- creation_user - p_creation_ip -- creation_ip - ); + v_revision_id := content_revision__new ( + p_resource_name, -- title + p_description, -- description + now(), -- publish_date + ''text/plain'', -- mime_type + NULL, -- nls_language + NULL, -- data + p_resource_item_id, -- item_id + NULL, -- revision_id + now(), -- creation_date + p_creation_user, -- creation_user + p_creation_ip -- creation_ip + ); - PERFORM content_item__set_live_revision (v_revision_id); + PERFORM content_item__set_live_revision (v_revision_id); - insert into rl_resources_revisions ( - resource_revision_id) - values ( + insert into rl_resources_revisions ( + resource_revision_id) + values ( v_revision_id); - PERFORM acs_permission__grant_permission( - v_revision_id, - p_creation_user, - ''admin'' - ); + PERFORM acs_permission__grant_permission( + v_revision_id, + p_creation_user, + ''admin'' + ); - return v_revision_id; + return v_revision_id; end;' language 'plpgsql'; @@ -287,23 +289,23 @@ create or replace function rl_resource__new_name (integer) returns text as ' declare - p_package_id alias for $1; + p_package_id alias for $1; - v_name cr_items.name%TYPE; - v_package_key apm_packages.package_key%TYPE; - v_id integer; + v_name cr_items.name%TYPE; + v_package_key apm_packages.package_key%TYPE; + v_id integer; begin - select package_key into v_package_key from apm_packages - where package_id = p_package_id; + select package_key into v_package_key from apm_packages + where package_id = p_package_id; - select acs_object_id_seq.nextval into v_id from dual; + select acs_object_id_seq.nextval into v_id from dual; - -- Set the name - select v_package_key || ''_'' || - to_char(current_timestamp, ''YYYYMMDD'') || ''_'' || - v_id into v_name; + -- Set the name + select v_package_key || ''_'' || + to_char(current_timestamp, ''YYYYMMDD'') || ''_'' || + v_id into v_name; - return v_name; + return v_name; end;' language 'plpgsql'; ---------------------------------- Index: openacs-4/contrib/packages/resource-list/www/add-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/resource-list/www/add-edit.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/contrib/packages/resource-list/www/add-edit.tcl 20 Feb 2004 01:11:53 -0000 1.2 +++ openacs-4/contrib/packages/resource-list/www/add-edit.tcl 2 Mar 2004 21:32:32 -0000 1.3 @@ -27,8 +27,8 @@ # the unique identifier for this package set package_id [ad_conn package_id] set user_id [ad_maybe_redirect_for_registration] +set url [ad_conn package_url] - if {[exists_and_not_null resource_id]} { set title "Edit a $resource_term_lower" set context_bar [ad_context_bar "Edit $resource_term"] @@ -89,7 +89,7 @@ util_memoize_flush "resource_list_pending_get_count_cached" util_memoize_flush "resource_list_get_count_cached" - ad_returnredirect "one?[export_url_vars resource_item_id]" + ad_returnredirect "[set url]view/$resource_item_id" ad_script_abort } -edit_data { @@ -117,7 +117,7 @@ } -after_submit { - ad_returnredirect "one?[export_url_vars resource_item_id]" + ad_returnredirect "[set url]view/$resource_item_id" ad_script_abort } Index: openacs-4/contrib/packages/resource-list/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/resource-list/www/index.adp,v diff -u -r1.2 -r1.3 --- openacs-4/contrib/packages/resource-list/www/index.adp 20 Feb 2004 01:11:53 -0000 1.2 +++ openacs-4/contrib/packages/resource-list/www/index.adp 2 Mar 2004 21:32:32 -0000 1.3 @@ -31,7 +31,7 @@ -

@resources.resource_title@

@resources.resource_description@

+

@resources.resource_title@

@resources.resource_description@

@@ -51,7 +51,7 @@ By @types.type_name@

Index: openacs-4/contrib/packages/resource-list/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/resource-list/www/index.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/contrib/packages/resource-list/www/index.tcl 20 Feb 2004 01:11:53 -0000 1.2 +++ openacs-4/contrib/packages/resource-list/www/index.tcl 2 Mar 2004 21:32:32 -0000 1.3 @@ -29,7 +29,7 @@ write_p:onevalue create_p:onevalue admin_p:onevalue - + url:onevalue } # --------------------------------------------------------------- # @@ -54,6 +54,7 @@ # the unique identifier for this package set package_id [ad_conn package_id] set user_id [ad_verify_and_get_user_id] +set url [ad_conn package_url] # permissions permission::require_permission -party_id $user_id -object_id $package_id -privilege read Index: openacs-4/contrib/packages/resource-list/www/one.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/resource-list/www/one.adp,v diff -u -r1.3 -r1.4 --- openacs-4/contrib/packages/resource-list/www/one.adp 20 Feb 2004 01:11:53 -0000 1.3 +++ openacs-4/contrib/packages/resource-list/www/one.adp 2 Mar 2004 21:32:32 -0000 1.4 @@ -27,7 +27,7 @@ Categories: Index: openacs-4/contrib/packages/resource-list/www/one.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/resource-list/www/one.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/contrib/packages/resource-list/www/one.tcl 20 Feb 2004 01:11:53 -0000 1.2 +++ openacs-4/contrib/packages/resource-list/www/one.tcl 2 Mar 2004 21:32:32 -0000 1.3 @@ -11,10 +11,10 @@ @return resources Multirow data set of resources. } { - resource_item_id:integer + resource_item_id:integer,multiple } -properties { - + url:onevalue context_bar:onevalue res:multirow create:multirow @@ -28,17 +28,25 @@ # --------------------------------------------------------------- # +if {[llength $resource_item_id] > 1} { + set resource_item_id [lindex $resource_item_id 0] +} + # set up context bar set context_bar [ad_context_bar "View"] # the unique identifier for this package set package_id [ad_conn package_id] set user_id [ad_verify_and_get_user_id] +set url [ad_conn package_url] -db_1row res_query {} -column_array res +if {![db_0or1row res_query {} -column_array res]} { + ad_return_forbidden "No such resource" "There is no such resource. If you believe this is erroneous, please contact the system administrator" + ad_script_abort +} -set edit_link "add-edit?resource_revision_id=$res(resource_revision_id)" +set edit_link "[set url]add-edit?resource_revision_id=$res(resource_revision_id)" set res(resource_description) [ad_text_to_html $res(resource_description)] @@ -60,9 +68,9 @@ db_1row create_query {} -column_array create -set comments [general_comments_get_comments -print_content_p 1 $res(resource_item_id) "[ad_conn url]?resource_item_id=$res(resource_item_id)"] +set comments [general_comments_get_comments -print_content_p 1 $res(resource_item_id) "[set url]view/$res(resource_item_id)"] -set comments_link [general_comments_create_link -object_name resource-list -link_text "Comment on this resource" -context_id $package_id $res(resource_item_id) "[ad_conn url]?resource_item_id=$resource_item_id"] +set comments_link [general_comments_create_link -object_name resource-list -link_text "Comment on this resource" -context_id $package_id $res(resource_item_id) "[set url]view/$resource_item_id"] db_multirow cats get_categories { } Index: openacs-4/contrib/packages/resource-list/www/type-add-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/resource-list/www/type-add-edit.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/contrib/packages/resource-list/www/type-add-edit.tcl 20 Feb 2004 01:11:53 -0000 1.2 +++ openacs-4/contrib/packages/resource-list/www/type-add-edit.tcl 2 Mar 2004 21:32:32 -0000 1.3 @@ -93,14 +93,17 @@ db_foreach get_category_items { } { lappend options [list $short_name $category_id] } - ad_form -extend -name add_edit -form \ - [list \ - [list \ + + set select_name "Select: $type_short_name" + + ad_form -extend -name add_edit -form \ + [list \ + [list \ categories:text(checkbox),multiple \ - {label "Select: [set type_short_name]"} \ - {options [list $options]} \ - {values $categories} \ - ] \ - ] + {label $selectname} \ + {options [list $options]} \ + {values $categories} \ + ] \ + ] } Index: openacs-4/contrib/packages/resource-list/www/view.vuh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/resource-list/www/view.vuh,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/resource-list/www/view.vuh 2 Mar 2004 21:32:32 -0000 1.1 @@ -0,0 +1,18 @@ +# Transform requests of type: a/b +# into this internal request: A?c=b +# for example, note/495 > note-edit?item_id=496 +# a: base name of this .vuh file +# b: from the request +# A: hard-coded +# C: hard-coded + +set query [ad_conn url] + +set request [string range $query [expr [string last / $query] + 1] end] + +rp_form_put resource_item_id $request + +set internal_path "/packages/[ad_conn package_key]/www/one" + +rp_internal_redirect $internal_path +