aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMoritz Strohm <strohm@data-quest.de>2025-09-10 11:19:44 +0000
committerMoritz Strohm <strohm@data-quest.de>2025-09-10 11:19:44 +0000
commit0d665daed55a2edf92bffdc22416bb073181ec0d (patch)
treedfbe0de9bc1faaf4daf0757fc00f137f372b2ba8 /lib
parentaac4ccb7ee22e342fb0238a778cdf960355b2f6d (diff)
TimedFolder: added one minute of time in the checks in isVisible, isReadable and isWritable, really fixes #5874
Closes #5874 Merge request studip/studip!4482 (cherry picked from commit cc9dbbccb76f32066f153b7635193cbd07efdd16) ee2f0ac6 removed first solution for the BIESt 640a819c TimedFolder: added one minute of time in the checks in isVisible, isReadable and isWritable 86b9a1dd changed display of start and end time in timed folder description Co-authored-by: Moritz Strohm <strohm@data-quest.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/filesystem/TimedFolder.php26
1 files changed, 19 insertions, 7 deletions
diff --git a/lib/filesystem/TimedFolder.php b/lib/filesystem/TimedFolder.php
index a89c6a3..70373d5 100644
--- a/lib/filesystem/TimedFolder.php
+++ b/lib/filesystem/TimedFolder.php
@@ -56,6 +56,19 @@ class TimedFolder extends PermissionEnabledFolder
}
/**
+ * A helper method to calculate the real end time that is used in time comparisons.
+ * Since the end time is a timestamp that only contains hours and minutes, the folder
+ * will be invisible, unreadable and unwritable in the minute in that timestamp unless
+ * one more minute is added.
+ *
+ * @returns int The real end time. This is the end timestamp + 60.
+ */
+ protected function getRealEndTime() : int
+ {
+ return $this->end_time + 60;
+ }
+
+ /**
* Is the current folder visible for the given user?
* That depends on parent folder visibility and time settings.
*
@@ -65,9 +78,10 @@ class TimedFolder extends PermissionEnabledFolder
public function isVisible($user_id = null)
{
$now = time();
+ $real_end_time = $this->getRealEndTime();
return (
($this->start_time == 0 || $this->start_time <= $now) &&
- ($this->end_time == 0 || $this->end_time >= $now)
+ ($this->end_time == 0 || $real_end_time > $now)
||
$GLOBALS['perm']->have_studip_perm($this->must_have_perm, $this->range_id, $user_id)) &&
parent::isVisible($user_id);
@@ -76,9 +90,10 @@ class TimedFolder extends PermissionEnabledFolder
public function isReadable($user_id = null)
{
$now = time();
+ $real_end_time = $this->getRealEndTime();
return (
($this->start_time == 0 || $this->start_time <= $now) &&
- ($this->end_time == 0 || $this->end_time >= $now)
+ ($this->end_time == 0 || $real_end_time > $now)
||
$GLOBALS['perm']->have_studip_perm($this->must_have_perm, $this->range_id, $user_id)) &&
StandardFolder::isReadable($user_id);
@@ -87,9 +102,10 @@ class TimedFolder extends PermissionEnabledFolder
public function isWritable($user_id = null)
{
$now = time();
+ $real_end_time = $this->getRealEndTime();
return (
($this->start_time == 0 || $this->start_time <= $now) &&
- ($this->end_time == 0 || $this->end_time >= $now)
+ ($this->end_time == 0 || $real_end_time > $now)
||
$GLOBALS['perm']->have_studip_perm($this->must_have_perm, $this->range_id, $user_id)) &&
parent::isWritable($user_id);
@@ -185,10 +201,6 @@ class TimedFolder extends PermissionEnabledFolder
$this->folderdata['data_content']['permission'] = $permvalue;
$start = strtotime($request['start_time']);
$end = strtotime($request['end_time']);
- if (date('i', $end) === '59') {
- //Add 59 seconds to $end to get to the last second of the minute:
- $end += 59;
- }
if (!$start && !$end) {