original_string: public function setReceptionCode($code, $comment, $userId)
      {
          // Make sure it is a \Gems_Util_ReceptionCode object
          if (! $code instanceof \Gems_Util_ReceptionCode) {
              $code = $this->util->getReceptionCode($code);
          }
          $changed = 0;
  
          // Apply this code both only when it is a track code.
          // Patient level codes are just cascaded to the tokens.
          //
          // The exception is of course when the exiting values must
          // be overwritten, e.g. when cooperation is retracted.
          if ($code->isForTracks() || $code->isOverwriter()) {
              $values['gr2t_reception_code'] = $code->getCode();
          }
  
          $values['gr2t_comment'] = $comment;
  
          $changed = $this->_updateTrack($values, $userId);
  
          // Stopcodes have a different logic.
          if ($code->isStopCode()) {
              // Cascade stop to unanswered tokens
              foreach ($this->getTokens() as $token) {
                  if ($token->hasSuccesCode() && (! $token->isCompleted())) {
                      $changed += $token->setReceptionCode($code, $comment, $userId);
                  }
              }
              $changed = max($changed, 1);
  
              // Update token count / completion
              $this->_checkTrackCount($userId);
  
          } elseif (! $code->isSuccess()) {
              // Cascade code to tokens
              foreach ($this->getTokens() as $token) {
                  if ($token->hasSuccesCode()) {
                      $token->setReceptionCode($code, $comment, $userId);
                  }
              }
          }
  
          return $changed;
      }
code: public function setReceptionCode($code, $comment, $userId)
      {
          // Make sure it is a \Gems_Util_ReceptionCode object
          if (! $code instanceof \Gems_Util_ReceptionCode) {
              $code = $this->util->getReceptionCode($code);
          }
          $changed = 0;
  
          // Apply this code both only when it is a track code.
          // Patient level codes are just cascaded to the tokens.
          //
          // The exception is of course when the exiting values must
          // be overwritten, e.g. when cooperation is retracted.
          if ($code->isForTracks() || $code->isOverwriter()) {
              $values['gr2t_reception_code'] = $code->getCode();
          }
  
          $values['gr2t_comment'] = $comment;
  
          $changed = $this->_updateTrack($values, $userId);
  
          // Stopcodes have a different logic.
          if ($code->isStopCode()) {
              // Cascade stop to unanswered tokens
              foreach ($this->getTokens() as $token) {
                  if ($token->hasSuccesCode() && (! $token->isCompleted())) {
                      $changed += $token->setReceptionCode($code, $comment, $userId);
                  }
              }
              $changed = max($changed, 1);
  
              // Update token count / completion
              $this->_checkTrackCount($userId);
  
          } elseif (! $code->isSuccess()) {
              // Cascade code to tokens
              foreach ($this->getTokens() as $token) {
                  if ($token->hasSuccesCode()) {
                      $token->setReceptionCode($code, $comment, $userId);
                  }
              }
          }
  
          return $changed;
      }
code_tokens: public function setReceptionCode ( $ code , $ comment , $ userId ) { // Make sure it is a \Gems_Util_ReceptionCode object if ( ! $ code instanceof \ Gems_Util_ReceptionCode ) { $ code = $ this -> util -> getReceptionCode ( $ code ) ; } $ changed = 0 ; // Apply this code both only when it is a track code. // Patient level codes are just cascaded to the tokens. // // The exception is of course when the exiting values must // be overwritten, e.g. when cooperation is retracted. if ( $ code -> isForTracks ( ) || $ code -> isOverwriter ( ) ) { $ values [ 'gr2t_reception_code' ] = $ code -> getCode ( ) ; } $ values [ 'gr2t_comment' ] = $ comment ; $ changed = $ this -> _updateTrack ( $ values , $ userId ) ; // Stopcodes have a different logic. if ( $ code -> isStopCode ( ) ) { // Cascade stop to unanswered tokens foreach ( $ this -> getTokens ( ) as $ token ) { if ( $ token -> hasSuccesCode ( ) && ( ! $ token -> isCompleted ( ) ) ) { $ changed += $ token -> setReceptionCode ( $ code , $ comment , $ userId ) ; } } $ changed = max ( $ changed , 1 ) ; // Update token count / completion $ this -> _checkTrackCount ( $ userId ) ; } elseif ( ! $ code -> isSuccess ( ) ) { // Cascade code to tokens foreach ( $ this -> getTokens ( ) as $ token ) { if ( $ token -> hasSuccesCode ( ) ) { $ token -> setReceptionCode ( $ code , $ comment , $ userId ) ; } } } return $ changed ; }
docstring: Set the reception code for this respondent track and make sure the
  necessary cascade to the tokens and thus the source takes place.
  
  @param string $code The new (non-success) reception code or a \Gems_Util_ReceptionCode object
  @param string $comment Comment for tokens. False values leave value unchanged
  @param int $userId The current user
  @return int 1 if the token has changed, 0 otherwise
docstring_tokens: Set the reception code for this respondent track and make sure the necessary cascade to the tokens and thus the source takes place .