Index: openacs-4/packages/new-portal/www/portal-ae-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/new-portal/www/Attic/portal-ae-2.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/new-portal/www/portal-ae-2.tcl 28 Sep 2001 21:23:51 -0000 1.1 +++ openacs-4/packages/new-portal/www/portal-ae-2.tcl 28 Sep 2001 21:29:57 -0000 1.2 @@ -12,74 +12,61 @@ portal_id:naturalnum,notnull } -# XXX permission filter? +# XXX permission filter? The vars are in the URL !!! BAD! + set user_id [ad_conn user_id] set master_template [ad_parameter master_template] db_transaction { # does the portal exist? - if { [portal_exists_p] } { + if { [portal_exists_p $portal_id] } { # aks - update the vars XXX fixme + } else { + # portal doesn't exist yet. Create it. - # which vars should be set? - # (yes, I know, dynamic SQL is bad. tell me how to do it otherwise, k?) - # foreach var [ list name template_id ] { - # if { [info exists $var] } { - # lappend things_to_set "$var = :$var" - # } - # } + # undefined name? - this should not happen - aks + if { ! [info exists name] } { + set name "Untitled Portal" + } - #db_dml update_portal \ - # "update portals set [join $things_to_set ","] where portal_id = :portal_id" - # - - } else { - - # portal doesn't exist yet. Create it. - - # undefined name? - this should not happen - aks - if { ! [info exists name] } { - set name "Untitled Portal" - } - - # insert the portal and grant permission on it. - db_exec_plsql insert_portal { - declare - - pid portals.portal_id%TYPE; - - begin - - pid := portal.new ( + # insert the portal and grant permission on it. + db_exec_plsql insert_portal { + declare + + pid portals.portal_id%TYPE; + + begin + + pid := portal.new ( portal_id => :portal_id, name => :name, - owner_id => :user_id, - parent_portal_id => :default_portal_id + layout_id => :layout_id, + owner_id => :user_id ); - + acs_permission.grant_permission ( object_id => pid, grantee_id => :user_id, privilege => 'read' - ); - - acs_permission.grant_permission ( + ); + + acs_permission.grant_permission ( object_id => pid, grantee_id => :user_id, privilege => 'write' - ); - - acs_permission.grant_permission ( + ); + + acs_permission.grant_permission ( object_id => pid, grantee_id => :user_id, privilege => 'admin' - ); - end; + ); + end; + } } } - ns_returnredirect "element-layout?[export_url_vars portal_id]"