Index: openacs-4/packages/calendar/calendar.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/calendar.info,v diff -u -r1.9 -r1.10 --- openacs-4/packages/calendar/calendar.info 27 Feb 2002 03:59:24 -0000 1.9 +++ openacs-4/packages/calendar/calendar.info 16 Mar 2002 21:06:44 -0000 1.10 @@ -41,12 +41,15 @@ + + + @@ -59,6 +62,8 @@ + + @@ -81,6 +86,9 @@ + + + Index: openacs-4/packages/calendar/sql/oracle/cal-item-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/sql/oracle/cal-item-create.sql,v diff -u -r1.5 -r1.6 --- openacs-4/packages/calendar/sql/oracle/cal-item-create.sql 12 Mar 2002 05:26:16 -0000 1.5 +++ openacs-4/packages/calendar/sql/oracle/cal-item-create.sql 16 Mar 2002 21:06:44 -0000 1.6 @@ -57,6 +57,10 @@ constraint cal_item_which_cal_fk references calendars on delete cascade + item_type_id integer, + constraint cal_items_type_fk + foreign key (on_which_calendar, item_type_id) + references cal_item_types(calendar_id, item_type_id) ); comment on table cal_items is ' @@ -92,6 +96,7 @@ timespan_id in acs_events.timespan_id%TYPE default null, activity_id in acs_events.activity_id%TYPE default null, recurrence_id in acs_events.recurrence_id%TYPE default null, + item_type_id in cal_items.item_type_id%TYPE default null, object_type in acs_objects.object_type%TYPE default 'cal_item', context_id in acs_objects.context_id%TYPE default null, creation_date in acs_objects.creation_date%TYPE default sysdate, @@ -132,6 +137,7 @@ timespan_id in acs_events.timespan_id%TYPE default null, activity_id in acs_events.activity_id%TYPE default null, recurrence_id in acs_events.recurrence_id%TYPE default null, + item_type_id in cal_items.item_type_id%TYPE default null, object_type in acs_objects.object_type%TYPE default 'cal_item', context_id in acs_objects.context_id%TYPE default null, creation_date in acs_objects.creation_date%TYPE default sysdate, @@ -162,8 +168,8 @@ ); insert into cal_items - (cal_item_id, on_which_calendar) - values (v_cal_item_id, on_which_calendar); + (cal_item_id, on_which_calendar, item_type_id) + values (v_cal_item_id, on_which_calendar, item_type_id); -- assign the default permission to the cal_item -- by default, cal_item are going to inherit the Index: openacs-4/packages/calendar/sql/oracle/calendar-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/sql/oracle/calendar-create.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/calendar/sql/oracle/calendar-create.sql 19 Jan 2002 23:45:46 -0000 1.2 +++ openacs-4/packages/calendar/sql/oracle/calendar-create.sql 16 Mar 2002 21:06:44 -0000 1.3 @@ -221,6 +221,27 @@ '; +---------------------------- +-- Event Types for Calendars +---------------------------- + +create sequence cal_item_type_seq; + +create table cal_item_types ( + item_type_id integer not null + constraint cal_item_type_id_pk + primary key, + calendar_id integer not null + constraint cal_item_type_cal_id_fk + references calendars(calendar_id), + type varchar(100) not null, + -- this constraint is obvious given that item_type_id + -- is unique, but it's necessary to allow strong + -- references to the pair calendar_id, item_type_id (ben) + constraint cal_item_types_un + unique (calendar_id, item_type_id) +); + ------------------------------------------------------------- -- Load cal_item_object ------------------------------------------------------------- Index: openacs-4/packages/calendar/tcl/cal-item-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/tcl/cal-item-procs.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/calendar/tcl/cal-item-procs.tcl 11 Mar 2002 16:42:07 -0000 1.4 +++ openacs-4/packages/calendar/tcl/cal-item-procs.tcl 16 Mar 2002 21:06:44 -0000 1.5 @@ -86,6 +86,7 @@ on_which_calendar creation_ip creation_user +{item_type_id ""} } { create a new cal_item @@ -132,14 +133,14 @@ on_which_calendar => :on_which_calendar, activity_id => :activity_id, timespan_id => :timespan_id, + item_type_id => :item_type_id, creation_user => :creation_user, creation_ip => :creation_ip ); end; } ] - # getting the permissions out # all this is because cal-item is not a child # of the calendar. @@ -157,13 +158,20 @@ # the stuff in pl/sql layer didn't work # NOTE: need to fold the following back in into pl/sql. - db_foreach get_permissions_to_items { + # Fix by Ben to prevent possible deadlock + # FIXME: this should all be moved into on PL/SQL statement (ben) + + set permissions_to_add [db_list_of_lists get_permissions_to_items { select grantee_id, privilege from acs_permissions where object_id = :on_which_calendar - } { + }] + foreach perm $permissions_to_add { + set grantee_id [lindex $perm 0] + set privilege [lindex $perm 1] + # setting the permission db_exec_plsql 4_grant_calendar_permissions_to_items { @@ -203,6 +211,7 @@ end_date name description +{item_type_id ""} } { updating a new cal_item @@ -221,17 +230,23 @@ db_1row get_interval_id "" - # call edit procedure - db_exec_plsql update_interval " + db_transaction { + # call edit procedure + db_exec_plsql update_interval " begin - time_interval.edit ( - interval_id => :interval_id, - start_date => to_date(:start_date,:date_format), - end_date => to_date(:end_date,:date_format) - ); + time_interval.edit ( + interval_id => :interval_id, + start_date => to_date(:start_date,:date_format), + end_date => to_date(:end_date,:date_format) + ); end; - " + " + # Update the item_type_id + db_dml update_item_type_id "update cal_items + set item_type_id= :item_type_id + where cal_item_id= :cal_item_id" + } } Index: openacs-4/packages/calendar/tcl/calendar-display-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/tcl/Attic/calendar-display-procs-oracle.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/calendar/tcl/calendar-display-procs-oracle.xql 14 Mar 2002 04:58:29 -0000 1.3 +++ openacs-4/packages/calendar/tcl/calendar-display-procs-oracle.xql 16 Mar 2002 21:06:44 -0000 1.4 @@ -49,14 +49,17 @@ to_char(start_date,'HH24:MI') as start_date, to_char(end_date,'HH24:MI') as end_date, nvl(e.name, a.name) as name, - e.event_id as item_id + e.event_id as item_id, + (select type from cal_item_types where item_type_id= cal_items.item_type_id) as item_type from acs_activities a, acs_events e, timespans s, - time_intervals t + time_intervals t, + cal_items where e.timespan_id = s.timespan_id and s.interval_id = t.interval_id and e.activity_id = a.activity_id +and e.event_id = cal_items.cal_item_id and start_date between to_date(:sunday_of_the_week,'YYYY-MM-DD') and to_date(:saturday_of_the_week,'YYYY-MM-DD') @@ -77,17 +80,20 @@ to_char(start_date, 'HH24:MI') as start_date, to_char(end_date, 'HH24:MI') as end_date, nvl(e.name, a.name) as name, - e.event_id as item_id + e.event_id as item_id, + (select type from cal_item_types where item_type_id= cal_items.item_type_id) as item_type from acs_activities a, acs_events e, timespans s, - time_intervals t + time_intervals t, + cal_items where e.timespan_id = s.timespan_id and s.interval_id = t.interval_id and e.activity_id = a.activity_id and start_date between to_date(:current_date,:date_format) and to_date(:current_date,:date_format) + (24 - 1/3600)/24 +and cal_items.cal_item_id= e.event_id and e.event_id in ( select cal_item_id Index: openacs-4/packages/calendar/tcl/calendar-display-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/tcl/Attic/calendar-display-procs.tcl,v diff -u -r1.8 -r1.9 --- openacs-4/packages/calendar/tcl/calendar-display-procs.tcl 14 Mar 2002 04:58:29 -0000 1.8 +++ openacs-4/packages/calendar/tcl/calendar-display-procs.tcl 16 Mar 2002 21:06:44 -0000 1.9 @@ -147,12 +147,18 @@ # ns_log Notice "bma: one calendar $calendar_name" db_foreach select_day_items {} { + if {[empty_string_p $item_type]} { + set item_details "$calendar_name" + } else { + set item_details "$calendar_name - $item_type" + } + if {$pretty_start_date == "00:00 AM" && $pretty_end_date == "00:00 AM"} { # Hack for no-time items - set item "$name ($calendar_name)" + set item "$name ($item_details)" set ns_set_pos "X" } else { - set item "$pretty_start_date - $pretty_end_date: $name ($calendar_name)" + set item "$pretty_start_date - $pretty_end_date: $name ($item_details)" set ns_set_pos $start_hour } Index: openacs-4/packages/calendar/www/cal-item-create.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/Attic/cal-item-create.tcl,v diff -u -r1.10 -r1.11 --- openacs-4/packages/calendar/www/cal-item-create.tcl 14 Mar 2002 04:58:29 -0000 1.10 +++ openacs-4/packages/calendar/www/cal-item-create.tcl 16 Mar 2002 21:06:44 -0000 1.11 @@ -20,6 +20,7 @@ {calendar_id "-1"} {return_url ""} {recurrence_p 0} + {item_type_id ""} } if { $date == "now" } { @@ -85,7 +86,7 @@ # no private calendar detected. # we need to create the private calendar - set calender_id [calendar_create_private $user_id ] + set calendar_id [calendar_create_private $user_id ] } set calendar_id [calendar_have_private_p -return_id 1 $user_id] @@ -108,14 +109,17 @@ } -# create new cal_item -set cal_item_id [cal_item_create $start_datetime \ +db_transaction { + # create new cal_item + set cal_item_id [cal_item_create $start_datetime \ $end_datetime \ $name \ $description \ $calendar_id \ $creation_ip \ - $creation_user] + $creation_user \ + $item_type_id] +} if {$recurrence_p} { # We must ask for recurrence information Index: openacs-4/packages/calendar/www/cal-item-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/Attic/cal-item-edit.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/calendar/www/cal-item-edit.tcl 11 Mar 2002 16:42:07 -0000 1.5 +++ openacs-4/packages/calendar/www/cal-item-edit.tcl 16 Mar 2002 21:06:44 -0000 1.6 @@ -18,6 +18,7 @@ {name ""} {description ""} {return_url ""} + {item_type_id ""} } # find out the user_id @@ -67,7 +68,7 @@ $end_datetime \ $name \ $description \ - ] + $item_type_id] # set the proper rediret value to view and date set action "view" Index: openacs-4/packages/calendar/www/cal-item-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/Attic/cal-item-oracle.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/calendar/www/cal-item-oracle.xql 11 Mar 2002 16:42:07 -0000 1.3 +++ openacs-4/packages/calendar/www/cal-item-oracle.xql 16 Mar 2002 21:06:44 -0000 1.4 @@ -11,16 +11,19 @@ to_char(end_date, 'HH24:MI') as end_time, nvl(a. name, e.name) as name, nvl(e.description, a.description) as description, - recurrence_id + recurrence_id, + item_type_id, + on_which_calendar as calendar_id from acs_activities a, acs_events e, timespans s, - time_intervals t + time_intervals t, + cal_items where e.timespan_id = s.timespan_id and s.interval_id = t.interval_id and e.activity_id = a.activity_id and e.event_id = :cal_item_id - + and cal_items.cal_item_id = :cal_item_id Index: openacs-4/packages/calendar/www/cal-item.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/Attic/cal-item.adp,v diff -u -r1.9 -r1.10 --- openacs-4/packages/calendar/www/cal-item.adp 11 Mar 2002 16:42:07 -0000 1.9 +++ openacs-4/packages/calendar/www/cal-item.adp 16 Mar 2002 21:06:44 -0000 1.10 @@ -78,6 +78,32 @@ + + + + Item Type + + + + + + Index: openacs-4/packages/calendar/www/cal-item.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/Attic/cal-item.tcl,v diff -u -r1.8 -r1.9 --- openacs-4/packages/calendar/www/cal-item.tcl 13 Mar 2002 22:50:53 -0000 1.8 +++ openacs-4/packages/calendar/www/cal-item.tcl 16 Mar 2002 21:06:44 -0000 1.9 @@ -75,6 +75,8 @@ # admin permission set admin_p [ad_permission_p $cal_item_id calendar_admin] +set item_type_id "" + #------------------------------------------------ # only worry about the query when it is an edit if { $action == "edit" } { @@ -93,19 +95,24 @@ to_char(end_date, 'HH24:MI') as end_time, nvl(a. name, e.name) as name, nvl(e.description, a.description) as description, - recurrence_id + recurrence_id, + item_type_id, + on_which_calendar as calendar_id from acs_activities a, acs_events e, timespans s, - time_intervals t + time_intervals t, + cal_items where e.timespan_id = s.timespan_id and s.interval_id = t.interval_id and e.activity_id = a.activity_id and e.event_id = :cal_item_id + and cal_items.cal_item_id= :cal_item_id } - - + set force_calendar_id $calendar_id + + set cal_item_types [calendar::get_item_types -calendar_id $force_calendar_id] # forced error checking set name [ad_quotehtml $name] set description [ad_quotehtml $description] @@ -127,6 +134,8 @@ if {![empty_string_p $force_calendar_id]} { set force_calendar_name [calendar_get_name $force_calendar_id] + + set cal_item_types [calendar::get_item_types -calendar_id $force_calendar_id] } } Index: openacs-4/packages/calendar/www/admin/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/admin/index.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/calendar/www/admin/index.tcl 23 Apr 2001 23:09:38 -0000 1.1 +++ openacs-4/packages/calendar/www/admin/index.tcl 16 Mar 2002 21:06:44 -0000 1.2 @@ -3,6 +3,8 @@ ad_page_contract { Main Calendar Admin Page. + ## HACKED BY BEN FOR SLOAN ## + ## FEATURES TEMPORARILY TAKEN OUT ## This pages checks to see if the user has any group calendar that he or she is the admin of. @@ -15,17 +17,14 @@ } -properties { context_bar:onevalue - user_id:onevalue - data:onevalue - calendars:multirow } # find out the user_id set user_id [ad_verify_and_get_user_id] set package_id [ad_conn package_id] -set context_bar "calendar admin" +set context_bar "Admin" db_multirow calendars calendar_list {