Commit e51ecb52 authored by Frank Bergmann's avatar Frank Bergmann

Initial import

parents
-- Org role design issues
allow two tables to hold org roles so that
o event editors can modify roles after creating event w/o affecting original role?
-- Custom fields design issues
-- Chat with Arjun about attachments
ms: ok, so every time fs is instanciated it creates a new root folder mapped to the new fs package_id. you manually map the package_id of the package that you want attacments for (events in your case) to the specific fs root folder id you want
arjun: so when i'm using the attachments api, i'll use the fs package_id for the -object_id switches?
ms: no don't pass the fs package_id as object id. object_id = the acs object you are attaching something to (forum post, cal event) once the fs root folder is setup once, you don't have to worry about it again
arjun: any way to automate this process for packages? should i set up an init proc to map the folder and write an attachments_p flag to one of my tables? (i'd write an attachments enabled flag if my init proc could find an fs_root_folder to map to)
ms: yes, that would be how i would do it. using a _post_instanciation proc in your pkgs -init file
thoughts
o add post_instantiation proc that creates new fs and attachments instances under events and creates the root folder mapping as arjun mentioned above
-- Notes and code snippets for bios work
<fullquery name="biography">
<querytext>
select attr_value
from acs_attribute_values
where object_id = :user_id
and attribute_id =
(select attribute_id
from acs_attributes
where object_type = 'person'
and attribute_name = 'bio')
</querytext>
</fullquery>
if { $bio_change_to == 0 } {
# perform the insert
db_dml insert_bio "insert into acs_attribute_values
(object_id, attribute_id, attr_value)
values
(:user_id, (select attribute_id
from acs_attributes
where object_type = 'person'
and attribute_name = 'bio'), :bio)"
} elseif { $bio_change_to == 2 } {
# perform the update
db_dml update_bio "update acs_attribute_values
set attr_value = :bio
where object_id = :user_id
and attribute_id =
(select attribute_id
from acs_attributes
where object_type = 'person'
and attribute_name = 'bio')"
}
needed functionality
--------------------
o integration with survey
o add interface for editing organizer bio (reinstate organizer-add-2?)
o system doesn't handle multi-day events like 3.x did (?)
o update 3.x documentation!
clean up
--------
o clean up packages and the files that rely on them so they do not ask for redundant info - if we care about this??
- events-registrations-package-create.sql asks for both user_id and creation_user (we may want this to have staff add somebody - we'll see)
o bring proc namespace declarations inline with new conventions
o decide on party_id vs. user_id then make API consistent
o move parts of event.adp and activity.adp to adp chunks for reuse?
- look for other similar candidates for template sharing
o convert forms to use ad_form (possibly change pages as well - event-role-ae, etc.)
o check ad_page_contract usage consistency (properties, etc.)
o use related_link_url field in acs_events rather than our own detail_url?
- move form element to event-ae pages
- adjust event.new
- adjust order-one, event-info, activity
! acs_event.new doesn't accept related_url arg (even though it's in acs_events) so deal with this later?
- ask someone on irc to commit changes to plsql interface
wish list
---------
o support for recurring events
o integrate with search (active events only)
o generate rss feed for active events
o integrate with provider-profile to display events a user has attended or is registered for
o integrate usps_abbrev for venues with the ref-zip codes (or whatever else it is called) module so we can enter the state for an event
--
THINGS THAT HAVE BEEN FINISHED
------------------------------
DRB
o remove unnecessary permissions... as it stands we don't need any special permissions (it only relies on read, write and admin)
MICHAEL
o integrate with attachments for agenda upload
o move common queries from *.xql to procs (done?) MATTHEW AGREES THAT THIS IS DONE
o move oracle specific stuff [(+), decode(), etc.] to -oracle.xql files
- is logical_negation() cross platform? MATTHEW AGREES THAT THIS IS DONE
MATTHEW
o integrate with bulk-mail for spamming
o implement permissions
NOT DOING THIS AS PER COMMMUNITY CONSENSUS o templating system integration with master template for admin, and some small UI useablility changes
o subsite awareness
o when adding an event, maximum capacity should not be allowed to be higher than the max capacity of that venue - I think we should just leave it like that.
o activity and event check on various pages (i.e., does id exists in db?)
o check that order-one won't serve up past reg_deadline (-validate)
UNNECCESARY?? EVENT_ADD_2 ISN'T USED o more error checking in event-add-2 (deadline > sysdate)
IT IS GOOD ENOUGHo delete unnecessary code (once we are "done") - this way somebody looking at the code won't
change one file and not realize that the problem is elsewhere for example:
- tcl/venue-database.xql I don't think it needs the events::venue::new.new query
FIXED o events page -> "view page users see" broken - event page shows old events (why?)
This diff is collapsed.
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was originally written by Bryan Che and Phillip Greenspun
--
-- GNU GPL v2
--
-- Activity Object Type
declare
begin
acs_object_type.create_type(
object_type => 'events_activity',
pretty_name => 'Event Activity',
pretty_plural => 'Event Activities',
supertype => 'acs_activity',
table_name => 'events_activities',
id_column => 'activity_id'
);
end;
/
show errors;
-- create activity attributes
declare
attr_id acs_attributes.attribute_id%TYPE;
begin
attr_id := acs_attribute.create_attribute (
object_type => 'events_activity',
attribute_name => 'description',
datatype => 'string',
pretty_name => 'Description',
pretty_plural => 'Descriptions'
);
attr_id := acs_attribute.create_attribute (
object_type => 'events_activity',
attribute_name => 'detail_url',
datatype => 'string',
pretty_name => 'Detail URL',
pretty_plural => 'Detail URLs'
);
end;
/
show errors;
-- Each activity has the super_type of ACS_ACTIVITY
-- Table events_activities supplies additional information
create table events_activities (
activity_id integer
constraint events_activity_id_fk
references acs_activities
constraint events_activity_id_pk
primary key,
-- FIXME: (from old package) activities are owned by user groups
-- use map function in acs_activity? why?
--
-- keep track of event package instances in this table
package_id integer
constraint events_activities_pkg_id_fk
references apm_packages(package_id)
on delete cascade,
default_price number default 0 not null,
currency char(3) default 'USD',
-- Is this activity occurring? If not, we can't assign
-- any new events to it.
available_p char(1) default 't' check (available_p in ('t', 'f')),
deleted_p char(1) default 'f' check (deleted_p in ('t', 'f')),
-- URL for more details
detail_url varchar(256),
default_contact_user_id integer references users
);
comment on table events_activities is '
Table events_activities supplies additional information for events_activities type.
';
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
drop table events_activities;
delete from acs_objects where object_type = 'events_activity';
declare begin
acs_object_type.drop_type (object_type => 'events_activity' );
end;
/
show errors;
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
-- The Activity Package
create or replace package events_activity
as
function new (
activity_id in events_activities.activity_id%TYPE default null,
package_id in events_activities.package_id%TYPE,
detail_url in events_activities.detail_url%TYPE default null,
default_contact_user_id in events_activities.default_contact_user_id%TYPE default null,
name in acs_activities.name%TYPE default null,
description in acs_activities.description%TYPE default null,
html_p in acs_activities.html_p%TYPE default 'f',
status_summary in acs_activities.status_summary%TYPE default null,
object_type in acs_object_types.object_type%TYPE default 'events_activity',
creation_date in acs_objects.creation_date%TYPE default sysdate,
creation_user in acs_objects.creation_user%TYPE,
creation_ip in acs_objects.creation_ip%TYPE,
context_id in acs_objects.context_id%TYPE default null
) return events_activities.activity_id%TYPE;
procedure del (
activity_id in events_activities.activity_id%TYPE
);
end events_activity;
/
show errors;
create or replace package body events_activity
as
function new (
activity_id in events_activities.activity_id%TYPE default null,
package_id in events_activities.package_id%TYPE,
detail_url in events_activities.detail_url%TYPE default null,
default_contact_user_id in events_activities.default_contact_user_id%TYPE default null,
name in acs_activities.name%TYPE default null,
description in acs_activities.description%TYPE default null,
html_p in acs_activities.html_p%TYPE default 'f',
status_summary in acs_activities.status_summary%TYPE default null,
object_type in acs_object_types.object_type%TYPE default 'events_activity',
creation_date in acs_objects.creation_date%TYPE default sysdate,
creation_user in acs_objects.creation_user%TYPE,
creation_ip in acs_objects.creation_ip%TYPE,
context_id in acs_objects.context_id%TYPE default null
) return events_activities.activity_id%TYPE
is
v_activity_id events_activities.activity_id%TYPE;
begin
v_activity_id:= acs_activity.new (
activity_id => activity_id,
name => name,
description => description,
html_p => html_p,
status_summary => status_summary,
object_type => object_type,
creation_date => creation_date,
creation_user => creation_user,
creation_ip => creation_ip,
context_id => context_id
);
insert into events_activities
(activity_id, package_id, detail_url, default_contact_user_id)
values
(v_activity_id, package_id, detail_url, default_contact_user_id);
return v_activity_id;
end new;
procedure del (
activity_id in events_activities.activity_id%TYPE
)
is
cursor v_activity_events is
select event_id from acs_events
where activity_id = del.activity_id;
begin
-- find and delete event instances
for row in v_activity_events loop
events_event.del(row.event_id);
end loop;
delete from events_def_actvty_attr_map where activity_id = del.activity_id;
delete from events_org_role_activity_map where activity_id = del.activity_id;
delete from events_activities where activity_id = del.activity_id;
acs_object.delete(activity_id);
end del;
end events_activity;
/
show errors;
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Phillip Greenspun
--
-- GNU GPL v2
--
drop package events_activity;
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was originally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
-- Each event can have custom fields registrants should enter. To
-- accomplish this, we use the acs_attribute system, adding attributes
-- to the events_registration object and keeping a mapping of attribute to
-- each event/activity.
create table events_event_attr_map (
event_id integer
constraint evnts_evnt_attr_map_evnt_id_fk
references events_events,
attribute_id integer
constraint evnts_evnt_attr_map_attr_id_fk
references acs_attributes,
constraint event_attr_map_pk
primary key(event_id, attribute_id)
);
create index evnts_attr_map_event_id_idx on events_event_attr_map (event_id);
create table events_def_actvty_attr_map (
activity_id integer
constraint evnts_act_attr_map_act_id_fk
references events_activities,
attribute_id integer
constraint evnts_act_attr_map_attr_id_fk
references acs_attributes,
constraint events_activity_attr_map_pk
primary key(activity_id, attribute_id)
);
create index evnts_act_attr_map_act_id_idx on events_def_actvty_attr_map (activity_id);
create sequence events_attr_cat_seq start with 1;
create table events_attr_categories (
category_id integer
constraint events_attr_categories_pk
primary key,
category_name varchar(100)
);
create table events_attr_category_map (
attribute_id integer
constraint events_attr_cat_map_attr_id_fk
references acs_attributes,
category_id integer
constraint events_attr_cat_map_cat_id_fk
references events_attr_categories,
constraint events_attr_category_map_pk
primary key(attribute_id, category_id)
);
create index evnts_attr_cat_map_attr_id_idx on events_attr_category_map (attribute_id);
insert into events_attr_categories
(category_id, category_name)
values
(events_attr_cat_seq.nextval, 'Personal');
insert into events_attr_categories
(category_id, category_name)
values
(events_attr_cat_seq.nextval, 'Professional');
insert into events_attr_categories
(category_id, category_name)
values
(events_attr_cat_seq.nextval, 'Travel\Accomodations');
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was originally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
drop sequence events_attr_cat_seq;
drop table events_attr_category_map;
drop table events_attr_categories;
drop table events_def_actvty_attr_map;
drop table events_event_attr_map;
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was originally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
-- event venues
@ events-venues-create.sql
@ events-venues-package-create.sql
-- events and activities
@ events-events-create.sql
@ events-activities-create.sql
-- venue hierarchy and connections
@ events-venues-hc-create.sql
-- event prices
@ events-prices-create.sql
-- event registrations and orders
@ events-orders-create.sql
@ events-orders-package-create.sql
@ events-registrations-create.sql
@ events-registrations-package-create.sql
-- custom fields
@ events-attributes-create.sql
-- event organizers
@ events-organizers-create.sql
-- events package (references custom fields)
@ events-events-package-create.sql
@ events-activities-package-create.sql
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was originally written by Bryan Che and Phillip Greenspun
--
-- GNU GPL v2
--
-- event organizers
@ events-organizers-drop.sql
-- custom fields
@ events-attributes-drop.sql
-- event registrations and orders
@ events-registrations-drop.sql
@ events-registrations-package-drop.sql
@ events-orders-drop.sql
@ events-orders-package-drop.sql
-- event prices
@ events-prices-drop.sql
-- venue hierarchy and connections
@ events-venues-hc-drop.sql
-- events and activities
@ events-events-drop.sql
@ events-events-package-drop.sql
@ events-activities-drop.sql
@ events-activities-package-drop.sql
-- event venues
@ events-venues-drop.sql
@ events-venues-package-drop.sql
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was originally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
--
-- Event Object Type
--
declare
begin
acs_object_type.create_type(
object_type => 'events_event',
pretty_name => 'Event',
pretty_plural => 'Events',
supertype => 'acs_event',
table_name => 'events_events',
id_column => 'event_id'
);
end;
/
show errors
declare
attr_id acs_attributes.attribute_id%TYPE;
begin
attr_id := acs_attribute.create_attribute (
object_type => 'events_event',
attribute_name => 'max_people',
datatype => 'integer',
pretty_name => 'Max People',
pretty_plural => 'Max People'
);
attr_id := acs_attribute.create_attribute (
object_type => 'events_event',
attribute_name => 'reg_deadline',
datatype => 'date',
pretty_name => 'Registration Deadline',
pretty_plural => 'Registration Deadlines'
);
attr_id := acs_attribute.create_attribute (
object_type => 'events_event',
attribute_name => 'available_p',
datatype => 'string',
pretty_name => 'Available?',
pretty_plural => 'Available?'
);
attr_id := acs_attribute.create_attribute (
object_type => 'events_event',
attribute_name => 'display_after',
datatype => 'string',
pretty_name => 'Display After',
pretty_plural => 'Display After'
);
attr_id := acs_attribute.create_attribute (
object_type => 'events_event',
attribute_name => 'av_note',
datatype => 'string',
pretty_name => 'Audio/Visual Note',
pretty_plural => 'Audio/Visual Notes'
);
attr_id := acs_attribute.create_attribute (
object_type => 'events_event',
attribute_name => 'refreshments_note',
datatype => 'string',
pretty_name => 'Refreshment Note',
pretty_plural => 'Refreshment Notes'
);
attr_id := acs_attribute.create_attribute (
object_type => 'events_event',
attribute_name => 'additional_note',
datatype => 'string',
pretty_name => 'Additional Note',
pretty_plural => 'Additional Notes'
);
end;
/
show errors;
-- Each event has the super_type of ACS_EVENTS
-- Table events_events supplies additional information
create table events_events (
event_id integer
constraint events_event_id_fk
references acs_events
constraint events_event_id_pk
primary key,
venue_id integer
constraint events_venue_id_fk
references events_venues,
display_after varchar(4000),
max_people integer,
contact_user_id integer
constraint events_cntct_usr_id_fk
references users,
reg_deadline date not null,
available_p char(1) default 't' check (available_p in ('t', 'f')),
deleted_p char(1) default 'f' check (deleted_p in ('t', 'f')),
reg_cancellable_p char(1) default 't' check (reg_cancellable_p in ('t', 'f')),
reg_needs_approval_p char(1) default 'f' check (reg_needs_approval_p in ('t', 'f')),
av_note varchar(4000),
refreshments_note varchar(4000),
additional_note varchar(4000),
alternative_reg varchar(4000),
bulk_mail_id integer
constraint bulk_mail_id_fk
references bulk_mail_messages
);
comment on table events_events is '
Table events_events supplies additional information for events_event type.
';
comment on column events_events.event_id is '
Primary Key
';
comment on column events_events.display_after is '
This field contains text that will be displayed to user
after registering for an event.
';
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was originally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
declare
cursor v_event_ids is
select event_id from events_events;
begin
for row in v_event_ids loop
delete from events_events where event_id = row.event_id;
delete from acs_events where event_id = row.event_id;
delete from acs_objects where object_id = row.event_id;
end loop;
end;
/
show errors;
drop table events_events;
declare begin
acs_object_type.drop_type (object_type => 'events_event');
end;
/
show errors;
This diff is collapsed.
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Phillip Greenspun
--
-- GNU GPL v2
--
drop package events_event;
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was originally written by Bryan Che and Phillip Greenspun
--
-- GNU GPL v2
--
-- Order Object Type
declare
begin
acs_object_type.create_type(
object_type => 'events_order',
pretty_name => 'Order',
pretty_plural => 'Orders',
supertype => 'acs_object',
table_name => 'events_orders',
id_column => 'order_id'
);
end;
/
show errors;
-- Table to hold additional attributes
create table events_orders (
order_id constraint events_orders_order_id_fk
references acs_objects
constraint events_orders_order_id_pk
primary key,
-- ec_order_id integer references ec_orders,
-- the person who made the order
user_id integer
constraint events_orders_user_id_fk
references users,
paid_p char(1) default null check (paid_p in ('t', 'f', null)),
payment_method varchar(50),
confirmed_date date,
price_charged number,
-- the date this registration was refunded, if it was refunded
refunded_date date,
price_refunded number
);
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
drop table events_orders;
delete from acs_objects where object_type = 'events_order';
declare
begin
acs_object_type.drop_type (
object_type => 'events_order'
);
end;
/
show errors;
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was originally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
-- Order Package
create or replace package events_order
as
function new (
order_id in events_orders.order_id%TYPE default null,
user_id in users.user_id%TYPE,
creation_date in acs_objects.creation_date%TYPE default sysdate,
creation_user in acs_objects.creation_user%TYPE,
creation_ip in acs_objects.creation_ip%TYPE,
context_id in acs_objects.context_id%TYPE default null
) return events_orders.order_id%TYPE;
procedure del (
order_id in events_orders.order_id%TYPE
);
end events_order;
/
show errors;
create or replace package body events_order
as
function new (
order_id in events_orders.order_id%TYPE default null,
user_id in users.user_id%TYPE,
creation_date in acs_objects.creation_date%TYPE default sysdate,
creation_user in acs_objects.creation_user%TYPE,
creation_ip in acs_objects.creation_ip%TYPE,
context_id in acs_objects.context_id%TYPE default null
) return events_orders.order_id%TYPE
is
v_order_id acs_objects.object_id%TYPE;
begin
v_order_id:= acs_object.new (
object_id => order_id,
object_type => 'events_order',
creation_date => creation_date,
creation_user => creation_user,
creation_ip => creation_ip,
context_id => context_id
);
insert into events_orders
(order_id, user_id)
values
(v_order_id, user_id);
return v_order_id;
end new;
procedure del (
order_id in events_orders.order_id%TYPE
)
is
begin
acs_object.delete(del.order_id);
end del;
end events_order;
/
show errors;
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Phillip Greenspun
--
-- GNU GPL v2
--
drop package events_order;
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was originally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
-- Organizer roles for activities and events
create sequence events_org_roles_seq start with 1;
create table events_organizer_roles (
role_id integer
constraint evnts_org_roles_role_id_pk
primary key,
role varchar(200)
constraint evnts_org_roles_role_nn
not null,
responsibilities clob,
-- is this a role that we want event registrants to see?
public_role_p char(1) default 'f'
constraint evnts_org_roles_public_role_p
check (public_role_p in ('t', 'f')),
package_id integer
constraint evnts_org_roles_pkg_id_fk
references apm_packages
on delete cascade
);
create table events_org_role_activity_map (
role_id integer
constraint evnts_org_role_am_role_id_fk
references events_organizer_roles,
activity_id integer
constraint evnts_org_role_act_id_fk
references events_activities
);
create table events_org_role_event_map (
role_id integer
constraint evnts_org_role_em_role_id_fk
references events_organizer_roles,
event_id integer
constraint evnts_org_role_evnt_id_fk
references events_events
);
create table events_organizers_map (
user_id constraint evnt_org_map_user_id_nn
not null
constraint evnt_org_map_user_id_fk
references users,
role_id integer
constraint evnt_org_map_role_id_nn
not null
constraint evnt_org_map_role_id_fk
references events_organizer_roles,
event_id integer
constraint evnt_org_map_evnt_id_nn
not null
constraint evnt_org_map_evnt_id_fk
references events_events,
constraint events_org_map_pk primary key (user_id, role_id, event_id)
);
-- create a view to see event organizer roles and the people in those roles
create or replace view events_organizers
as
select eor.*, eom.user_id, eorem.event_id
from events_organizer_roles eor,
events_org_role_event_map eorem,
events_organizers_map eom
where eor.role_id = eorem.role_id
and eorem.role_id = eom.role_id(+);
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Phillip Greenspun
--
-- GNU GPL v2
--
drop sequence events_org_roles_seq;
drop table events_org_role_event_map;
drop table events_org_role_activity_map;
drop table events_organizers_map;
drop table events_organizer_roles;
drop view events_organizers
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Phillip Greenspun
--
-- GNU GPL v2
--
-- Not implemented yet
create sequence events_price_id_sequence;
create table events_prices (
price_id integer primary key,
event_id integer not null references events_events,
-- e.g., "Developer", "Student"
description varchar(100) not null,
-- we also store the price here too in case someone doesn't want
-- to use the ecommerce module but still wants to have prices
price number not null,
-- This is for hooking up to ecommerce.
-- Each product is a different price for this event. For example,
-- student price and normal price products for an event.
-- product_id integer references ec_products,
-- prices may be different for early, normal, late, on-site
-- admission,
-- depending on the date
expire_date date not null,
available_date date not null
);
create index evnt_price_idx on events_prices(price_id, event_id);
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Phillip Greenspun
--
-- GNU GPL v2
--
drop sequence events_price_id_sequence;
drop table events_prices;
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Phillip Greenspun
--
-- GNU GPL v2
--
--
-- Registration Object Type
--
declare
begin
acs_object_type.create_type(
object_type => 'events_registration',
pretty_name => 'Registration',
pretty_plural => 'Registrations',
supertype => 'acs_object',
table_name => 'events_registrations',
id_column => 'reg_id'
);
end;
/
show errors;
-- declare
-- attr_id acs_attributes.attribute_id%TYPE;
-- begin
-- --
-- -- events_registration foundation attributes
-- --
-- attr_id := acs_attribute.create_attribute (
-- object_type => 'events_registration',
-- attribute_name => 'reg_state',
-- datatype => 'string',
-- pretty_name => 'Registration State',
-- pretty_plural => 'Registration States'
-- );
--
-- attr_id := acs_attribute.create_attribute (
-- object_type => 'events_registration',
-- attribute_name => 'shipped_date',
-- datatype => 'date',
-- pretty_name => 'Shipped Date',
-- pretty_plural => 'Shipped Dates'
-- );
--
-- --
-- -- create built-in user-visible registration attributes
-- --
-- attr_id := acs_attribute.create_attribute (
-- object_type => 'events_registration',
-- attribute_name => 'org',
-- datatype => 'string',
-- pretty_name => 'Organization',
-- pretty_plural => 'Organizations',
-- sort_order => 1
-- );
--
-- attr_id := acs_attribute.create_attribute (
-- object_type => 'events_registration',
-- attribute_name => 'title_at_org',
-- datatype => 'string',
-- pretty_name => 'Title',
-- pretty_plural => 'Titles',
-- sort_order => 2
-- );
--
-- attr_id := acs_attribute.create_attribute (
-- object_type => 'events_registration',
-- attribute_name => 'attending_reason',
-- datatype => 'string',
-- pretty_name => 'Reason for attending',
-- pretty_plural => 'Reasons for attending',
-- sort_order => 3
-- );
--
-- attr_id := acs_attribute.create_attribute (
-- object_type => 'events_registration',
-- attribute_name => 'where_heard',
-- datatype => 'string',
-- pretty_name => 'Where did you hear about this activity?',
-- pretty_plural => 'Where did you hear about these activities?',
-- sort_order => 4
-- );
--
-- attr_id := acs_attribute.create_attribute (
-- object_type => 'events_registration',
-- attribute_name => 'need_hotel_p',
-- datatype => 'boolean',
-- pretty_name => 'Do you need a hotel?',
-- pretty_plural => 'Do you need a hotel?',
-- sort_order => 5
-- );
--
-- attr_id := acs_attribute.create_attribute (
-- object_type => 'events_registration',
-- attribute_name => 'need_car_p',
-- datatype => 'boolean',
-- pretty_name => 'Do you need a car?',
-- pretty_plural => 'Do you need a car?',
-- sort_order => 6
-- );
--
-- attr_id := acs_attribute.create_attribute (
-- object_type => 'events_registration',
-- attribute_name => 'need_plane_p',
-- datatype => 'boolean',
-- pretty_name => 'Do you need a plane ticket?',
-- pretty_plural => 'Do you need a plane ticket?',
-- sort_order => 7
-- );
--
-- -- no sort order - comments will always be last
-- attr_id := acs_attribute.create_attribute (
-- object_type => 'events_registration',
-- attribute_name => 'comments',
-- datatype => 'string',
-- pretty_name => 'Comments',
-- pretty_plural => 'Comments'
-- );
--
-- end;
-- /
-- show errors;
--
create table events_registrations(
-- Goes into table at confirmation time:
reg_id integer not null primary key,
event_id integer not null references events_events,
-- order_id integer not null references events_orders,
-- price_id integer not null references events_prices,
-- the person registered for this reg_id (may not be the person
-- who made the order)
user_id integer not null references users,
-- reg_states: pending, shipped, canceled, waiting
--pending: waiting for approval
--shipped: registration all set
--canceled: registration canceled
--waiting: registration is wait-listed
reg_state varchar(50) not null check (reg_state in ('pending', 'approved', 'canceled', 'waiting')),
-- when the registration was made
-- reg_date date,
-- when the registration was approved
approval_date date,
-- org varchar(500),
-- title_at_org varchar(500),
-- attending_reason clob,
-- where_heard varchar(4000),
-- does this person need a hotel?
-- need_hotel_p char(1) default 'f' check (need_hotel_p in ('t', 'f')),
-- does this person need a rental car?
-- need_car_p char(1) default 'f' check (need_car_p in ('t', 'f')),
-- does this person need airfare?
-- need_plane_p char(1) default 'f' check (need_plane_p in ('t', 'f')),
comments varchar(4000)
);
--
-- Indexes
--
-- removed price_id from index - 7/19/02
create index evnt_reg_idx on events_registrations(reg_id, user_id, reg_state);
-- need this index for speeding up /events/admin/order-history-one.tcl
--create index users_last_name_idx on users(lower(last_name), last_name, first_names, email, user_id);
--
-- Triggers
--
-- trigger for recording when a registration ships
create or replace trigger event_ship_date_trigger
before insert or update on events_registrations
for each row
when (old.reg_state <> 'approved' and new.reg_state = 'approved')
begin
:new.approval_date := sysdate;
end;
/
show errors
--
-- Views
--
--
-- create or replace view events_reg_not_canceled
-- as
-- select *
-- from events_registrations
-- where reg_state <> 'canceled';
--
-- create or replace view events_reg_canceled
-- as
-- select *
-- from events_registrations
-- where reg_state = 'canceled';
--
-- create or replace view events_reg_shipped
-- as
-- select *
-- from events_registrations
-- where reg_state = 'shipped';
--
-- create a view that shows order states based upon each order's
-- registrations. The order states are:
-- void: All registrations canceled
-- incomplete: This order is not completely fulfilled--some registrations
-- are either canceled, waiting, or pending
-- fulfilled: This order is completely fulfilled
-- create or replace view events_orders_states
-- as
-- select o.*,
-- o_states.order_state
-- from events_orders o,
-- (select
-- order_id,
-- decode (floor(avg (decode (reg_state,
-- 'canceled', 0,
-- 'waiting', 1,
-- 'pending', 2,
-- 'shipped', 3,
-- 0))),
-- 0, 'canceled',
-- 1, 'incomplete',
-- 2, 'incomplete',
-- 3, 'fulfilled',
-- 'void') as order_state
-- from events_registrations
-- group by order_id) o_states
--where o_states.order_id = o.order_id;
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Phillip Greenspun
--
-- GNU GPL v2
--
--drop view events_orders_states;
--drop view events_reg_not_canceled;
--drop view events_reg_canceled;
--drop view events_reg_shipped;
drop table events_registrations;
delete from acs_objects where object_type = 'events_registration';
declare
begin
acs_object_type.drop_type (
object_type => 'events_registration'
);
end;
/
show errors;
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
-- The Registration Package
create or replace package events_registration
as
function new (
reg_id in events_registrations.reg_id%TYPE default null,
event_id in events_events.event_id%TYPE,
user_id in users.user_id%TYPE,
reg_state in events_registrations.reg_state%TYPE,
comments in events_registrations.comments%TYPE,
creation_date in acs_objects.creation_date%TYPE default sysdate,
creation_user in acs_objects.creation_user%TYPE,
creation_ip in acs_objects.creation_ip%TYPE,
context_id in acs_objects.context_id%TYPE default null
) return events_registrations.reg_id%TYPE;
procedure del (
reg_id in events_registrations.reg_id%TYPE
);
end events_registration;
/
show errors;
create or replace package body events_registration
as
function new (
reg_id in events_registrations.reg_id%TYPE default null,
event_id in events_events.event_id%TYPE,
user_id in users.user_id%TYPE,
reg_state in events_registrations.reg_state%TYPE,
comments in events_registrations.comments%TYPE,
creation_date in acs_objects.creation_date%TYPE default sysdate,
creation_user in acs_objects.creation_user%TYPE,
creation_ip in acs_objects.creation_ip%TYPE,
context_id in acs_objects.context_id%TYPE default null
) return events_registrations.reg_id%TYPE
is
v_reg_id acs_objects.object_id%TYPE;
begin
v_reg_id:= acs_object.new (
object_id => reg_id,
object_type => 'events_registration',
creation_date => creation_date,
creation_user => creation_user,
creation_ip => creation_ip,
context_id => context_id
);
insert into events_registrations
(reg_id, event_id, user_id, reg_state, comments)
values
(v_reg_id, event_id, user_id, reg_state, comments);
return v_reg_id;
end new;
procedure del (
reg_id in events_registrations.reg_id%TYPE
)
is
begin
acs_object.delete(reg_id);
end del;
end events_registration;
/
show errors;
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Phillip Greenspun
--
-- GNU GPL v2
--
drop package events_registration;
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was originally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
--
-- Venue Object Types
--
declare
begin
acs_object_type.create_type(
object_type => 'events_venue',
pretty_name => 'Venue',
pretty_plural => 'Venues',
supertype => 'acs_object',
table_name => 'events_venues',
id_column => 'venue_id',
package_name => 'events_venue'
);
end;
/
show errors;
declare
attr_id acs_attributes.attribute_id%TYPE;
begin
attr_id := acs_attribute.create_attribute (
object_type => 'events_venue',
attribute_name => 'venue_name',
datatype => 'string',
pretty_name => 'Name',
pretty_plural => 'Names'
);
attr_id := acs_attribute.create_attribute (
object_type => 'events_venue',
attribute_name => 'address1',
datatype => 'string',
pretty_name => 'Address 1',
pretty_plural => 'Address 1'
);
attr_id := acs_attribute.create_attribute (
object_type => 'events_venue',
attribute_name => 'address2',
datatype => 'string',
pretty_name => 'Address 2',
pretty_plural => 'Address 2'
);
attr_id := acs_attribute.create_attribute (
object_type => 'events_venue',
attribute_name => 'city',
datatype => 'string',
pretty_name => 'City',
pretty_plural => 'Cities'
);
attr_id := acs_attribute.create_attribute (
object_type => 'events_venue',
attribute_name => 'usps_abbrev',
datatype => 'string',
pretty_name => 'USPS Abbreviation',
pretty_plural => 'USPS Abbreviations'
);
attr_id := acs_attribute.create_attribute (
object_type => 'events_venue',
attribute_name => 'postal_code',
datatype => 'string',
pretty_name => 'Postal Code',
pretty_plural => 'Postal Codes'
);
attr_id := acs_attribute.create_attribute (
object_type => 'events_venue',
attribute_name => 'iso',
datatype => 'string',
pretty_name => 'Country Code',
pretty_plural => 'Country Codes'
);
attr_id := acs_attribute.create_attribute (
object_type => 'events_venue',
attribute_name => 'description',
datatype => 'string',
pretty_name => 'Description',
pretty_plural => 'Descriptions'
);
attr_id := acs_attribute.create_attribute (
object_type => 'events_venue',
attribute_name => 'fax_number',
datatype => 'string',
pretty_name => 'Fax Number',
pretty_plural => 'Fax Numbers'
);
attr_id := acs_attribute.create_attribute (
object_type => 'events_venue',
attribute_name => 'phone_number',
datatype => 'string',
pretty_name => 'Phone Number',
pretty_plural => 'Phone Numbers'
);
attr_id := acs_attribute.create_attribute (
object_type => 'events_venue',
attribute_name => 'email',
datatype => 'string',
pretty_name => 'Email Address',
pretty_plural => 'Email Addresses'
);
attr_id := acs_attribute.create_attribute (
object_type => 'events_venue',
attribute_name => 'max_people',
datatype => 'string',
pretty_name => 'Maximum Number of People',
pretty_plural => 'Maximum Number of People'
);
end;
/
show errors;
-- where the events occur
create table events_venues (
venue_id integer
constraint events_venues_pk
primary key,
venue_name varchar(200) not null,
address1 varchar(100),
address2 varchar(100),
city varchar(100),
usps_abbrev char(2),
postal_code varchar(20),
iso char(2) default 'US' references countries,
time_zone number references timezones(tz_id),
-- some contact info for this venue
phone_number varchar(30),
fax_number varchar(30),
email varchar(100),
needs_reserve_p char(1) default 'f' check (needs_reserve_p in ('t', 'f')),
max_people integer,
description varchar(4000),
package_id integer
constraint evnts_venues_pkg_id_fk
references apm_packages
on delete cascade
);
\ No newline at end of file
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
drop table events_venues cascade constraints;
delete from acs_objects where object_type = 'events_venue';
declare
begin
acs_object_type.drop_type (
object_type => 'events_venue'
);
end;
/
show errors;
\ No newline at end of file
--
-- The Events Package
--
-- @author Brad Duell (bduell@ncacasi.org)
-- @version $Id$
--
-- GNU GPL v2
--
-- allow venue hierarchy
create table events_venues_venues_map (
parent_venue_id integer not null,
child_venue_id integer not null,
package_id integer
constraint events_v_v_pkg_id_fk
references apm_packages
on delete cascade,
constraint events_v_v_pk
primary key(parent_venue_id, child_venue_id, package_id),
constraint events_v_v_pv_id_fk foreign key(parent_venue_id)
references events_venues(venue_id),
constraint events_v_v_cv_id_fk foreign key(child_venue_id)
references events_venues(venue_id));
-- allow venue connections
create table events_venues_connecting_map (
left_venue_id integer not null,
right_venue_id integer not null,
package_id integer
constraint events_v_c_pkg_id_fk
references apm_packages
on delete cascade,
constraint events_v_c_pk
primary key(left_venue_id, right_venue_id, package_id),
constraint events_v_c_lv_id_fk foreign key(left_venue_id)
references events_venues(venue_id),
constraint events_v_c_rv_id_fk foreign key(right_venue_id)
references events_venues(venue_id));
-- use-case mapping between venue connections
create table events_venues_conn_used_map (
event_id integer not null,
venue_id integer not null,
connected_venue_id integer not null,
package_id integer
constraint events_v_cu_pkg_id_fk
references apm_packages
on delete cascade,
constraint events_v_cu_pk
primary key(event_id, venue_id, connected_venue_id, package_id),
constraint events_v_cu_v_id_fk foreign key(venue_id)
references events_venues(venue_id),
constraint events_v_cu_cv_id_fk foreign key(connected_venue_id)
references events_venues(venue_id),
constraint events_v_cu_e_id_fk foreign key(event_id)
references events_events(event_id));
\ No newline at end of file
--
-- The Events Package
--
-- @author Brad Duell (bduell@ncacasi.org)
-- @version $Id$
--
-- GNU GPL v2
--
drop table events_venues_conn_used_map;
drop table events_venues_connecting_map;
drop table events_venues_venues_map;
\ No newline at end of file
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
-- The Venue Package
create or replace package events_venue
as
function new (
venue_id in events_venues.venue_id%TYPE default null,
package_id in events_venues.package_id%TYPE default null,
venue_name in events_venues.venue_name%TYPE,
address1 in events_venues.address1%TYPE default null,
address2 in events_venues.address2%TYPE default null,
city in events_venues.city%TYPE,
usps_abbrev in events_venues.usps_abbrev%TYPE default null,
postal_code in events_venues.postal_code%TYPE default null,
time_zone in events_venues.time_zone%TYPE default null,
iso in events_venues.iso%TYPE default null,
phone_number in events_venues.phone_number%TYPE default null,
fax_number in events_venues.fax_number%TYPE default null,
email in events_venues.email%TYPE default null,
needs_reserve_p in events_venues.needs_reserve_p%TYPE default 'f',
max_people in events_venues.max_people%TYPE default null,
description in events_venues.description%TYPE default null
) return events_venues.venue_id%TYPE;
procedure del (
venue_id in events_venues.venue_id%TYPE
);
end events_venue;
/
show errors;
create or replace package body events_venue
as
function new (
venue_id in events_venues.venue_id%TYPE default null,
package_id in events_venues.package_id%TYPE default null,
venue_name in events_venues.venue_name%TYPE,
address1 in events_venues.address1%TYPE default null,
address2 in events_venues.address2%TYPE default null,
city in events_venues.city%TYPE,
usps_abbrev in events_venues.usps_abbrev%TYPE default null,
postal_code in events_venues.postal_code%TYPE default null,
time_zone in events_venues.time_zone%TYPE default null,
iso in events_venues.iso%TYPE default null,
phone_number in events_venues.phone_number%TYPE default null,
fax_number in events_venues.fax_number%TYPE default null,
email in events_venues.email%TYPE default null,
needs_reserve_p in events_venues.needs_reserve_p%TYPE default 'f',
max_people in events_venues.max_people%TYPE default null,
description in events_venues.description%TYPE default null
) return events_venues.venue_id%TYPE
is
v_venue_id events_venues.venue_id%TYPE;
begin
insert into events_venues
(venue_id, venue_name, address1, address2, city, usps_abbrev, postal_code, iso, phone_number,
time_zone, fax_number, email, needs_reserve_p, max_people, description, package_id)
values
(venue_id, venue_name, address1, address2, city, usps_abbrev, postal_code, iso, phone_number,
time_zone, fax_number, email, needs_reserve_p, max_people, description, package_id);
return v_venue_id;
end new;
procedure del (
venue_id in events_venues.venue_id%TYPE
)
is
begin
delete from events_venues where venue_id = del.venue_id;
acs_object.delete(del.venue_id);
end del;
end events_venue;
/
show errors;
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Phillip Greenspun
--
-- GNU GPL v2
--
drop package events_venue;
This diff is collapsed.
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was originally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
-- Activity Object Type
create function inline_0 ()
returns integer as '
begin
PERFORM acs_object_type__create_type (
''events_activity'', -- object_type
''Event Activity'', -- pretty_name
''Event Activities'', -- pretty_plural
''acs_activity'', -- supertype
''events_activities'', -- table_name
''activity_id'', -- id_column
null, -- package_name
''f'', -- abstract_p
null, -- type_extensions_table
''events_activity.name'' -- name_method
);
return 0;
end;' language 'plpgsql';
select inline_0 ();
drop function inline_0 ();
create function inline_1 ()
returns integer as '
begin
PERFORM acs_attribute__create_attribute (
''events_activity'', -- object_type
''description'', -- attribute_name
''string'', -- datatype
''Description'', -- pretty_name
''Descriptions'', -- pretty_plural
null, -- table_name
null, -- column_name
null, -- default_value
1, -- min_n_values
1, -- max_n_values
null, -- sort_order
''type_specific'', -- storage
''f'' -- static_p
);
PERFORM acs_attribute__create_attribute (
''events_activity'', -- object_type
''detail_url'', -- attribute_name
''string'', -- datatype
''Detail URL'', -- pretty_name
''Detail URLs'', -- pretty_plural
null, -- table_name
null, -- column_name
null, -- default_value
1, -- min_n_values
1, -- max_n_values
null, -- sort_order
''type_specific'', -- storage
''f'' -- static_p
);
return 0;
end;' language 'plpgsql';
select inline_1 ();
drop function inline_1 ();
-- Each activity has the super_type of ACS_ACTIVITY
-- Table events_activities supplies additional information
create table events_activities (
activity_id integer
constraint events_activity_id_fk
references acs_activities
constraint events_activity_id_pk
primary key,
-- FIXME: (from old package) activities are owned by user groups
-- use map function in acs_activity? why?
--
-- keep track of event package instances in this table
package_id integer
constraint events_activities_pkg_id_fk
references apm_packages(package_id)
on delete cascade,
default_price numeric default 0 not null,
currency char(3) default 'USD',
-- Is this activity occurring? If not, we can't assign
-- any new events to it.
available_p boolean default 't',
deleted_p boolean default 'f',
-- URL for more details
detail_url varchar(256),
default_contact_user_id integer references users
);
comment on table events_activities is '
Table events_activities supplies additional information for events_activities type.
';
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Phillip Greenspun
--
-- GNU GPL v2
--
drop table events_activities;
delete from acs_objects where object_type = 'events_activity';
select acs_object_type__drop_type(
'events_activity',
't'
);
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
-- The Activity Package
select define_function_args('events_activity__new','activity_id,package_id,detail_url,default_contact_user_id,name,description,html_p;f,status_summary,object_type;events_activity,creation_date,creation_user,creation_ip,context_id');
create function events_activity__new (integer,integer,varchar,integer,varchar,varchar,boolean,varchar,varchar,timestamp,integer,varchar,integer)
returns integer as '
declare
p_activity_id alias for $1; -- default null
p_package_id alias for $2;
p_detail_url alias for $3; -- default null
p_default_contact_user_id alias for $4;
p_name alias for $5; -- default null
p_description alias for $6; -- default null
p_html_p alias for $7; -- default ''f''
p_status_summary alias for $8; -- default null
p_object_type alias for $9; -- default ''events_activity''
p_creation_date alias for $10; -- default now()
p_creation_user alias for $11;
p_creation_ip alias for $12;
p_context_id alias for $13; -- default null
v_activity_id integer;
begin
v_activity_id := acs_activity__new (
p_activity_id,
p_name,
p_description,
p_html_p,
p_status_summary,
p_object_type,
p_creation_date,
p_creation_user,
p_creation_ip,
coalesce(p_context_id, p_package_id)
);
insert into events_activities
(activity_id, package_id, detail_url, default_contact_user_id)
values
(v_activity_id, p_package_id, p_detail_url, p_default_contact_user_id);
return v_activity_id;
end;' language 'plpgsql';
select define_function_args('events_activity__name','activity_id');
create function events_activity__name(integer)
returns varchar as '
declare
p_activity_id alias for $1;
begin
return name from acs_activities where activity_id = p_activity_id;
end;
' language 'plpgsql';
select define_function_args('events_activity__delete','activity_id');
create function events_activity__delete (integer)
returns integer as '
declare
p_activity_id alias for $1;
begin
cursor v_activity_events is
select event_id as v_event_id from acs_events
where activity_id = p_activity_id;
begin
-- find and delete event instances
for row in v_activity_events loop
events_event__delete(v_event_id);
end loop;
delete from events_def_actvty_attr_map where activity_id = p_activity_id;
delete from events_org_role_activity_map where activity_id = p_activity_id;
delete from events_activities where activity_id = p_activity_id;
raise NOTICE ''Deleting note...'';
PERFORM acs_object__delete(p_activity_id);
return 0;
end;' language 'plpgsql';
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Phillip Greenspun
--
-- GNU GPL v2
--
drop function events_activity__new (integer,integer,varchar,integer,varchar,varchar,boolean,varchar,varchar,timestamp,integer,varchar,integer);
drop function events_activity__name(integer);
drop function events_activity__delete (integer);
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was originally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
-- Each event can have custom fields registrants should enter. To
-- accomplish this, we use the acs_attribute system, adding attributes
-- to the events_registration object and keeping a mapping of attribute to
-- each event/activity.
create table events_event_attr_map (
event_id integer
constraint evnts_evnt_attr_map_evnt_id_fk
references events_events,
attribute_id integer
constraint evnts_evnt_attr_map_attr_id_fk
references acs_attributes,
constraint event_attr_map_pk
primary key(event_id, attribute_id)
);
create index evnts_attr_map_event_id_idx on events_event_attr_map (event_id);
create table events_def_actvty_attr_map (
activity_id integer
constraint evnts_act_attr_map_act_id_fk
references events_activities,
attribute_id integer
constraint evnts_act_attr_map_attr_id_fk
references acs_attributes,
constraint events_activity_attr_map_pk
primary key(activity_id, attribute_id)
);
create index evnts_act_attr_map_act_id_idx on events_def_actvty_attr_map (activity_id);
create sequence events_attr_cat_seq start 1;
create table events_attr_categories (
category_id integer
constraint events_attr_categories_pk
primary key,
category_name varchar(100)
);
create table events_attr_category_map (
attribute_id integer
constraint events_attr_cat_map_attr_id_fk
references acs_attributes,
category_id integer
constraint events_attr_cat_map_cat_id_fk
references events_attr_categories,
constraint events_attr_category_map_pk
primary key(attribute_id, category_id)
);
create index evnts_attr_cat_map_attr_id_idx on events_attr_category_map (attribute_id);
insert into events_attr_categories
(category_id, category_name)
values
(nextval('events_attr_cat_seq'), 'Personal');
insert into events_attr_categories
(category_id, category_name)
values
(nextval('events_attr_cat_seq'), 'Professional');
insert into events_attr_categories
(category_id, category_name)
values
(nextval('events_attr_cat_seq'), 'Travel\Accomodations');
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was originally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
drop sequence events_attr_cat_seq;
drop table events_attr_category_map;
drop table events_attr_categories;
drop table events_def_actvty_attr_map;
drop table events_event_attr_map;
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was originally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
-- event venues
\i events-venues-create.sql
\i events-venues-package-create.sql
-- events and activities
\i events-events-create.sql
\i events-activities-create.sql
\i events-activities-package-create.sql
-- venue hierarchy and connections
\i events-venues-hc-create.sql
-- event prices
\i events-prices-create.sql
-- event registrations and orders
\i events-orders-create.sql
\i events-orders-package-create.sql
\i events-registrations-create.sql
\i events-registrations-package-create.sql
-- custom fields
\i events-attributes-create.sql
-- events package (references custom fields)
\i events-events-package-create.sql
-- event organizers
\i events-organizers-create.sql
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was originally written by Bryan Che and Phillip Greenspun
--
-- GNU GPL v2
--
-- event organizers
\i events-organizers-drop.sql
-- custom fields
\i events-attributes-drop.sql
-- venue hierarchy and connections
\i events-venues-hc-drop.sql
-- events and activities
\i events-events-drop.sql
\i events-events-package-drop.sql
\i events-activities-drop.sql
\i events-activities-package-drop.sql
-- event registrations and orders
\i events-registrations-drop.sql
\i events-registrations-package-drop.sql
\i events-orders-drop.sql
\i events-orders-package-drop.sql
-- event prices
\i events-prices-drop.sql
-- event venues
\i events-venues-drop.sql
\i events-venues-package-drop.sql
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was originally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
--
-- Event Object Type
--
create function inline_0 ()
returns integer as '
begin
PERFORM acs_object_type__create_type (
''events_event'', -- object_type
''Event'', -- pretty_name
''Events'', -- pretty_plural
''acs_event'', -- supertype
''events_events'', -- table_name
''event_id'', -- id_column
null, -- package_name
''f'', -- abstract_p
null, -- type_extensions_table
''events_event.name'' -- name_method
);
return 0;
end;' language 'plpgsql';
select inline_0 ();
drop function inline_0 ();
create function inline_1 ()
returns integer as '
begin
PERFORM acs_attribute__create_attribute (
''events_event'', -- object_type
''max_people'', -- attribute_name
''string'', -- datatype
''Max People'', -- pretty_name
''Max People'', -- pretty_plural
null, -- table_name
null, -- column_name
null, -- default_value
1, -- min_n_values
1, -- max_n_values
null, -- sort_order
''type_specific'', -- storage
''f'' -- static_p
);
PERFORM acs_attribute__create_attribute (
''events_event'', -- object_type
''reg_deadline'', -- attribute_name
''string'', -- datatype
''Registration Deadline'', -- pretty_name
''Registrations Deadlines'', -- pretty_plural
null, -- table_name
null, -- column_name
null, -- default_value
1, -- min_n_values
1, -- max_n_values
null, -- sort_order
''type_specific'', -- storage
''f'' -- static_p
);
PERFORM acs_attribute__create_attribute (
''events_event'', -- object_type
''available_p'', -- attribute_name
''string'', -- datatype
''Available?'', -- pretty_name
''Available?'', -- pretty_plural
null, -- table_name
null, -- column_name
null, -- default_value
1, -- min_n_values
1, -- max_n_values
null, -- sort_order
''type_specific'', -- storage
''f'' -- static_p
);
PERFORM acs_attribute__create_attribute (
''events_event'', -- object_type
''display_after'', -- attribute_name
''string'', -- datatype
''Display After'', -- pretty_name
''Display After'', -- pretty_plural
null, -- table_name
null, -- column_name
null, -- default_value
1, -- min_n_values
1, -- max_n_values
null, -- sort_order
''type_specific'', -- storage
''f'' -- static_p
);
PERFORM acs_attribute__create_attribute (
''events_event'', -- object_type
''av_note'', -- attribute_name
''string'', -- datatype
''Audio/Visual Note'', -- pretty_name
''Audio/Visual Notes'', -- pretty_plural
null, -- table_name
null, -- column_name
null, -- default_value
1, -- min_n_values
1, -- max_n_values
null, -- sort_order
''type_specific'', -- storage
''f'' -- static_p
);
PERFORM acs_attribute__create_attribute (
''events_event'', -- object_type
''refreshements_note'', -- attribute_name
''string'', -- datatype
''Refreshment Note'', -- pretty_name
''Refreshment Notes'', -- pretty_plural
null, -- table_name
null, -- column_name
null, -- default_value
1, -- min_n_values
1, -- max_n_values
null, -- sort_order
''type_specific'', -- storage
''f'' -- static_p
);
PERFORM acs_attribute__create_attribute (
''events_event'', -- object_type
''additional_note'', -- attribute_name
''string'', -- datatype
''Additional Note'', -- pretty_name
''Additional Notes'', -- pretty_plural
null, -- table_name
null, -- column_name
null, -- default_value
1, -- min_n_values
1, -- max_n_values
null, -- sort_order
''type_specific'', -- storage
''f'' -- static_p
);
return 0;
end;' language 'plpgsql';
select inline_1 ();
drop function inline_1 ();
-- Each event has the super_type of ACS_EVENTS
-- Table events_events supplies additional information
create table events_events (
event_id integer
constraint events_event_id_fk
references acs_events
constraint events_event_id_pk
primary key,
venue_id integer
constraint events_venue_id_fk
references events_venues,
display_after varchar(4000),
max_people integer,
contact_user_id integer
constraint events_cntct_usr_id_fk
references users,
reg_deadline timestamptz not null,
available_p boolean default 't',
deleted_p boolean default 'f',
reg_cancellable_p boolean default 't',
reg_needs_approval_p boolean default 'f',
av_note varchar(4000),
refreshments_note varchar(4000),
additional_note varchar(4000),
alternative_reg varchar(4000),
bulk_mail_id integer
constraint bulk_mail_id_fk
references bulk_mail_messages
);
comment on table events_events is '
Table events_events supplies additional information for events_event type.
';
comment on column events_events.event_id is '
Primary Key
';
comment on column events_events.display_after is '
This field contains text that will be displayed to user
after registering for an event.
';
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was originally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
create function inline_0 ()
returns integer as '
declare
event_rec record;
begin
for event_rec in select event_id from events_events
loop
delete from events_events where event_id = event_rec.event_id;
delete from acs_events where event_id = event_rec.event_id;
delete from acs_objects where object_id = event_rec.event_id;
end loop;
return 0;
end;' language 'plpgsql';
select inline_0();
drop function inline_0();
drop table events_events;
select acs_object_type__drop_type(
'events_event',
't'
);
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
--
--
-- -- The Event Package
--
select define_function_args('events_event__new','event_id,venue_id,display_after,max_people,reg_deadline,available_p;t,deleted_p;f,reg_cancellable_p,reg_needs_approval_p,refreshments_note,av_note,additional_note,alternative_reg,activity_id');
create function events_event__new (integer,integer,varchar,integer,timestamp,boolean,boolean,boolean,boolean,integer,varchar,varchar,varchar,varchar,integer)
returns integer as '
declare
p_event_id alias for $1; -- default null
p_venue_id alias for $2;
p_display_after alias for $3; -- default null
p_max_people alias for $4; -- default null
p_reg_deadline alias for $5;
p_available_p alias for $6; -- default ''t''
p_deleted_p alias for $7; -- default ''f''
p_reg_cancellable_p alias for $8;
p_reg_needs_approval_p alias for $9;
p_contact_user_id alias for $10;
p_refreshments_note alias for $11; -- default null
p_av_note alias for $12; -- default null
p_additional_note alias for $13; -- null
p_alternative_reg alias for $14; -- null
p_activity_id alias for $15;
v_activity_attrs record;
v_activity_org_roles record;
begin
insert into events_events
(event_id, contact_user_id, venue_id, display_after, max_people, reg_deadline, available_p, deleted_p, reg_cancellable_p, reg_needs_approval_p, refreshments_note, av_note, additional_note, alternative_reg)
values
(p_event_id, p_contact_user_id, p_venue_id, p_display_after, p_max_people, p_reg_deadline::timestamp, p_available_p, p_deleted_p, p_reg_cancellable_p, p_reg_needs_approval_p, p_refreshments_note, p_av_note, p_additional_note, p_alternative_reg);
for v_activity_attrs in select
attribute_id as v_attribute_id
from events_def_actvty_attr_map edaam
where edaam.activity_id = p_activity_id
LOOP
-- copy over pointers to custom fields (registration attributes)
insert into events_event_attr_map
(event_id, attribute_id)
values
(p_event_id, v_activity_attrs.v_attribute_id);
end loop;
for v_activity_org_roles in select
role_id as v_role_id
from events_org_role_activity_map eoram
where eoram.activity_id = p_activity_id
LOOP
-- copy over pointers to custom fields (registration attributes)
insert into events_org_role_event_map
(event_id, role_id)
values
(p_event_id, v_activity_org_roles.v_role_id);
end loop;
return p_event_id;
end;' language 'plpgsql';
select define_function_args('events_event__name','event_id');
create function events_event__name(integer)
returns varchar as '
declare
p_event_id alias for $1;
begin
return aa.name from acs_activities aa, acs_events ae where
aa.activity_id = ae.activity_id
and ae.event_id = p_event_id;
end;
' language 'plpgsql';
select define_function_args('events_event__delete','event_id');
create function events_event__delete (integer)
returns integer as '
declare
p_event_id alias for $1;
begin
delete from events_org_role_event_map where event_id = del.event_id;
delete from events_event_attr_map where event_id = del.event_id;
delete from events_events where event_id = del.event_id;
raise NOTICE ''Deleting note...'';
PERFORM acs_object__delete(p_event_id);
return 0;
end;' language 'plpgsql';
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Phillip Greenspun
--
-- GNU GPL v2
--
drop function events_event__delete (integer);
drop function events_event__name(integer);
drop function events_event__new (integer,integer,varchar,integer,timestamp,boolean,boolean,boolean,boolean,integer,varchar,varchar,varchar,varchar,integer);
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was originally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
-- Order Object Type
create function inline_0 ()
returns integer as '
begin
PERFORM acs_object_type__create_type (
''events_order'', -- object_type
''Order'', -- pretty_name
''Orders'', -- pretty_plural
''acs_object'', -- supertype
''events_orders'', -- table_name
''order_id'', -- id_column
null, -- package_name
''f'', -- abstract_p
null, -- type_extensions_table
null -- name_method
);
return 0;
end;' language 'plpgsql';
select inline_0 ();
drop function inline_0 ();
-- Table to hold additional attributes
--
-- THE ORACLE CODE DIDN'T SAY ORDER_ID WAS AN INTEGER???? is this okay???? Does it need to be added???
--
create table events_orders (
order_id integer
constraint events_orders_order_id_fk
references acs_objects
constraint events_orders_order_id_pk
primary key,
-- ec_order_id integer references ec_orders,
-- the person who made the order
user_id integer
constraint events_orders_user_id_fk
references users,
paid_p boolean default null,
payment_method varchar(50),
confirmed_date timestamptz,
price_charged numeric,
-- the date this registration was refunded, if it was refunded
refunded_date timestamptz,
price_refunded numeric
);
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
delete from acs_objects where object_type = 'events_order';
select acs_object_type__drop_type(
'events_order',
't'
);
drop table events_orders;
--
-- The Events Package
--
-- @author Matthew Geddert (geddert@yahoo.com)
-- @version $Id$
--
-- This package was originally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
-- Order Package
select define_function_args('events_order__new','order_id,event_id,user_id,creation_date,creation_user,creation_ip,context_id');
create function events_order__new (integer,integer,integer,timestamp,integer,varchar,integer)
returns integer as '
declare
p_order_id alias for $1; -- default null
p_event_id alias for $2;
p_user_id alias for $3;
p_creation_date alias for $4; -- default now()
p_creation_user alias for $5;
p_creation_ip alias for $6;
p_context_id alias for $7; -- default null
v_order_id integer;
begin
v_order_id := acs_object__new (
p_order_id,
''events_order'',
p_creation_date,
p_creation_user,
p_creation_ip,
coalesce(p_context_id, p_event_id)
);
insert into events_orders
(order_id, user_id)
values
(v_order_id, p_user_id);
return v_order_id;
end;' language 'plpgsql';
-- select define_function_args('events_order__name','order_id');
--
-- create function events_order__name(integer)
-- returns varchar as '
-- declare
-- p_order_id alias for $1;
-- begin
-- return p_order_id as event_order_name;
-- end;
-- ' language 'plpgsql';
--
select define_function_args('events_order__delete','order_id');
create function events_order__delete (integer)
returns integer as '
declare
p_order_id alias for $1;
begin
delete from events_orders
where order_id = p_order_id;
raise NOTICE ''Deleting note...'';
PERFORM acs_object__delete(p_order_id);
return 0;
end;' language 'plpgsql';
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Phillip Greenspun
--
-- GNU GPL v2
--
drop function events_order__new (integer,integer,integer,timestamp,integer,varchar,integer);
-- drop function events_order__name (integer);
drop function events_order__delete (integer);
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was originally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
-- Organizer roles for activities and events
create sequence events_org_roles_seq start 1;
create table events_organizer_roles (
role_id integer
constraint evnts_org_roles_role_id_pk
primary key,
role varchar(200)
constraint evnts_org_roles_role_nn
not null,
responsibilities text,
-- is this a role that we want event registrants to see?
public_role_p boolean default 'f',
package_id integer
constraint evnts_org_roles_pkg_id_fk
references apm_packages
on delete cascade
);
create table events_org_role_activity_map (
role_id integer
constraint evnts_org_role_am_role_id_fk
references events_organizer_roles,
activity_id integer
constraint evnts_org_role_act_id_fk
references events_activities
);
create table events_org_role_event_map (
role_id integer
constraint evnts_org_role_em_role_id_fk
references events_organizer_roles,
event_id integer
constraint evnts_org_role_evnt_id_fk
references events_events
);
create table events_organizers_map (
user_id integer
constraint evnt_org_map_user_id_nn
not null
constraint evnt_org_map_user_id_fk
references users,
role_id integer
constraint evnt_org_map_role_id_nn
not null
constraint evnt_org_map_role_id_fk
references events_organizer_roles,
event_id integer
constraint evnt_org_map_evnt_id_nn
not null
constraint evnt_org_map_evnt_id_fk
references events_events,
constraint events_org_map_pk unique (user_id, role_id, event_id)
);
-- create a view to see event organizer roles and the people in those roles
create view events_organizers
as
select eor.*, eom.user_id, eom.event_id
from events_organizer_roles eor,
events_org_role_event_map eorem left join events_organizers_map eom on (eorem.role_id = eom.role_id)
where eor.role_id = eorem.role_id;
-- this is the old view
--
--create view events_organizers
--as
--select eor.*, eom.user_id, eom.event_id
-- from events_organizer_roles eor,
-- events_organizers_map eom
-- where eor.role_id = eom.role_id;
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Phillip Greenspun
--
-- GNU GPL v2
--
drop view events_organizers;
drop sequence events_org_roles_seq;
drop table events_org_role_event_map;
drop table events_org_role_activity_map;
drop table events_organizer_roles;
drop table events_organizers_map;
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
-- Not implemented yet
--
-- IS THIS HOW TO CREATE A SEQUENCE ?????
--
create sequence events_price_id_sequence;
create table events_prices (
price_id integer primary key,
event_id integer not null references events_events,
-- e.g., "Developer", "Student"
description varchar(100) not null,
-- we also store the price here too in case someone doesn't want
-- to use the ecommerce module but still wants to have prices
price numeric not null,
-- This is for hooking up to ecommerce.
-- Each product is a different price for this event. For example,
-- student price and normal price products for an event.
-- product_id integer references ec_products,
-- prices may be different for early, normal, late, on-site
-- admission,
-- depending on the date
expire_date timestamptz not null,
available_date timestamptz not null
);
create index evnt_price_idx on events_prices(price_id, event_id);
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Phillip Greenspun
--
-- GNU GPL v2
--
--
-- IS THIS HOW TO DROP A SEQUENCE????
--
drop sequence events_price_id_sequence;
drop table events_prices;
This diff is collapsed.
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Phillip Greenspun
--
-- GNU GPL v2
--
delete from acs_objects where object_type = 'events_registration';
select acs_object_type__drop_type(
'events_registration',
't'
);
--drop view events_orders_states;
--drop view events_reg_not_canceled;
--drop view events_reg_canceled;
--drop view events_reg_shipped;
DROP FUNCTION event_ship_date_trigger_proc ();
DROP trigger event_ship_date_trigger on events_registrations;
drop table events_registrations;
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
-- The Registration Package
select define_function_args('events_registration__new','reg_id,event_id,user_id,reg_state,comments,creation_date,creation_user,creation_ip,context_id');
create function events_registration__new (integer,integer,integer,varchar,varchar,timestamp,integer,varchar,integer)
returns integer as '
declare
p_reg_id alias for $1; -- default null
p_event_id alias for $2;
p_user_id alias for $3;
p_reg_state alias for $4;
p_comments alias for $5;
p_creation_date alias for $6; -- default now()
p_creation_user alias for $7;
p_creation_ip alias for $8;
p_context_id alias for $9; -- default null
v_reg_id integer;
begin
v_reg_id := acs_object__new (
null,
''events_registration'',
now(),
p_creation_user,
p_creation_ip,
p_event_id
);
insert into events_registrations
(reg_id, event_id, user_id, reg_state, comments)
values
(v_reg_id, p_event_id, p_user_id, p_reg_state, p_comments);
return v_reg_id;
end;' language 'plpgsql';
-- select define_function_args('events_registration__name','registration_id');
--
-- create function events_registration__name(integer)
-- returns varchar as '
-- declare
-- p_registration_id alias for $1;
-- begin
-- return p_registration_id as events_registration_name;
-- end;
-- ' language 'plpgsql';
select define_function_args('events_registration__delete','reg_id');
create function events_registration__delete (integer)
returns integer as '
declare
p_reg_id alias for $1;
begin
delete from events_registrations
where reg_id = p_reg_id;
raise NOTICE ''Deleting note...'';
PERFORM acs_object__delete(p_reg_id);
return 0;
end;' language 'plpgsql';
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Phillip Greenspun
--
-- GNU GPL v2
--
drop function events_registration__new (integer,integer,integer,varchar,varchar,timestamp,integer,varchar,integer);
-- drop function events_registration__name (integer);
drop function events_registration__delete (integer);
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was originally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
--
-- Venue Object Types
--
create function inline_0 ()
returns integer as '
begin
PERFORM acs_object_type__create_type (
''events_venue'', -- object_type
''Venue'', -- pretty_name
''Venues'', -- pretty_plural
''acs_object'', -- supertype
''events_venues'', -- table_name
''venue_id'', -- id_column
''events_venue'', -- package_name
''f'', -- abstract_p
null, -- type_extensions_table
''events_venue.name'' -- name_method
);
return 0;
end;' language 'plpgsql';
select inline_0 ();
drop function inline_0 ();
create function inline_1 ()
returns integer as '
begin
PERFORM acs_attribute__create_attribute (
''events_venue'', -- object_type
''venue_name'', -- attribute_name
''string'', -- datatype
''Name'', -- pretty_name
''Names'', -- pretty_plural
null, -- table_name
null, -- column_name
null, -- default_value
1, -- min_n_values
1, -- max_n_values
null, -- sort_order
''type_specific'', -- storage
''f'' -- static_p
);
PERFORM acs_attribute__create_attribute (
''events_venue'', -- object_type
''address1'', -- attribute_name
''string'', -- datatype
''Address 1'', -- pretty_name
''Address 1'', -- pretty_plural
null, -- table_name
null, -- column_name
null, -- default_value
1, -- min_n_values
1, -- max_n_values
null, -- sort_order
''type_specific'', -- storage
''f'' -- static_p
);
PERFORM acs_attribute__create_attribute (
''events_venue'', -- object_type
''address2'', -- attribute_name
''string'', -- datatype
''Address 2'', -- pretty_name
''Address 2'', -- pretty_plural
null, -- table_name
null, -- column_name
null, -- default_value
1, -- min_n_values
1, -- max_n_values
null, -- sort_order
''type_specific'', -- storage
''f'' -- static_p
);
PERFORM acs_attribute__create_attribute (
''events_venue'', -- object_type
''city'', -- attribute_name
''string'', -- datatype
''City'', -- pretty_name
''Cities'', -- pretty_plural
null, -- table_name
null, -- column_name
null, -- default_value
1, -- min_n_values
1, -- max_n_values
null, -- sort_order
''type_specific'', -- storage
''f'' -- static_p
);
PERFORM acs_attribute__create_attribute (
''events_venue'', -- object_type
''usps_abbrev'', -- attribute_name
''string'', -- datatype
''USPS Abbreviation'', -- pretty_name
''USPS Abbreviations'', -- pretty_plural
null, -- table_name
null, -- column_name
null, -- default_value
1, -- min_n_values
1, -- max_n_values
null, -- sort_order
''type_specific'', -- storage
''f'' -- static_p
);
PERFORM acs_attribute__create_attribute (
''events_venue'', -- object_type
''postal_code'', -- attribute_name
''string'', -- datatype
''Postal Code'', -- pretty_name
''Postal Codes'', -- pretty_plural
null, -- table_name
null, -- column_name
null, -- default_value
1, -- min_n_values
1, -- max_n_values
null, -- sort_order
''type_specific'', -- storage
''f'' -- static_p
);
PERFORM acs_attribute__create_attribute (
''events_venue'', -- object_type
''iso'', -- attribute_name
''string'', -- datatype
''Country Code'', -- pretty_name
''Country Codes'', -- pretty_plural
null, -- table_name
null, -- column_name
null, -- default_value
1, -- min_n_values
1, -- max_n_values
null, -- sort_order
''type_specific'', -- storage
''f'' -- static_p
);
PERFORM acs_attribute__create_attribute (
''events_venue'', -- object_type
''description'', -- attribute_name
''string'', -- datatype
''Description'', -- pretty_name
''Descriptions'', -- pretty_plural
null, -- table_name
null, -- column_name
null, -- default_value
1, -- min_n_values
1, -- max_n_values
null, -- sort_order
''type_specific'', -- storage
''f'' -- static_p
);
PERFORM acs_attribute__create_attribute (
''events_venue'', -- object_type
''fax_number'', -- attribute_name
''string'', -- datatype
''Fax Number'', -- pretty_name
''Fax Numbers'', -- pretty_plural
null, -- table_name
null, -- column_name
null, -- default_value
1, -- min_n_values
1, -- max_n_values
null, -- sort_order
''type_specific'', -- storage
''f'' -- static_p
);
PERFORM acs_attribute__create_attribute (
''events_venue'', -- object_type
''phone_number'', -- attribute_name
''string'', -- datatype
''Phone Number'', -- pretty_name
''Phone Numbers'', -- pretty_plural
null, -- table_name
null, -- column_name
null, -- default_value
1, -- min_n_values
1, -- max_n_values
null, -- sort_order
''type_specific'', -- storage
''f'' -- static_p
);
PERFORM acs_attribute__create_attribute (
''events_venue'', -- object_type
''email'', -- attribute_name
''string'', -- datatype
''Email Address'', -- pretty_name
''Email Addresses'', -- pretty_plural
null, -- table_name
null, -- column_name
null, -- default_value
1, -- min_n_values
1, -- max_n_values
null, -- sort_order
''type_specific'', -- storage
''f'' -- static_p
);
PERFORM acs_attribute__create_attribute (
''events_venue'', -- object_type
''max_people'', -- attribute_name
''string'', -- datatype
''Maximum Number of People'', -- pretty_name
''Maximum Number of People'', -- pretty_plural
null, -- table_name
null, -- column_name
null, -- default_value
1, -- min_n_values
1, -- max_n_values
null, -- sort_order
''type_specific'', -- storage
''f'' -- static_p
);
return 0;
end;' language 'plpgsql';
select inline_1 ();
drop function inline_1 ();
--
--
-- Should usps_abbrev be - referneces us_states(abbrev)?
--
--
-- where the events occur
create table events_venues (
venue_id integer
constraint events_venues_pk
primary key,
venue_name varchar(200) not null,
address1 varchar(100),
address2 varchar(100),
city varchar(100),
usps_abbrev char(2),
postal_code varchar(20),
iso char(2) default 'US' references countries,
time_zone integer references timezones(tz_id),
-- some contact info for this venue
phone_number varchar(30),
fax_number varchar(30),
email varchar(100),
needs_reserve_p boolean default 'f',
max_people integer,
description varchar(4000),
package_id integer
constraint evnts_venues_pkg_id_fk
references apm_packages
on delete cascade
);
\ No newline at end of file
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
delete from acs_objects where object_type = 'events_venue';
select acs_object_type__drop_type(
'events_venue',
't'
);
drop table events_venues;
\ No newline at end of file
--
-- The Events Package
--
-- @author Brad Duell (bduell@ncacasi.org)
-- @version $Id$
--
-- GNU GPL v2
--
-- allow venue hierarchy
create table events_venues_venues_map (
parent_venue_id integer not null references events_venues(venue_id),
child_venue_id integer not null references events_venues(venue_id),
package_id integer
constraint events_v_v_pkg_id_fk
references apm_packages(package_id)
on delete cascade,
primary key (parent_venue_id, child_venue_id, package_id)
);
-- allow venue connections
create table events_venues_connecting_map (
left_venue_id integer not null references events_venues(venue_id),
right_venue_id integer not null references events_venues(venue_id),
package_id integer
constraint events_v_c_pkg_id_fk
references apm_packages(package_id)
on delete cascade,
primary key (left_venue_id, right_venue_id, package_id)
);
-- use-case mapping between venue connections
create table events_venues_conn_used_map (
event_id integer not null references events_events,
venue_id integer not null references events_venues,
connected_venue_id integer not null references events_venues(venue_id),
package_id integer
constraint events_v_cu_pkg_id_fk
references apm_packages(package_id)
on delete cascade,
primary key (event_id, venue_id, connected_venue_id, package_id)
);
\ No newline at end of file
--
-- The Events Package
--
-- @author Brad Duell (bduell@ncacasi.org)
-- @version $Id$
--
-- GNU GPL v2
--
drop table events_venues_conn_used_map;
drop table events_venues_connecting_map;
drop table events_venues_venues_map;
\ No newline at end of file
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net), Matthew Geddert (geddert@yahoo.com)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--
-- The Venue Package
select define_function_args('events_venue__new','venue_id,package_id,venue_name,address1,address2,city,usps_abbrev,postal_code,time_zone,iso,phone_number,fax_number,email,needs_reserve_p;f,max_people,description');
create function events_venue__new (integer,integer,varchar,varchar,varchar,varchar,varchar,varchar,integer,varchar,varchar,varchar,varchar,boolean,integer,varchar)
returns integer as '
declare
p_venue_id alias for $1; -- default null
p_package_id alias for $2;
p_venue_name alias for $3;
p_address1 alias for $4; -- default null
p_address2 alias for $5; -- default null
p_city alias for $6;
p_usps_abbrev alias for $7; -- default null
p_postal_code alias for $8; -- default null
p_time_zone alias for $9; -- default null
p_iso alias for $10; -- default null
p_phone_number alias for $11; -- default null
p_fax_number alias for $12; -- default null
p_email alias for $13; -- default null
p_needs_reserve_p alias for $14; -- default ''f''
p_max_people alias for $15; -- default null
p_description alias for $16; -- default null
begin
insert into events_venues
(venue_id, venue_name, address1, address2, city, phone_number, fax_number, email, needs_reserve_p, max_people, description, usps_abbrev, postal_code, time_zone, iso, package_id)
values
(p_venue_id, p_venue_name, p_address1, p_address2, p_city, p_phone_number, p_fax_number, p_email, p_needs_reserve_p, p_max_people, p_description, p_usps_abbrev, p_postal_code, p_time_zone, p_iso, p_package_id);
return p_venue_id;
end;' language 'plpgsql';
select define_function_args('events_venue__name','venue_id');
create function events_venue__name(integer)
returns varchar as '
declare
p_venue_id alias for $1;
begin
return venue_name from events_venues where venue_id = p_venue_id;
end;
' language 'plpgsql';
select define_function_args('events_venue__delete','venue_id');
create function events_venue__delete (integer)
returns integer as '
declare
p_venue_id alias for $1;
begin
delete from events_venues where venue_id = p_venue_id;
raise NOTICE ''Deleting events_venue...'';
PERFORM acs_object__delete(p_venue_id);
return 0;
end;' language 'plpgsql';
--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id$
--
-- This package was orinally written by Bryan Che and Phillip Greenspun
--
-- GNU GPL v2
--
drop function events_venue__new (integer,integer,varchar,varchar,varchar,varchar,varchar,varchar,integer,varchar,varchar,varchar,varchar,boolean,integer,varchar);
drop function events_venue__name (integer);
drop function events_venue__delete (integer);
<?xml version="1.0"?>
<queryset>
<fullquery name="events::activity::get.select_activity_info">
<querytext>
select a.name, a.description, ae.available_p, ae.detail_url,
ae.default_contact_user_id, u.email as default_contact_email,
u.first_names || ' ' || u.last_name as default_contact_name
from acs_activities a, events_activities ae, cc_users u
where a.activity_id = :activity_id
and a.activity_id = ae.activity_id
and ae.default_contact_user_id = u.user_id(+)
</querytext>
</fullquery>
<fullquery name="events::activity::delete.delete_activity">
<querytext>
declare begin
events_activity.del(:activity_id);
end;
</querytext>
</fullquery>
</queryset>
<?xml version="1.0"?>
<queryset>
<fullquery name="events::activity::get.select_activity_info">
<querytext>
select a.name, a.description, ae.available_p, ae.detail_url,
ae.default_contact_user_id, u.email as default_contact_email,
u.first_names || ' ' || u.last_name as default_contact_name
from acs_activities a, events_activities ae left join cc_users u on (ae.default_contact_user_id = u.user_id)
where a.activity_id = :activity_id
and a.activity_id = ae.activity_id
</querytext>
</fullquery>
<fullquery name="events::activity::delete.delete_activity">
<querytext>
select
events_activity__del(:activity_id);
</querytext>
</fullquery>
</queryset>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment