Browse Source

fixed issues reported by upgrade status module

d10-dev
Paul Pound 2 years ago
parent
commit
f949837ee1
  1. 6
      reserve.inc
  2. 18
      reserve.series.inc

6
reserve.inc

@ -28,7 +28,7 @@ function reserve_categories($ebundle = null) {
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);
@ -67,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);
@ -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, '<=')

18
reserve.series.inc

@ -1,4 +1,4 @@
<?php <?php
/** /**
* Reservation CRUD for supporting Series * Reservation CRUD for supporting Series
@ -39,7 +39,7 @@ function reserve_reserve_reservation_insert($entity) {
$ebundle = $rtype . '.' . \Drupal::entityTypeManager() $ebundle = $rtype . '.' . \Drupal::entityTypeManager()
->getStorage($rtype)->load($rid)->bundle(); ->getStorage($rtype)->load($rid)->bundle();
$day = date('l', strtotime($start)); $day = date('l', strtotime($start));
$msg = ''; $msg = '';
switch ($repeat_type) { switch ($repeat_type) {
// every day until.... // every day until....
@ -48,7 +48,7 @@ function reserve_reserve_reservation_insert($entity) {
$back = '-1 day'; $back = '-1 day';
$msg = t('You have booked every day from %start until %end', array('%start' => $start_yyyy_mm_dd, '%end' => $end)); $msg = t('You have booked every day from %start until %end', array('%start' => $start_yyyy_mm_dd, '%end' => $end));
break; break;
// this day of the week until.. // this day of the week until..
case 2: case 2:
$skip = '+7 day'; $skip = '+7 day';
@ -70,7 +70,7 @@ function reserve_reserve_reservation_insert($entity) {
$failed = array(); $failed = array();
while (strtotime($date) <= strtotime($back, strtotime($end))) { while (strtotime($date) <= strtotime($back, strtotime($end))) {
$date = date('Y-m-d', strtotime($skip, strtotime($date))); $date = date('Y-m-d', strtotime($skip, strtotime($date)));
// must check to see if next booking is available // must check to see if next booking is available
// the first one we don't check as we could not have picked it if it wasn't // the first one we don't check as we could not have picked it if it wasn't
if (reserve_is_slot_free($rid, $ebundle, $date, $time, $length)) { if (reserve_is_slot_free($rid, $ebundle, $date, $time, $length)) {
@ -111,12 +111,12 @@ function reserve_reserve_reservation_update($entity) {
} }
$sid = $entity->reservation_series_id->getString(); $sid = $entity->reservation_series_id->getString();
// if not part of a Series or special single only url -> do nothing // if not part of a Series or special single only url -> do nothing
if (!$sid || isset($_GET['single'])) { if (!$sid || isset($_GET['single'])) {
return; return;
} }
// reservation details // reservation details
$start = $entity->reservation_date->getString(); $start = $entity->reservation_date->getString();
$time = $entity->reservation_time->getString(); $time = $entity->reservation_time->getString();
@ -130,6 +130,7 @@ function reserve_reserve_reservation_update($entity) {
// grab all reservations in this series except the one being submitted // grab all reservations in this series except the one being submitted
$ids = \Drupal::service('entity_type.manager') $ids = \Drupal::service('entity_type.manager')
->getStorage('reserve_reservation')->getQuery() ->getStorage('reserve_reservation')->getQuery()
->accessCheck(TRUE)
->condition('status', TRUE) ->condition('status', TRUE)
->condition('reservation_series_id', $sid) ->condition('reservation_series_id', $sid)
->condition('id', $entity->id(), '!=') ->condition('id', $entity->id(), '!=')
@ -162,7 +163,7 @@ function reserve_reserve_reservation_update($entity) {
if (count($failed)) { if (count($failed)) {
$dates = Markup::create('<br>' . implode('<br>', $failed)); $dates = Markup::create('<br>' . implode('<br>', $failed));
\Drupal::messenger()->addStatus(t('NOTE: The following dates did not have their length changed due to scheduling conflicts: %dates', array('%dates' => $dates))); \Drupal::messenger()->addStatus(t('NOTE: The following dates did not have their length changed due to scheduling conflicts: %dates', array('%dates' => $dates)));
} }
} }
/** /**
@ -183,6 +184,7 @@ function _reserve_series_delete($entity) {
// grab all reservations in this series // grab all reservations in this series
$ids = \Drupal::service('entity_type.manager') $ids = \Drupal::service('entity_type.manager')
->getStorage('reserve_reservation')->getQuery() ->getStorage('reserve_reservation')->getQuery()
->accessCheck(TRUE)
->condition('reservation_series_id', $sid) ->condition('reservation_series_id', $sid)
->execute(); ->execute();
$results = \Drupal::entityTypeManager()->getStorage('reserve_reservation')->loadMultiple($ids); $results = \Drupal::entityTypeManager()->getStorage('reserve_reservation')->loadMultiple($ids);
@ -190,5 +192,5 @@ function _reserve_series_delete($entity) {
$result->delete(); $result->delete();
} }
$title = $entity->get('name')->getString(); $title = $entity->get('name')->getString();
\Drupal::messenger()->addStatus(t('The reservation series @title was deleted.', array('@title' => $title))); \Drupal::messenger()->addStatus(t('The reservation series @title was deleted.', array('@title' => $title)));
} }

Loading…
Cancel
Save