/** * Updates the gems__tokens table so all tokens stick to the (possibly) new token name rules. * * @param int $userId Id of the user who takes the action (for logging) * @return int The number of tokens changed */ protected function updateTokens($userId, $updateTokens = true) { $tokenLib = $this->tracker->getTokenLibrary(); $sql = 'UPDATE gems__tokens SET gto_id_token = ' . $this->_getTokenFromToSql($tokenLib->getFrom(), $tokenLib->getTo(), 'gto_id_token') . ', gto_changed = CURRENT_TIMESTAMP, gto_changed_by = ' . $this->_gemsDb->quote($userId) . ' WHERE ' . $this->_getTokenFromSqlWhere($tokenLib->getFrom(), 'gto_id_token') . ' AND gto_id_survey IN (SELECT gsu_id_survey FROM gems__surveys WHERE gsu_id_source = ' . $this->_gemsDb->quote($this->getId()) . ')'; return $this->_gemsDb->query($sql)->rowCount(); }