calendar::item::edit (public)

 calendar::item::edit -cal_item_id cal_item_id -start_date start_date \
    -end_date end_date -name name -description description \
    [ -item_type_id item_type_id ] [ -edit_all_p edit_all_p ] \
    [ -edit_past_events_p edit_past_events_p ] \
    [ -calendar_id calendar_id ] [ -location location ] \
    [ -related_link_url related_link_url ] \
    [ -related_link_text related_link_text ] \
    [ -redirect_to_rel_link_p redirect_to_rel_link_p ] \
    [ -cal_uid cal_uid ] [ -ical_vars ical_vars ]

Defined in packages/calendar/tcl/cal-item-procs.tcl

Edit the item

Switches:
-cal_item_id
(required)
-start_date
(required)
-end_date
(required)
-name
(required)
-description
(required)
-item_type_id
(optional)
-edit_all_p
(defaults to "0") (optional)
-edit_past_events_p
(defaults to "1") (optional)
-calendar_id
(optional)
-location
(optional)
-related_link_url
(optional)
-related_link_text
(optional)
-redirect_to_rel_link_p
(optional)
-cal_uid
(optional)
-ical_vars
(optional)

Partial Call Graph (max 5 caller/called nodes):
%3 test_cal_item_edit_recurrence cal_item_edit_recurrence (test calendar) calendar::item::edit calendar::item::edit test_cal_item_edit_recurrence->calendar::item::edit _ _ (public) calendar::item::edit->_ ad_return_complaint ad_return_complaint (public) calendar::item::edit->ad_return_complaint ad_script_abort ad_script_abort (public) calendar::item::edit->ad_script_abort calendar::do_notifications calendar::do_notifications (public) calendar::item::edit->calendar::do_notifications calendar::item::dates_valid_p calendar::item::dates_valid_p (private) calendar::item::edit->calendar::item::dates_valid_p packages/calendar/www/cal-item-new.tcl packages/calendar/ www/cal-item-new.tcl packages/calendar/www/cal-item-new.tcl->calendar::item::edit

Testcases:
cal_item_edit_recurrence
Source code:
    if {[dates_valid_p -start_date $start_date -end_date $end_date]} {
        if {$edit_all_p} {
            set recurrence_id [db_string select_recurrence_id {}]
            #
            # If the recurrence id is empty (coming from NULL value),
            # then we stop here and just do the normal update
            #
            if {$recurrence_id ne ""} {
                #ns_log notice "recurrence_id $recurrence_id"
                calendar::item::edit_recurrence  -event_id $cal_item_id  -start_date $start_date  -end_date $end_date  -name $name  -description $description  -item_type_id $item_type_id  -calendar_id $calendar_id  -edit_past_events_p $edit_past_events_p

                return
            }
        }

        # Convert from user timezone to system timezone
        if { $start_date ne $end_date } {

            # Convert to server timezone only if it's not an all-day event
            # otherwise, keep the start and end time as 00:00

            set start_date [lc_time_conn_to_system $start_date]
            set end_date   [lc_time_conn_to_system $end_date]
        }

        db_dml update_event {}

        # update the time interval based on the timespan id

        db_1row get_interval_id {}

        db_transaction {
            #
            # If a cal_uid is given, update the attributes in the
            # cal_uid mapping table
            #
            if {$cal_uid ne ""} {
                #
                # We have to determine the activity id for the upsert
                # operation in cal_uids.
                #
                set activity_id [db_string select_activity_id {
                    select activity_id from acs_events where event_id = :cal_item_id
                }]
                #ns_log notice "======= cal_uid_upsert with activity_id $activity_id"
                db_exec_plsql cal_uid_upsert {}
            }

            # call edit procedure
            db_exec_plsql update_interval {}

            # Update the item_type_id and calendar_id
            set colspecs [list]
            lappend colspecs "item_type_id = :item_type_id"
            if { $calendar_id ne "" } {
                lappend colspecs "on_which_calendar = :calendar_id"

                db_dml update_context_id {
                    update acs_objects
                    set    context_id = :calendar_id
                    where  object_id = :cal_item_id
                }
            }

            db_dml update_item_type_id [subst {
                update cal_items
                set    [join $colspecs ", "]
                where  cal_item_id= :cal_item_id
            }]

            calendar::do_notifications -mode Edited -cal_item_id $cal_item_id

            callback calendar::item::after_edit -cal_item_id $cal_item_id
        }
    } else {
        ad_return_complaint 1 [_ calendar.start_time_before_end_time]
        ad_script_abort
    }
Generic XQL file:
<fullquery name="calendar::item::edit.select_recurrence_id">
    <querytext>
select recurrence_id from acs_events where event_id= :cal_item_id
</querytext>
</fullquery>

<fullquery name="calendar::item::edit.update_activity">
    <querytext>
    update acs_activities 
    set    name = :name,
           description = :description
    where  activity_id
    in     (
           select activity_id
           from   acs_events
           where  event_id = :cal_item_id
           )
    </querytext>
</fullquery>

<fullquery name="calendar::item::edit.update_event">
    <querytext>
    update acs_events
    set    name = :name,
           description = :description,
           location = :location,
	   related_link_url = :related_link_url,
	   related_link_text = :related_link_text,
	   redirect_to_rel_link_p = :redirect_to_rel_link_p
    where  event_id = :cal_item_id
    </querytext>
</fullquery>

<fullquery name="calendar::item::edit.get_interval_id">
    <querytext>
    select interval_id 
    from   timespans
    where  timespan_id
    in     (
           select timespan_id
           from   acs_events
           where  event_id = :cal_item_id
           )
    </querytext>
</fullquery>
packages/calendar/tcl/cal-item-procs.xql

PostgreSQL XQL file:
<fullquery name="calendar::item::edit.update_interval">
    <querytext>
	select time_interval__edit (
					:interval_id,
					:start_date::timestamptz,
					:end_date::timestamptz
	)

      </querytext>
</fullquery>

<fullquery name="calendar::item::edit.cal_uid_upsert">
    <querytext>
    select cal_uid__upsert(:cal_uid, :activity_id, :ical_vars) from dual
  </querytext>
</fullquery>
packages/calendar/tcl/cal-item-procs-postgresql.xql

Oracle XQL file:
<fullquery name="calendar::item::edit.update_interval">
    <querytext>
      
	begin
	  time_interval.edit (
	    interval_id  => :interval_id,
	    start_date   => to_date(:start_date,'YYYY-MM-DD HH24:MI'),
	    end_date     => to_date(:end_date,'YYYY-MM-DD HH24:MI')
	  );
	end;
    
      </querytext>
</fullquery>

<fullquery name="calendar::item::edit.cal_uid_upsert">
    <querytext>

    begin
         cal_uid.upsert(:cal_uid, :activity_id, :ical_vars);
    end;
  </querytext>
</fullquery>
packages/calendar/tcl/cal-item-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: