/** * Hook performing actual save * * @param string $newCode * @param int $userId * @return $changed */ public function setReceptionCode($newCode, $userId) { $oldCode = $this->respondentTrack->getReceptionCode()->getCode(); // Use the repesondent track function as that cascades the consent code $changed = $this->respondentTrack->setReceptionCode($newCode, $this->formData['gr2t_comment'], $userId); if ($this->unDelete) { $this->addMessage($this->_('Track restored.')); if (isset($this->formData['restore_tokens']) && $this->formData['restore_tokens']) { $count = 0; foreach ($this->respondentTrack->getTokens() as $token) { if ($token instanceof \Gems_Tracker_Token) { if ($oldCode === $token->getReceptionCode()->getCode()) { $count += $token->setReceptionCode($newCode, null, $userId); } } } $this->addMessage(sprintf($this->plural('%d token reception codes restored.', '%d tokens reception codes restored.', $count), $count)); } } else { if ($this->util->getReceptionCode($newCode)->isStopCode()) { $this->addMessage($this->_('Track stopped.')); } else { $this->addMessage($this->_('Track deleted.')); } } return $changed; }
/** * Determines if this particular track should be included * in the report * * @param \Gems_Tracker_RespondentTrack $track * @return boolean This dummy implementation always returns true */ protected function _isTrackInFilter(\Gems_Tracker_RespondentTrack $track) { $result = false; $trackInfo = array('code' => $track->getCode(), 'trackid' => $track->getTrackId(), 'resptrackid' => $track->getRespondentTrackId(), 'respid' => $track->getRespondentId()); if (empty($this->trackFilter)) { $result = true; } else { // Now read the filter and split by track code or track id foreach ($this->trackFilter as $filter) { $remaining = array_diff_assoc($filter, $trackInfo); if (empty($remaining)) { $result = true; break; } } } // Only if track has a success code if ($result && $track->getReceptionCode()->isSuccess()) { return true; } return false; }