@ -1,4 +1,5 @@
<?php
<?php
use Drupal\field\Entity\FieldConfig;
/**
/**
* @file
* @file
* Classes and general Room Reservations helper functions.
* Classes and general Room Reservations helper functions.
@ -21,13 +22,13 @@ function reserve_categories($ebundle = null) {
$entity_type = ebundle_split($ebundle, 'type');
$entity_type = ebundle_split($ebundle, 'type');
$bundle = ebundle_split($ebundle, 'bundle');
$bundle = ebundle_split($ebundle, 'bundle');
$field = reserve_category_fields($ebundle);
$field = reserve_category_fields($ebundle);
$fconfig = \Drupal\field\Entity\ FieldConfig::loadByName($entity_type, $bundle, $field)->getSettings();
$fconfig = FieldConfig::loadByName($entity_type, $bundle, $field)->getSettings();
$ids = array_filter($fconfig['categories']);
$ids = array_filter($fconfig['categories']);
}
}
else {
else {
$query = \Drupal::service('entity_type.manager')
$query = \Drupal::service('entity_type.manager')
->getStorage('reserve_category')->getQuery();
->getStorage('reserve_category')->getQuery();
$ids = $query->condition('status', TRUE)->execute();
$ids = $query->condition('status', TRUE)->accessCheck(FALSE)-> execute();
}
}
$cats = \Drupal::entityTypeManager()->getStorage('reserve_category')->loadMultiple($ids);
$cats = \Drupal::entityTypeManager()->getStorage('reserve_category')->loadMultiple($ids);
@ -66,7 +67,7 @@ function reserve_entities($ebundle) {
}
}
//->sort('reservations_display_order', 'ASC')
//->sort('reservations_display_order', 'ASC')
$ids = $query->execute();
$ids = $query->accessCheck(FALSE)-> execute();
$entities = \Drupal::entityTypeManager()->getStorage($entity_type)->loadMultiple($ids);
$entities = \Drupal::entityTypeManager()->getStorage($entity_type)->loadMultiple($ids);
@ -696,7 +697,7 @@ function reserve_start_conflicts($room, $yyyy_mmdd, $time) {
)
)
";
";
$conflicts_found = FALSE;
$conflicts_found = FALSE;
$conflicts_found = db_ query($sql, array(
$conflicts_found = \Drupal::database()-> query($sql, array(
':room' => $room,
':room' => $room,
':date0' => $search_items[0]['date'], ':time0' => $search_items[0]['start_time'], ':length0' => $search_items[0]['length'],
':date0' => $search_items[0]['date'], ':time0' => $search_items[0]['start_time'], ':length0' => $search_items[0]['length'],
':date1' => $search_items[1]['date'], ':time1' => $search_items[1]['start_time'], ':length1' => $search_items[1]['length'],
':date1' => $search_items[1]['date'], ':time1' => $search_items[1]['start_time'], ':length1' => $search_items[1]['length'],
@ -705,8 +706,7 @@ function reserve_start_conflicts($room, $yyyy_mmdd, $time) {
':date4' => $search_items[4]['date'], ':time4' => $search_items[4]['start_time'], ':length4' => $search_items[4]['length'],
':date4' => $search_items[4]['date'], ':time4' => $search_items[4]['start_time'], ':length4' => $search_items[4]['length'],
':date5' => $search_items[5]['date'], ':time5' => $search_items[5]['start_time'], ':length5' => $search_items[5]['length'],
':date5' => $search_items[5]['date'], ':time5' => $search_items[5]['start_time'], ':length5' => $search_items[5]['length'],
':date6' => $search_items[6]['date'], ':time6' => $search_items[6]['start_time'], ':length6' => $search_items[6]['length'],
':date6' => $search_items[6]['date'], ':time6' => $search_items[6]['start_time'], ':length6' => $search_items[6]['length'],
':date7' => $search_items[7]['date'], ':time7' => $search_items[7]['start_time'], ':length7' => $search_items[7]['length'])
':date7' => $search_items[7]['date'], ':time7' => $search_items[7]['start_time'], ':length7' => $search_items[7]['length']))->rowCount();
)->rowCount();
return $conflicts_found;
return $conflicts_found;
}
}
@ -933,6 +933,7 @@ function reserve_daily_max_exceeded($yyyy_mmdd) {
if ($user->id()) {
if ($user->id()) {
$ids = \Drupal::service('entity_type.manager')
$ids = \Drupal::service('entity_type.manager')
->getStorage('reserve_reservation')->getQuery()
->getStorage('reserve_reservation')->getQuery()
->accessCheck(FALSE)
->condition('user_id', $user->id())
->condition('user_id', $user->id())
->condition('reservation_date', $yyyy_mmdd . '%', 'like')
->condition('reservation_date', $yyyy_mmdd . '%', 'like')
->execute();
->execute();
@ -966,6 +967,7 @@ function reserve_user_reservations() {
$latest_date = date('Y-m-d', strtotime("now +13 days"));
$latest_date = date('Y-m-d', strtotime("now +13 days"));
$ids = \Drupal::service('entity_type.manager')
$ids = \Drupal::service('entity_type.manager')
->getStorage('reserve_reservation')->getQuery()
->getStorage('reserve_reservation')->getQuery()
->accessCheck(TRUE)
->condition('user_id', $user->id())
->condition('user_id', $user->id())
->condition('reservation_date', $earliest_date, '>=')
->condition('reservation_date', $earliest_date, '>=')
->condition('reservation_date', $latest_date, '< =')
->condition('reservation_date', $latest_date, '< =')