From 7a5c8ff018936ed7328042c88a2edae3c29d91be Mon Sep 17 00:00:00 2001 From: Florian Larysch Date: Wed, 2 Sep 2015 12:56:32 +0200 Subject: 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. --- model/Conference.php | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'model') 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() { -- cgit v1.2.3