Index: openacs-4/packages/new-portal/www/element-add-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/new-portal/www/Attic/element-add-2.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/new-portal/www/element-add-2.tcl 28 Sep 2001 23:51:39 -0000 1.4 +++ openacs-4/packages/new-portal/www/element-add-2.tcl 1 Oct 2001 19:13:19 -0000 1.5 @@ -1,20 +1,43 @@ # www/element-add.tcl ad_page_contract { - Add an element to a portal. + Add an element to a portal by binding a DS to a PE } { portal_id:naturalnum,notnull,permission(write) name:trim,notnull,nohtml region:notnull - element_ids:naturalnum,multiple,notnull + ds_ids:naturalnum,multiple,notnull } - # XXX fix me themes # XXX check for name constraint violations # AKS: most of the references to "element" here are really # to DS +# Check if any of the PEs need to be configured +# i.e. "config_required_p = t" and "configured_p = f" for this DS in +# the portal_datasource_def_params table. If so, redirect to configure +# it, then remove it from the PE list and come back here. + +foreach ds_id $ds_ids { + # can the user read this element? + if { ! [ad_permission_p $ds_id read] } { + continue + } + + if { ! [db_0or1row check_config_select " + select 1 + from portal_datasource_def_params + where datasource_id = :ds_id and + config_required_p = 't' and + configured_p = 'f'"] } { + # needs to be configured, redirect to config page + # everything that this page needs along the way + ad_returnredirect "element-config?[export_url_vars portal_id name region ds_ids]" + } +} + + set layout_id [portal_get_layout_id $portal_id] # this is required to execute the query that initializes the @@ -29,9 +52,9 @@ set master_template [ad_parameter master_template] # shouldn't it be possible to do this with one query? Hmmm. -foreach element_id $element_ids { +foreach ds_id $ds_ids { # can the user read this element? - if { ! [ad_permission_p $element_id read] } { + if { ! [ad_permission_p $ds_id read] } { continue } @@ -50,7 +73,7 @@ (:new_element_id, :name, :portal_id, - :element_id, + :ds_id, nvl((select max(theme_id) from portal_element_themes), 1), :region, nvl((select max(sort_key) + 1 from portal_element_map where region = :region), 1))"