final public function leave_date(BadmintonDate $badminton_date) { /* (BadmintonDate) -> Bool Attempts for the current user to leave the badminton date */ if ($this->user_id && $badminton_date->date_id) { if ($this->in_date($badminton_date)) { if ($badminton_date->can_be_left()) { $sql = "UPDATE `joins` SET status = '" . self::LEFT_STATUS . "' WHERE date_id = '$badminton_date->date_id' AND user_id = '$this->user_id'"; $result = $this->dbc->query($sql) or die ($this->dbc->error); $action = new LeaveBadmintonDate(array( 'leaver' => clone $this, 'badminton_date' => $badminton_date) ); $affected_rows = $this->dbc->affected_rows; if ($affected_rows == 1) { //New row was inserted //Push the action ActionFactory::push_action($action); //Push notifications to the group NotificationFactory::push_notification($action); } return true; } else { return false; } } else { return true; } } else { throw new UnexpectedValueException('UnexpectedValueException occured on request on method call leave_date, invalid parameters'); } }