Index: openacs-4/contrib/packages/portal/portal.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/portal.info,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/portal.info 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,154 @@ + + + + + New Portal + New Portals + f + t + + + + oracle + postgresql + + Arjun Sanyal + yon + Portals + 2001-02-20 + OpenForce, Inc. + Portals are used to aggregate content from different sources within a single page. Props to Ian Baker for "Portal". + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: openacs-4/contrib/packages/portal/catalog/portal.en_US.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/catalog/portal.en_US.ISO-8859-1.xml,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/catalog/portal.en_US.ISO-8859-1.xml 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,23 @@ + + + + + Change Theme: + Create a new page + Error, bad params! \n + Please notify the system administrator of this error. Thank You + Page + Add Page + Revert the entire portal to the default arrangement + Bad direction! + Change Theme + Remove Empty Page + Revert + You must enter new name for the page. + No Elements on this page + transaction failed + Page: + Change Page Layout + Change page layout: + Bad direction: + Index: openacs-4/contrib/packages/portal/sql/oracle/add-sloan-theme.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/oracle/add-sloan-theme.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/oracle/add-sloan-theme.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,49 @@ +-- +-- 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. +-- + +-- +-- The New Portal Package +-- copyright 2001, OpenForce, Inc. +-- distributed under the GNU GPL v2 +-- +-- Arjun Sanyal (arjun@openforce.net) +-- $Id: add-sloan-theme.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + + +-- ampersands break if I don't do this. +set scan off + +-- Insert some default templates. +declare + layout_id portal_layouts.layout_id%TYPE; + theme_id portal_element_themes.theme_id%TYPE; +begin + + theme_id := portal_element_theme.new ( + name => 'Sloan', + description => 'MIT Sloan theme', + filename => 'themes/sloan-theme', + resource_dir => 'themes/sloan-theme'); + + +end; +/ + + + + + Index: openacs-4/contrib/packages/portal/sql/oracle/datasource-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/oracle/datasource-package-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/oracle/datasource-package-create.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,107 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- create portal datasource package +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: datasource-package-create.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +create or replace package portal_datasource +as + + function new ( + p_name in portal_datasources.name%TYPE, + p_shadeable_p in portal_datasources.shadeable_p%TYPE default 't' + p_hideable_p in portal_datasources.hideable_p%TYPE default 't' + p_description in portal_datasources.description%TYPE default null + ) return portal_datasources.datasource_id%TYPE; + + procedure delete ( + p_datasource_id in portal_datasources.datasource_id%TYPE + ); + + procedure set_def_param ( + p_datasource_id in portal_datasource_parameters.datasource_id%TYPE, + p_config_required_p in portal_datasource_parameters.config_required_p%TYPE default null, + p_configured_p in portal_datasource_parameters.configured_p%TYPE default null, + p_key in portal_datasource_parameters.key%TYPE, + p_value in portal_datasource_parameters.value%TYPE default null + ); + +end portal_datasource; +/ +show errors + +create or replace package body portal_datasource +as + + function new ( + p_name in portal_datasources.name%TYPE, + p_shadeable_p in portal_datasources.shadeable_p%TYPE default 't' + p_hideable_p in portal_datasources.hideable_p%TYPE default 't' + p_description in portal_datasources.description%TYPE default null + ) return portal_datasources.datasource_id%TYPE + is + v_datasource_id portal_datasources.datasource_id%TYPE; + begin + + insert into portal_datasources + (datasource_id, name, shadeable_p, hideable_p, description) + values + (portal_seq.nextval, p_name, p_shadeable_p, p_hideable_p, p_description) + returning datasource_id + into v_datasource_id; + + return v_datasource_id; + + end new; + + procedure delete ( + p_datasource_id in portal_datasources.datasource_id%TYPE + ) + is + begin + + delete + from portal_datasources + where datasource_id = p_datasource_id; + + end delete; + + procedure set_def_param ( + p_datasource_id in portal_datasource_parameters.datasource_id%TYPE, + p_config_required_p in portal_datasource_parameters.config_required_p%TYPE default null, + p_configured_p in portal_datasource_parameters.configured_p%TYPE default null, + p_key in portal_datasource_parameters.key%TYPE, + p_value in portal_datasource_parameters.value%TYPE default null + ) + is + begin + + insert into portal_datasource_parameters + (parameter_id, datasource_id, config_required_p, configured_p, key, value) + values + (portal_seq.nextval, p_datasource_id, p_config_required_p, p_configured_p, p_key, p_value); + + end set_def_param; + +end portal_datasource; +/ +show errors Index: openacs-4/contrib/packages/portal/sql/oracle/datasource-package-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/oracle/datasource-package-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/oracle/datasource-package-drop.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,27 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- drop portal datasource package +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: datasource-package-drop.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +drop package body portal_datasource; +drop package portal_datasource; Index: openacs-4/contrib/packages/portal/sql/oracle/datasource-sc-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/oracle/Attic/datasource-sc-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/oracle/datasource-sc-create.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,145 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- create portal datasource service contract +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: datasource-sc-create.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +declare + sc_dotlrn_contract integer; + foo integer; +begin + + sc_dotlrn_contract := acs_sc_contract.new( + contract_name => 'portal_datasource', + contract_desc => 'Portal Datasource interface' + ); + + -- Get my name - not to be confused with the pretty_name + foo := acs_sc_msg_type.new( + msg_type_name => 'portal_datasource.GetMyName.InputType', + msg_type_spec => '' + ); + + foo := acs_sc_msg_type.new( + msg_type_name => 'portal_datasource.GetMyName.OutputType', + msg_type_spec => 'my_name:string' + ); + + foo := acs_sc_operation.new( + 'portal_datasource', + 'GetMyName', + 'Get the name', + 't', -- not cacheable + 0, -- n_args + 'portal_datasource.GetMyName.InputType', + 'portal_datasource.GetMyName.OutputType' + ); + + -- Get a pretty name + foo := acs_sc_msg_type.new( + msg_type_name => 'portal_datasource.GetPrettyName.InputType', + msg_type_spec => '' + ); + + foo := acs_sc_msg_type.new( + msg_type_name => 'portal_datasource.GetPrettyName.OutputType', + msg_type_spec => 'pretty_name:string' + ); + + foo := acs_sc_operation.new( + 'portal_datasource', + 'GetPrettyName', + 'Get the pretty name', + 't', -- not cacheable + 0, -- n_args + 'portal_datasource.GetPrettyName.InputType', + 'portal_datasource.GetPrettyName.OutputType' + ); + + -- AddSelfToPage: Tell the datasource to add itself to a portal + -- The "args" string is an ns_set of extra arguments + foo := acs_sc_msg_type.new( + msg_type_name => 'portal_datasource.AddSelfToPage.InputType', + msg_type_spec => 'page_id:integer,args:string' + ); + + foo := acs_sc_msg_type.new( + msg_type_name => 'portal_datasource.AddSelfToPage.OutputType', + msg_type_spec => 'element_id:integer' + ); + + foo := acs_sc_operation.new( + 'portal_datasource', + 'AddSelfToPage', + 'Adds itself to the given page returns an element_id', + 'f', -- not cacheable + 2, -- n_args + 'portal_datasource.AddSelfToPage.InputType', + 'portal_datasource.AddSelfToPage.OutputType' + ); + + -- RemoveSelfFromPage: Tell the PE to remove itself from a page + -- The "args" string is an ns_set of extra arguments + foo := acs_sc_msg_type.new( + msg_type_name => 'portal_datasource.RemoveSelfFromPage.InputType', + msg_type_spec => 'page_id:integer,args:string' + ); + + foo := acs_sc_msg_type.new( + msg_type_name => 'portal_datasource.RemoveSelfFromPage.OutputType', + msg_type_spec => '' + ); + + foo := acs_sc_operation.new( + 'portal_datasource', + 'RemoveSelfFromPage', + ' remove itself from the given page', + 'f', -- not cacheable + 2, -- n_args + 'portal_datasource.RemoveSelfFromPage.InputType', + 'portal_datasource.RemoveSelfFromPage.OutputType' + ); + + -- Show: the portal element's display proc + foo := acs_sc_msg_type.new( + msg_type_name => 'portal_datasource.Show.InputType', + msg_type_spec => 'cf:string' + ); + + foo := acs_sc_msg_type.new( + msg_type_name => 'portal_datasource.Show.OutputType', + msg_type_spec => 'output:string' + ); + + foo := acs_sc_operation.new( + 'portal_datasource', + 'Show', + 'Render the portal element returning a chunk of HTML', + 'f', -- not cacheable + 1, -- n_args + 'portal_datasource.Show.InputType', + 'portal_datasource.Show.OutputType' + ); + +end; +/ +show errors Index: openacs-4/contrib/packages/portal/sql/oracle/datasource-sc-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/oracle/Attic/datasource-sc-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/oracle/datasource-sc-drop.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,194 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- drop portal datasource service contract +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: datasource-sc-drop.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +declare + contract_id integer; + msg_type_id integer; + op_id integer; +begin + + -- drop GetMyName + op_id := acs_sc_operation.get_id ( + contract_name => 'portal_datasource', + operation_name => 'GetMyName' + ); + + acs_sc_operation.delete ( + operation_id => op_id, + contract_name => 'portal_datasource', + operation_name => 'GetMyName' + ); + + msg_type_id := acs_sc_msg_type.get_id ( + msg_type_name => 'portal_datasource.GetMyName.InputType' + ); + + acs_sc_msg_type.delete ( + msg_type_name => 'portal_datasource.GetMyName.InputType', + msg_type_id => msg_type_id + ); + + msg_type_id := acs_sc_msg_type.get_id ( + msg_type_name => 'portal_datasource.GetMyName.OutputType' + ); + + acs_sc_msg_type.delete ( + msg_type_name => 'portal_datasource.GetMyName.OutputType', + msg_type_id => msg_type_id + ); + + -- drop GetPrettyName + op_id := acs_sc_operation.get_id ( + contract_name => 'portal_datasource', + operation_name => 'GetPrettyName' + ); + + acs_sc_operation.delete ( + operation_id => op_id, + contract_name => 'portal_datasource', + operation_name => 'GetPrettyName' + ); + + msg_type_id := acs_sc_msg_type.get_id ( + msg_type_name => 'portal_datasource.GetPrettyName.InputType' + ); + + acs_sc_msg_type.delete ( + msg_type_name => 'portal_datasource.GetPrettyName.InputType', + msg_type_id => msg_type_id + ); + + msg_type_id := acs_sc_msg_type.get_id ( + msg_type_name => 'portal_datasource.GetPrettyName.OutputType' + ); + + acs_sc_msg_type.delete ( + msg_type_name => 'portal_datasource.GetPrettyName.OutputType', + msg_type_id => msg_type_id + ); + + + -- Drop add_self_to_page + op_id := acs_sc_operation.get_id ( + contract_name => 'portal_datasource', + operation_name => 'AddSelfToPage' + ); + + acs_sc_operation.delete ( + operation_id => op_id, + contract_name => 'portal_datasource', + operation_name => 'AddSelfToPage' + ); + + msg_type_id := acs_sc_msg_type.get_id ( + msg_type_name => 'portal_datasource.AddSelfToPage.InputType' + ); + + acs_sc_msg_type.delete ( + msg_type_name => 'portal_datasource.AddSelfToPage.InputType', + msg_type_id => msg_type_id + ); + + msg_type_id := acs_sc_msg_type.get_id ( + msg_type_name => 'portal_datasource.AddSelfToPage.OutputType' + ); + + acs_sc_msg_type.delete ( + msg_type_name => 'portal_datasource.AddSelfToPage.OutputType', + msg_type_id => msg_type_id + ); + + -- Delete Show + op_id := acs_sc_operation.get_id ( + contract_name => 'portal_datasource', + operation_name => 'Show' + ); + + acs_sc_operation.delete ( + operation_id => op_id, + contract_name => 'portal_datasource', + operation_name => 'Show' + ); + + msg_type_id := acs_sc_msg_type.get_id ( + msg_type_name => 'portal_datasource.Show.InputType' + ); + + acs_sc_msg_type.delete ( + msg_type_name => 'portal_datasource.Show.InputType', + msg_type_id => msg_type_id + ); + + msg_type_id := acs_sc_msg_type.get_id ( + msg_type_name => 'portal_datasource.Show.OutputType' + ); + + acs_sc_msg_type.delete ( + msg_type_name => 'portal_datasource.Show.OutputType', + msg_type_id => msg_type_id + ); + + -- RemoveSelfFromPage + op_id := acs_sc_operation.get_id ( + contract_name => 'portal_datasource', + operation_name => 'RemoveSelfFromPage' + ); + + acs_sc_operation.delete ( + operation_id => op_id, + contract_name => 'portal_datasource', + operation_name => 'RemoveSelfFromPage' + ); + + msg_type_id := acs_sc_msg_type.get_id ( + msg_type_name => 'portal_datasource.RemoveSelfFromPage.InputType' + ); + + acs_sc_msg_type.delete ( + msg_type_name => 'portal_datasource.RemoveSelfFromPage.InputType', + msg_type_id => msg_type_id + ); + + acs_sc_msg_type.delete ( + msg_type_id := acs_sc_msg_type.get_id ( + msg_type_name => 'portal_datasource.RemoveSelfFromPage.OutputType' + ); + + acs_sc_msg_type.delete ( + msg_type_name => 'portal_datasource.RemoveSelfFromPage.OutputType', + msg_type_id => msg_type_id + ); + + -- drop the contract + contract_id := acs_sc_contract.get_id ('portal_datasource'); + + acs_sc_contract.delete ( + contract_id => contract_id, + contract_name => 'portal_datasource' + ); + +end; +/ +show errors Index: openacs-4/contrib/packages/portal/sql/oracle/defaults.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/oracle/Attic/defaults.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/oracle/defaults.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,92 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- create portal defaults +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: defaults.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +set scan off + +declare + layout_id portal_layouts.layout_id%TYPE; + theme_id portal_themes.theme_id%TYPE; +begin + + -- one-column layout, without a header. + layout_id := portal_layout.new( + name => '1_column', + description => 'A simple 1 column layout', + filename => 'layouts/simple1', + resource_dir => 'layouts/components/simple1' + ); + + -- the supported regions for that layout. + portal_layout.add_region(layout_id => layout_id, region => '1'); + + -- two-column layout, without a header. + layout_id := portal_layout.new( + name => '2_column', + description => 'A simple 2 column layout', + filename => 'layouts/simple2', + resource_dir => 'layouts/components/simple2' + ); + + -- the supported regions for that layout. + portal_layout.add_region(layout_id => layout_id, region => '1'); + portal_layout.add_region(layout_id => layout_id, region => '2'); + + -- same as above, only, three columns. + layout_id := portal_layout.new( + name => '3_column', + description => 'A simple 3 column layout', + filename => 'layouts/simple3', + resource_dir => 'layouts/components/simple3' + ); + + portal_layout.add_region(layout_id => layout_id, region => '1'); + portal_layout.add_region(layout_id => layout_id, region => '2'); + portal_layout.add_region(layout_id => layout_id, region => '3'); + + -- Now, some element themes. + theme_id := portal_theme.new( + name => 'simple', + description => 'A simple red table-based theme', + filename => 'themes/simple-theme', + resource_dir => 'themes/simple-theme' + ); + + theme_id := portal_theme.new( + name => 'nada', + description => 'The un-theme. No graphics.', + filename => 'themes/nada-theme', + resource_dir => 'themes/nada-theme' + ); + + theme_id := portal_theme.new( + name => 'deco', + description => 'An Art Deco theme', + filename => 'themes/deco-theme', + resource_dir => 'themes/deco-theme' + ); + +end; +/ +show errors Index: openacs-4/contrib/packages/portal/sql/oracle/layout-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/oracle/layout-package-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/oracle/layout-package-create.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,103 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- create portal layouts package +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: layout-package-create.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +create or replace package portal_layout +as + + function new ( + p_layout_id in portal_layouts.layout_id%TYPE default null, + p_name in portal_layouts.name%TYPE, + p_description in portal_layouts.description%TYPE default null, + p_filename in portal_layouts.filename%TYPE, + p_resource_dir in portal_layouts.resource_dir%TYPE, + p_object_type in acs_objects.object_type%TYPE default 'portal_layout', + p_creation_date in acs_objects.creation_date%TYPE default sysdate, + p_creation_user in acs_objects.creation_user%TYPE default null, + p_creation_ip in acs_objects.creation_ip%TYPE default null, + p_context_id in acs_objects.context_id%TYPE default null + ) return portal_layouts.layout_id%TYPE; + + procedure delete ( + p_layout_id in portal_layouts.layout_id%TYPE + ); + +end portal_layout; +/ +show errors + +create or replace package body portal_layout +as + + function new ( + p_layout_id in portal_layouts.layout_id%TYPE default null, + p_name in portal_layouts.name%TYPE, + p_description in portal_layouts.description%TYPE default null, + p_filename in portal_layouts.filename%TYPE, + p_resource_dir in portal_layouts.resource_dir%TYPE, + p_object_type in acs_objects.object_type%TYPE default 'portal_layout', + p_creation_date in acs_objects.creation_date%TYPE default sysdate, + p_creation_user in acs_objects.creation_user%TYPE default null, + p_creation_ip in acs_objects.creation_ip%TYPE default null, + p_context_id in acs_objects.context_id%TYPE default null + ) return portal_layouts.layout_id%TYPE + is + v_layout_id portal_layouts.layout_id%TYPE; + begin + + v_layout_id := acs_object.new( + object_id => p_layout_id, + object_type => p_object_type, + creation_date => p_creation_date, + creation_user => p_creation_user, + creation_ip => p_creation_ip, + context_id => p_context_id + ); + + insert into portal_layouts + (layout_id, name, description, filename, resource_dir) + values + (v_layout_id, p_name, p_description, p_filename, p_resource_dir); + + return v_layout_id; + + end new; + + procedure delete ( + p_layout_id in portal_layouts.layout_id%TYPE + ) + is + begin + + delete + from portal_layouts + where layout_id = p_layout_id; + + acs_object.delete(p_layout_id); + + end delete; + +end portal_layout; +/ +show errors Index: openacs-4/contrib/packages/portal/sql/oracle/layout-package-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/oracle/layout-package-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/oracle/layout-package-drop.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,27 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- drop portal layouts package +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: layout-package-drop.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +drop package body portal_layout; +drop package portal_layout; Index: openacs-4/contrib/packages/portal/sql/oracle/objects-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/oracle/objects-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/oracle/objects-create.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,80 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- create portal metadata +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: objects-create.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +begin + acs_object_type.create_type( + supertype => 'acs_object', + object_type => 'portal', + pretty_name => 'Portal', + pretty_plural => 'Portals', + table_name => 'PORTALS', + id_column => 'PORTAL_ID', + package_name => 'portal' + ); +end; +/ +show errors; + +begin + acs_object_type.create_type( + supertype => 'acs_object', + object_type => 'portal_theme', + pretty_name => 'Portal Theme', + pretty_plural => 'Portal Themes', + table_name => 'PORTAL_THEMES', + id_column => 'THEME_ID', + package_name => 'portal_themes' + ); +end; +/ +show errors; + +begin + acs_object_type.create_type( + supertype => 'acs_object', + object_type => 'portal_page', + pretty_name => 'Portal Page', + pretty_plural => 'Portal Pages', + table_name => 'PORTAL_PAGES', + id_column => 'PAGE_ID', + package_name => 'portal_page' + ); +end; +/ +show errors; + +begin + acs_object_type.create_type( + supertype => 'acs_object', + object_type => 'portal_layout', + pretty_name => 'Portal Layout', + pretty_plural => 'Portal Layouts', + table_name => 'PORTAL_LAYOUTS', + id_column => 'LAYOUT_ID', + package_name => 'portal_layout' + ); +end; +/ +show errors; Index: openacs-4/contrib/packages/portal/sql/oracle/objects-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/oracle/objects-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/oracle/objects-drop.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,49 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- drop portal metadata +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: objects-drop.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +delete +from acs_permissions +where object_id in (select object_id + from acs_objects + where object_type in ('portal', 'portal_theme', 'portal_page', 'portal_layout')); + +delete +from acs_permissions +where object_id in (select package_id + from apm_packages + where package_key = 'portal'); + +delete +from acs_objects +where object_type in ('portal', 'portal_theme', 'portal_page', 'portal_layout'); + +begin + acs_object_type.drop_type('portal_layout'); + acs_object_type.drop_type('portal_page'); + acs_object_type.drop_type('portal_theme'); + acs_object_type.drop_type('portal'); +end; +/ +show errors Index: openacs-4/contrib/packages/portal/sql/oracle/page-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/oracle/page-package-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/oracle/page-package-create.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,151 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- create portal pages package +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: page-package-create.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +create or replace package portal_page +as + + function new ( + p_page_id in portal_pages.page_id%TYPE default null, + p_name in portal_pages.name%TYPE default 'Untitled Page', + p_portal_id in portal_pages.portal_id%TYPE, + p_layout_id in portal_pages.layout_id%TYPE default null, + p_object_type in acs_objects.object_type%TYPE default 'portal_page', + p_creation_date in acs_objects.creation_date%TYPE default sysdate, + p_creation_user in acs_objects.creation_user%TYPE default null, + p_creation_ip in acs_objects.creation_ip%TYPE default null, + p_context_id in acs_objects.context_id%TYPE default null + ) return portal_pages.page_id%TYPE; + + procedure delete ( + p_page_id in portal_pages.page_id%TYPE + ); + +end portal_page; +/ +show errors + +create or replace package body portal_page +as + + function new ( + p_page_id in portal_pages.page_id%TYPE default null, + p_name in portal_pages.name%TYPE default 'Untitled Page', + p_portal_id in portal_pages.portal_id%TYPE, + p_layout_id in portal_pages.layout_id%TYPE default null, + p_object_type in acs_objects.object_type%TYPE default 'portal_page', + p_creation_date in acs_objects.creation_date%TYPE default sysdate, + p_creation_user in acs_objects.creation_user%TYPE default null, + p_creation_ip in acs_objects.creation_ip%TYPE default null, + p_context_id in acs_objects.context_id%TYPE default null + ) return portal_pages.page_id%TYPE + is + v_page_id portal_pages.page_id%TYPE; + v_layout_id portal_pages.layout_id%TYPE; + v_sort_key portal_pages.sort_key%TYPE; + begin + + v_page_id := acs_object.new( + object_id => p_page_id, + object_type => p_object_type, + creation_date => p_creation_date, + creation_user => p_creation_user, + creation_ip => p_creation_ip, + context_id => nvl(p_context_id, p_portal_id) + ); + + if p_layout_id is null then + select min(layout_id) + into v_layout_id + from portal_layouts; + else + v_layout_id := p_layout_id; + end if; + + select nvl(max(sort_key) + 1, 0) + into v_sort_key + from portal_pages + where portal_id = p_portal_id; + + insert into portal_pages + (page_id, name, portal_id, layout_id, sort_key) + values + (v_page_id, p_name, p_portal_id, v_layout_id, v_sort_key); + + return v_page_id; + + end new; + + procedure delete ( + p_page_id in portal_pages.page_id%TYPE + ) + is + v_portal_id portal_pages.portal_id%TYPE; + v_sort_key portal_pages.sort_key%TYPE; + v_curr_sort_key portal_pages.sort_key%TYPE; + v_page_count_from_0 integer; + begin + + -- IMPORTANT: sort keys MUST be an unbroken sequence from 0 to max(sort_key) + + select portal_id, sort_key + into v_portal_id, v_sort_key + from portal_pages + where page_id = p_page_id; + + select (count(*) - 1) + into v_page_count_from_0 + from portal_pages + where portal_id = v_portal_id; + + for i in 0 .. v_page_count_from_0 loop + + if i = v_sort_key then + + delete + from portal_pages + where page_id = p_page_id; + + elsif i > v_sort_key then + + update portal_pages + set sort_key = -1 + where sort_key = i; + + update portal_pages + set sort_key = i - 1 + where sort_key = -1; + + end if; + + end loop; + + acs_object.delete(page_id); + + end delete; + +end portal_page; +/ +show errors + Index: openacs-4/contrib/packages/portal/sql/oracle/page-package-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/oracle/page-package-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/oracle/page-package-drop.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,27 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- drop portal pages package +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: page-package-drop.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +drop package body portal_page; +drop package portal_page; Index: openacs-4/contrib/packages/portal/sql/oracle/portal-core-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/oracle/portal-core-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/oracle/portal-core-create.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,361 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- create portals model +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: portal-core-create.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +create sequence portal_seq; + +create table portal_datasources ( + datasource_id integer + constraint portal_datasources_pk + primary key, + name varchar(200) + constraint p_datasources_name_nn + not null, + shadeable_p char(1) + default 't' + constraint p_datasources_shadeable_p_nn + not null + constraint p_datasources_shadeable_p_ck + check (shadeable_p in ('t', 'f')), + hideable_p char(1) + default 't' + constraint p_datasources_hideable_p_nn + not null + constraint p_datasources_hideable_p_ck + check (hideable_p in ('t', 'f')), + description varchar(200) +); + +comment on table portal_datasources ' + a portal datasource is the package of code that generates the content + of a portal element. the foo-portlet packages create datasources. +'; + +create table portal_datasource_parameters ( + datasource_id constraint p_ds_params_datasource_id_fk + references portal_datasources (datasource_id) + on delete cascade + constraint p_ds_params_datasource_id_nn + not null, + key varchar(200) + constraint p_ds_params_key_nn + not null, + value varchar(200), + config_required_p char(1) + default 'f' + constraint p_ds_params_cfg_req_p_nn + not null + constraint p_ds_params_cfg_req_p_ck + check (config_required_p in ('t', 'f')), + configured_p char(1) + default 'f' + constraint p_ds_params_cfg_p_nn + not null + constraint p_ds_params_cfg_p_ck + check (configured_p in ('t', 'f')), + constraint portal_datasource_params_pk + primary key (datasource_id, key) +); + +comment on table portal_datasource_parameters ' + maintains a set of default parameters for portal datsources. these + are copied to a portal element when it is created. + + configuration semantics: + + config_required_p | configured_p | + ----------------- | ----------------- | ---------------------------------- + t | t | static configuration is provided + | | for the portal elements. it can be + | | changed later. + ----------------- | ----------------- | ---------------------------------- + t | f | the portal element must be + | | configured when created. + ----------------- | ----------------- | ---------------------------------- + f | t | an optional default configuration + | | is provided. + ----------------- | ----------------- | ---------------------------------- + f | f | configuration is optional and no + | | default is provided. +'; + +comment on column portal_datasource_parameters.config_required_p ' + this parameter requires configuration. if configured_p is true then no + action is needed at portal element creation since the portal element + can simply use the default value provided. if configured_p is false then + the portal element must provide a value for this parameter at creation + time. +'; + +comment on column portal_datasource_parameters.configured_p ' + if true then a default value is provided for this parameter. +'; + +create table portal_layouts ( + layout_id constraint p_layouts_layout_id_fk + references acs_objects (object_id) + constraint portal_layouts_pk + primary key, + name varchar(200) + constraint p_layouts_name_un + unique + constraint p_layouts_name_nn + not null, + description varchar(200), + filename varchar(200), + resource_dir varchar(200) +); + +comment on table portal_layouts ' + a portal layout is a template that defines regions for portal + elements to "fill in". Examples of layouts are two column and + three column +'; + +comment on column portal_layouts.filename ' + the relative path to the layout template from the "portal/www/" + directory without the ending ".adp" extension. Example: "layouts/simple2" +'; + +comment on column portal_layouts.resource_dir ' + XXX remove me +'; + +create table portal_layout_regions ( + layout_id constraint p_layout_regions_layout_id_fk + references portal_layouts (layout_id) + on delete cascade + constraint p_layout_regions_layout_id_nn + not null, + region varchar(20) + constraint p_layout_regions_region_nn + not null, + constraint portal_layout_regions_pk + primary key (layout_id, region) +); + +comment on table portal_layout_regions ' + this table describes each of the regions in each of the layouts. + for example a two column layout would have two entries in this + table: region = 1 and region = 2. +'; + +comment on column portal_layout_regions.region ' + an ordering of regions in a layout starting from 1 +'; + +create table portal_themes ( + theme_id constraint p_themes_theme_id_fk + references acs_objects (object_id) + constraint portal_themes_pk + primary key, + name varchar(200) + constraint p_themes_name_un + unique + constraint p_themes_name_nn + not null, + description varchar(200), + filename varchar(200), + resource_dir varchar(200) +); + +comment on table portal_themes ' + decoration templates for portal elements +'; + +comment on column portal_themes.filename ' + the relative path to the theme template from the "portal/www/" + directory without the ending ".adp" extension. Example: "themes/deco-theme" +'; + +comment on column portal_themes.resource_dir ' + the relative path to the theme's resource directory from the "portal/www/" + directory. The resource directory typically contains graphics files. + Example: "themes/deco-theme" +'; + +create table portals ( + portal_id constraint portal_portal_id_fk + references acs_objects (object_id) + constraint portals_pk + primary key, + name varchar(200) + default 'Untitled' + constraint portal_name_nn + not null, + template_id constraint template_id_fk + references portals (portal_id), + theme_id constraint portal_theme_id_fk + references portal_themes (theme_id) + constraint portal_theme_id_nn + not null +); + +comment on table portals ' + portals are containers of one or more portal pages. +'; + +comment on column portals.template_id ' + a portal may have a template (another portal) +'; + +comment on column portals.theme_id ' + portals one theme for all it's contained pages +'; + + +create table portal_pages ( + page_id constraint p_pages_page_id_fk + references acs_objects (object_id) + constraint portal_pages_pk + primary key, + name varchar(200) + default 'Untitled Page' + constraint p_pages_name_nn + not null, + portal_id constraint p_pages_portal_id_fk + references portals (portal_id) + constraint p_pages_portal_id_nn + not null, + layout_id constraint p_pages_layout_id_fk + references portal_layouts (layout_id) + constraint p_pages_layout_id_nn + not null, + sort_key integer + constraint p_pages_sort_key_nn + not null, + constraint p_pages_portal_id_sort_key_un + unique (portal_id, sort_key) +); + +create index p_pages_prtl_page_idx on portal_pages (portal_id, page_id); + +comment on table portal_pages ' + portal pages are containers for portal elements. can be thought of + as the "tabs" on a portal +'; + +comment on column portal_pages.sort_key ' + an ordering of the pages contained in the same portal starting from + 0 for the first page and increasing in an gapless integer sequence +'; + +create table portal_elements ( + element_id integer + constraint portal_elements_pk + primary key, + datasource_id constraint p_elements_datasource_id_fk + references portal_datasources (datasource_id) + on delete cascade + constraint p_elements_datasource_id_nn + not null, + name varchar(200) + constraint p_elements_name_nn + not null, + page_id constraint p_elements_page_id_fk + references portal_pages (page_id) + on delete cascade + not null, + region varchar(20) + constraint p_elements_region_nn + not null, + sort_key integer + constraint p_elements_sort_key_nn + not null + constraint p_elements_sort_key_ck + check (sort_key > 0), + state varchar(6) + default 'full' + constraint p_elements_state_ck + check (state in ('full', 'shaded', 'hidden', 'pinned')), + shadeable_p char(1) + default 't' + constraint p_elements_shadeable_p_nn + not null + constraint p_elements_shadeable_p_ck + check (shadeable_p in ('t', 'f')), + hideable_p char(1) + default 't' + constraint p_elements_hideable_p_nn + not null + constraint p_elements_hideable_p_ck + check (hideable_p in ('t', 'f')), + constraint p_elements_page_id_name_un + unique (page_id, name) +); + +comment on table portal_elements ' + the user-visible "box" on a portal page that displays the content of a datasource +'; + +comment on column portal_elements.sort_key ' + an ordering of elements contained in the same region on a page starting from + 0 for the first element and increasing in an gapless integer sequence +'; + +comment on column portal_elements.state ' + one of the set "full" (normal), "shaded" (title bar only), "hidden" (not shown), + or "pinned" (like full, but without state change links). portal themes impliment these + different behaviors based on a given elements state +'; + +create table portal_element_parameters ( + parameter_id integer + constraint portal_element_parameters_pk + primary key, + element_id constraint p_element_params_element_id_fk + references portal_elements (element_id) + on delete cascade + constraint p_element_params_element_id_nn + not null, + key varchar(50) + constraint p_element_params_key_nn + not null, + value varchar(200), + config_required_p char(1) + default 'f' + constraint p_element_params_cfg_req_p_nn + not null + constraint p_element_params_cfg_req_p_ck + check (config_required_p in ('t', 'f')), + configured_p char(1) + default 'f' + constraint p_element_params_cfg_p_nn + not null + constraint p_element_params_cfg_p_ck + check(configured_p in ('t', 'f')) +); + +create index p_element_params_elem_key_idx on portal_element_parameters (element_id, key); + +comment on table portal_element_parameters ' + parameters on a per-element basis. the data structure is that of a multiset (aka bag) + where multiple entries with the same key (for the same element) are allowed ?? XXXX. +'; + +comment on column portal_element_parameters.config_required_p ' +'; + +comment on column portal_element_parameters.configured_p ' +'; Index: openacs-4/contrib/packages/portal/sql/oracle/portal-core-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/oracle/portal-core-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/oracle/portal-core-drop.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,36 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- drop portals model +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: portal-core-drop.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +drop sequence portal_seq; + +drop table portal_element_parameters; +drop table portal_elements; +drop table portal_pages; +drop table portals; +drop table portal_themes; +drop table portal_layout_regions; +drop table portal_layouts; +drop table portal_datasource_def_params; +drop table portal_datasources; Index: openacs-4/contrib/packages/portal/sql/oracle/portal-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/oracle/portal-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/oracle/portal-create.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,35 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- create portals +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: portal-create.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +@@ portal-core-create.sql; +@@ objects-create.sql; +@@ page-package-create.sql; +@@ portal-package-create.sql; +@@ theme-package-create.sql; +@@ layout-package-create.sql; +@@ datasource-package-create.sql; +@@ datasource-sc-create.sql; + +@@ defaults.sql; Index: openacs-4/contrib/packages/portal/sql/oracle/portal-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/oracle/portal-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/oracle/portal-drop.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,33 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- drop portals +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: portal-drop.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +@@ datasource-sc-drop.sql +@@ datasource-package-drop.sql; +@@ layout-package-drop.sql; +@@ portal-package-drop.sql; +@@ theme-package-drop.sql; +@@ page-package-drop.sql; +@@ portal-core-drop.sql +@@ objects-drop.sql Index: openacs-4/contrib/packages/portal/sql/oracle/portal-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/oracle/portal-package-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/oracle/portal-package-create.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,197 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- create portals package +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: portal-package-create.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +create or replace package portal +as + + function new ( + p_portal_id in portals.portal_id%TYPE default null, + p_name in portals.name%TYPE default 'Untitled', + p_theme_id in portals.theme_id%TYPE default null, + p_template_id in portals.template_id%TYPE default null, + p_object_type in acs_objects.object_type%TYPE default 'portal', + p_creation_date in acs_objects.creation_date%TYPE default sysdate, + p_creation_user in acs_objects.creation_user%TYPE default null, + p_creation_ip in acs_objects.creation_ip%TYPE default null, + p_context_id in acs_objects.context_id%TYPE default null + ) return portals.portal_id%TYPE; + + procedure delete ( + p_portal_id in portals.portal_id%TYPE + ); + +end portal; +/ +show errors + +create or replace package body portal +as + + function new ( + p_portal_id in portals.portal_id%TYPE default null, + p_name in portals.name%TYPE default 'Untitled', + p_theme_id in portals.theme_id%TYPE default null, + p_template_id in portals.template_id%TYPE default null, + p_object_type in acs_objects.object_type%TYPE default 'portal', + p_creation_date in acs_objects.creation_date%TYPE default sysdate, + p_creation_user in acs_objects.creation_user%TYPE default null, + p_creation_ip in acs_objects.creation_ip%TYPE default null, + p_context_id in acs_objects.context_id%TYPE default null + ) return portals.portal_id%TYPE + is + v_portal_id portals.portal_id%TYPE; + v_theme_id portals.theme_id%TYPE; + v_page_id portal_pages.page_id%TYPE; + v_new_element_id portal_elements.element_id%TYPE; + v_new_parameter_id portal_element_parameters.parameter_id%TYPE; + begin + + v_portal_id := acs_object.new( + object_id => p_portal_id, + object_type => p_object_type, + creation_date => p_creation_date, + creation_user => p_creation_user, + creation_ip => p_creation_ip, + context_id => p_context_id + ); + + if template_id is null then + + if p_theme_id is null then + select max(theme_id) + into v_theme_id + from portal_themes; + else + v_theme_id := p_theme_id; + end if; + + insert + into portals + (portal_id, name, theme_id) + values + (v_portal_id, p_name, v_theme_id); + + else + + -- we have a portal as our template. copy it's theme, pages, layouts, + -- elements, and element params. + select theme_id + into v_theme_id + from portals + where portal_id = p_template_id; + + insert + into portals + (portal_id, name, theme_id, template_id) + values + (v_portal_id, p_name, v_theme_id, p_template_id); + + -- now insert the pages from the portal template + for v_page in (select * + from portal_pages + where portal_id = p_template_id) + loop + + v_page_id := portal_page.new( + name => v_page.name, + portal_id => v_portal_id, + layout_id => v_page.layout_id + creation_date => p_creation_date, + creation_user => p_creation_user, + creation_ip => p_creation_ip, + context_id => v_portal_id + ); + + -- now get the elements on the template's page and put them on the new page + for v_element in (select * + from portal_elements + where page_id = v_page.page_id) + loop + + select portal_seq.nextval + into v_new_element_id + from dual; + + insert + into portal_elements + (element_id, name, page_id, datasource_id, region, sort_key, state, shadeable_p, hideable_p) + select v_new_element_id, name, v_page_id, datasource_id, region, sort_key, state, shadeable_p, hideable_p + from portal_elements + where element_id = v_element.element_id; + + -- now for the element's params + for v_param in (select * + from portal_element_parameters + where element_id = v_element.element_id) + loop + + select portal_seq.nextval + into v_new_parameter_id + from dual; + + insert + into portal_element_parameters + (parameter_id, element_id, config_required_p, configured_p, key, value) + select v_new_parameter_id, v_new_element_id, config_required_p, configured_p, key, value + from portal_element_parameters + where parameter_id = v_param.parameter_id; + + end loop; + + end loop; + + end loop; + + end if; + + return v_portal_id; + + end new; + + procedure delete ( + p_portal_id in portals.portal_id%TYPE + ) + is + begin + + for v_page in (select page_id + from portal_pages + where portal_id = p_portal_id + order by sort_key desc) + loop + portal_page.delete(v_page.page_id); + end loop; + + delete + from portals + where portal_id = p_portal_id; + + acs_object.delete(p_portal_id); + + end delete; + +end portal; +/ +show errors Index: openacs-4/contrib/packages/portal/sql/oracle/portal-package-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/oracle/portal-package-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/oracle/portal-package-drop.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,27 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- drop portals package +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: portal-package-drop.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +drop package body portal; +drop package portal; Index: openacs-4/contrib/packages/portal/sql/oracle/theme-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/oracle/theme-package-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/oracle/theme-package-create.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,98 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- create portal themes package +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: theme-package-create.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +create or replace package portal_theme +as + + function new ( + p_theme_id in portal_themes.theme_id%TYPE default null, + p_name in portal_themes.name%TYPE, + p_description in portal_themes.description%TYPE default null, + p_filename in portal_themes.filename%TYPE, + p_resource_dir in portal_themes.resource_dir%TYPE, + p_object_type in acs_objects.object_type%TYPE default 'portal_theme', + p_creation_date in acs_objects.creation_date%TYPE default sysdate, + p_creation_user in acs_objects.creation_user%TYPE default null, + p_creation_ip in acs_objects.creation_ip%TYPE default null, + p_context_id in acs_objects.context_id%TYPE default null + ) return portal_themes.theme_id%TYPE; + + procedure delete ( + p_theme_id in portal_themes.theme_id%TYPE + ); + +end portal_theme; +/ +show errors + +create or replace package body portal_theme +as + + function new ( + p_theme_id in portal_themes.theme_id%TYPE default null, + p_name in portal_themes.name%TYPE, + p_description in portal_themes.description%TYPE default null, + p_filename in portal_themes.filename%TYPE, + p_resource_dir in portal_themes.resource_dir%TYPE, + p_object_type in acs_objects.object_type%TYPE default 'portal_theme', + p_creation_date in acs_objects.creation_date%TYPE default sysdate, + p_creation_user in acs_objects.creation_user%TYPE default null, + p_creation_ip in acs_objects.creation_ip%TYPE default null, + p_context_id in acs_objects.context_id%TYPE default null + ) return portal_themes.theme_id%TYPE + is + v_theme_id portal_themes.theme_id%TYPE; + begin + + v_theme_id := acs_object.new( + object_id => p_theme_id, + object_type => p_object_type, + creation_date => p_creation_date, + creation_user => p_creation_user, + creation_ip => p_creation_ip, + context_id => p_context_id + ); + + insert + into portal_themes + (theme_id, name, description, filename, resource_dir) + values + (v_theme_id, p_name, p_description, p_filename, p_resource_dir); + + return v_theme_id; + + end new; + + procedure delete ( + p_theme_id in portal_themes.theme_id%TYPE + ) + is + begin + acs_object.delete(p_theme_id); + end delete; + +end portal_theme; +/ +show errors Index: openacs-4/contrib/packages/portal/sql/oracle/theme-package-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/oracle/theme-package-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/oracle/theme-package-drop.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,27 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- drop portal themes package +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: theme-package-drop.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +drop package body portal_theme; +drop package portal_theme; Index: openacs-4/contrib/packages/portal/sql/oracle/upgrade/upgrade-jun-07-2002.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/oracle/upgrade/upgrade-jun-07-2002.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/oracle/upgrade/upgrade-jun-07-2002.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,3 @@ + +create index p_element__prms_elem_id_idx on portal_element_parameters (element_id); +create index p_element_prms_elem_key_idx on portal_element_parameters (element_id, key); Index: openacs-4/contrib/packages/portal/sql/oracle/upgrade/upgrade-jun-11-2002.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/oracle/upgrade/upgrade-jun-11-2002.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/oracle/upgrade/upgrade-jun-11-2002.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,11 @@ +-- remove the 3 col with header layout from the system +-- the data in the portal_layout_regions table will cascade +declare + v_layout_id portal_layouts.layout_id%TYPE; +begin + select layout_id into v_layout_id from portal_layouts where name = '3-column w/ Header'; + + portal_layout.delete( layout_id => v_layout_id ); +end; + + Index: openacs-4/contrib/packages/portal/sql/postgresql/add-sloan-theme.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/postgresql/add-sloan-theme.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/postgresql/add-sloan-theme.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,43 @@ +-- +-- 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. +-- + +-- +-- The New Portal Package +-- copyright 2001, OpenForce, Inc. +-- distributed under the GNU GPL v2 +-- +-- Arjun Sanyal (arjun@openforce.net) +-- $Id: add-sloan-theme.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + + +-- Insert some default templates. +create function inline_0() +returns integer as ' +begin + perform portal_element_theme__new ( + ''Sloan'', -- name + ''MIT Sloan theme'', -- description + ''themes/sloan-theme'', -- filename + ''themes/sloan-theme'' -- directory + ); + return 0; +end;' language 'plpgsql'; + +select inline_0(); + +drop function inline_0(); + Index: openacs-4/contrib/packages/portal/sql/postgresql/datasource-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/postgresql/datasource-package-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/postgresql/datasource-package-create.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,103 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- create portal datasource package +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: datasource-package-create.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +select define_function_args('portal_datasource__new', 'name,shadeable_p;t,hideable_p;t,description'); + +create or replace function portal_datasource__new (varchar, varchar, varchar, varchar) +returns integer as ' +declare + p_name alias for $1; + p_shadeable_p alias for $2; + p_hideable_p alias for $3; + p_description alias for $4; + v_datasource_id portal_datasources.datasource_id%TYPE; +begin + + v_datasource_id := nextval(''portal_seq''); + + insert into portal_datasources + (datasource_id, name, shadeable_p, hideable_p, description) + values + (v_datasource_id, p_name, p_shadeable_p, p_hideable_p, p_description); + + return v_datasource_id; + +end;' language 'plpgsql'; + +create or replace function portal_datasource__new (varchar, varchar) +returns integer as ' +declare + p_name alias for $1; + p_description alias for $2; + v_datasource_id portal_datasources.datasource_id%TYPE; +begin + + v_datasource_id := portal_datasource__new( + p_name, + ''t'', + ''t'', + p_description + ); + + return v_datasource_id; + +end;' language 'plpgsql'; + +select define_function_args('portal_datasource__delete', 'datasource_id'); + +create or replace function portal_datasource__delete (integer) +returns integer as ' +declare + p_datasource_id alias for $1; +begin + + delete + from portal_datasources + where datasource_id = :p_datasource_id; + + return 0; + +end;' language 'plpgsql'; + +select define_function_args('portal_datasource__set_def_param', 'datasource_id,config_required_p,configured_p,key,value'); + +create or replace function portal_datasource__set_def_param (integer,varchar,varchar,varchar,varchar) +returns integer as ' +declare + p_datasource_id alias for $1; + p_config_required_p alias for $2; + p_configured_p alias for $3; + p_key alias for $4; + p_value alias for $5; +begin + + insert into portal_datasource_parameters + (parameter_id, datasource_id, config_required_p, configured_p, key, value) + values + (portal_seq.nextval, p_datasource_id, p_config_required_p, p_configured_p, p_key, p_value); + + return 0; + +end;' language 'plpgsql'; Index: openacs-4/contrib/packages/portal/sql/postgresql/datasource-package-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/postgresql/datasource-package-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/postgresql/datasource-package-drop.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,26 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- drop portal datasource package +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: datasource-package-drop.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +select drop_package('portal_datasource'); Index: openacs-4/contrib/packages/portal/sql/postgresql/datasource-sc-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/postgresql/Attic/datasource-sc-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/postgresql/datasource-sc-create.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,148 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- create portal datasource service contract +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: datasource-sc-create.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +create function inline_0 () +returns integer as ' +begin + + perform acs_sc_contract__new( + ''portal_datasource'', + ''Portal Datasource interface'' + ); + + -- Get my name - not to be confused with the pretty_name + perform acs_sc_msg_type__new( + ''portal_datasource.GetMyName.InputType'', + '''' + ); + + perform acs_sc_msg_type__new( + ''portal_datasource.GetMyName.OutputType'', + ''get_my_name:string'' + ); + + perform acs_sc_operation__new( + ''portal_datasource'', + ''GetMyName'', + ''Get the name'', + ''t'', + 0, + ''portal_datasource.GetMyName.InputType'', + ''portal_datasource.GetMyName.OutputType'' + ); + + -- Get a pretty name + perform acs_sc_msg_type__new( + ''portal_datasource.GetPrettyName.InputType'', + '''' + ); + + perform acs_sc_msg_type__new( + ''portal_datasource.GetPrettyName.OutputType'', + ''pretty_name:string'' + ); + + perform acs_sc_operation__new( + ''portal_datasource'', + ''GetPrettyName'', + ''Get the pretty name'', + ''t'', + 0, + ''portal_datasource.GetPrettyName.InputType'', + ''portal_datasource.GetPrettyName.OutputType'' + ); + + -- Tell the datasource to add itself to a portal page + -- add_self_to_page + -- The "args" string is an ns_set of extra arguments + perform acs_sc_msg_type__new( + ''portal_datasource.AddSelfToPage.InputType'', + ''page_id:integer,instance_id:integer,args:string'' + ); + + perform acs_sc_msg_type__new( + ''portal_datasource.AddSelfToPage.OutputType'', + ''element_id:integer'' + ); + + perform acs_sc_operation__new( + ''portal_datasource'', + ''AddSelfToPage'', + ''Adds itself to the given page returns an element_id'', + ''f'', + 3, + ''portal_datasource.AddSelfToPage.InputType'', + ''portal_datasource.AddSelfToPage.OutputType'' + ); + + perform acs_sc_msg_type__new( + ''portal_datasource.Show.InputType'', + ''cf:string'' + ); + + perform acs_sc_msg_type__new( + ''portal_datasource.Show.OutputType'', + ''output:string'' + ); + + perform acs_sc_operation__new( + ''portal_datasource'', + ''Show'', + ''Render the portal element returning a chunk of HTML'', + ''f'', + 1, + ''portal_datasource.Show.InputType'', + ''portal_datasource.Show.OutputType'' + ); + + -- Tell the PE to remove itself from a page + -- remove_self_from_page + perform acs_sc_msg_type__new( + ''portal_datasource.RemoveSelfFromPage.InputType'', + ''page_id:integer,instance_id:integer'' + ); + + perform acs_sc_msg_type__new( + ''portal_datasource.RemoveSelfFromPage.OutputType'', + '''' + ); + + perform acs_sc_operation__new( + ''portal_datasource'', + ''RemoveSelfFromPage'', + '' remove itself from the given page'', + ''f'', + 2, + ''portal_datasource.RemoveSelfFromPage.InputType'', + ''portal_datasource.RemoveSelfFromPage.OutputType'' + ); + + return 0; + +end;' language 'plpgsql'; + +select inline_0(); + +drop function inline_0(); Index: openacs-4/contrib/packages/portal/sql/postgresql/datasource-sc-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/postgresql/Attic/datasource-sc-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/postgresql/datasource-sc-drop.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,111 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- drop portal datasource service contract +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: datasource-sc-drop.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +create function inline_0 () +returns integer as ' +begin + + -- drop GetMyName + perform acs_sc_operation__delete( + ''portal_datasource'', + ''GetMyName'' + ); + + perform acs_sc_msg_type__delete( + ''portal_datasource.GetMyName.InputType'' + ); + + perform acs_sc_msg_type__delete( + ''portal_datasource.GetMyName.OutputType'' + ); + + -- drop GetPrettyName + perform acs_sc_operation__delete( + ''portal_datasource'', + ''GetPrettyName'' + ); + + perform acs_sc_msg_type__delete( + ''portal_datasource.GetPrettyName.InputType'' + ); + + perform acs_sc_msg_type__delete( + ''portal_datasource.GetPrettyName.OutputType'' + ); + + -- Drop add_self_to_page + perform acs_sc_operation__delete( + ''portal_datasource'', + ''AddSelfToPage'' + ); + + perform acs_sc_msg_type__delete( + ''portal_datasource.AddSelfToPage.InputType'' + ); + + perform acs_sc_msg_type__delete( + ''portal_datasource.AddSelfToPage.OutputType'' + ); + + -- Delete Show + perform acs_sc_operation__delete( + ''portal_datasource'', + ''Show'' + ); + + perform acs_sc_msg_type__delete( + ''portal_datasource.Show.InputType'' + ); + + perform acs_sc_msg_type__delete( + ''portal_datasource.Show.OutputType'' + ); + + -- RemoveSelfFromPage + perform acs_sc_operation__delete( + ''portal_datasource'', + ''RemoveSelfFromPage'' + ); + + perform acs_sc_msg_type__delete( + ''portal_datasource.RemoveSelfFromPage.InputType'' + ); + + perform acs_sc_msg_type__delete( + ''portal_datasource.RemoveSelfFromPage.OutputType'' + ); + + -- drop the contract + perform acs_sc_contract__delete( + ''portal_datasource'' + ); + + return 0; + +end;' language 'plpgsql'; + +select inline_0(); + +drop function inline_0(); Index: openacs-4/contrib/packages/portal/sql/postgresql/defaults.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/postgresql/Attic/defaults.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/postgresql/defaults.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,96 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- create portal defaults +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: defaults.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +create function inline_0 () +returns integer as ' +declare + layout_id portal_layouts.layout_id%TYPE; + theme_id portal_themes.theme_id%TYPE; +begin + + -- one-column layout, without a header. + layout_id := portal_layout__new( + ''1_column'', + ''A simple 1-column layout'', + ''layouts/simple1'', + ''layouts/components/simple1'' + ); + + -- the supported regions for that layout. + perform portal_layout__add_region(layout_id, ''1''); + + -- two-column layout, without a header. + layout_id := portal_layout__new( + ''2_column'', + ''A simple 2-column layout'', + ''layouts/simple2'', + ''layouts/components/simple2'' + ); + + -- the supported regions for that layout. + perform portal_layout__add_region(layout_id, ''1''); + perform portal_layout__add_region(layout_id, ''2''); + + -- same as above, only, three columns. + layout_id := portal_layout__new( + ''3_column'', + ''A simple 3-column layout'', + ''layouts/simple3'', + ''layouts/components/simple3'' + ); + + perform portal_layout__add_region(layout_id, ''1''); + perform portal_layout__add_region(layout_id, ''2''); + perform portal_layout__add_region(layout_id, ''3''); + + -- Now, some element themes. + theme_id := portal_theme__new( + ''simple'', + ''A simple red table-based theme'', + ''themes/simple-theme'', + ''themes/simple-theme'' + ); + + theme_id := portal_theme__new( + ''nada'', + ''The un-theme. No graphics.'', + ''themes/nada-theme'', + ''themes/nada-theme'' + ); + + theme_id := portal_theme__new( + ''deco'', + ''An Art Deco theme'', + ''themes/deco-theme'', + ''themes/deco-theme'' + ); + + return 0; + +end;' language 'plpgsql'; + +select inline_0(); + +drop function inline_0(); Index: openacs-4/contrib/packages/portal/sql/postgresql/layout-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/postgresql/layout-package-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/postgresql/layout-package-create.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,78 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- create portal layouts package +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: layout-package-create.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +select define_function_args('portal_layout__new', 'layout_id,name,description,filename,resource_dir,object_type;portal_layout,creation_date,creation_user,creation_ip,context_id'); + +create or replace function portal_layout__new (integer,varchar,varchar,varchar,varchar,varchar,timestamp,integer,varchar,integer) +returns integer as ' +declare + p_layout_id alias for $1; + p_name alias for $2; + p_description alias for $3; + p_filename alias for $4; + p_resource_dir alias for $5; + p_object_type alias for $6; + p_creation_date alias for $7; + p_creation_user alias for $8; + p_creation_ip alias for $9; + p_context_id alias for $10; + v_layout_id portal_layouts.layout_id%TYPE; +begin + + v_layout_id := acs_object__new( + p_layout_id, + p_object_type, + p_creation_date, + p_creation_user, + p_creation_ip, + p_context_id, + ''t'' + ); + + insert into portal_layouts + (layout_id, name, description, filename, resource_dir) + values + (v_layout_id, p_name, p_description, p_filename, p_resource_dir); + + return v_layout_id; + +end;' language 'plpgsql'; + +select define_function_args('portal_layout__delete', 'layout_id'); + +create or replace function portal_layout__delete (integer) +returns integer as ' + p_layout_id alias for $1; +begin + + delete + from portal_layouts + where layout_id = p_layout_id; + + perform acs_object__delete(p_layout_id); + + return 0; + +end;' language 'plpgsql'; Index: openacs-4/contrib/packages/portal/sql/postgresql/layout-package-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/postgresql/layout-package-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/postgresql/layout-package-drop.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,26 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- drop portal layouts package +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: layout-package-drop.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +select drop_package('portal_layout'); Index: openacs-4/contrib/packages/portal/sql/postgresql/objects-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/postgresql/objects-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/postgresql/objects-create.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,76 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- create portal metadata +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: objects-create.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +select acs_object_type__create_type( + 'portal', + 'Portal', + 'Portals', + 'acs_object', + 'PORTALS', + 'PORTAL_ID', + 'portal', + 'f', + null, + null +); + +select acs_object_type__create_type( + 'portal_theme', + 'Portal Theme', + 'Portal Themes', + 'acs_object', + 'PORTAL_THEMES', + 'THEME_ID', + 'portal_themes', + 'f', + null, + null +); + +select acs_object_type__create_type( + 'portal_page', + 'Portal Page', + 'Portal Pages', + 'acs_object', + 'PORTAL_PAGES', + 'PAGE_ID', + 'portal_page', + 'f', + null, + null +); + +select acs_object_type__create_type( + 'portal_layout', + 'Portal Layout', + 'Portal Layouts', + 'acs_object', + 'PORTAL_LAYOUTS', + 'LAYOUT_ID', + 'portal_layout', + 'f', + null, + null +); Index: openacs-4/contrib/packages/portal/sql/postgresql/objects-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/postgresql/objects-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/postgresql/objects-drop.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,45 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- drop portal metadata +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: objects-drop.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +delete +from acs_permissions +where object_id in (select object_id + from acs_objects + where object_type in ('portal', 'portal_theme', 'portal_page', 'portal_layout')); + +delete +from acs_permissions +where object_id in (select package_id + from apm_packages + where package_key = 'portal'); + +delete +from acs_objects +where object_type in ('portal', 'portal_theme', 'portal_page', 'portal_layout'); + +select acs_object_type__drop_type('portal', 'f'); +select acs_object_type__drop_type('portal_theme', 'f'); +select acs_object_type__drop_type('portal_page', 'f'); +select acs_object_type__drop_type('portal_layout', 'f'); Index: openacs-4/contrib/packages/portal/sql/postgresql/page-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/postgresql/page-package-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/postgresql/page-package-create.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,127 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- create portal pages package +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: page-package-create.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +select define_function_args('portal_page__new', 'page_id,name,portal_id,layout_id,object_type;portal_page,creation_date,creation_user,creation_ip,context_id'); + +create or replace function portal_page__new (integer,varchar,integer,integer,varchar,timestamp,integer,varchar,integer) +returns integer as ' +declare + p_page_id alias for $1; + p_name alias for $2; + p_portal_id alias for $3; + p_layout_id alias for $4; + p_object_type alias for $5; + p_creation_date alias for $6; + p_creation_user alias for $7; + p_creation_ip alias for $8; + p_context_id alias for $9; + v_page_id portal_pages.page_id%TYPE; + v_layout_id portal_pages.layout_id%TYPE; + v_sort_key portal_pages.sort_key%TYPE; +begin + + v_page_id := acs_object__new( + p_page_id, + p_object_type, + p_creation_date, + p_creation_user, + p_creation_ip, + coalesce(p_context_id, p_portal_id), + ''t'' + ); + + if p_layout_id is null then + select min(layout_id) + into v_layout_id + from portal_layouts; + else + v_layout_id := p_layout_id; + end if; + + select coalesce(max(sort_key) + 1, 0) + into v_sort_key + from portal_pages + where portal_id = p_portal_id; + + insert into portal_pages + (page_id, name, portal_id, layout_id, sort_key) + values + (v_page_id, p_name, p_portal_id, v_layout_id, v_sort_key); + + return v_page_id; + +end;' language 'plpgsql'; + +select define_function_args('portal_page__delete', 'page_id'); + +create or replace function portal_page__delete(integer) +returns integer as ' +declare + p_page_id alias for $1; + v_portal_id portal_pages.portal_id%TYPE; + v_sort_key portal_pages.sort_key%TYPE; + v_curr_sort_key portal_pages.sort_key%TYPE; + v_page_count_from_0 integer; +begin + + -- IMPORTANT: sort keys MUST be an unbroken sequence from 0 to max(sort_key) + + select portal_id, sort_key + into v_portal_id, v_sort_key + from portal_pages + where page_id = p_page_id; + + select (count(*) - 1) + into v_page_count_from_0 + from portal_pages + where portal_id = v_portal_id; + + for i in 0 .. v_page_count_from_0 loop + + if i = v_sort_key then + + delete + from portal_pages + where page_id = p_page_id; + + elsif i > v_sort_key then + + update portal_pages + set sort_key = -1 + where sort_key = i; + + update portal_pages + set sort_key = i - 1 + where sort_key = -1; + + end if; + + end loop; + + perform acs_object__delete(p_page_id); + + return 0; + +end;' language 'plpgsql'; Index: openacs-4/contrib/packages/portal/sql/postgresql/page-package-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/postgresql/page-package-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/postgresql/page-package-drop.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,26 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- drop portal pages package +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: page-package-drop.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +select drop_package('portal_page'); Index: openacs-4/contrib/packages/portal/sql/postgresql/portal-core-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/postgresql/portal-core-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/postgresql/portal-core-create.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,354 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- create portals model +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: portal-core-create.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +create sequence portal_seq; + +create table portal_datasources ( + datasource_id integer + constraint portal_datasources_pk + primary key, + name varchar(200) + constraint p_datasources_name_nn + not null, + shadeable_p char(1) + default 't' + constraint p_datasources_shadeable_p_nn + not null + constraint p_datasources_shadeable_p_ck + check (shadeable_p in ('t', 'f')), + hideable_p char(1) + default 't' + constraint p_datasources_hideable_p_nn + not null + constraint p_datasources_hideable_p_ck + check (hideable_p in ('t', 'f')), + description varchar(200) +); + +comment on table portal_datasources ' +'; + +create table portal_datasource_parameters ( + datasource_id integer + constraint p_ds_params_datasource_id_fk + references portal_datasources (datasource_id) + on delete cascade + constraint p_ds_params_datasource_id_nn + not null, + key varchar(200) + constraint p_ds_params_key_nn + not null, + value varchar(200), + config_required_p char(1) + default 'f' + constraint p_ds_params_cfg_req_p_nn + not null + constraint p_ds_params_cfg_req_p_ck + check (config_required_p in ('t', 'f')), + configured_p char(1) + default 'f' + constraint p_ds_params_cfg_p_nn + not null + constraint p_ds_params_cfg_p_ck + check (configured_p in ('t', 'f')), + constraint portal_datasource_params_pk + primary key (datasource_id, key) + +); + +comment on table portal_datasource_parameters ' + maintains a set of default parameters for portal datsources. these + are copied to a portal element when it is created. + + configuration semantics: + + config_required_p | configured_p | + ----------------- | ----------------- | ---------------------------------- + t | t | static configuration is provided + | | for the portal elements. it can be + | | changed later. + ----------------- | ----------------- | ---------------------------------- + t | f | the portal element must be + | | configured when created. + ----------------- | ----------------- | ---------------------------------- + f | t | an optional default configuration + | | is provided. + ----------------- | ----------------- | ---------------------------------- + f | f | configuration is optional and no + | | default is provided. +'; + +comment on column portal_datasource_parameters.config_required_p ' + this parameter requires configuration. if configured_p is true then no + action is needed at portal element creation since the portal element + can simply use the default value provided. if configured_p is false then + the portal element must provide a value for this parameter at creation + time. +'; + +comment on column portal_datasource_parameters.configured_p ' + if true then a default value is provided for this parameter. +'; + +create table portal_layouts ( + layout_id integer + constraint p_layouts_layout_id_fk + references acs_objects (object_id) + constraint portal_layouts_pk + primary key, + name varchar(200) + constraint p_layouts_name_un + unique + constraint p_layouts_name_nn + not null, + description varchar(200), + filename varchar(200), + resource_dir varchar(200) +); + +comment on table portal_layouts ' +'; + +comment on column portal_layouts.filename ' +'; + +comment on column portal_layouts.resource_dir ' +'; + +create table portal_layout_regions ( + layout_id integer + constraint p_layout_regions_layout_id_fk + references portal_layouts (layout_id) + on delete cascade + constraint p_layout_regions_layout_id_nn + not null, + region varchar(20) + constraint p_layout_regions_region_nn + not null, + constraint portal_layout_regions_pk + primary key (layout_id, region) +); + +comment on table portal_layout_regions ' +'; + +comment on column portal_layout_regions.region ' +'; + +-- Themes are templates with decoration for PEs, nothing more. +-- At this point they will just be bits of ADPs in the filesystem +create table portal_themes ( + theme_id integer + constraint p_themes_theme_id_fk + references acs_objects (object_id) + constraint portal_themes_pk + primary key, + name varchar(200) + constraint p_themes_name_un + unique + constraint p_themes_name_nn + not null, + description varchar(200), + filename varchar(200), + resource_dir varchar(200) +); + +comment on table portal_themes ' +'; + +comment on column portal_themes.filename ' +'; + +comment on column portal_themes.resource_dir ' +'; + +-- Portals are essentially "containers" for PEs that bind to DSs. +-- Parties have, optionally have portals +-- Restrict to party check? +-- Roles and perms issues? +create table portals ( + portal_id integer + constraint p_portal_id_fk + references acs_objects (object_id) + constraint portals_pk + primary key, + name varchar(200) + default 'Untitled' + constraint p_name_nn + not null, + theme_id integer + constraint p_theme_id_fk + references portal_themes (theme_id) + constraint p_theme_id_nn + not null, + template_id integer + constraint p_template_id_fk + references portals (portal_id) +); + +comment on table portals ' +'; + +comment on column portals.template_id ' +'; + +create table portal_pages ( + page_id integer + constraint p_pages_page_id_fk + references acs_objects (object_id) + constraint portal_pages_pk + primary key, + name varchar(200) + default 'Untitled Page' + constraint p_pages_name_nn + not null, + portal_id integer + constraint p_pages_portal_id_fk + references portals (portal_id) + constraint p_pages_portal_id_nn + not null, + layout_id integer + constraint p_pages_layout_id_fk + references portal_layouts (layout_id) + constraint p_pages_layout_id_nn + not null, + sort_key integer + constraint p_pages_sort_key_nn + not null, + constraint p_pages_portal_id_sort_key_un + unique (portal_id, sort_key) +); + +create index portal_pages_prtl_page_idx on portal_pages (portal_id, page_id); + +comment on table portal_pages ' +'; + +comment on column portal_pages.sort_key ' +'; + +-- Support for multi-page portals (think my.yahoo.com) +-- PE are fully owned by one and only one portal. They are not +-- "objects" that live on after their portal is gone. One way to think +-- of them is a map b/w a portal and a DS, with satellite data of a +-- theme, a config, a region, etc. +-- +-- No securtiy checks are done here. If you can view and bind to a DS you have +-- a PE for it. + +create table portal_elements ( + element_id integer + constraint portal_elements_pk + primary key, + datasource_id integer + constraint p_elements_datasource_id_fk + references portal_datasources (datasource_id) + on delete cascade + constraint p_elements_datasource_id_nn + not null, + name varchar(200) + constraint p_elements_name_nn + not null, + page_id integer + constraint p_elements_page_id_fk + references portal_pages + on delete cascade + constraint p_elements_page_id_nn + not null, + region varchar(20) + constraint p_elements_region_nn + not null, + sort_key integer + constraint p_elements_sort_key_nn + not null + constraint p_elements_sort_key_ck + check (sort_key > 0), + state varchar(6) + default 'full' + constraint p_elements_state_ck + check (state in ('full', 'shaded', 'hidden', 'pinned')), + shadeable_p char(1) + default 't' + constraint p_elements_shadeable_p_nn + not null + constraint p_elements_shadeable_p_ck + check (shadeable_p in ('t', 'f')), + hideable_p char(1) + default 't' + constraint p_elements_hideable_p_nn + not null + constraint p_elements_hideable_p_ck + check (hideable_p in ('t', 'f')), + constraint p_elements_page_id_name_un + unique (page_id, name) +); + +comment on table portal_elements ' +'; + +comment on column portal_elements.sort_key ' +'; + +comment on column portal_elements.state ' +'; + +create table portal_element_parameters ( + parameter_id integer + constraint portal_element_parameters_pk + primary key, + element_id integer + constraint p_element_params_element_id_fk + references portal_elements (element_id) + on delete cascade + constraint p_element_params_element_id_nn + not null, + key varchar(50) + constraint p_element_params_key_nn + not null, + value varchar(200), + config_required_p char(1) + default 'f' + constraint p_element_params_cfg_req_p_nn + not null + constraint p_element_params_cfg_req_p_ck + check (config_required_p in ('t', 'f')), + configured_p char(1) + default 'f' + constraint p_element_params_cfg_p_nn + not null + constraint p_element_params_cfg_p_ck + check (configured_p in ('t', 'f')) +); + +create index p_element_params_element_key_idx on portal_element_parameters (element_id, key); + +comment on table portal_element_parameters ' +'; + +comment on column portal_element_parameters.config_required_p ' +'; + +comment on column portal_element_parameters.configured_p ' +'; Index: openacs-4/contrib/packages/portal/sql/postgresql/portal-core-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/postgresql/portal-core-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/postgresql/portal-core-drop.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,36 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- drop portals model +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: portal-core-drop.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +drop sequence portal_seq; + +drop table portal_element_parameters; +drop table portal_elements; +drop table portal_pages; +drop table portals; +drop table portal_themes; +drop table portal_layout_regions; +drop table portal_layouts; +drop table portal_datasource_parameters; +drop table portal_datasources; Index: openacs-4/contrib/packages/portal/sql/postgresql/portal-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/postgresql/portal-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/postgresql/portal-create.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,34 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- create portal +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: portal-create.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +\i portal-core-create.sql; +\i objects-create.sql; +\i page-package-create.sql; +\i portal-package-create.sql; +\i theme-package-create.sql; +\i layout-package-create.sql; +\i datasource-package-create.sql; +\i datasource-sc-create.sql; +\i defaults.sql; Index: openacs-4/contrib/packages/portal/sql/postgresql/portal-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/postgresql/portal-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/postgresql/portal-drop.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,33 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- drop portal +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: portal-drop.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +\i datasource-sc-drop.sql; +\i datasource-package-drop.sql; +\i layout-package-drop.sql; +\i portal-package-drop.sql; +\i theme-package-drop.sql; +\i page-package-drop.sql; +\i portal-core-drop.sql; +\i objects-drop.sql; Index: openacs-4/contrib/packages/portal/sql/postgresql/portal-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/postgresql/portal-package-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/postgresql/portal-package-create.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,180 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- create portals package +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: portal-package-create.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +select define_function_args('portal__new', 'portal_id,name,theme_id,template_id,object_type;portal,creation_date,creation_user,creation_ip,context_id'); + +create or replace function portal__new (integer,varchar,integer,integer,varchar,timestamp,integer,varchar,integer) +returns integer as ' +declare + p_portal_id alias for $1; + p_name alias for $2; + p_theme_id alias for $3; + p_template_id alias for $4; + p_object_type alias for $5; + p_creation_date alias for $6; + p_creation_user alias for $7; + p_creation_ip alias for $8; + p_context_id alias for $9; + v_portal_id portals.portal_id%TYPE; + v_theme_id portals.theme_id%TYPE; + v_layout_id portal_layouts.layout_id%TYPE; + v_page_id portal_pages.page_id%TYPE; + v_page record; + v_element record; + v_param record; + v_new_element_id integer; + v_new_parameter_id integer; +begin + + v_portal_id := acs_object__new( + p_portal_id, + p_object_type, + p_creation_date, + p_creation_user, + p_creation_ip, + p_context_id, + ''t'' + ); + + if p_template_id is null then + + if p_theme_id is null then + select max(theme_id) + into v_theme_id + from portal_themes; + else + v_theme_id := p_theme_id; + end if; + + insert + into portals + (portal_id, name, theme_id) + values + (v_portal_id, p_name, v_theme_id); + + else + + -- we have a portal as our template. copy its theme, pages, layouts, + -- elements, and element params. + select theme_id + into v_theme_id + from portals + where portal_id = p_template_id; + + insert + into portals + (portal_id, name, theme_id, template_id) + values + (v_portal_id, p_name, v_theme_id, p_template_id); + + -- now insert the pages from the portal template + for v_page in select * + from portal_pages + where portal_id = p_template_id + loop + + v_page_id := portal_page__new( + null, + v_page.name, + v_portal_id, + v_page.layout_id, + null, + p_creation_date, + p_creation_user, + p_creation_ip, + v_portal_id + ); + + -- now get the elements on the templates page and put them on the new page + for v_element in select * + from portal_elements + where page_id = v_page.page_id + loop + + select portal_seq.nextval + into v_new_element_id + from dual; + + insert + into portal_elements + (element_id, name, page_id, datasource_id, region, sort_key, state, shadeable_p, hideable_p) + select v_new_element_id, name, v_page_id, datasource_id, region, sort_key, state, shadeable_p, hideable_p + from portal_elements + where element_id = v_element.element_id; + + -- now for the elements params + for v_param in select * + from portal_element_parameters + where element_id = v_element.element_id + loop + + select portal_seq.nextval + into v_new_parameter_id + from dual; + + insert + into portal_element_parameters + (parameter_id, element_id, config_required_p, configured_p, key, value) + select v_new_parameter_id, v_new_element_id, config_required_p, configured_p, key, value + from portal_element_parameters + where parameter_id = v_param.parameter_id; + + end loop; + + end loop; + + end loop; + + end if; + + return v_portal_id; + +end;' language 'plpgsql'; + +select define_function_args('portal__delete', 'portal_id'); + +create or replace function portal__delete (integer) +returns integer as ' +declare + p_portal_id alias for $1; + v_page record; +begin + + for v_page in select page_id + from portal_pages + where portal_id = p_portal_id + loop + perform portal_page__delete(v_page.page_id); + end loop; + + delete + from portals + where portal_id = p_portal_id; + + perform acs_object__delete(p_portal_id); + + return 0; + +end;' language 'plpgsql'; Index: openacs-4/contrib/packages/portal/sql/postgresql/portal-package-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/postgresql/portal-package-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/postgresql/portal-package-drop.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,26 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- drop portals package +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: portal-package-drop.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +select drop_package('portal'); Index: openacs-4/contrib/packages/portal/sql/postgresql/theme-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/postgresql/theme-package-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/postgresql/theme-package-create.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,102 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- create portal themes package +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: theme-package-create.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +select define_function_args('portal_theme__new', 'theme_id,name,description,filename,resource_dir,object_type;portal_theme,creation_date,creation_user,creation_ip,context_id'); + +create or replace function portal_theme__new (integer,varchar,varchar,varchar,varchar,varchar,timestamp,integer,varchar,integer) +returns integer as ' +declare + p_theme_id alias for $1; + p_name alias for $2; + p_description alias for $3; + p_filename alias for $4; + p_resource_dir alias for $5; + p_object_type alias for $6; + p_creation_date alias for $7; + p_creation_user alias for $8; + p_creation_ip alias for $9; + p_context_id alias for $10; + v_theme_id portal_themes.theme_id%TYPE; +begin + + v_theme_id := acs_object__new( + p_theme_id, + p_object_type, + p_creation_date, + p_creation_user, + p_creation_ip, + p_context_id, + ''t'' + ); + + insert + into portal_themes + (theme_id, name, description, filename, resource_dir) + values + (v_theme_id, p_name, p_description, p_filename, p_resource_dir); + + return v_theme_id; + +end;' language 'plpgsql'; + +create or replace function portal_theme__new (varchar,varchar,varchar,varchar) +returns integer as ' +declare + p_name alias for $1; + p_description alias for $2; + p_filename alias for $3; + p_resource_dir alias for $4; + v_theme_id portal_themes.theme_id%TYPE; +begin + + v_theme_id := portal_theme__new( + null, + p_name, + p_description, + p_filename, + p_resource_dir, + ''portal_theme'', + now(), + null, + null, + null + ); + + return v_theme_id; + +end;' language 'plpgsql'; + +select define_function_args('portal_theme__delete', 'theme_id'); + +create or replace function portal_theme__delete (integer) +returns integer as ' + p_theme_id alias for $1; +begin + + perform acs_object__delete(p_theme_id); + + return 0; + +end;' language 'plpgsql'; Index: openacs-4/contrib/packages/portal/sql/postgresql/theme-package-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/postgresql/theme-package-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/sql/postgresql/theme-package-drop.sql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,26 @@ +-- +-- Copyright (C) 2001, 2002 MIT +-- +-- 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. +-- + +-- +-- drop portal themes package +-- +-- @author arjun@openforce.net +-- @author yon@openforce.net +-- @creation-date 2001-10-01 +-- @version $Id: theme-package-drop.sql,v 1.1 2002/10/25 21:29:17 yon Exp $ +-- + +select drop_package('portal_theme'); Index: openacs-4/contrib/packages/portal/tcl/datasource-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/tcl/datasource-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/tcl/datasource-procs.tcl 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,64 @@ +# +# Copyright (C) 2001, 2002 MIT +# +# 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_library { + + portal datasource procs + + @author arjun@openforce.net + @author yon@openforce.net + @creation-date 2001-09-10 + @version $Id: datasource-procs.tcl,v 1.1 2002/10/25 21:29:17 yon Exp $ + +} + +namespace eval portal::datasource { + + ad_proc -public get { + {-datasource_id:required} + } { + return the datasource in "array get" format + } { + db_1row select_datasource {} -column_array datasource + return [array get datasource] + } + + ad_proc -public get_name { + {-datasource_id:required} + } { + array set datasource [get -datasource_id $datasource_id] + return $datasource(name) + } + + ad_proc -public get_id { + {-name:required} + } { + get the id from the name + } { + return [db_string select_id {}] + } + + ad_proc -public call { + {-name:required} + {-op:required} + {-list_args ""} + } { + call a method on a datasource + } { + return [acs_sc_call portal_datasource $op $list_args $name] + } + +} Index: openacs-4/contrib/packages/portal/tcl/datasource-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/tcl/datasource-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/tcl/datasource-procs.xql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,21 @@ + + + + + + + select * + from portal_datasources + where datasource_id = :datasource_id + + + + + + select datasource_id + from portal_datasources + where name = :name + + + + Index: openacs-4/contrib/packages/portal/tcl/element-parameter-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/tcl/element-parameter-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/tcl/element-parameter-procs.tcl 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,100 @@ +# +# Copyright (C) 2001, 2002 MIT +# +# 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_library { + + portal element parameter procs + + @author arjun@openforce.net + @author yon@openforce.net + @creation-date 2001-09-10 + @version $Id: element-parameter-procs.tcl,v 1.1 2002/10/25 21:29:17 yon Exp $ + +} + +namespace eval portal::element::parameter { + + ad_proc -public new { + {-element_id:required} + {-key:required} + {-value:required} + } { + new parameter value + } { + db_dml insert_parameter {} + } + + ad_proc -private delete { + {-element_id:required} + {-key:required} + {-value} + } { + removes a value for a parameter or all values for that parameter. + } { + if {[info exists $value]} { + db_dml delete_one_parameter_value {} + } else { + db_dml delete_parameter {} + } + } + + ad_proc -public get { + {-element_id:required} + {-key:required} + } { + returns a list of values for this element/key combination + } { + return [db_list select_parameters {}] + } + + ad_proc -public set_value { + {-element_id:required} + {-key:required} + {-value:required} + } { + set the value of a parameter + } { + db_dml update_parameter {} + } + + ad_proc -public get_all { + {-element_id:required} + } { + return all parameters for element_id in "array get" format + } { + db_foreach select_parameters {} { + lappend parameters($key) $value + } + + return [array get parameters] + } + + ad_proc -private toggle { + {-element_id:required} + {-key:required} + } { + toggles a boolean (t or f) parameter + } { + set value [lindex [get -element_id $element_id -key $key] 0] + + if {[string equal $value t]} { + set_value -element_id $element_id -key $key -value f + } elseif {[string equal $value f]} { + set_value -element_id $element_id -key $key -value t + } + } + +} Index: openacs-4/contrib/packages/portal/tcl/element-parameter-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/tcl/element-parameter-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/tcl/element-parameter-procs.xql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,65 @@ + + + + + + + insert into portal_element_parameters + (parameter_id, element_id, configured_p, key, value) + select portal_seq.nextval, :element_id, 't', :key, :value + from dual + where not exists (select parameter_id + from portal_element_parameters + where element_id = :element_id + and key = :key + and value= :value) + + + + + + delete + from portal_element_parameters + where element_id = :element_id + and key = :key + and value = :value + + + + + + delete + from portal_element_parameters + where element_id = :element_id + and key = :key + + + + + + select value + from portal_element_parameters + where element_id = :element_id + and key = :key + + + + + + update portal_element_parameters + set value = :value + where element_id = :element_id + and key = :key + + + + + + select key, + value + from portal_element_parameters + where element_id = :element_id + + + + Index: openacs-4/contrib/packages/portal/tcl/element-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/tcl/element-procs-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/tcl/element-procs-oracle.xql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,85 @@ + + + + oracle8.1.6 + + + + insert into portal_elements + (element_id, datasource_id, name, page_id, region, sort_key, shadeable_p, hideable_p) + select :element_id, + :datasource_id, + :name, + :page_id, + :region, + nvl((select max(portal_elements.sort_key) + 1 + from portal_elements + where page_id = :page_id + and region = :region), 1), + portal_datasources.shadeable_p, + portal_datasources.hideable_p + from portal_datasources + where portal_datasources.datasource_id = :datasource_id + + + + + + select sort_key as other_sort_key, + element_id as other_element_id + from (select * + from portal_elements + where page_id = :page_id + and region = :region + and sort_key < :sort_key + and state != 'pinned' + order by sort_key desc) + where rownum = 1 + + + + + + select sort_key as other_sort_key, + element_id as other_element_id + from (select * + from portal_elements + where page_id = :page_id + and region = :region + and sort_key > :sort_key + and state != 'pinned' + order by sort_key asc) + where rownum = 1 + + + + + + update portal_elements + set region = :region, + sort_key = (select nvl((select max(sort_key) + 1 + from portal_elements + where page_id = :page_id + and region = :region), + 1) + from dual) + where element_id = :element_id + + + + + + update portal_elements + set page_id = :page_id, + region = :region, + sort_key = (select nvl((select max(sort_key) + 1 + from portal_elements + where page_id = :page_id + and region = :region), + 1) + from dual) + where element_id = :element_id + + + + Index: openacs-4/contrib/packages/portal/tcl/element-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/tcl/element-procs-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/tcl/element-procs-postgresql.xql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,85 @@ + + + + postgresql7.2 + + + + insert into portal_elements + (element_id, datasource_id, name, page_id, region, sort_key, shadeable_p, hideable_p) + select :element_id, + :datasource_id, + :name, + :page_id, + :region, + coalesce((select max(portal_elements.sort_key) + 1 + from portal_elements + where page_id = :page_id + and region = :region), 1), + portal_datasources.shadeable_p, + portal_datasources.hideable_p + from portal_datasources + where portal_datasources.datasource_id = :datasource_id + + + + + + select sort_key as other_sort_key, + element_id as other_element_id + from (select * + from portal_elements + where page_id = :page_id + and region = :region + and sort_key < :sort_key + and state != 'pinned' + order by sort_key desc) as other_element + limit 1 + + + + + + select sort_key as other_sort_key, + element_id as other_element_id + from (select * + from portal_elements + where page_id = :page_id + and region = :region + and sort_key > :sort_key + and state != 'pinned' + order by sort_key asc) as other_element + limit 1 + + + + + + update portal_elements + set region = :region, + sort_key = (select coalesce((select max(sort_key) + 1 + from portal_elements + where page_id = :page_id + and region = :region), + 1) + from dual) + where element_id = :element_id + + + + + + update portal_elements + set page_id = :page_id, + region = :region, + sort_key = (select coalesce((select max(sort_key) + 1 + from portal_elements + where page_id = :page_id + and region = :region), + 1) + from dual) + where element_id = :element_id + + + + Index: openacs-4/contrib/packages/portal/tcl/element-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/tcl/element-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/tcl/element-procs.tcl 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,658 @@ +# +# Copyright (C) 2001, 2002 MIT +# +# 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_library { + + portal element procs + + @author arjun@openforce.net + @author yon@openforce.net + @creation-date 2001-09-10 + @version $Id: element-procs.tcl,v 1.1 2002/10/25 21:29:17 yon Exp $ + +} + +namespace eval portal::element { + + ad_proc -public new { + {-page_id:required} + {-region:required} + {-datasource_name:required} + {-name ""} + } { + create a new portal element of type portlet_name on the given page and + region + } { + + set datasource_id [portal::datasource::get_id -name $datasource_name] + + if {[empty_string_p $name]} { + set name $datasource_name + } + + set element_id [db_nextval portal_seq] + + if {[db_0or1row select_template_element_id {}]} { + db_transaction { + db_dml insert_element_with_template {} + db_dml insert_element_parameters_with_template {} + } + } else { + db_transaction { + db_dml insert_element {} + db_dml insert_element_parameters {} + } + } + + return $element_id + + } + + ad_proc -public delete { + {-element_id:required} + } { + db_dml delete_element {} + } + + ad_proc -public delete_all { + {-portal_id:required} + {-datasource_name:required} + } { + delete al portal elements of type datasource_name from portal_id + } { + + foreach element_id [get_list_from_datasource_name \ + -portal_id $portal_id \ + -datasource_name $datasource_name \ + ] { + delete -element_id $element_id + } + + } + + ad_proc -public get { + {-element_id:required} + } { + return element info in "array get" format + } { + db_1row select_element {} -column_array element + return [array get element] + } + + ad_proc -public set_values { + {-element:required} + } { + set the fields of a portal element + } { + array set element_array $element + template::util::array_to_vars element_array + + db_dml update_element {} + } + + ad_proc -public get_name { + {-element_id:required} + } { + array set element [get -element_id $element_id] + return $element(name) + } + + ad_proc -public set_name { + {-element_id:required} + {-name:required} + } { + array set element [get -element_id $element_id] + set element(name) $name + + set_values -element [array get element] + } + + ad_proc -public get_page_id { + {-element_id:required} + } { + return the element's page_id + } { + array set element [get -element_id $element_id] + return $element(page_id) + } + + ad_proc -public get_region { + {-element_id:required} + } { + return the element's region + } { + array set element [get -element_id $element_id] + return $element(region) + } + + ad_proc -public set_region { + {-element_id:required} + {-region:required} + } { + array set element [get -element_id $element_id] + set element(region) $region + + set_values -element [array get element] + } + + ad_proc -public get_state { + {-element_id:required} + } { + return the element's state + } { + array set element [get -element_id $element_id] + return $element(state) + } + + ad_proc -public set_state { + {-element_id:required} + {-state:required} + } { + array set element [get -element_id $element_id] + set element(state) $state + + set_values -element [array get element] + } + + ad_proc -public get_shadeable_p { + {-element_id:required} + } { + return the element's shadeable_p + } { + array set element [get -element_id $element_id] + return $element(shadeable_p) + } + + ad_proc -public set_shadeable_p { + {-element_id:required} + {-shadeable_p:required} + } { + array set element [get -element_id $element_id] + set element(shadeable_p) $shadeable_p + + set_values -element [array get element] + } + + ad_proc -public get_hideable_p { + {-element_id:required} + } { + return the element's hideable_p + } { + array set element [get -element_id $element_id] + return $element(hideable_p) + } + + ad_proc -public set_hideable_p { + {-element_id:required} + {-hideable_p:required} + } { + array set element [get -element_id $element_id] + set element(hideable_p) $hideable_p + + set_values -element [array get element] + } + + ad_proc -public pin { + {-element_id:required} + } { + array set element [get -element_id $element_id] + + set element(state) pinned + set element(shadeable_p) f + set element(hideable_p) f + + set_values -element [array get element] + } + + ad_proc -public unpin { + {-element_id:required} + } { + set_state -element_id $element_id -state full + } + + ad_proc -public get_list_from_datasource_name { + {-portal_id:required} + {-datasource_name:required} + } { + get a list of element_ids of type datasource_name on a particular portal + } { + set datasource_id [portal::datasource::get_id -name $datasource_name] + return [db_list select_element_ids {}] + } + + ad_proc -private move { + {-element_id:required} + {-direction:required} + } { + moves an element within a page + } { + if {[string equal $direction up] || [string equal $direction down]} { + move_vertically -element_id $element_id -direction $direction + } elseif {[string equal $direction left] || [string equal $direction right]} { + move_horizontally -element_id $element_id -direction $direction + } + } + + ad_proc -private move_vertically { + {-element_id:required} + {-direction:required} + } { + swaps the element with either the previous or next one in the region, + depending on the value of direction. + } { + + array set element [get -element_id $element_id] + template::util::array_to_vars element + + if {[string equal $direction up]} { + if {![db_0or1row select_previous_element {}]} { + return + } + } elseif {[string equal $direction down]} { + if {![db_0or1row select_next_element {}]} { + return + } + } else { + ad_return_complaint 1 "portal::element::swap: bad direction: $direction" + } + + db_transaction { + # because of the uniqueness constraint on sort_keys we need to set + # a dummy key, then do the swap. + set dummy_sort_key -1 + + # set the source element to the dummy key + db_dml swap_sort_keys_1 {} + + # set the target's sort_key to the source's sort_key + db_dml swap_sort_keys_2 {} + + # set the source's sort_key to the target's sort_key + db_dml swap_sort_keys_3 {} + } + + } + + ad_proc -private move_horizontally { + {-element_id:required} + {-direction:required} + } { + move a portal element between regions + } { + + set region [get_region -element_id $element_id] + + if {[string equal $direction left]} { + incr region -1 + } elseif {[string equal $direction right]} { + incr region 1 + } + + db_dml update_region {} + + } + + ad_proc -private move_to_page { + {-element_id:required} + {-page_id:required} + {-region ""} + } { + move this element to another page + } { + + set current_region $region + if {[empty_string_p $region]} { + set current_region [get_region -element_id $element_id] + } + + set target_n_regions [portal::layout::get_region_count_not_cached \ + -layout_id [portal::page::get_layout_id -page_id $page_id] + ] + + if {$current_region > $target_n_regions} { + set region $target_n_regions + } else { + set region $current_region + } + + db_dml update_element {} + + } + + ad_proc -public choose_region { + {-page_id:required} + } { + select the region on the page with the fewest elements on it + } { + + set min_num 99999 + set min_region 0 + + set layout_id [portal::page::get_layout_id -page_id $page_id] + set region_list [portal::layout::get_region_list -layout_id $layout_id] + + foreach region $region_list { + + set count [db_string select_region_count {}] + + if {$count == 0} { + set min_region $region + break + } + + if {$min_num > $count} { + set min_num $count + set min_region $region + } + + } + + if {$min_region == 0} { + set min_region 1 + } + + return $min_region + + } + + ad_proc -private render { + {-element_id:required} + {-edit_p f} + } { + render a portal element + } { + + array set element [get -element_id $element_id] + array set theme [portal::theme::get \ + -theme_id [portal::get_theme_id \ + -portal_id [portal::page::get_portal_id -page_id $element(page_id)] \ + ] \ + ] + + array set config [list \ + shaded_p [util_decode $element(state) shaded t f] \ + shadeable_p $element(shadeable_p) \ + hideable_p $element(hideable_p) \ + ] + array set config [portal::element::parameter::get_all -element_id $element_id] + + if {!$edit_p} { + array set config {shadeable_p f hideable_p f} + } + + set datasource_name [portal::datasource::get_name \ + -datasource_id $element(datasource_id) \ + ] + + # if the element's name is the same as its datasource's, then we call + # the datasource's GetPrettyName operation + if {[string equal $element(name) $datasource_name]} { + set element(name) [portal::datasource::call \ + -name $datasource_name \ + -op GetPrettyName \ + ] + } + + # generate the content of this portal element + with_catch errmsg { + set element(content) [portal::datasource::call \ + -name $datasource_name \ + -op Show \ + -list_args [list [array get config]] \ + ] + } { + ns_log error "portal::element::render show callback error!\n\n$errmsg\n\n" + set element(content) "application error" + } + + set element(content) [string trim $element(content)] + set element(shadeable_p) $config(shadeable_p) + set element(hideable_p) $config(hideable_p) + set element(shaded_p) $config(shaded_p) + set element(filename) "[portal::www_path]/$theme(filename)" + set element(resource_dir) "[portal::mount_point]$theme(resource_dir)" + + return [array get element] + + } + + ad_proc -private render_raw { + {-element_id:required} + } { + just call the "show" event for this element + } { + + array set element [get -element_id $element_id] + + array set config [list \ + shaded_p [util_decode $element(state) shaded t f] \ + shadeable_p $element(shadeable_p) \ + hideable_p $element(hideable_p) \ + ] + array set config [portal::element::parameter::get_all -element_id $element_id] + + set datasource_name [portal::datasource::get_name \ + -datasource_id $element(datasource_id) \ + ] + + set element(name) [portal::datasource::call \ + -name $datasource_name \ + -op GetPrettyName \ + ] + + with_catch errmsg { + portal::datasource::call \ + -name $datasource_name \ + -op Show \ + -list_args [list [array get config]] + } { + ns_log error "portal::element::render_raw show callback error!\n\n$errmsg\n\n" + set element(content) "application error" + } + + set element(content) [string trim $element(content)] + array set element {shadeable_p f shaded_p f hideable_p f} + set element(filename) "[portal::www_path]/themes/raw-theme" + + return [array get element] + + } + + ad_proc -public configure { + {-element_id:requried} + {-op:requried} + {-return_url:requried} + } { + dispatch on the element_id and op requested + } { + + set state [portal::element::get_state -element_id $element_id] + + switch $op { + shade { + if {[string equal $state shaded]} { + set new_state full + } else { + set new_state shaded + } + } + hide { + if {[string equal $state hidden]} { + set new_state full + } else { + set new_state hidden + } + } + } + + portal::element::set_state -element_id $element_id -state $new_state + ad_returnredirect $return_url + + } + + ad_proc -public add_element_parameters { + {-portal_id:required} + {-portlet_name:required} + {-value:required} + {-key "package_id"} + {-page_name ""} + {-pretty_name ""} + {-extra_params ""} + {-force_region ""} + {-param_action "overwrite"} + } { + A helper proc for portlet "add_self_to_page" procs. + Adds the given portlet as an portal element to the given + page. If the portlet is already in the given portal page, + it appends the value to the element's parameters with the + given key. Returns the element_id used. + + IMPROVE ME: refactor + + @return element_id The new element's id + @param portal_id The page to add the portlet to + @param portlet_name The name of the portlet to add + @param key the key for the value (defaults to package_id) + @param value the value of the key + @param extra_params a list of extra key/value pairs to insert or append + } { + + if {[empty_string_p $param_action]} { + set param_action "overwrite" + } + + # Find out if this portlet already exists in this page + set element_id_list [get_list_from_datasource_name -portal_id $portal_id -datasource_name $portlet_name] + + if {[llength $element_id_list] == 0} { + db_transaction { + + # Tell portal to add this element to the page + set element_id [add_element \ + -portal_id $portal_id \ + -portlet_name $portlet_name \ + -pretty_name $pretty_name \ + -page_name $page_name \ + -force_region $force_region + ] + + # There is already a value for the param which is overwritten + portal::element::parameter::set_value -element_id $element_id -key $key -value $value + + if {![empty_string_p $extra_params]} { + + for {set x 0} {$x < [llength $extra_params]} {incr x 2} { + portal::element::parameter::set_value \ + -element_id $element_id \ + -key [lindex $extra_params $x] \ + -value [lindex $extra_params [expr $x + 1]] + } + } + } + } else { + db_transaction { + set element_id [lindex $element_id_list 0] + + if {[string equal $param_action "append"]} { + portal::element::parameter::new -element_id $element_id -key $key -value $value + } elseif {[string equal $param_action "overwrite"]} { + portal::element::parameter::set_value -element_id $element_id -key $key -value $value + } else { + error "portal::add_element_parameters error: bad param action! $param_action 1" + } + + if {![empty_string_p $extra_params]} { + + for {set x 0} {$x < [llength $extra_params]} {incr x 2} { + if {[string equal $param_action "append"]} { + portal::element::parameter::new \ + -element_id $element_id \ + -key [lindex $extra_params $x] \ + -value [lindex $extra_params [expr $x + 1]] + } elseif {[string equal $param_action "overwrite"]} { + portal::element::parameter::set_value \ + -element_id $element_id \ + -key [lindex $extra_params $x] \ + -value [lindex $extra_params [expr $x + 1]] + } else { + error "portal::add_element_parameters error: bad param action! $param_action 2" + } + } + } + } + } + return $element_id + } + + ad_proc -public remove_element_parameters { + {-portal_id:required} + {-portlet_name:required} + {-value:required} + {-key "package_id"} + {-extra_params ""} + } { + A helper proc for portlet "remove_self_from_page" procs. + The inverse of the above proc. + + Removes the given parameters from all the the portlets + of this type on the given page. If by removing this param, + there are no more params (say instace_id's) of this type, + that means that the portlet has become empty and can be + + @param portal_id The portal page to act on + @param portlet_name The name of the portlet to (maybe) remove + @param key the key for the value (defaults to package_id) + @param value the value of the key + @param extra_params a list of extra key/value pairs to remove + } { + # get the element IDs (could be more than one!) + set element_ids [get_list_from_datasource_name -portal_id $portal_id -datasource_name $portlet_name] + + # step 1: remove all the given param(s) from all of the pe's + db_transaction { + foreach element_id $element_ids { + + portal::element::parameter::delete \ + -element_id $element_id \ + -key $key \ + -value $value + + if {![empty_string_p $extra_params]} { + + for {set x 0} {$x < [llength $extra_params]} {incr x 2} { + + portal::element::parameter::delete \ + -element_id $element_id \ + -key [lindex $extra_params $x] \ + -value [lindex $extra_params [expr $x + 1]] + } + } + } + } + + # step 2: Check if we should really remove the element + db_transaction { + foreach element_id $element_ids { + if {[llength [portal::element::parameter::get \ + -element_id $element_id \ + -key $key]] == 0} { + remove_element -element_id $element_id + } + } + } + } + +} Index: openacs-4/contrib/packages/portal/tcl/element-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/tcl/element-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/tcl/element-procs.xql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,125 @@ + + + + + + + select count(*) + from portal_elements, + portal_pages + where portal_pages.page_id = :page_id + and portal_pages.page_id = portal_elements.page_id + and portal_elements.region = :region + + + + + + select portal_elements.element_id as template_element_id + from portal_elements, + portal_pages, + portals + where portal_elements.page_id = portal_pages.page_id + and portal_pages.portal_id = portals.template_id + and portals.portal_id = (select portal_id + from portal_pages + where page_id = :page_id) + and portal_elements.datasource_id = :datasource_id + + + + + + insert into portal_element_parameters + (parameter_id, element_id, config_required_p, configured_p, key, value) + select portal_seq.nextval, :element_id, config_required_p, configured_p, key, value + from portal_datasource_parameters + where datasource_id = :datasource_id + + + + + + insert into portal_elements + (element_id, datasource_id, name, page_id, region, sort_key, state, shadeable_p, hideable_p) + select :element_id, :datasource_id, :name, :page_id, region, sort_key, state, shadeable_p, hideable_p + from portal_elements + where element_id = :template_element_id + + + + + + insert into portal_element_parameters + (parameter_id, element_id, config_required_p, configured_p, key, value) + select portal_seq.nextval, :element_id, config_required_p, configured_p, key, value + from portal_element_parameters + where element_id = :template_element_id + + + + + + delete + from portal_elements + where element_id = :element_id + + + + + + select * + from portal_elements + where element_id = :element_id + + + + + + update portal_elements + set datasource_id = :datasource_id, + name = :name, + page_id = :page_id, + region = :region, + sort_key = :sortkey, + state = :state + where element_id = :element_id + + + + + + select portal_elements.element_id + from portal_elements, + portal_pages + where portal_pages.portal_id = :portal_id + and portal_elements.datasource_id = :datasource_id + and portal_elements.page_id = portal_pages.page_id + + + + + + update portal_elements + set sort_key = :dummy_sort_key + where element_id = :element_id + + + + + + update portal_elements + set sort_key = :sort_key + where element_id = :other_element_id + + + + + + update portal_elements + set sort_key = :other_sort_key + where element_id = :element_id + + + + Index: openacs-4/contrib/packages/portal/tcl/layout-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/tcl/layout-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/tcl/layout-procs.tcl 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,80 @@ +# +# Copyright (C) 2001, 2002 MIT +# +# 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_library { + + portal layout procs + + @author arjun@openforce.net + @author yon@openforce.net + @creation-date 2001-09-10 + @version $Id: layout-procs.tcl,v 1.1 2002/10/25 21:29:17 yon Exp $ + +} + +namespace eval portal::layout { + + ad_proc -public get_region_count { + {-layout_id:required} + } { + get the number of regions (aka columns) this layout supports + } { + return [util_memoize "portal::layout::get_region_count_not_cached -layout_id $layout_id"] + } + + ad_proc -private get_region_count_not_cached { + {-layout_id:required} + } { + return [db_string select_region_count {}] + } + + ad_proc -public get_region_list { + {-layout_id:required} + } { + get a list of the regions that a layout supports + } { + return [util_memoize "portal::layout::get_region_list_not_cached -layout_id $layout_id"] + } + + ad_proc -private get_region_list_not_cached { + {-layout_id:required} + } { + return [db_list select_region_list {}] + } + + ad_proc -public get_layout_list { + } { + returns a list of all the layouts in the system as ns_sets with keys + being: name, description, and number of regions. + } { + return [db_list_of_ns_sets select_layout_list {}] + } + + ad_proc -public get_id_from_name { + {-name:required} + } { + get the layout_id for the given layout name + } { + return [util_memoize "portal::layout::get_id_from_name_not_cached -name $name"] + } + + ad_proc -private get_id_from_name_not_cached { + {-name:required} + } { + return [db_string select_id_from_name {} -default ""] + } + +} Index: openacs-4/contrib/packages/portal/tcl/layout-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/tcl/layout-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/tcl/layout-procs.xql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,39 @@ + + + + + + + select count(*) + from portal_layout_regions + where layout_id = :layout_id + + + + + + select region + from portal_layout_regions + where layout_id = :layout_id + order by region + + + + + + select layout_id, + name as layout_name, + description as layout_description + from portal_layouts + + + + + + select layout_id + from portal_layouts + where name = :name + + + + Index: openacs-4/contrib/packages/portal/tcl/page-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/tcl/Attic/page-procs-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/tcl/page-procs-oracle.xql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,14 @@ + + + + oracle8.1.6 + + + + begin + portal_page.delete(page_id => :page_id); + end; + + + + Index: openacs-4/contrib/packages/portal/tcl/page-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/tcl/Attic/page-procs-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/tcl/page-procs-postgresql.xql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,12 @@ + + + + postgresql7.2 + + + + select portal_page__delete(:page_id); + + + + Index: openacs-4/contrib/packages/portal/tcl/page-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/tcl/page-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/tcl/page-procs.tcl 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,161 @@ +# +# Copyright (C) 2001, 2002 MIT +# +# 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_library { + + portal page procs + + @author arjun@openforce.net + @author yon@openforce.net + @creation-date 2001-09-10 + @version $Id: page-procs.tcl,v 1.1 2002/10/25 21:29:17 yon Exp $ + +} + +namespace eval portal::page { + + ad_proc -public new { + {-portal_id:required} + {-name:required} + {-layout_name ""} + } { + create a new page and associate it with the given portal_id + } { + set layout_id [portal::layout::get_id_from_name -name $layout_name] + + set extra_vars [ns_set create] + ns_set put $extra_vars portal_id $portal_id + ns_set put $extra_vars name $name + ns_set put $extra_vars layout_id $layout_id + + return [package_instantiate_object -extra_vars $extra_vars portal_page] + } + + ad_proc -public delete { + {-page_id:required} + } { + db_exec_plsql delete_page {} + } + + ad_proc -public get { + {-page_id:required} + } { + get page info in "array get" format (cached) + } { + return [util_memoize "portal::page::get_not_cached -page_id $page_id"] + } + + ad_proc -private get_not_cached { + {-page_id:required} + } { + db_1row select_page {} -column_array page + return [array get page] + } + + ad_proc -public set_values { + {-page:required} + } { + set the fields of a portal page + } { + array set page_array $page + template::util::array_to_vars page_array + + db_dml update_page {} + util_memoize_flush "portal::page::get_not_cached -page_id $page_id" + } + + ad_proc -public get_name { + {-page_id:required} + } { + array set page [get -page_id $page_id] + return $page(name) + } + + ad_proc -public set_name { + {-page_id:required} + {-name:required} + } { + array set page [get -page_id $page_id] + set page(name) $name + + set_values -page [array get page] + } + + ad_proc -public get_portal_id { + {-page_id:required} + } { + array set page [get -page_id $page_id] + return $page(portal_id) + } + + ad_proc -public get_layout_id { + {-page_id:required} + } { + array set page [get -page_id $page_id] + return $page(layout_id) + } + + ad_proc -public set_layout_id { + {-page_id:required} + {-layout_id:required} + } { + array set page [get -page_id $page_id] + set page(layout_id) $layout_id + + set_values -page [array get page] + } + + ad_proc -public get_id { + {-portal_id:required} + {-page_name ""} + {-sort_key 0} + } { + get the page_id given a portal_id and a page name. if no name is given + the first page is returned. + } { + if {![empty_string_p $page_name]} { + set page_id [db_string get_page_id_from_name {} -default ""] + if {[empty_string_p $page_id]} { + # there is no page by that name in the portal, return page 0 + return [get_page_id -portal_id $portal_id] + } else { + return $page_id + } + } else { + return [db_string get_page_id_select {}] + } + } + + ad_proc -public first_page_p { + {-portal_id:required} + {-page_id:required} + } { + returns 1 if the given page_id is the first page in the given portal, otherwise 0. + } { + if {$page_id == [portal::get_page_id -portal_id $portal_id -sort_key 0]} { + return 1 + } else { + return 0 + } + } + + ad_proc -private has_visible_elements { + {-page_id:required} + } { + return [db_string select_visible_elements_p {} -default 0] + } + +} Index: openacs-4/contrib/packages/portal/tcl/page-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/tcl/page-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/tcl/page-procs.xql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,33 @@ + + + + + + + select * + from portal_pages + where page_id = :page_id + + + + + + update portal_pages + set name = :name, + portal_id = :portal_id, + layout_id = :layout_id, + sort_key = :sort_key + where page_id = :page_id + + + + + + select case when count(*) = 0 then 0 else 1 end + from portal_elements + where page_id = :page_id + and state != 'hidden' + + + + Index: openacs-4/contrib/packages/portal/tcl/portal-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/tcl/portal-procs-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/tcl/portal-procs-oracle.xql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,29 @@ + + + + oracle8.1.6 + + + + begin + portal.delete(portal_id => :portal_id); + end; + + + + + + update portal_elements + set region = :region, + page_id = :page_id, + sort_key = (select nvl((select max(sort_key) + 1 + from portal_elements + where page_id = :page_id + and region = :region), + 1) + from dual) + where element_id = :element_id + + + + Index: openacs-4/contrib/packages/portal/tcl/portal-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/tcl/portal-procs-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/tcl/portal-procs-postgresql.xql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,27 @@ + + + + postgresql7.2 + + + + select portal__delete(:portal_id); + + + + + + update portal_elements + set region = :region, + page_id = :page_id, + sort_key = (select coalesce((select max(sort_key) + 1 + from portal_elements + where page_id = :page_id + and region = :region), + 1) + from dual) + where element_id = :element_id + + + + Index: openacs-4/contrib/packages/portal/tcl/portal-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/tcl/portal-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/tcl/portal-procs.tcl 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,924 @@ +# +# Copyright (C) 2001, 2002 MIT +# +# 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_library { + + portal procs + + @author arjun@openforce.net + @author yon@openforce.net + @creation-date 2001-09-01 + @version $Id: portal-procs.tcl,v 1.1 2002/10/25 21:29:17 yon Exp $ + +} + +namespace eval portal { + + ad_proc -private package_key {} { + returns the package_key + } { + return "portal" + } + + ad_proc -public get_package_id {} { + returns the package_id + } { + return [apm_package_id_from_key [package_key]] + } + + # work around for template::util::url_to_file + ad_proc -private www_path {} { + returns the path of the www dir of the portal package. we need this for + stupid template tricks. + } { + return "/packages/[package_key]/www" + } + + ad_proc -public mount_point {} { + caches the mount point + } { + return [lindex [site_node::get_url_from_object_id -object_id [get_package_id]] 0] + } + + ad_proc -public automount_point {} { + packages such as dotlrn can automount the portal here + } { + return portal + } + + ad_proc -public new { + {-party_id:required} + {-name Untitled} + {-template_id ""} + {-context_id ""} + {-page_list {{{Page 1} 2_column}}} + } { + create a new portal for the passed in party_id. create pages passed in + the page_list. + } { + db_transaction { + + set extra_vars [ns_set create] + ns_set put $extra_vars name $name + ns_set put $extra_vars template_id $template_id + ns_set put $extra_vars context_id $context_id + + set portal_id [package_instantiate_object -extra_vars $extra_vars portal] + + permission::grant -party_id $party_id -object_id $portal_id -privilege read + permission::grant -party_id $party_id -object_id $portal_id -privilege write + permission::grant -party_id $party_id -object_id $portal_id -privilege admin + + if {[empty_string_p $template_id]} { + foreach page $page_list { + portal::page::new \ + -portal_id $portal_id \ + -name [lindex $page 0] \ + -layout_name [lindex $page 1] + } + } + + } + + return $portal_id + } + + ad_proc -public delete { + {-portal_id:required} + } { + delete a portal + } { + db_dml delete_permissions {} + db_exec_plsql delete_portal {} + } + + ad_proc -public get { + {-portal_id:required} + } { + get portal info in "array get" format (cached) + } { + return [util_memoize "portal::get_not_cached -portal_id $portal_id"] + } + + ad_proc -private get_not_cached { + {-portal_id:required} + } { + get portal info in "array get" format (not cached) + } { + db_1row select_portal_info {} -column_array portal + return [array get portal] + } + + ad_proc -public set_values { + {-portal:required} + } { + set the fields of a portal + } { + array set portal_array $portal + template::util::array_to_vars portal + + db_dml update_portal {} + util_memoize_flush "portal::get_not_cached -portal_id $portal_id" + } + + ad_proc -public get_name { + {-portal_id:required} + } { + array set portal [get -portal_id $portal_id] + return $portal(name) + } + + ad_proc -public set_name { + {-portal_id:required} + {-name:required} + } { + array set portal [get -portal_id $portal_id] + set portal(name) $name + + set_values -portal [array get portal] + } + + ad_proc -public get_theme_id { + {-portal_id:required} + } { + array set portal [get -portal_id $portal_id] + return $portal(theme_id) + } + + ad_proc -public set_theme_id { + {-portal_id:required} + {-theme_id:required} + } { + array set portal [get -portal_id $portal_id] + set portal(theme_id) $theme_id + + set_values -portal [array get portal] + } + + ad_proc -private get_template_id { + {-portal_id:required} + } { + array set portal [get -portal_id $portal_id] + return $portal(template_id) + } + + ad_proc -public get_page_count { + {-portal_id:required} + } { + return [db_string select_page_count {}] + } + + ad_proc -public get_page_list { + {-portal_id:required} + } { + @return list of page_ids associated with the given portal (in sort_key order). + } { + return [db_list select_page_ids {}] + } + + ad_proc -public render { + {-portal_id:required} + {-page_num 0} + {-render_style individual} + } { + returns a chunk of html that is a fully rendered portal + } { + permission::require -privilege read -object_id $portal_id + set edit_p [permission::permission_p -object_id $portal_id -privilege write] + + set master_template [parameter::get -parameter master_template] + + # get the portal and layout + db_1row portal_select {} -column_array portal + set page_id $portal(page_id) + + set element_ids [list] + db_foreach element_select {} -column_array entry { + lappend element_ids($entry(region)) $entry(element_id) + } + + set element_list [array get element_ids] + + # set up the template, it includes the layout template, + # which in turn includes the theme, then elements + if {[empty_string_p $element_list]} { + # The portal has no elements, show anyway (they can configure) + set template " + @portal.name@" + } else { + set element_src "[www_path]/render-styles/${render_style}/render-element" + set template " + @portal.name@ + " + } + + # necessary hack to work around the acs-templating system + set __adp_stub "[get_server_root][www_path]/." + set {master_template} \"master\" + + # compile and evaluate the template + set code [template::adp_compile -string $template] + return [template::adp_eval code] + } + + ad_proc -private layout_elements { + element_list + {var_stub "element_ids"} + } { + Split a list up into a bunch of variables for inserting into a + layout template. This seems pretty kludgy (probably because it is), + but a template::multirow isn't really well suited to data of this + shape. It'll setup a set of variables, $var_stub_1 - $var_stub_8 + and $var_stub_i1- $var_stub_i8, each contining the portal_ids that + belong in that region. - Ian Baker + + @param element_id_list An [array get]'d array, keys are regions, \ + values are lists of element_ids. + @param var_stub A name upon which to graft the bits that will be \ + passed to the template. + } { + array set elements $element_list + + foreach idx [list 1 2 3 4 5 6] { + upvar "${var_stub}_$idx" group + if { [info exists elements($idx) ] } { + set group $elements($idx) + } else { + set group {} + } + } + } + + ad_proc -public configure { + {-referer ""} + {-template_p f} + portal_id + return_url + } { + Return a portal or portal template configuration page. + All form targets point to file_stub-2. + + FIXME REFACTOR ME + + @param portal_id + @return_url + } { + set edit_p [permission::permission_p -object_id $portal_id -privilege write] + + if {!$edit_p} { + permission::require -privilege admin -object_id $portal_id + set edit_p 1 + } + + # + # Set up some whole page stuff + # + + set master_template [ad_parameter master_template] + set action_string [generate_action_string] + set element_src "[portal::www_path]/place-element" + + if {[empty_string_p $referer]} { + set return_text "Go back" + } else { + set return_text "" + set return_url $referer + } + + # + # Begin creating the template + # + + set template " + +

+ $return_text +

" + + # + # Theme selection chunk + # + + set theme_chunk " +

+ + + Change Theme: +
" + set current_theme_id [portal::get_theme_id -portal_id $portal_id] + + foreach theme [portal::theme::get_list] { + set theme_id [ns_set get $theme theme_id] + set name [ns_set get $theme name] + set description [ns_set get $theme description] + + append theme_chunk "
\n" + } + + append theme_chunk "
" + append template "$theme_chunk" + + # + # Per-page template chunks + # + + set list_of_page_ids [get_page_list -portal_id $portal_id] + + foreach page_id $list_of_page_ids { + + set first_page_p [portal::first_page_p -portal_id $portal_id -page_id $page_id] + set page_name [portal::page::get_name -page_id $page_id] + set page_layout_id [portal::page::get_layout_id -page_id $page_id] + + append template "" + + # + # Page rename chunk + # + + set page_name_chunk " + + + + + + +
Page: + + + " + append template "$page_name_chunk" + + if {[portal::page::has_visible_elements -page_id $page_id] || $first_page_p} { + + # + # Page with non-hidden elements OR the first page of the portal + # + + db_1row portal_and_page_info_select {} -column_array portal + + # fake some elements for the in the template + foreach region [portal::layout::get_region_list -layout_id $portal(layout_id)] { + lappend fake_element_ids($region) $portal_id + } + + set element_list [array get fake_element_ids] + + append template " +
+ " + + # clear out the region array + array unset fake_element_ids + } + + if {![portal::has_visible_elements -page_id $page_id]} { + + # + # Non first page with all hidden elements + # + + # + # Remove page chunk - don't allow removal of the first page + # + + if {!$first_page_p} { + append template " + + " + } + + # + # Layout change chunk - only shown when there are no visible elements on the page + # + + set layout_chunk "" + + foreach layout [portal::layout::get_layout_list] { + set layout_id [ns_set get $layout layout_id] + set layout_name [ns_set get $layout layout_name] + set layout_description [ns_set get $layout layout_description] + set one_layout_chunk " $layout_name - $layout_description" + append layout_chunk "
\n" + } + + + append template " + + " + + } + + + # close the page's table + append template "
+ +
+
+ No Elements on this page +
+ + + + +
+
+
+
+
+ + Change page layout: +
+ + + + $layout_chunk + +
+
+
" + + } + + # + # New page chunk + # + + set new_page_num [expr [get_page_count -portal_id $portal_id] + 1] + + append template " + +
+ + + + Add a new page: + + +
+ " + + # + # Revert page chunk + # + + if {![empty_string_p [get_template_id -portal_id $portal_id]]} { + append template " +
+
+ + + Revert to the default arrangement: + +
" + } + + # + # Templating system hacks + # + + set __adp_stub "[get_server_root][www_path]/." + set {master_template} \"master\" + + set code [template::adp_compile -string $template] + set output [template::adp_eval code] + + return $output + } + + ad_proc -public configure_dispatch { + {-template_p f} + {-portal_id:required} + {-form:required} + } { + Dispatches the configuration operation. + We get the target region number from the op. + + @param portal_id the portal to edit + @param formdata an ns_set with all the formdata + } { + + set edit_p [permission::permission_p -object_id $portal_id -privilege write] + + if {!$edit_p} { + permission::require -privilege admin -object_id $portal_id + set edit_p 1 + } + + set op [ns_set get $form op] + + switch $op { + "Revert" { + db_transaction { + set template_id [get_template_id -portal_id $portal_id] + + # revert theme + set_theme_id -portal_id $portal_id -theme_id [get_theme_id -portal_id $template_id] + + # revert pages + # first equalize number of pages in the target + set template_page_count [get_page_count -portal_id $template_id] + set target_page_count [get_page_count -portal_id $portal_id] + set difference [expr $template_page_count - $target_page_count] + + if {$difference > 0} { + # less pages in target + for {set x 0} {$x < $difference} {incr x} { + + set name "portal revert dummy page $x" + portal::page::new \ + -portal_id $portal_id \ + -name $name \ + } + } elseif {$difference < 0} { + # more pages in target, delete them from the end, + # putting any elements on them on the first page, + # we put them in the right place later + for {set x 0} {$x < [expr abs($difference)]} {incr x} { + + set max_page_id [db_string revert_max_page_id_select {}] + set page_id [db_string revert_min_page_id_select {}] + set region 1 + + db_foreach revert_move_elements_for_del {} { + portal::move_element_to_page \ + -page_id $page_id \ + -element_id $element_id \ + -region 1 + } + + portal::page::delete -page_id $max_page_id + } + } + + # now that they have the same number of pages, get to it + foreach source_page_id [get_page_list -portal_id $template_id] { + + db_1row revert_get_source_page_info {} + + set target_page_id [db_string revert_get_target_page_id {}] + + db_dml revert_page_update {} + + # revert elements in two steps like "swap" + db_foreach revert_get_source_elements {} { + # the element might not be on the target page... + set target_element_id \ + [db_string revert_get_target_element {}] + + db_dml revert_element_update {} + } + } + } + } + Rename { + portal::set_name \ + -portal_id $portal_id \ + -name [ns_set get $form new_name] + } + swap - + move { + portal::element::move \ + -element_id [ns_set get $form element_id] \ + -direction [ns_set get $form direction] + } + "Show Here" { + set region [ns_set get $form region] + set element_id [ns_set get $form element_id] + set page_id [ns_set get $form page_id] + + db_transaction { + # The new element's sk will be the last in the region + db_dml show_here_update_sk {} + db_dml show_here_update_state {} + } + } + "Move to page" { + portal::element::move_to_page \ + -page_id [ns_set get $form page_id] \ + -element_id [ns_set get $form element_id] + } + hide { + set element_id_list [list] + + # iterate through the set, destructive! + while { [expr [ns_set find $form "element_id"] + 1 ] } { + lappend element_id_list [ns_set get $form "element_id"] + ns_set delkey $form "element_id" + } + + if {! [empty_string_p $element_id_list] } { + db_transaction { + foreach element_id $element_id_list { + db_dml hide_update {} + + # after hiding an element, add + # it to the _first_ page + # of the portal. + portal::move_element_to_page \ + -page_id [portal::get_page_id -portal_id $portal_id] \ + -element_id $element_id + } + } + } + } + "Change Theme" { + set_theme_id -portal_id $portal_id -theme_id [ns_set get $form theme_id] + } + "Add Page" { + set name [ns_set get $form name] + if {[empty_string_p $name]} { + ad_return_complaint 1 "You must enter a name for the new page." + } + portal::page::new -portal_id $portal_id -name $name + } + "Remove Empty Page" { + portal::page::delete -page_id [ns_set get $form page_id] + } + "Change Page Layout" { + portal::page::set_layout_id \ + -page_id [ns_set get $form page_id] \ + -layout_id [ns_set get $form layout_id] + } + "Rename Page" { + set name [ns_set get $form name] + set page_id [ns_set get $form page_id] + + if {[empty_string_p $name]} { + ad_return_complaint 1 "You must enter new name for the page." + } + portal::page::set_name -page_id $page_id -name $name + } + toggle_pinned { + set element_id [ns_set get $form element_id] + + if {[string equal [portal::element::get_state -element_id $element_id] full]} { + portal::element::pin -element_id $element_id + } else { + portal::element::unpin -element_id $element_id + } + } + toggle_shadeable { + set element_id [ns_set get $form element_id] + + if {[string equal [portal::element::get_shadeable_p -element_id $element_id] f]} { + portal::element::set_shadeable_p -element_id $element_id -shadeable_p t + } else { + portal::element::set_shadeable_p -element_id $element_id -shadeable_p f + } + } + toggle_hideable { + set element_id [ns_set get $form element_id] + + if {[string equal [portal::element::get_hideable_p -element_id $element_id] f]} { + portal::element::set_hideable_p -element_id $element_id -hideable_p t + } else { + portal::element::set_hideable_p -element_id $element_id -hideable_p f + } + } + default { + ns_log error "portal::configure_dispatch: bad op = $op!" + ad_return_complaint 1 "portal::configure_dispatch: bad op!\nop = $op" + } + } + } + + # + # portal template procs - util and configuration + # + + ad_proc -public template_configure { + portal_id + return_url + } { + Just a wrapper for the configure proc. + + @param portal_id + @return A portal configuration page + } { + portal::configure -template_p "t" $portal_id $return_url + } + + ad_proc -public template_configure_dispatch { + portal_id + form + } { + Just a wrapper for the configure_dispatch proc + + @param portal_id + @param formdata an ns_set with all the formdata + } { + configure_dispatch -template_p "t" $portal_id $form + } + + ad_proc -public navbar { + {-portal_id:required} + {-td_align "left"} + {-link ""} + {-pre_html ""} + {-post_html ""} + {-link_all 0} + {-extra_td_html ""} + {-table_html_args ""} + } { + wraps portal::dimensional to create a dotlrn navbar + + @return the id of the page + @param portal_id + @param link the relative link to set for hrefs + @param current_page_link f means that there is no link for the current page + } { + set ad_dim_struct [list] + + db_foreach list_page_nums_select {} { + lappend ad_dim_struct [list $page_num $name [list]] + } + + set ad_dim_struct "{ page_num \"Page:\" 0 [list $ad_dim_struct] }" + + return [dimensional -no_header \ + -no_bars \ + -link_all $link_all \ + -td_align $td_align \ + -pre_html $pre_html \ + -post_html $post_html \ + -extra_td_html $extra_td_html \ + -table_html_args $table_html_args \ + $ad_dim_struct \ + $link] + } + + ad_proc -private generate_action_string { + } { + Portal configuration pages need this to set up + the target for the generated links. It's just the + current location with "-2" appended to the name of the + page. + } { + return "[lindex [ns_conn urlv] [expr [ns_conn urlc] - 1]]-2" + } + + ad_proc -public show_proc_helper { + {-template_src ""} + {-package_key:required} + {-config_list:required} + } { + hides ugly templating calls for portlet "show" procs + } { + + if { $template_src == ""} { + set template_src $package_key + } + + # some stupid upvar tricks to get them set right + upvar __ts ts + set ts $template_src + + upvar __pk pk + set pk $package_key + + upvar __cflist cflist + set cflist $config_list + + uplevel 1 { + set template "" + set __adp_stub "[get_server_root]/packages/$__pk/www/." + set code [template::adp_compile -string $template] + set output [template::adp_eval code] + return $output + } + } + + ad_proc dimensional { + {-no_header:boolean} + {-no_bars:boolean} + {-link_all 0} + {-th_bgcolor "#ECECEC"} + {-td_align "center"} + {-extra_td_html ""} + {-table_html_args "border=0 cellspacing=0 cellpadding=3 width=100%"} + {-pre_html ""} + {-post_html ""} + option_list + {url {}} + {options_set ""} + {optionstype url} + } { + An enhanced ad_dimensional. see that proc for usage details + } { + if {[empty_string_p $option_list]} { + return + } + + if {[empty_string_p $options_set]} { + set options_set [ns_getform] + } + + if {[empty_string_p $url]} { + set url [ad_conn url] + } + + set html "\n\n \n" + + if {!$no_header_p} { + foreach option $option_list { + append html " \n" + } + } + + append html " \n \n" + + foreach option $option_list { + append html " \n" + } + + append html " \n
[lindex $option 1]
" + + if {!$no_bars_p} { + append html "\[" + } + + # find out what the current option value is. + # check if a default is set otherwise the first value is used + set option_key [lindex $option 0] + set option_val [lindex $option 2] + if {![empty_string_p $options_set]} { + set option_val [ns_set get $options_set $option_key] + } + + set first_p 1 + foreach option_value [lindex $option 3] { + set thisoption_name [lindex $option_value 0] + set thisoption_value [lindex $option_value 1] + set thisoption_link_p 1 + if {[llength $option_value] > 3} { + set thisoption_link_p [lindex $option_value 3] + } + + if {$first_p} { + set first_p 0 + } else { + if {!$no_bars_p} { + append html " | " + } else { + append html "   " + } + } + + if {([string equal $option_val $thisoption_name] == 1 && !$link_all) || !$thisoption_link_p} { + append html "${pre_html}${thisoption_value}${post_html}" + } else { + append html "${pre_html}${thisoption_value}${post_html}" + } + } + + if {!$no_bars_p} { + append html "\]" + } + + append html "$extra_td_html
\n" + } + +} Index: openacs-4/contrib/packages/portal/tcl/portal-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/tcl/portal-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/tcl/portal-procs.xql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,241 @@ + + + + + + + delete + from acs_permissions + where object_id = :portal_id + + + + + + select * + from portals + where portal_id = :portal_id + + + + + + update portals + set name = :name, + theme_id = :theme_id, + template_id = :template_id + where portal_id = :portal_id + + + + + + select portals.name, + portals.portal_id, + portals.theme_id, + portal_layouts.layout_id, + portal_layouts.filename as layout_filename, + portal_pages.page_id + from portals, + portal_pages, + portal_layouts + where portal_pages.sort_key = :page_num + and portal_pages.portal_id = :portal_id + and portal_pages.portal_id = portals.portal_id + and portal_pages.layout_id = portal_layouts.layout_id + + + + + + select portal_elements.element_id, + portal_elements.region, + portal_elements.sort_key + from portal_elements, + portal_pages + where portal_pages.portal_id = :portal_id + and portal_elements.page_id = :page_id + and portal_elements.page_id = portal_pages.page_id + and portal_elements.state != 'hidden' + order by portal_elements.region, + portal_elements.sort_key + + + + + + select portals.name, + portals.portal_id, + portal_layouts.filename as template, + portal_pages.name as page_name, + portal_pages.layout_id as layout_id + from portals, + portal_layouts, + portal_pages + where portal_pages.portal_id = :portal_id + and portal_pages.page_id = :page_id + and portal_pages.portal_id = portals.portal_id + and portal_pages.layout_id = portal_layouts.layout_id + + + + + + update portal_elements + set state = 'full' + where element_id = :element_id + + + + + + update portal_elements + set state = 'hidden' + where element_id = :element_id + + + + + + select max(page_id) + from portal_pages + where portal_id = :portal_id + + + + + + select min(page_id) + from portal_pages + where portal_id = :portal_id + + + + + + select element_id + from portal_elements + where page_id = :max_page_id + + + + + + select name, + layout_id, + sort_key + from portal_pages + where page_id = :source_page_id + + + + + + select page_id + from portal_pages + where portal_id = :portal_id + and sort_key = :sort_key + + + + + + update portal_pages + set name = :name, + layout_id = :layout_id + where page_id = :target_page_id + + + + + + select portal_elements.region, + portal_elements.sort_key, + portal_elements.state, + portal_datasources.datasource_id, + portal_datasources.name, + portal_elements.name as pretty_name + from portal_elements, + portal_datasources + where portal_elements.page_id = :source_page_id + and portal_elements.datasource_id = portal_datasources.datasource_id + + + + + + select portal_pages.element_id + from portal_elements, + portal_pages + where portal_pages.portal_id = :portal_id + and portal_elements.page_id = portal_pages.page_id + and portal_elements.datasource_id = :datasource_id + and portal_elements.name = :name + + + + + + update portal_elements + set region = :region, + sort_key = :sort_key, + state = :state, + page_id = :target_page_id + where element_id = :target_element_id + + + + + + select page_id + from portal_pages + where portal_id = :portal_id + and sort_key = :sort_key + + + + + + select count(*) + from portal_pages + where portal_id = :portal_id + + + + + + select page_id + from portal_pages + where portal_id = :portal_id + order by sort_key + + + + + + select name, + sort_key as page_num + from portal_pages + where portal_id = :portal_id + order by sort_key + + + + + + select theme_id + from portals + where portal_id = :portal_id + + + + + + select page_id + from portal_pages + where portal_id = :portal_id + and name = :page_name + + + + Index: openacs-4/contrib/packages/portal/tcl/theme-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/tcl/theme-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/tcl/theme-procs.tcl 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,56 @@ +# +# Copyright (C) 2001, 2002 MIT +# +# 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_library { + + portal theme procs + + @author arjun@openforce.net + @author yon@openforce.net + @creation-date 2002-10-01 + @version $Id: theme-procs.tcl,v 1.1 2002/10/25 21:29:17 yon Exp $ + +} + +namespace eval portal::theme { + + ad_proc -public get { + {-theme_id:required} + } { + return a theme in "array get" format + } { + return [util_memoize "portal::theme::get_not_cached -theme_id $theme_id"] + } + + ad_proc -private get_not_cached { + {-theme_id:required} + } { + db_1row select_theme {} -column_array theme + return [array get theme] + } + + ad_proc -public get_list {} { + returns a list of all the themes in the system as ns_sets with + keys being: theme_id, name, description + } { + return [util_memoize "portal::theme::get_list_not_cached"] + } + + ad_proc -private get_list_not_cached {} { + return [db_list_of_ns_sets select_theme_list {}] + } + +} Index: openacs-4/contrib/packages/portal/tcl/theme-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/tcl/theme-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/tcl/theme-procs.xql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,23 @@ + + + + + + + select * + from portal_themes + where theme_id = :theme_id + + + + + + select theme_id, + name, + description + from portal_themes + order by name + + + + Index: openacs-4/contrib/packages/portal/www/place-element-other-page.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/www/Attic/place-element-other-page.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/www/place-element-other-page.adp 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,37 @@ +<% + + # + # Copyright (C) 2001, 2002 MIT + # + # 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. + # + +%> + +
+ + + + + + + + + + + +
Index: openacs-4/contrib/packages/portal/www/place-element-other-page.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/www/Attic/place-element-other-page.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/www/place-element-other-page.tcl 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,28 @@ +# +# Copyright (C) 2001, 2002 MIT +# +# 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. +# + +# moving to other pages +set element_id $element_multi(element_id) + +template::multirow create pages page_id name element_id +set other_page_avail_p 0 + +db_foreach other_pages_select {} { + set other_page_avail_p 1 + + template::multirow append pages \ + $page_id $name +} Index: openacs-4/contrib/packages/portal/www/place-element-other-page.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/www/Attic/place-element-other-page.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/www/place-element-other-page.xql 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,15 @@ + + + + + +select page_id, name +from portal_pages pp +where +pp.portal_id = :portal_id +and pp.page_id != :page_id +order by sort_key + + + + Index: openacs-4/contrib/packages/portal/www/place-element.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/www/Attic/place-element.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/www/place-element.adp 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,100 @@ +<% + + # + # Copyright (C) 2001, 2002 MIT + # + # 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. + # + +%> + +
+ + + + + + + +
+ + +
+ + + + +
@element_multi.name@ + + + + + + + remove portlet + + + + + move up + + + + move down + + + + + + + move right + + + + move left + move right + + + + move left + + + + + + + + +
+ + + +
+

+ + + + + + +

Index: openacs-4/contrib/packages/portal/www/place-element.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/www/Attic/place-element.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/www/place-element.tcl 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,69 @@ +# +# Copyright (C) 2001, 2002 MIT +# +# 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 { + Place elements on the configure page. This template gets its vars + from the layout template (e.g. simple2.adp) which is sourced + by portal::configure + + @author Arjun Sanyal (arjun@openforce.net) + @creation-date 9/28/2001 + @cvs_id $Id: place-element.tcl,v 1.1 2002/10/25 21:29:17 yon Exp $ +} -properties { + region:onevalue + action_string:onevalue + portal_id:onevalue + element_multi:multirow +} + +set num_regions [portal::layout::get_region_count -layout_id $layout_id] + +template::multirow create element_multi \ + element_id \ + name \ + sort_key \ + state \ + hideable_p + +set region_count 0 + +db_foreach select_elements_by_region {} { + + template::multirow append element_multi \ + $element_id \ + $name \ + $sort_key \ + $state \ + $hideable_p \ + $page_id + + incr region_count +} + + +# generate some html for the hidden elements +set show_avail_p 0 +set show_html "" + +append show_html " + + + + + +@show_html@ + + + + +None. You can not add any portlets to this page because they are all in use. + + + + + + Index: openacs-4/contrib/packages/portal/www/show-here.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/www/Attic/show-here.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/www/show-here.tcl 25 Oct 2002 21:29:17 -0000 1.1 @@ -0,0 +1,41 @@ +# +# 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 { + Add porlet form + + @author Caroline@meekshome.com + @creation-date 9/28/2001 + @cvs_id $Id: show-here.tcl,v 1.1 2002/10/25 21:29:17 yon Exp $ +} -properties { + region:onevalue + action_string:onevalue + portal_id:onevalue +} + +# generate some html for the hidden elements +set show_avail_p 0 +set show_html "" + +append show_html "