Index: openacs-4/packages/static-portlet/catalog/static-portlet.en_US.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/static-portlet/catalog/static-portlet.en_US.ISO-8859-1.xml,v diff -u -r1.12.6.3 -r1.12.6.4 --- openacs-4/packages/static-portlet/catalog/static-portlet.en_US.ISO-8859-1.xml 27 Jun 2004 11:26:25 -0000 1.12.6.3 +++ openacs-4/packages/static-portlet/catalog/static-portlet.en_US.ISO-8859-1.xml 10 Aug 2004 16:44:18 -0000 1.12.6.4 @@ -1,5 +1,5 @@ - + Custom Portlet Custom Portlet Administration @@ -9,14 +9,20 @@ Create a new %element_pretty_name% Edit Edit content element + False 0 File Delete %element_pretty_name% %pretty_name% Editing %element_pretty_name% %pretty_name% + Enforce this applet to be shown in the Portal + Enforce True means that the static portlet will be \ + added right away in the target portals that are already created, \ + False means that will be available to use when customizing the portal or when performing revert action <strong>Note</strong>: You can use plain text or HTML in the Content area. Use this form to create a new %element_pretty_name%. The %element_pretty_name% will be created and automatically placed on the first page of %portal_name% portal. Goto the %control_panel_text% and select Customize Layout to move this %element_pretty_name%. Name New New %element_pretty_name% + True Use this form to create a new %element_pretty_name%. The %element_pretty_name% will be created and automatically placed on the first page of %portal_name% portal. Go to the administration page and select Customize Layout to move this %element_pretty_name%. Or, You may upload a <strong>text</strong> file here, the contents of which will replace the current contents of the portlet. 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 -r1.16.6.2 -r1.16.6.3 --- openacs-4/packages/static-portlet/tcl/static-portal-content-procs.tcl 9 Aug 2004 05:31:53 -0000 1.16.6.2 +++ openacs-4/packages/static-portlet/tcl/static-portal-content-procs.tcl 10 Aug 2004 16:42:53 -0000 1.16.6.3 @@ -48,7 +48,7 @@ } { This is a bit different from other add_self_to_page procs. } { - + if {![empty_string_p $template_id]} { # we got a template_id, so we know that (1) that we are # being called from add_applet_to_community. That means that @@ -111,8 +111,8 @@ portal::set_element_param $element_id package_id $package_id portal::set_element_param $element_id content_id $content_id - } + return $element_id } ad_proc -public clone { Index: openacs-4/packages/static-portlet/www/element.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/static-portlet/www/element.tcl,v diff -u -r1.10.2.1.4.2 -r1.10.2.1.4.3 --- openacs-4/packages/static-portlet/www/element.tcl 28 Jul 2004 00:35:06 -0000 1.10.2.1.4.2 +++ openacs-4/packages/static-portlet/www/element.tcl 10 Aug 2004 16:44:18 -0000 1.10.2.1.4.3 @@ -45,10 +45,26 @@ set file_content_id $content_id } + +set type [db_string get_type { select type from dotlrn_portal_types_map where portal_id = :portal_id } -default ""] +set templates [list user dotlrn_class_instance dotlrn_club dotlrn_community] + ad_form -name static_element -form { element_content_id:key {pretty_name:text(text) {label "[_ static-portlet.Name]"} {html {size 60}}} {content:text(textarea) {label "[_ static-portlet.Content]"} {html {rows 15 cols 80 wrap soft}}} +} + +if {[lsearch $templates $type] >= 0} { + set elements [list \ + [list {enforce_portlet:text(select)} [list label [_ static-portlet.lt_Enforce_this_applet_t]] \ + [list help_text [_ static-portlet.lt_Enforce_True_means_th]] \ + [list options [list [_ static-portlet.True] 1] [list [_ static-portlet.False_0]]] \ + [list value 0]]] + ad_form -extend -name static_element -form $elements +} + +ad_form -extend -name static_element -form { {portal_id:text(hidden) {value $portal_id}} {package_id:text(hidden) {value $package_id}} {referer:text(hidden) {value $referer}} @@ -63,34 +79,138 @@ -pretty_name $pretty_name ] - static_portal_content::add_to_portal \ - -portal_id $portal_id \ - -package_id $package_id \ - -content_id $item_id + set old_element_id [static_portal_content::add_to_portal \ + -portal_id $portal_id \ + -package_id $package_id \ + -content_id $item_id] + + + } + # support for templates & already created portals for users, + # classes, etc. (roc) + + switch $type { + user { + set query "select portal_id as target_portal_id from dotlrn_users" + set community_id $package_id + set new_content_id $item_id + } + dotlrn_class_instance { set query "select portal_id as target_portal_id, community_id from dotlrn_class_instances_full" } + dotlrn_club { set query "select portal_id as target_portal_id, community_id from dotlrn_clubs_full" } + dotlrn_community { set query "select portal_id as target_portal_id, community_id from dotlrn_communities_full" } + default { + ad_returnredirect $referer + ad_script_abort + } + } + + + db_foreach dotlrn_type_portals "$query" { + + if {$type != "user" } { + # clone the template's content + set new_content_id [static_portal_content::new \ + -package_id $community_id \ + -content $content \ + -pretty_name $pretty_name ] + } + + + set new_element_id [ static_portal_content::add_to_portal \ + -portal_id $target_portal_id \ + -package_id $community_id \ + -content_id $new_content_id] + + portal::set_element_param $new_element_id "package_id" $community_id + portal::set_element_param $new_element_id "content_id" $new_content_id + + if {$enforce_portlet == 0} { + db_dml hide_portlet { update portal_element_map set state = 'hidden' where element_id = :new_element_id } + } + + } + + # redirect and abort ad_returnredirect $referer ad_script_abort } -edit_data { + db_transaction { + static_portal_content::update \ -portal_id $portal_id \ -content_id $element_content_id \ -pretty_name $pretty_name \ -content $content + } + + switch $type { + user { set query "select portal_id as target_portal_id from dotlrn_users" } + dotlrn_class_instance { set query "select portal_id as target_portal_id, community_id from dotlrn_class_instances_full" } + dotlrn_club { set query "select portal_id as target_portal_id, community_id from dotlrn_clubs_full" } + dotlrn_community { set query "select portal_id as target_portal_id, community_id from dotlrn_communities_full" } + default { + ad_returnredirect $referer + ad_script_abort + } + } + + db_foreach dotlrn_type_portals "$query" { + + if {$type != "user" } { + set element_content_id [db_string get_content_id { + select content_id + from static_portal_content + where package_id = :community_id + and pretty_name = :pretty_name + }] + } + + + static_portal_content::update \ + -portal_id $target_portal_id \ + -content_id $element_content_id \ + -pretty_name $pretty_name \ + -content $content + + set element_id [portal::get_element_id_from_unique_param -portal_id $target_portal_id -key content_id -value $element_content_id] + if {$enforce_portlet == 0} { + db_dml hide_portlet { update portal_element_map set state = 'hidden' where element_id = :element_id } + } else { + db_dml hide_portlet { update portal_element_map set state = 'full' where element_id = :element_id } + } + + } + + # redirect and abort ad_returnredirect $referer ad_script_abort } + ad_form -name static_file -html {enctype multipart/form-data} -form { file_content_id:key {pretty_name:text(text) {label "[_ static-portlet.Name]"} {html {size 60}}} {upload_file:file {label "[_ static-portlet.File]"}} +} + +if {[lsearch $templates $type] >= 0} { + set elements [list \ + [list {enforce_portlet:text(select)} [list label [_ static-portlet.lt_Enforce_this_applet_t]] \ + [list help_text [_ static-portlet.lt_Enforce_True_means_th]] \ + [list options [list [_ static-portlet.True] 1] [list [_ static-portlet.False_0]]] \ + [list value 0]]] + ad_form -extend -name static_file -form $elements +} + +ad_form -extend -name static_file -form { {portal_id:text(hidden) {value $portal_id}} {package_id:text(hidden) {value $package_id}} {referer:text(hidden) {value $referer}} @@ -117,12 +237,59 @@ -content $content \ -pretty_name $pretty_name ] + static_portal_content::add_to_portal \ -portal_id $portal_id \ -package_id $package_id \ -content_id $item_id + } + # support for templates & already created portals for users, + # classes, etc. (roc) + + switch $type { + user { + set query "select portal_id as target_portal_id from dotlrn_users" + set community_id $package_id + set new_content_id $item_id + } + dotlrn_class_instance { set query "select portal_id as target_portal_id, community_id from dotlrn_class_instances_full" } + dotlrn_club { set query "select portal_id as target_portal_id, community_id from dotlrn_clubs_full" } + dotlrn_community { set query "select portal_id as target_portal_id, community_id from dotlrn_communities_full" } + default { + ad_returnredirect $referer + ad_script_abort + } + } + + + db_foreach dotlrn_type_portals "$query" { + + if {$type != "user" } { + # clone the template's content + set new_content_id [static_portal_content::new \ + -package_id $community_id \ + -content $content \ + -pretty_name $pretty_name ] + } + + + set new_element_id [ static_portal_content::add_to_portal \ + -portal_id $target_portal_id \ + -package_id $community_id \ + -content_id $new_content_id] + + portal::set_element_param $new_element_id "package_id" $community_id + portal::set_element_param $new_element_id "content_id" $new_content_id + + if {$enforce_portlet == 0} { + db_dml hide_portlet { update portal_element_map set state = 'hidden' where element_id = :new_element_id } + } + + } + + # redirect and abort ad_returnredirect $referer ad_script_abort @@ -147,6 +314,44 @@ -content $content } + switch $type { + user { set query "select portal_id as target_portal_id from dotlrn_users" } + dotlrn_class_instance { set query "select portal_id as target_portal_id, community_id from dotlrn_class_instances_full" } + dotlrn_club { set query "select portal_id as target_portal_id, community_id from dotlrn_clubs_full" } + dotlrn_community { set query "select portal_id as target_portal_id, community_id from dotlrn_communities_full" } + default { + ad_returnredirect $referer + ad_script_abort + } + } + + db_foreach dotlrn_type_portals "$query" { + + if {$type != "user" } { + set file_content_id [db_string get_content_id { + select content_id + from static_portal_content + where package_id = :community_id + and pretty_name = :pretty_name + }] + } + + + static_portal_content::update \ + -portal_id $target_portal_id \ + -content_id $file_content_id \ + -pretty_name $pretty_name \ + -content $content + + set element_id [portal::get_element_id_from_unique_param -portal_id $target_portal_id -key content_id -value $file_content_id] + if {$enforce_portlet == 0} { + db_dml hide_portlet { update portal_element_map set state = 'hidden' where element_id = :element_id } + } else { + db_dml hide_portlet { update portal_element_map set state = 'full' where element_id = :element_id } + } + + } + # redirect and abort ad_returnredirect $referer ad_script_abort