/**
  * Restores tracks for a respondent, when the reception code matches the given $oldCode
  *
  * Used when restoring a respondent, and the restore tracks box is checked. This will
  * also restore all tokens in the tracks that have the same codes.
  *
  * @param \Gems_Util_ReceptionCode $oldCode The old reception code
  * @param \Gems_Util_ReceptionCode $newCode the new reception code
  * @return int  The number of restored tracks
  */
 public function restoreTracks(\Gems_Util_ReceptionCode $oldCode, \Gems_Util_ReceptionCode $newCode)
 {
     $count = 0;
     if (!$oldCode->isSuccess() && $newCode->isSuccess()) {
         $respTracks = $this->loader->getTracker()->getRespondentTracks($this->getId(), $this->getOrganizationId());
         foreach ($respTracks as $respTrack) {
             if ($respTrack instanceof \Gems_Tracker_RespondentTrack) {
                 if ($oldCode->getCode() === $respTrack->getReceptionCode()->getCode()) {
                     $respTrack->setReceptionCode($newCode, null, $this->currentUser->getUserId());
                     $respTrack->restoreTokens($oldCode, $newCode);
                     $count++;
                 }
             }
         }
     }
     return $count;
 }
 /**
  * Restores tokens for this track, when the reception code matches the given $oldCode
  *
  * Used when restoring a respondent or this tracks, and the restore tracks/tokens
  * box is checked.
  *
  * @param \Gems_Util_ReceptionCode $oldCode The old reception code
  * @param \Gems_Util_ReceptionCode $newCode the new reception code
  * @return int  The number of restored tokens
  */
 public function restoreTokens(\Gems_Util_ReceptionCode $oldCode, \Gems_Util_ReceptionCode $newCode)
 {
     $count = 0;
     if (!$oldCode->isSuccess() && $newCode->isSuccess()) {
         foreach ($this->getTokens() as $token) {
             if ($token instanceof \Gems_Tracker_Token) {
                 if ($oldCode->getCode() === $token->getReceptionCode()->getCode()) {
                     $token->setReceptionCode($newCode, null, $this->currentUser->getUserId());
                     $count++;
                 }
             }
         }
     }
     return $count;
 }