protected function checkTokenDates($token, $round, $userId)
    {
        // Change only not-completed tokens with a positive successcode where at least one date
        // is not set by user input
        if ($token->isCompleted() || !$token->getReceptionCode()->isSuccess() || ($token->isValidFromManual() && $token->isValidUntilManual())) {
            return 0;
        }

        $respTrack = $token->getRespondentTrack();
        if ($token->isValidFromManual()) {
            $validFrom = $token->getValidFrom();
        } else {
            $fromDate  = $this->getValidFromDate(
                    $round['gro_valid_after_source'], $round['gro_valid_after_field'], $round['gro_valid_after_id'], $token, $respTrack
            );
            $validFrom = $this->calculateFromDate(
                    $fromDate, $round['gro_valid_after_unit'], $round['gro_valid_after_length']
            );
        }

        if ($token->isValidUntilManual()) {
            $validUntil = $token->getValidUntil();
        } else {
            $untilDate  = $this->getValidUntilDate(
                    $round['gro_valid_for_source'], $round['gro_valid_for_field'], $round['gro_valid_for_id'], $token, $respTrack, $validFrom
            );
            $validUntil = $this->calculateUntilDate(
                    $untilDate, $round['gro_valid_for_unit'], $round['gro_valid_for_length']
            );
        }

        return $token->setValidFrom($validFrom, $validUntil, $userId);
    }
protected function checkTokenDates($token, $round, $userId)
    {
        // Change only not-completed tokens with a positive successcode where at least one date
        // is not set by user input
        if ($token->isCompleted() || !$token->getReceptionCode()->isSuccess() || ($token->isValidFromManual() && $token->isValidUntilManual())) {
            return 0;
        }

        $respTrack = $token->getRespondentTrack();
        if ($token->isValidFromManual()) {
            $validFrom = $token->getValidFrom();
        } else {
            $fromDate  = $this->getValidFromDate(
                    $round['gro_valid_after_source'], $round['gro_valid_after_field'], $round['gro_valid_after_id'], $token, $respTrack
            );
            $validFrom = $this->calculateFromDate(
                    $fromDate, $round['gro_valid_after_unit'], $round['gro_valid_after_length']
            );
        }

        if ($token->isValidUntilManual()) {
            $validUntil = $token->getValidUntil();
        } else {
            $untilDate  = $this->getValidUntilDate(
                    $round['gro_valid_for_source'], $round['gro_valid_for_field'], $round['gro_valid_for_id'], $token, $respTrack, $validFrom
            );
            $validUntil = $this->calculateUntilDate(
                    $untilDate, $round['gro_valid_for_unit'], $round['gro_valid_for_length']
            );
        }

        return $token->setValidFrom($validFrom, $validUntil, $userId);
    }
protected function checkTokenDates ( $ token , $ round , $ userId ) { // Change only not-completed tokens with a positive successcode where at least one date // is not set by user input if ( $ token -> isCompleted ( ) || ! $ token -> getReceptionCode ( ) -> isSuccess ( ) || ( $ token -> isValidFromManual ( ) && $ token -> isValidUntilManual ( ) ) ) { return 0 ; } $ respTrack = $ token -> getRespondentTrack ( ) ; if ( $ token -> isValidFromManual ( ) ) { $ validFrom = $ token -> getValidFrom ( ) ; } else { $ fromDate = $ this -> getValidFromDate ( $ round [ 'gro_valid_after_source' ] , $ round [ 'gro_valid_after_field' ] , $ round [ 'gro_valid_after_id' ] , $ token , $ respTrack ) ; $ validFrom = $ this -> calculateFromDate ( $ fromDate , $ round [ 'gro_valid_after_unit' ] , $ round [ 'gro_valid_after_length' ] ) ; } if ( $ token -> isValidUntilManual ( ) ) { $ validUntil = $ token -> getValidUntil ( ) ; } else { $ untilDate = $ this -> getValidUntilDate ( $ round [ 'gro_valid_for_source' ] , $ round [ 'gro_valid_for_field' ] , $ round [ 'gro_valid_for_id' ] , $ token , $ respTrack , $ validFrom ) ; $ validUntil = $ this -> calculateUntilDate ( $ untilDate , $ round [ 'gro_valid_for_unit' ] , $ round [ 'gro_valid_for_length' ] ) ; } return $ token -> setValidFrom ( $ validFrom , $ validUntil , $ userId ) ; }
Check the valid from and until dates for this token

@param \GemS_Tracker_Token $token
@param array $round
@param int   $userId Id of the user who takes the action (for logging)
@return int 1 if the token has changed
Check the valid from and until dates for this token