aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+studip@gmail.com>2024-09-25 06:59:40 +0000
committerJan-Hendrik Willms <tleilax+studip@gmail.com>2024-09-25 06:59:40 +0000
commit57c22c7079d12b5225c6abd622e291bab45b7bde (patch)
treec7d9e3cb79f7848d6d8c69ebf163c99cf404efa6 /lib
parentdd008ac05181141f852481e0f985b2adc55ff207 (diff)
fix export of course dates, fixes #4626
Closes #4626 Merge request studip/studip!3438
Diffstat (limited to 'lib')
-rw-r--r--lib/classes/CourseDateList.php42
-rw-r--r--lib/models/CourseDate.php2
-rw-r--r--lib/models/resources/Resource.php2
3 files changed, 22 insertions, 24 deletions
diff --git a/lib/classes/CourseDateList.php b/lib/classes/CourseDateList.php
index 881d6da..5f6d4b1 100644
--- a/lib/classes/CourseDateList.php
+++ b/lib/classes/CourseDateList.php
@@ -138,40 +138,38 @@ class CourseDateList implements Stringable
return $this->regular_dates;
}
+ /**
+ * @param bool $include_regular_dates
+ * @param bool $include_cancelled_dates
+ * @param bool $sorted
+ * @return CourseDate[]|CourseExDate[]
+ */
public function getSingleDates(
bool $include_regular_dates = false,
bool $include_cancelled_dates = false,
bool $sorted = false
): array {
+ $all_single_dates = [];
+
if ($include_regular_dates) {
- $all_single_dates = [];
foreach ($this->regular_dates as $regular_date) {
foreach ($regular_date->dates as $date) {
$all_single_dates[] = $date;
}
}
- $all_single_dates = array_merge($all_single_dates, $this->single_dates);
- if ($include_cancelled_dates) {
- $all_single_dates = array_merge($all_single_dates, $this->cancelled_dates);
- }
- if ($sorted) {
- uasort($all_single_dates, self::compareSingleDatesOrCancelledDates(...));
- }
- return $all_single_dates;
- } else {
- if ($include_cancelled_dates || $sorted) {
- $all_single_dates = $this->single_dates;
- if ($include_cancelled_dates) {
- $all_single_dates = array_merge($all_single_dates, $this->cancelled_dates);
- }
- if ($sorted) {
- uasort($all_single_dates, self::compareSingleDatesOrCancelledDates(...));
- }
- return $all_single_dates;
- } else {
- return $this->single_dates;
- }
}
+
+ $all_single_dates = array_merge($all_single_dates, $this->single_dates);
+
+ if ($include_cancelled_dates) {
+ $all_single_dates = array_merge($all_single_dates, $this->cancelled_dates);
+ }
+
+ if ($sorted) {
+ uasort($all_single_dates, self::compareSingleDatesOrCancelledDates(...));
+ }
+
+ return $all_single_dates;
}
public function getCancelledDates() : array
diff --git a/lib/models/CourseDate.php b/lib/models/CourseDate.php
index 943bf23..46610d5 100644
--- a/lib/models/CourseDate.php
+++ b/lib/models/CourseDate.php
@@ -235,7 +235,7 @@ class CourseDate extends SimpleORMap implements PrivacyObject, Event
/**
* Returns the assigned room for this date as an object.
*
- * @return Room Either the object or null if no room is assigned
+ * @return Resource Either the object or null if no room is assigned
*/
public function getRoom()
{
diff --git a/lib/models/resources/Resource.php b/lib/models/resources/Resource.php
index e1d8b67..4dae189 100644
--- a/lib/models/resources/Resource.php
+++ b/lib/models/resources/Resource.php
@@ -2817,7 +2817,7 @@ class Resource extends SimpleORMap implements StudipItem
/**
* Converts a Resource object to an object of a specialised resource class.
*
- * @return Resource|other An object of a specialised resource class
+ * @return Resource An object of a specialised resource class
* or a Resource object, if the resource is a standard resource
* with the class_name 'Resource' in its resource category.
* If the derived resource class is not available, an instance of