From 1a3b4e2a334c57cc403be1d8e21fd8e162d9df5c Mon Sep 17 00:00:00 2001 From: msquare Date: Sat, 12 Nov 2016 23:00:46 +0100 Subject: redone shift coloring and shift signup state --- includes/model/ShiftSignupState.php | 98 +++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 includes/model/ShiftSignupState.php (limited to 'includes/model/ShiftSignupState.php') diff --git a/includes/model/ShiftSignupState.php b/includes/model/ShiftSignupState.php new file mode 100644 index 00000000..f9226375 --- /dev/null +++ b/includes/model/ShiftSignupState.php @@ -0,0 +1,98 @@ +state = $state; + $this->freeEntries = $free_entries; + } + + /** + * Combine this state with another state from the same shift. + * + * @param ShiftSignupState $shiftSignupState + * The other state to combine + */ + public function combineWith(ShiftSignupState $shiftSignupState) { + $this->freeEntries += $shiftSignupState->getFreeEntries(); + + switch ($this->state) { + case ShiftSignupState::ANGELTYPE: + case ShiftSignupState::OCCUPIED: + $this->state = $shiftSignupState->getState(); + } + } + + /** + * Returns true, if signup is allowed + */ + public function isSignupAllowed() { + switch ($this->state) { + case ShiftSignupState::FREE: + case ShiftSignupState::ADMIN: + return true; + } + return false; + } + + /** + * Return the shift signup state + */ + public function getState() { + return $this->state; + } + + /** + * How many places are free in this shift for the angeltype? + */ + public function getFreeEntries() { + return $this->freeEntries; + } +} + +?> \ No newline at end of file -- cgit v1.2.3-70-g09d2