You are here

function opening_hours_repeat_stop_propagation in Opening hours 7

Same name and namespace in other branches
  1. 6 opening_hours.module \opening_hours_repeat_stop_propagation()

Prevent additional propagation of instance.

Sets the repeat end date of an instance to the date of the latest existing instance to prevent additional propagation.

2 calls to opening_hours_repeat_stop_propagation()
_opening_hours_instance_delete in includes/opening_hours.pages.inc
Helper function to delete an existing instance.
_opening_hours_instance_update in includes/opening_hours.pages.inc
Helper function to update an existing instance.

File

./opening_hours.module, line 470
Opening hours module.

Code

function opening_hours_repeat_stop_propagation($instance_id) {

  // Get the date of the last non-deleted instance.
  $max_date = db_query('
    SELECT MAX(date) FROM {opening_hours} WHERE original_instance_id = :id
  ', array(
    ':id' => $instance_id,
  ))
    ->fetchField();
  db_query("\n    UPDATE {opening_hours}\n    SET repeat_end_date = :date\n    WHERE instance_id = :id\n  ", array(
    ':date' => $max_date,
    ':id' => $instance_id,
  ));
}