diff options
author | Florian Larysch | 2015-09-02 12:56:32 +0200 |
---|---|---|
committer | Florian Larysch | 2015-09-02 14:31:39 +0200 |
commit | 7a5c8ff018936ed7328042c88a2edae3c29d91be (patch) | |
tree | 23efc9fdb4e3c8fd1c44cc49a3f30be0a6ed1987 /model/Conference.php | |
parent | 502371650e4e1fe99ec382104e2eba945925a459 (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/Conference.php')
-rw-r--r-- | model/Conference.php | 35 |
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() { |