protected function addNewTokens(\Gems_Tracker_RespondentTrack $respTrack, $userId)
    {
        $orgId       = $respTrack->getOrganizationId();
        $respId      = $respTrack->getRespondentId();
        $respTrackId = $respTrack->getRespondentTrackId();

        // $this->t

        $sql = "SELECT gro_id_round, gro_id_survey, gro_id_order, gro_icon_file, gro_round_description
            FROM gems__rounds
            WHERE gro_id_track = ? AND
                gro_active = 1 AND
                gro_id_round NOT IN (SELECT gto_id_round FROM gems__tokens WHERE gto_id_respondent_track = ?) AND
                (gro_organizations IS NULL OR gro_organizations LIKE CONCAT('%|',?,'|%'))
            ORDER BY gro_id_order";

        $newRounds = $this->db->fetchAll($sql, array($this->_trackId, $respTrackId, $orgId));

        $this->db->beginTransaction();
        foreach ($newRounds as $round) {

            $values = array();

            // From the respondent track
            $values['gto_id_respondent_track'] = $respTrackId;
            $values['gto_id_respondent']       = $respId;
            $values['gto_id_organization']     = $orgId;
            $values['gto_id_track']            = $this->_trackId;

            // From the rounds
            $values['gto_id_round']          = $round['gro_id_round'];
            $values['gto_id_survey']         = $round['gro_id_survey'];
            $values['gto_round_order']       = $round['gro_id_order'];
            $values['gto_icon_file']         = $round['gro_icon_file'];
            $values['gto_round_description'] = $round['gro_round_description'];

            // All other values are not changed by this query and get the default DB value on insertion

            $this->tracker->createToken($values, $userId);
        }
        $this->db->commit();

        return count($newRounds);
    }
protected function addNewTokens(\Gems_Tracker_RespondentTrack $respTrack, $userId)
    {
        $orgId       = $respTrack->getOrganizationId();
        $respId      = $respTrack->getRespondentId();
        $respTrackId = $respTrack->getRespondentTrackId();

        // $this->t

        $sql = "SELECT gro_id_round, gro_id_survey, gro_id_order, gro_icon_file, gro_round_description
            FROM gems__rounds
            WHERE gro_id_track = ? AND
                gro_active = 1 AND
                gro_id_round NOT IN (SELECT gto_id_round FROM gems__tokens WHERE gto_id_respondent_track = ?) AND
                (gro_organizations IS NULL OR gro_organizations LIKE CONCAT('%|',?,'|%'))
            ORDER BY gro_id_order";

        $newRounds = $this->db->fetchAll($sql, array($this->_trackId, $respTrackId, $orgId));

        $this->db->beginTransaction();
        foreach ($newRounds as $round) {

            $values = array();

            // From the respondent track
            $values['gto_id_respondent_track'] = $respTrackId;
            $values['gto_id_respondent']       = $respId;
            $values['gto_id_organization']     = $orgId;
            $values['gto_id_track']            = $this->_trackId;

            // From the rounds
            $values['gto_id_round']          = $round['gro_id_round'];
            $values['gto_id_survey']         = $round['gro_id_survey'];
            $values['gto_round_order']       = $round['gro_id_order'];
            $values['gto_icon_file']         = $round['gro_icon_file'];
            $values['gto_round_description'] = $round['gro_round_description'];

            // All other values are not changed by this query and get the default DB value on insertion

            $this->tracker->createToken($values, $userId);
        }
        $this->db->commit();

        return count($newRounds);
    }
protected function addNewTokens ( \ Gems_Tracker_RespondentTrack $ respTrack , $ userId ) { $ orgId = $ respTrack -> getOrganizationId ( ) ; $ respId = $ respTrack -> getRespondentId ( ) ; $ respTrackId = $ respTrack -> getRespondentTrackId ( ) ; // $this->t $ sql = "SELECT gro_id_round, gro_id_survey, gro_id_order, gro_icon_file, gro_round_description
            FROM gems__rounds
            WHERE gro_id_track = ? AND
                gro_active = 1 AND
                gro_id_round NOT IN (SELECT gto_id_round FROM gems__tokens WHERE gto_id_respondent_track = ?) AND
                (gro_organizations IS NULL OR gro_organizations LIKE CONCAT('%|',?,'|%'))
            ORDER BY gro_id_order" ; $ newRounds = $ this -> db -> fetchAll ( $ sql , array ( $ this -> _trackId , $ respTrackId , $ orgId ) ) ; $ this -> db -> beginTransaction ( ) ; foreach ( $ newRounds as $ round ) { $ values = array ( ) ; // From the respondent track $ values [ 'gto_id_respondent_track' ] = $ respTrackId ; $ values [ 'gto_id_respondent' ] = $ respId ; $ values [ 'gto_id_organization' ] = $ orgId ; $ values [ 'gto_id_track' ] = $ this -> _trackId ; // From the rounds $ values [ 'gto_id_round' ] = $ round [ 'gro_id_round' ] ; $ values [ 'gto_id_survey' ] = $ round [ 'gro_id_survey' ] ; $ values [ 'gto_round_order' ] = $ round [ 'gro_id_order' ] ; $ values [ 'gto_icon_file' ] = $ round [ 'gro_icon_file' ] ; $ values [ 'gto_round_description' ] = $ round [ 'gro_round_description' ] ; // All other values are not changed by this query and get the default DB value on insertion $ this -> tracker -> createToken ( $ values , $ userId ) ; } $ this -> db -> commit ( ) ; return count ( $ newRounds ) ; }
Creates all tokens that should exist, but do not exist

NOTE: When overruling this function you should not create tokens because they
were deleted by the user

@param \Gems_Tracker_RespondentTrack $respTrack The respondent track to check
@param int $userId Id of the user who takes the action (for logging)
@return int The number of tokens created by this code
Creates all tokens that should exist but do not exist