Index: openacs-4/packages/bboard-portlet/tcl/bboard-admin-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bboard-portlet/tcl/bboard-admin-portlet-procs.tcl,v diff -u -N -r1.8 -r1.9 --- openacs-4/packages/bboard-portlet/tcl/bboard-admin-portlet-procs.tcl 13 May 2002 06:00:06 -0000 1.8 +++ openacs-4/packages/bboard-portlet/tcl/bboard-admin-portlet-procs.tcl 29 May 2002 23:00:26 -0000 1.9 @@ -53,16 +53,13 @@ @return new element_id } { - # we use "portal::add_element" here since there is no - # configuration necessary for this portlet (no params) - set element_id [portal::add_element \ + return [portal::add_element_parameters \ -pretty_name [get_pretty_name] \ -portal_id $portal_id \ -portlet_name [get_my_name] \ + -key package_id \ + -value $package_id ] - - portal::set_element_param $element_id package_id $package_id - return $element_id } ad_proc -public remove_self_from_page { Index: openacs-4/packages/calendar-portlet/tcl/calendar-admin-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar-portlet/tcl/calendar-admin-portlet-procs.tcl,v diff -u -N -r1.7 -r1.8 --- openacs-4/packages/calendar-portlet/tcl/calendar-admin-portlet-procs.tcl 12 May 2002 18:15:04 -0000 1.7 +++ openacs-4/packages/calendar-portlet/tcl/calendar-admin-portlet-procs.tcl 29 May 2002 23:00:26 -0000 1.8 @@ -57,14 +57,12 @@ @return element_id The new element's id } { - set element_id [portal::add_element \ + return [portal::add_element_parameters \ -portal_id $portal_id \ -portlet_name [get_my_name] \ + -key calendar_id \ + -value $calendar_id ] - - portal::set_element_param $element_id calendar_id $calendar_id - - return $element_id } ad_proc -public remove_self_from_page { Index: openacs-4/packages/dotlrn/tcl/community-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/community-procs.tcl,v diff -u -N -r1.135 -r1.136 --- openacs-4/packages/dotlrn/tcl/community-procs.tcl 29 May 2002 19:05:11 -0000 1.135 +++ openacs-4/packages/dotlrn/tcl/community-procs.tcl 29 May 2002 23:00:25 -0000 1.136 @@ -1003,6 +1003,7 @@ } if {$complain_if_invalid_p && !$valid_p} { + ns_log notice "The name $community_key is already in use either by an active or archived group. \n Please go back and select a different name." ad_return_complaint 1 \ "The name $community_key is already in use either by an active or archived group. \n Please go back and select a different name." ad_script_abort @@ -1169,7 +1170,7 @@ } { get the package ID for a particular community } { - return [db_string select_package_id {} -default ""] + return [db_string select_package_id {}] } ad_proc -public get_applet_package_id { @@ -1404,6 +1405,8 @@ {-community_id:required} {-key:required} {-description ""} + {-parent_community_id ""} + {-term_id ""} } { Clones a community. Cloning is a deep copy of the comm's metadata with a newly generated key. Callbacks are @@ -1427,7 +1430,11 @@ # there is some special stuff for cloning subcomms if {[string equal "dotlrn_community" $community_type]} { set subcomm_p 1 - set parent_community_id [get_parent_id -community_id $community_id] + + # we needs this here in case we are being called from ourself + if {[empty_string_p $parent_community_id]} { + set parent_community_id [get_parent_id -community_id $community_id] + } set parent_type [dotlrn_community::get_community_type_from_community_id $parent_community_id] if {![string equal $parent_type [dotlrn_club::community_type]] && @@ -1446,9 +1453,23 @@ ns_set put $extra_vars parent_community_id $parent_community_id } else { + # we want to clone a club or class instance check_community_key_valid_p \ -complain_if_invalid \ -community_key $key + + if {![empty_string_p $term_id]} { + # it's a class instance that we're cloning + ns_set put $extra_vars class_key [db_string get_class_key { + select class_key + from dotlrn_class_instances_full + where class_instance_id = :community_id + }] + + ns_set put $extra_vars term_id $term_id + # re-write the comm type for class instances + set community_type [dotlrn_community::get_toplevel_community_type -community_type $community_type] + } } set pretty_name $key @@ -1575,11 +1596,21 @@ } } - # TODO: # recursively clone the subcommunities - # ad_return_complaint 1 "aks77 got here" - # ad_script_abort + set subcomm_list [get_subcomm_info_list -community_id $community_id] + + foreach subcomm $subcomm_list { + set subcomm_id [ns_set get $subcomm community_id] + + clone \ + -community_id $subcomm_id \ + -key [ns_set get $subcomm community_key] \ + -description [get_community_description -community_id $subcomm_id] \ + -parent_community_id $clone_id + } } + + return $clone_id } ad_proc -public archive { Index: openacs-4/packages/dotlrn/www/clone.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/clone.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn/www/clone.adp 29 May 2002 23:03:07 -0000 1.1 @@ -0,0 +1,28 @@ +<% + + # + # Copyright (C) 2001, 2002 OpenForce, Inc. + # + # This file is part of dotLRN. + # + # dotLRN is free software; you can redistribute it and/or modify it under the + # terms of the GNU General Public License as published by the Free Software + # Foundation; either version 2 of the License, or (at your option) any later + # version. + # + # dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY + # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + # details. + # + +%> + + +@title@ +@portal_id@ +1 +1 + +Note: This may take some time. Please be patient. + Index: openacs-4/packages/dotlrn/www/clone.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/clone.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn/www/clone.tcl 29 May 2002 23:03:07 -0000 1.1 @@ -0,0 +1,112 @@ +# +# Copyright (C) 2001, 2002 OpenForce, Inc. +# +# This file is part of dotLRN. +# +# dotLRN is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# + +ad_page_contract { + clone a community + + @author arjun (arjun@openforce.net) + @version $Id: clone.tcl,v 1.1 2002/05/29 23:03:07 arjun Exp $ +} -query { + {referer "one-community-admin"} +} -properties { + title:onevalue +} + +set class_instance_p 0 +set user_id [ad_get_user_id] +set community_id [dotlrn_community::get_community_id] +set community_name [dotlrn_community::get_community_name $community_id] +set title "Copy $community_name]" +set portal_id [dotlrn_community::get_portal_id -community_id $community_id] +set top_community_type [dotlrn_community::get_toplevel_community_type_from_community_id $community_id] + + +if { $top_community_type != "dotlrn_club" + && $top_community_type != "dotlrn_community" } { + + set class_instance_p 1 + set term_id [dotlrn_class::get_term_id -class_instance_id $community_id] +} + + +form create clone_form + +# generate the clone's key, with collision resolution here +set key [dotlrn::generate_key -increment -name $community_name] + +while {![dotlrn_community::check_community_key_valid_p -community_key $key]} { + set key [dotlrn::generate_key -increment -name $key] +} + +if {$class_instance_p} { + element create clone_form term \ + -label Term \ + -datatype integer \ + -widget select \ + -options [db_list_of_lists select_terms_for_select_widget { + select dotlrn_terms.term_name || ' ' || dotlrn_terms.term_year as term, + dotlrn_terms.term_id + from dotlrn_terms + where dotlrn_terms.end_date > sysdate + order by dotlrn_terms.start_date + }] +} + +element create clone_form pretty_name \ + -label "Name" \ + -datatype text \ + -widget text \ + -html {size 40} \ + -value $key + +element create clone_form description \ + -label Description \ + -datatype text \ + -widget textarea \ + -html {rows 5 cols 60 wrap soft} \ + -optional \ + -value "A copy of $community_name" + +element create clone_form referer \ + -label "Referer" \ + -datatype text \ + -widget hidden \ + -value $referer + +if {[form is_valid clone_form]} { + + + set term "" + + if {!$class_instance_p} { + form get_values clone_form pretty_name description referer + } else { + form get_values clone_form pretty_name description referer term + } + + set clone_id [dotlrn_community::clone \ + -community_id $community_id \ + -key $key \ + -description $description \ + -term_id $term + ] + set url [dotlrn_community::get_community_url $clone_id] + ad_returnredirect "$url/one-community-admin" + + ad_script_abort +} + +ad_return_template Index: openacs-4/packages/dotlrn-bboard/tcl/dotlrn-bboard-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-bboard/tcl/dotlrn-bboard-procs.tcl,v diff -u -N -r1.40 -r1.41 --- openacs-4/packages/dotlrn-bboard/tcl/dotlrn-bboard-procs.tcl 24 May 2002 01:58:45 -0000 1.40 +++ openacs-4/packages/dotlrn-bboard/tcl/dotlrn-bboard-procs.tcl 29 May 2002 23:00:25 -0000 1.41 @@ -276,7 +276,8 @@ Clone this applet's content from the old community to the new one } { ns_log notice "Cloning: [applet_key]" - dotlrn_bboard::add_applet_to_community $new_community_id + return [dotlrn_bboard::add_applet_to_community $new_community_id] + } Index: openacs-4/packages/dotlrn-calendar/tcl/dotlrn-calendar-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-calendar/tcl/dotlrn-calendar-procs.tcl,v diff -u -N -r1.56 -r1.57 --- openacs-4/packages/dotlrn-calendar/tcl/dotlrn-calendar-procs.tcl 24 May 2002 01:58:45 -0000 1.56 +++ openacs-4/packages/dotlrn-calendar/tcl/dotlrn-calendar-procs.tcl 29 May 2002 23:00:25 -0000 1.57 @@ -363,12 +363,16 @@ ns_log notice "Cloning: [applet_key]" # copy the old_comm's item types table - set old_calendar_id [get_group_calendar_id -community_id $old_calendar_id] + set old_calendar_id [get_group_calendar_id \ + -community_id $old_community_id + ] + + set calendar_id [calendar_create_helper -community_id $new_community_id] + db_dml copy_cal_item_types {} - set calendar_id [calendar_create_helper -community_id $community_id] return [add_applet_to_community_helper \ - -community_id $community_id \ + -community_id $new_community_id \ -calendar_id $calendar_id ] } Index: openacs-4/packages/dotlrn-calendar/tcl/dotlrn-calendar-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-calendar/tcl/Attic/dotlrn-calendar-procs.xql,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/dotlrn-calendar/tcl/dotlrn-calendar-procs.xql 17 May 2002 21:08:09 -0000 1.1 +++ openacs-4/packages/dotlrn-calendar/tcl/dotlrn-calendar-procs.xql 29 May 2002 23:00:25 -0000 1.2 @@ -2,12 +2,12 @@ - + insert into cal_item_types (item_type_id, calendar_id, type) - select acs_object_id_seq.nextval, :group_calendar_id, type + select acs_object_id_seq.nextval, :calendar_id, type from cal_item_types where calendar_id = :old_calendar_id Index: openacs-4/packages/dotlrn-dotlrn/tcl/dotlrn-dotlrn-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-dotlrn/tcl/dotlrn-dotlrn-procs.tcl,v diff -u -N -r1.30 -r1.31 --- openacs-4/packages/dotlrn-dotlrn/tcl/dotlrn-dotlrn-procs.tcl 24 May 2002 01:58:46 -0000 1.30 +++ openacs-4/packages/dotlrn-dotlrn/tcl/dotlrn-dotlrn-procs.tcl 29 May 2002 23:00:25 -0000 1.31 @@ -134,9 +134,8 @@ dotlrn_dotlrn::add_portlet_helper $portal_id $args - # this is not supposed to return anything, since - # any return value here is interpreted as a valid package_id! - return + # return the empty string + return "" } ad_proc -public remove_applet_from_community { @@ -266,7 +265,7 @@ community. } { ns_log notice "Cloning: [applet_key]" - dotlrn_dotlrn::add_applet_to_community $new_community_id + return [add_applet_to_community $new_community_id] } Index: openacs-4/packages/dotlrn-dotlrn/tcl/dotlrn-members-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-dotlrn/tcl/dotlrn-members-procs.tcl,v diff -u -N -r1.13 -r1.14 --- openacs-4/packages/dotlrn-dotlrn/tcl/dotlrn-members-procs.tcl 24 May 2002 01:58:46 -0000 1.13 +++ openacs-4/packages/dotlrn-dotlrn/tcl/dotlrn-members-procs.tcl 29 May 2002 23:00:25 -0000 1.14 @@ -73,9 +73,7 @@ dotlrn_members::add_portlet $portal_id $args - # this is not supposed to return anything, since - # any return value here is interpreted as a valid package_id! - return + return "" } ad_proc -public remove_applet_from_community { @@ -172,7 +170,7 @@ Clone this applet's content from the old community to the new one. Since there's no data, just add the applet to the clone } { - dotlrn_members::add_applet_to_community $new_community_id + return [dotlrn_members::add_applet_to_community $new_community_id] } # Index: openacs-4/packages/dotlrn-dotlrn/tcl/dotlrn-members-staff-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-dotlrn/tcl/dotlrn-members-staff-procs.tcl,v diff -u -N -r1.10 -r1.11 --- openacs-4/packages/dotlrn-dotlrn/tcl/dotlrn-members-staff-procs.tcl 24 May 2002 01:58:46 -0000 1.10 +++ openacs-4/packages/dotlrn-dotlrn/tcl/dotlrn-members-staff-procs.tcl 29 May 2002 23:00:25 -0000 1.11 @@ -62,9 +62,7 @@ -portal_id $portal_id \ -community_id $community_id - # this is not supposed to return anything, since - # any return value here is interpreted as a valid package_id! - return + return "" } ad_proc -public remove_applet_from_community { @@ -145,9 +143,6 @@ } { Clone this applet's content from the old community to the new one } { - ns_log notice "** Error in [get_pretty_name] 'clone' not implemented!" -# ad_return_complaint 1 "Please notifiy the administrator of this error: -# ** Error in [get_pretty_name]: 'clone' not implemented!" + return [add_applet_to_community $new_community_id] } - } Index: openacs-4/packages/dotlrn-faq/dotlrn-faq.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-faq/dotlrn-faq.info,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/dotlrn-faq/dotlrn-faq.info 14 May 2002 06:14:27 -0000 1.5 +++ openacs-4/packages/dotlrn-faq/dotlrn-faq.info 29 May 2002 23:00:25 -0000 1.6 @@ -14,12 +14,13 @@ Ben Adida - + + Index: openacs-4/packages/dotlrn-faq/tcl/dotlrn-faq-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-faq/tcl/dotlrn-faq-procs-oracle.xql,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/dotlrn-faq/tcl/dotlrn-faq-procs-oracle.xql 24 May 2002 01:58:46 -0000 1.1 +++ openacs-4/packages/dotlrn-faq/tcl/dotlrn-faq-procs-oracle.xql 29 May 2002 23:00:25 -0000 1.2 @@ -3,7 +3,7 @@ oracle8.1.6 - + begin faq.clone ( Index: openacs-4/packages/dotlrn-faq/tcl/dotlrn-faq-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-faq/tcl/dotlrn-faq-procs.tcl,v diff -u -N -r1.33 -r1.34 --- openacs-4/packages/dotlrn-faq/tcl/dotlrn-faq-procs.tcl 24 May 2002 01:58:46 -0000 1.33 +++ openacs-4/packages/dotlrn-faq/tcl/dotlrn-faq-procs.tcl 29 May 2002 23:00:25 -0000 1.34 @@ -230,34 +230,13 @@ Clone this applet's content from the old community to the new one } { ns_log notice "Cloning: [applet_key]" - add_applet_to_community $new_community_id - - clone_helper \ - -old_community_id $old_community_id \ - -new_community_id $new_community_id - } - - ad_proc -private clone_helper { - {-old_community_id:required} - {-new_community_id:required} - } { - Actually clone the faq data - } { - ns_log notice "Cloning: [get_pretty_name] in clone_helper" - - # get the faq package_id's for both comms + set new_package_id [add_applet_to_community $new_community_id] set old_package_id [dotlrn_community::get_applet_package_id \ $old_community_id \ [applet_key] ] - set new_package_id [dotlrn_community::get_applet_package_id \ - $new_community_id \ - [applet_key] - ] - - # call the faq pl/sql's "clone" op - db_exec_plsql clone {} + db_exec_plsql call_faq_clone {} + return $new_package_id } - } Index: openacs-4/packages/dotlrn-fs/tcl/dotlrn-fs-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-fs/tcl/dotlrn-fs-procs.tcl,v diff -u -N -r1.65 -r1.66 --- openacs-4/packages/dotlrn-fs/tcl/dotlrn-fs-procs.tcl 24 May 2002 01:58:46 -0000 1.65 +++ openacs-4/packages/dotlrn-fs/tcl/dotlrn-fs-procs.tcl 29 May 2002 23:00:25 -0000 1.66 @@ -407,14 +407,209 @@ } { Clone this applet's content from the old community to the new one } { - # check out content_folder.copy method - ns_log error "** Error in [get_pretty_name] 'clone' not implemented!" + ns_log notice "Cloning: [applet_key]" + + # this code is copied from add_applet_to_community above + # they should be refactored together + + # get the old comm's root folder id + set old_package_id [dotlrn_community::get_applet_package_id \ + $old_community_id \ + [applet_key] + ] + set old_root_folder [fs::get_root_folder -package_id $old_package_id] + + # + # do root folder stuff + # + set portal_id [dotlrn_community::get_portal_id -community_id $new_community_id] + set package_id [dotlrn::instantiate_and_mount $new_community_id [package_key]] + set community_name [dotlrn_community::get_community_name $new_community_id] + set folder_id [fs::new_root_folder \ + -package_id $package_id \ + -pretty_name "${community_name}'s Files" \ + -description "${community_name}'s Files" \ + ] + + set node_id [site_nodes::get_node_id_from_package_id -package_id $package_id] + portal::mapping::new -object_id $folder_id -node_id $node_id + + set party_id [acs_magic_object registered_users] + permission::revoke -party_id $party_id -object_id $folder_id -privilege read + permission::revoke -party_id $party_id -object_id $folder_id -privilege write + permission::revoke -party_id $party_id -object_id $folder_id -privilege admin + + set party_id [acs_magic_object the_public] + permission::revoke -party_id $party_id -object_id $folder_id -privilege read + permission::revoke -party_id $party_id -object_id $folder_id -privilege write + permission::revoke -party_id $party_id -object_id $folder_id -privilege admin + + # The root folder is available only to community members + set members [dotlrn_community::get_rel_segment_id \ + -community_id $new_community_id \ + -rel_type dotlrn_member_rel \ + ] + permission::grant -party_id $members -object_id $folder_id -privilege read + # admins of this community can admin the folder + set admins [dotlrn_community::get_rel_segment_id \ + -community_id $new_community_id \ + -rel_type dotlrn_admin_rel \ + ] + permission::grant -party_id $admins -object_id $folder_id -privilege admin + + # + # do public folder stuff + # + set public_folder_id [fs::new_folder \ + -name public \ + -pretty_name "${community_name}'s Public Files" \ + -parent_id $folder_id \ + ] + + portal::mapping::new -object_id $public_folder_id -node_id $node_id + + # The public folder is available to all dotLRN Full Access Users + set dotlrn_public [dotlrn::get_users_rel_segment_id] + permission::grant \ + -party_id $dotlrn_public \ + -object_id $public_folder_id \ + -privilege read + + # + # now to the cloning + # + + # first, get the contents of the old root folder and public folder_id + set user_id [ad_conn user_id] + set old_root_contents [fs::get_folder_contents \ + -folder_id $old_root_folder \ + -user_id $user_id + ] + set old_public_folder_id [get_public_folder_id -parent_id $old_root_folder] + + # go through the list of stuff + foreach item $old_root_contents { + # ns_set print $item + set object_id [ns_set get $item object_id] + + if {$object_id == $old_public_folder_id} { + # this is the old public folder so, copy + # it's _contents_ into the new public folder + set old_public_contents [fs::get_folder_contents \ + -folder_id $object_id \ + -user_id $user_id + ] + + foreach public_item $old_public_contents { + copy_fs_object \ + -object_id [ns_set get $public_item object_id] \ + -target_folder_id $public_folder_id \ + -user_id $user_id + } + # done with the old public folder + continue + } + + # the object is something not in the public folder + copy_fs_object \ + -object_id [ns_set get $item object_id] \ + -target_folder_id $folder_id \ + -user_id $user_id + + } + + # + # portlet stuff + # + + set args [ns_set create] + ns_set put $args package_id $package_id + ns_set put $args folder_id $folder_id + ns_set put $args param_action overwrite + + add_portlet_helper $portal_id $args + + # non-member portal stuff + set non_member_portal_id [dotlrn_community::get_non_member_portal_id \ + -community_id $new_community_id + ] + + # Make public-folder the only one available at non-member page + ns_set update $args package_id $package_id + ns_set update $args folder_id $public_folder_id + ns_set update $args force_region 2 + + add_portlet_helper $non_member_portal_id $args + + return $package_id } # # misc helper procs # + ad_proc -public copy_fs_object { + {-object_id:required} + {-target_folder_id:required} + {-user_id:required} + {-node_id ""} + } { + Copy an fs object of any type to a new folder. + Currently either simple, folder or file. + Optionall set up a node mapping on folders too. + } { + if {[fs::simple_p -object_id $object_id]} { + + fs::url_copy \ + -url_id $object_id \ + -target_folder_id $target_folder_id + + } elseif {[fs::folder_p -object_id $object_id]} { + + set name [fs_get_folder_name $object_id] + set ip [ns_conn peeraddr] + + # create a new folder since fs doesn't have copy_folder + set new_folder_id [fs::new_folder \ + -name $name \ + -pretty_name $name \ + -parent_id $target_folder_id + ] + + # set up the node mapping, if available + if {![empty_string_p $node_id]} { + portal::mapping::new -object_id $new_folder_id -node_id $node_id + } + + # we gotta copy the contents of the folder now + set folder_contents [fs::get_folder_contents \ + -folder_id $object_id \ + -user_id $user_id + ] + + foreach item $folder_contents { + + copy_fs_object \ + -object_id [ns_set get $item object_id] \ + -target_folder_id $new_folder_id \ + -user_id $user_id \ + -node_id $node_id + } + } else { + # move this to fs:: sometime + db_exec_plsql copy_file { + begin + :1 := file_storage.copy_file ( + file_id => :object_id, + target_folder_id => :target_folder_id, + creation_user => :user_id, + creation_ip => NULL + ); + end; + } + } + } + ad_proc -public get_user_default_page {} { return the user default page to add the portlet to } { Index: openacs-4/packages/dotlrn-news/tcl/dotlrn-news-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-news/tcl/dotlrn-news-procs.tcl,v diff -u -N -r1.23 -r1.24 --- openacs-4/packages/dotlrn-news/tcl/dotlrn-news-procs.tcl 24 May 2002 01:58:46 -0000 1.23 +++ openacs-4/packages/dotlrn-news/tcl/dotlrn-news-procs.tcl 29 May 2002 23:00:25 -0000 1.24 @@ -190,9 +190,15 @@ } { Clone this applet's content from the old community to the new one } { - ns_log error "** Error in [get_pretty_name] 'clone' not implemented!" -# ad_return_complaint 1 "Please notifiy the administrator of this error: -# ** Error in [get_pretty_name]: 'clone' not implemented!" + ns_log notice "Cloning: [applet_key]" + set new_package_id [add_applet_to_community $new_community_id] + set old_package_id [dotlrn_community::get_applet_package_id \ + $old_community_id \ + [applet_key] + ] + + db_exec_plsql call_news_clone {} + return $new_package_id } } Index: openacs-4/packages/dotlrn-portlet/tcl/dotlrn-admin-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-portlet/tcl/dotlrn-admin-portlet-procs.tcl,v diff -u -N -r1.9 -r1.10 --- openacs-4/packages/dotlrn-portlet/tcl/dotlrn-admin-portlet-procs.tcl 13 May 2002 06:00:06 -0000 1.9 +++ openacs-4/packages/dotlrn-portlet/tcl/dotlrn-admin-portlet-procs.tcl 29 May 2002 23:00:25 -0000 1.10 @@ -59,16 +59,13 @@ @return element_id The new element's id } { - set element_id [portal::add_element \ + return [portal::add_element_parameters \ -portal_id $portal_id \ -portlet_name [get_my_name] \ -force_region [ad_parameter "dotlrn_admin_portlet_force_region" [my_package_key]] \ + -key community_id \ + -value $community_id ] - - # set the community_id param that this portlet needs - portal::set_element_param $element_id "community_id" $community_id - - return $element_id } ad_proc -public remove_self_from_page { Index: openacs-4/packages/dotlrn-portlet/www/dotlrn-admin-portlet.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-portlet/www/dotlrn-admin-portlet.adp,v diff -u -N -r1.19 -r1.20 --- openacs-4/packages/dotlrn-portlet/www/dotlrn-admin-portlet.adp 22 May 2002 03:53:39 -0000 1.19 +++ openacs-4/packages/dotlrn-portlet/www/dotlrn-admin-portlet.adp 29 May 2002 23:00:25 -0000 1.20 @@ -22,6 +22,7 @@
  • @admin_pretty_name@
  • +
  • Copy this group

  • Index: openacs-4/packages/dotlrn-static/tcl/dotlrn-static-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-static/tcl/dotlrn-static-procs.tcl,v diff -u -N -r1.22 -r1.23 --- openacs-4/packages/dotlrn-static/tcl/dotlrn-static-procs.tcl 24 May 2002 22:13:02 -0000 1.22 +++ openacs-4/packages/dotlrn-static/tcl/dotlrn-static-procs.tcl 29 May 2002 23:00:25 -0000 1.23 @@ -227,7 +227,11 @@ } { Clone this applet's content from the old community to the new one } { - ns_log notice "** Error in [get_pretty_name] 'clone' not implemented!" + ns_log notice "Cloning [get_pretty_name]" + static_portal_content::clone \ + -portal_id [dotlrn_community::get_portal_id_not_cached \ + -community_id $new_community_id] \ + -package_id $new_community_id } } Index: openacs-4/packages/dotlrn-syllabus/tcl/dotlrn-syllabus-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-syllabus/tcl/dotlrn-syllabus-procs.tcl,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/dotlrn-syllabus/tcl/dotlrn-syllabus-procs.tcl 24 May 2002 01:58:46 -0000 1.5 +++ openacs-4/packages/dotlrn-syllabus/tcl/dotlrn-syllabus-procs.tcl 29 May 2002 23:00:25 -0000 1.6 @@ -79,6 +79,8 @@ ns_set put $args package_id $community_id add_portlet_helper $portal_id $args + + return "" } ad_proc -public remove_applet_from_community { Index: openacs-4/packages/dotlrn-syllabus/tcl/syllabus-admin-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-syllabus/tcl/syllabus-admin-portlet-procs.tcl,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/dotlrn-syllabus/tcl/syllabus-admin-portlet-procs.tcl 24 May 2002 01:58:46 -0000 1.3 +++ openacs-4/packages/dotlrn-syllabus/tcl/syllabus-admin-portlet-procs.tcl 29 May 2002 23:00:25 -0000 1.4 @@ -46,7 +46,7 @@ } { Adds a syllabus admin portlet element to the specified portal } { - return [portal::add_element \ + return [portal::add_element_parameters \ -portal_id $portal_id \ -portlet_name [get_my_name] ] Index: openacs-4/packages/faq-portlet/tcl/faq-admin-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq-portlet/tcl/faq-admin-portlet-procs.tcl,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/faq-portlet/tcl/faq-admin-portlet-procs.tcl 12 May 2002 18:15:04 -0000 1.5 +++ openacs-4/packages/faq-portlet/tcl/faq-admin-portlet-procs.tcl 29 May 2002 23:00:26 -0000 1.6 @@ -59,14 +59,12 @@ @return element_id The new element's id } { - set element_id [portal::add_element \ + return [portal::add_element_parameters \ -portal_id $portal_id \ -portlet_name [get_my_name] \ + -key package_id \ + -value $package_id ] - - portal::set_element_param $element_id package_id $package_id - - return $element_id } ad_proc -public remove_self_from_page { Index: openacs-4/packages/fs-portlet/tcl/fs-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/fs-portlet/tcl/fs-portlet-procs.tcl,v diff -u -N -r1.39 -r1.40 --- openacs-4/packages/fs-portlet/tcl/fs-portlet-procs.tcl 24 May 2002 01:58:44 -0000 1.39 +++ openacs-4/packages/fs-portlet/tcl/fs-portlet-procs.tcl 29 May 2002 23:00:26 -0000 1.40 @@ -68,6 +68,10 @@ } lappend extra_params [list package_id $package_id] + # it seems to me that package_id is not needed. + # that allows for dotlrn-fs to be cleaned up - aks + # + # -extra_params [eval concat $extra_params] return [portal::add_element_parameters \ -portal_id $portal_id \ @@ -77,8 +81,7 @@ -force_region $force_region \ -param_action $param_action \ -value $folder_id \ - -key folder_id \ - -extra_params [eval concat $extra_params] + -key folder_id ] } Index: openacs-4/packages/new-portal/tcl/portal-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/new-portal/tcl/portal-procs.tcl,v diff -u -N -r1.143 -r1.144 --- openacs-4/packages/new-portal/tcl/portal-procs.tcl 24 May 2002 01:58:46 -0000 1.143 +++ openacs-4/packages/new-portal/tcl/portal-procs.tcl 29 May 2002 23:00:26 -0000 1.144 @@ -1107,9 +1107,7 @@ db_dml template_params_insert {} } else { - # no template, or the template dosen't have this DS, - # or I'm a template! - + # no template, or the template dosen't have this D db_transaction { set new_element_id [db_nextval acs_object_id_seq] db_dml insert {} @@ -1216,7 +1214,12 @@ @param key @param value } { + #ns_log notice "aks80 set_element_param $element_id / $key / $value / [db_list_of_lists foo { + # select * from portal_element_parameters where element_id = :element_id}] " + db_dml update {} + + # ns_log notice "aks81 [get_element_param $element_id $key]" return 1 } Index: openacs-4/packages/news-portlet/tcl/news-admin-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/news-portlet/tcl/news-admin-portlet-procs.tcl,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/news-portlet/tcl/news-admin-portlet-procs.tcl 13 May 2002 06:00:07 -0000 1.6 +++ openacs-4/packages/news-portlet/tcl/news-admin-portlet-procs.tcl 29 May 2002 23:00:26 -0000 1.7 @@ -54,19 +54,16 @@ Adds a news admin PE to the given portal @param portal_id The page to add self to - @param package_id The package_id of the news pacakge + @param package_id The package_id of the news package @return element_id The new element's id } { - # there is only one news admin pe, so use: - set element_id [portal::add_element \ + return [portal::add_element_parameters \ -portal_id $portal_id \ -portlet_name [get_my_name] \ + -key package_id \ + -value $package_id ] - - portal::set_element_param $element_id package_id $package_id - - return $element_id } ad_proc -public remove_self_from_page { Index: openacs-4/packages/news-portlet/tcl/news-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/news-portlet/tcl/news-portlet-procs.tcl,v diff -u -N -r1.19 -r1.20 --- openacs-4/packages/news-portlet/tcl/news-portlet-procs.tcl 24 May 2002 01:58:44 -0000 1.19 +++ openacs-4/packages/news-portlet/tcl/news-portlet-procs.tcl 29 May 2002 23:00:26 -0000 1.20 @@ -78,7 +78,7 @@ {-package_id:required} } { Removes a news PE from the given page or the package_id of the - news pacakge from the portlet if there are others remaining + news package from the portlet if there are others remaining @param portal_id The page to remove self from @param package_id Index: openacs-4/packages/static-portlet/tcl/static-admin-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/static-portlet/tcl/static-admin-portlet-procs.tcl,v diff -u -N -r1.11 -r1.12 --- openacs-4/packages/static-portlet/tcl/static-admin-portlet-procs.tcl 15 May 2002 18:48:32 -0000 1.11 +++ openacs-4/packages/static-portlet/tcl/static-admin-portlet-procs.tcl 29 May 2002 23:00:26 -0000 1.12 @@ -52,21 +52,12 @@ } { Adds a static admin PE to the given portal } { - # we don't care if there are other instaces of the - # static portlet in this portal since this PE only has one - # and only one instace_id. i.e. There is no aggregation - # unlike bboard-portlet - - # there is only one static admin portlet per portal so use: - set element_id [portal::add_element \ + return [portal::add_element_parameters \ -portal_id $portal_id \ - -portlet_name [get_my_name] + -portlet_name [get_my_name] \ + -key package_id \ + -value $package_id ] - - # Set the instace of "static" that this PE will know - portal::set_element_param $element_id package_id $package_id - - return $element_id } ad_proc -public remove_self_from_page { Index: openacs-4/packages/static-portlet/tcl/static-portal-content-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/static-portlet/tcl/static-portal-content-procs.tcl,v diff -u -N -r1.9 -r1.10 --- openacs-4/packages/static-portlet/tcl/static-portal-content-procs.tcl 24 May 2002 01:58:45 -0000 1.9 +++ openacs-4/packages/static-portlet/tcl/static-portal-content-procs.tcl 29 May 2002 23:00:26 -0000 1.10 @@ -57,7 +57,7 @@ {-content_id ""} {-template_id ""} } { - This is a bit different from add_self_to_page procs. + This is a bit different from other add_self_to_page procs. } { if {![empty_string_p $template_id]} { @@ -109,11 +109,50 @@ -package_key "static-portlet"] ] - portal::set_element_param $element_id "pacakge_id" $package_id - portal::set_element_param $element_id "content_id" $content_id + portal::set_element_param $element_id package_id $package_id + portal::set_element_param $element_id content_id $content_id } } + ad_proc -public clone { + {-portal_id:required} + {-package_id:required} + } { + A helper proc for cloning. There could be multiple static portlets + that need to be cloned. Make a deep copy of all the static portal + content and update the all the corresponding element's pointers + } { + set ds_id [portal::get_datasource_id [static_portlet::get_my_name]] + + set element_list [db_list get_element_list { + select pem.element_id as element_id + from portal_element_map pem, portal_pages pp + where pp.portal_id= :portal_id + and pp.page_id = pem.page_id + and pem.datasource_id= :ds_id + }] + + foreach element_id $element_list { + set old_content_id [db_string select_element_id { + select value + from portal_element_parameters + where element_id = :element_id + and key = 'content_id'} + ] + + # make a new static content item from this item + set new_content_id [new \ + -package_id $package_id \ + -content [get_content -content_id $old_content_id] \ + -pretty_name [get_pretty_name -content_id $old_content_id] + ] + + # update the portal element's pointers + portal::set_element_param $element_id package_id $package_id + portal::set_element_param $element_id content_id $new_content_id + } + } + ad_proc -public remove_from_portal { {-portal_id:required} {-content_id:required} Index: openacs-4/packages/static-portlet/tcl/static-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/static-portlet/tcl/static-portlet-procs.tcl,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/static-portlet/tcl/static-portlet-procs.tcl 12 May 2002 18:15:04 -0000 1.6 +++ openacs-4/packages/static-portlet/tcl/static-portlet-procs.tcl 29 May 2002 23:00:26 -0000 1.7 @@ -16,7 +16,9 @@ ad_library { - Procedures to supports static portlets + Procedures to supports static portlets. Much of + the work for static portlets is done in the + static_portal_content file. @author arjun@openforce.net @cvs-id $Id$ @@ -50,16 +52,8 @@ } { Adds a static PE to the given page } { - # there is no aggregation, so use: - set element_id [portal::add_element \ - -portal_id $portal_id \ - -portlet_name [get_my_name] - ] - - # Set the instace of "static-portlet" that this PE will know - portal::set_element_param $element_id package_id $package_id - - return $element_id + ns_log notice "static_portlet::add_self_to_page - Don't call me. Use static_portal_content:: instead" + error } ad_proc -public remove_self_from_page { @@ -76,11 +70,9 @@ cf } { } { - portal::show_proc_helper \ -package_key [my_package_key] \ -config_list $cf \ -template_src "static-portlet" } - } Index: openacs-4/packages/static-portlet/www/static-admin-portlet.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/static-portlet/www/static-admin-portlet.tcl,v diff -u -N -r1.10 -r1.11 --- openacs-4/packages/static-portlet/www/static-admin-portlet.tcl 24 May 2002 01:58:45 -0000 1.10 +++ openacs-4/packages/static-portlet/www/static-admin-portlet.tcl 29 May 2002 23:00:26 -0000 1.11 @@ -23,11 +23,9 @@ } -properties { } -array set config $cf -set package_id $config(package_id) - set element_pretty_name [ad_parameter static_admin_portlet_element_pretty_name static-portlet "Custom Portlet"] set element_pretty_plural [ad_parameter static_admin_portlet_element_pretty_plural static-portlet "Custom Portlets"] +set package_id [dotlrn_community::get_community_id] db_multirow content select_content { select content_id, @@ -37,6 +35,5 @@ } set template_portal_id [dotlrn_community::get_portal_id] -set pacakge_id [dotlrn_community::get_community_id] set applet_url "[dotlrn_applet::get_url]/[static_portlet::my_package_key]" set referer [ad_conn url]