aboutsummaryrefslogtreecommitdiff
path: root/model
diff options
context:
space:
mode:
authorFlorian Larysch2015-09-02 12:56:32 +0200
committerFlorian Larysch2015-09-02 14:31:39 +0200
commit7a5c8ff018936ed7328042c88a2edae3c29d91be (patch)
tree23efc9fdb4e3c8fd1c44cc49a3f30be0a6ed1987 /model
parent502371650e4e1fe99ec382104e2eba945925a459 (diff)
Automatically open/close conference based on time.
Toggle the 'closed' bit based on the current time, rather than manually setting it in the config. This patch also adds a distinction between the time before the conference and after: Different pages will be displayed as to not confuse the user.
Diffstat (limited to 'model')
-rw-r--r--model/Conference.php35
1 files changed, 34 insertions, 1 deletions
diff --git a/model/Conference.php b/model/Conference.php
index e927a2b..d6ef913 100644
--- a/model/Conference.php
+++ b/model/Conference.php
@@ -7,7 +7,40 @@ class Conference extends ModelBase
}
public function isClosed() {
- return $this->get('CONFERENCE.CLOSED');
+ return !$this->hasBegun() || $this->hasEnded();
+ }
+
+ public function hasBegun() {
+ if($this->has('CONFERENCE.CLOSED')) {
+ $closed = $this->get('CONFERENCE.CLOSED');
+
+ /* when CLOSED is a boolean, we're reading an old config where
+ * conferences didn't have a pre-beginning phase, thus we always
+ * return true.
+ */
+ if(gettype($closed) == "boolean")
+ return true;
+
+ if($closed == "before")
+ return false;
+ else if($closed == "running")
+ return true;
+ }
+
+ return time() >= $this->get('CONFERENCE.STARTS_AT');
+ }
+
+ public function hasEnded() {
+ if($this->has('CONFERENCE.CLOSED')) {
+ $closed = $this->get('CONFERENCE.CLOSED');
+
+ if($closed == "after" || $closed === true)
+ return true;
+ else if($closed == "running" || $closed === false)
+ return false;
+ }
+
+ return time() >= $this->get('CONFERENCE.ENDS_AT');
}
public function hasAuthor() {