You are here

function availability_calendars_update_node_notes in Availability Calendars 6.2

Same name and namespace in other branches
  1. 7.2 availability_calendars.inc \availability_calendars_update_node_notes()

Updates the calendar notes for the given node in the given month.

Parameters

int $nid:

int $year:

int $month:

array $notes the (possibly empty) notes keyed by week number:

1 call to availability_calendars_update_node_notes()
availability_calendars_node_edit_calendar_month_form_submit in ./availability_calendars.node.inc
Callback function for submitting a node edit form.

File

./availability_calendars.inc, line 165
General helper methods for Availability Calendars, like database access and settings.

Code

function availability_calendars_update_node_notes($nid, $year, $month, $notes) {
  db_query('DELETE FROM {availability_calendars_week} WHERE nid = %d AND year = %d AND month = %d', $nid, $year, $month);
  foreach ($notes as $week => $note) {
    if (!empty($note)) {
      db_query("INSERT INTO {availability_calendars_week} (nid, year, month, week, note) VALUES (%d, %d, %d, %d, '%s')", $nid, $year, $month, $week, $note);
    }
  }
}