/** * This method inserts a booking recurrence by inserting a set of data. * * * @global type $ilDB * * @param array $a_booking_values * Array with the values of the booking * @param array $a_booking_attr_values * Array with the values of the booking-attributes * * @return integer 1 = successful, -1 not successful */ public function insertBookingRecurrence($a_booking_attr_values, $a_booking_values, $a_booking_participants) { global $ilUser; $count_booking_values_from = count($a_booking_values['from']); //Are there more than one startdays? Then its a sequence booking, so generate a new id if ($count_booking_values_from > 1) { $next_seq_id = $this->ilDB->nextID(dbc::BOOKING_SEQUENCES_TABLE); } else { $next_seq_id = NULL; } $query = "INSERT INTO " . dbc::BOOKINGS_TABLE . " (id, date_from, date_to, seq_id, room_id, pool_id, user_id, subject, public_booking, bookingcomment) VALUES "; // create SQL query $newBookIds = array(); for ($i = 0; $i < $count_booking_values_from; $i++) { $book_id = $this->ilDB->nextID(dbc::BOOKINGS_TABLE); $newBookIds[] = $book_id; $query .= "(" . $this->ilDB->quote($book_id, 'integer') . ", " . $this->ilDB->quote($a_booking_values['from'][$i], 'timestamp') . ", " . $this->ilDB->quote($a_booking_values['to'][$i], 'timestamp') . ", " . $this->ilDB->quote($next_seq_id, 'integer') . ", " . $this->ilDB->quote($a_booking_values['room'], 'integer') . ", " . $this->ilDB->quote($this->pool_id, 'integer') . ", " . $this->ilDB->quote($ilUser->getId(), 'integer') . ", " . $this->ilDB->quote($a_booking_values['subject'], 'text') . ", " . $this->ilDB->quote($a_booking_values['book_public'] == '1', 'boolean') . ", " . $this->ilDB->quote($a_booking_values['comment'], 'text') . "), "; } $q = substr($query, 0, -2); // delete last comma and blank $this->ilDB->manipulate($q); // SQL $insertedId = $this->ilDB->getLastInsertId(); if ($insertedId == -1) { return -1; } /** * add bookingAttributes, bookingParticipants, bookingAppointments * for each booking entry */ for ($i = 0; $i < $count_booking_values_from; $i++) { $this->ilRoomSharingDatabase->insertBookingAttributes($newBookIds[$i], $a_booking_attr_values); $this->ilRoomSharingDatabase->insertBookingParticipants($newBookIds[$i], $a_booking_participants); $this->ilRoomSharingDatabase->insertBookingAppointment($newBookIds[$i], $a_booking_values, $a_booking_values['from'][$i], $a_booking_values['to'][$i]); } return 1; }