/** * Add a one-off survey to the existing track. * * @param type $surveyId the gsu_id of the survey to add * @param type $surveyData * @param int $userId * @param boolean $checkTrack Should the track be checked? Set to false when adding more then one and check manually * @return \Gems_Tracker_Token */ public function addTokenToTrack(\Gems_Tracker_Token $token, $tokenData, $userId, $checkTrack = true) { //Now make sure the data to add is correct: $tokenData['gto_id_respondent_track'] = $this->_respTrackId; $tokenData['gto_id_organization'] = $this->_respTrackData['gr2t_id_organization']; $tokenData['gto_id_track'] = $this->_respTrackData['gr2t_id_track']; $tokenData['gto_id_respondent'] = $this->_respTrackData['gr2t_id_user']; $tokenData['gto_changed'] = new \MUtil_Db_Expr_CurrentTimestamp(); $tokenData['gto_changed_by'] = $userId; $where = $this->db->quoteInto('gto_id_token = ?', $token->getTokenId()); $this->db->update('gems__tokens', $tokenData, $where); $token->refresh(); if ($checkTrack === true) { //Now refresh the track to include the survey we just added (easiest way as order may change) $this->getTokens(true); $this->checkTrackTokens($userId, $token); // Update the track counter //$this->_checkTrackCount($userId); } return $token; }