Update the token data when a Mail has been sent.
@param  integer $tokenId TokenId to update. If none is supplied, use the current token
348395
public function updateToken($tokenId=false)
    {
        if (!$tokenId) {
            $tokenId = $this->token->getTokenId();
        }
        $tokenData['gto_mail_sent_num'] = new \Zend_Db_Expr('gto_mail_sent_num + 1');
        $tokenData['gto_mail_sent_date'] = \MUtil_Date::format(new \Zend_Date(), 'yyyy-MM-dd');

        $this->db->update('gems__tokens', $tokenData, $this->db->quoteInto('gto_id_token = ?', $tokenId));
    }
1247465
public function destroy_token($tokenId) {
		try {
			$sql = "DELETE FROM ". $this->table ." WHERE auth_token_id=:tokenId";
			$deleteRes = $this->db->run_update($sql, array('tokenId'=>$tokenId));
		}
		catch(exception $e) {
			throw new exception(__METHOD__ .": failed to destroy token::: ". $e->getMessage());
		}
		
		return($deleteRes);
	}
573053
public function update($token = null, $data = [])
    {
        return $this->app->tokens->update($token, $data);
    }
835540
public function setSent($sendId)
    {
        $bind = [
            'send_status' => \Dotdigitalgroup\Email\Model\Campaign::SENT,
            'sent_at' => $this->datetime->gmtDate()
        ];
        $conn = $this->getConnection();
        $conn->update(
            $this->getMainTable(),
            $bind,
            ['send_id = ?' => $sendId]
        );
    }
699905
public function execute($tokenData = null, $userId = null)
    {
        $batch   = $this->getBatch();
        $tracker = $this->loader->getTracker();
        $token   = $tracker->getToken($tokenData);

        if ($token->isCompleted()) {
            $respTrack = $token->getRespondentTrack();
            $userId    = $userId ? $userId : $this->loader->getCurrentUser()->getUserId();

            if ($result = $respTrack->handleRoundCompletion($token, $userId)) {
                $a = $batch->addToCounter('roundCompletionCauses');
                $b = $batch->addToCounter('roundCompletionChanges', $result);
                $batch->setMessage('roundCompletionChanges',
                        sprintf($this->_('%d token round completion events caused changed to %d tokens.'), $a, $b)
                        );
            }

            $trackId = $respTrack->getRespondentTrackId();
            $batch->setTask('Tracker_CheckTrackTokens', 'chktrck-' . $trackId, $trackId, $userId);
        }

        // Free memory
        $tracker->removeToken($token);
    }
930166
public static function update($token, array $params)
    {
        $params['token_id'] = $token;

        return self::invoke(__FUNCTION__, static::RESOURCE_NAME, $params);
    }
992211
private void insertOrUpdateToken(io.motown.ocpi.dto.Token tokenUpdate, Integer subscriptionId) {
        Token token = ocpiRepository.findTokenByUidAndIssuingCompany(tokenUpdate.uid, tokenUpdate.issuer);
        if (token == null) {
            token = new Token();
            token.setUid(tokenUpdate.uid);
            token.setSubscriptionId(subscriptionId);
            token.setDateCreated(new Date());
        }
        token.setTokenType(tokenUpdate.type);
        token.setAuthId(tokenUpdate.auth_id);
        token.setVisualNumber(tokenUpdate.visual_number);
        token.setIssuingCompany(tokenUpdate.issuer);
        token.setValid(tokenUpdate.valid);
        token.setWhitelist(tokenUpdate.whitelist);
        token.setLanguageCode(tokenUpdate.languageCode);

        try {
            token.setLastUpdated(AppConfig.DATE_FORMAT.parse(tokenUpdate.last_updated));
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
        ocpiRepository.insertOrUpdate(token);
    }
1342507
public function isAccessTokenRevoked($tokenId)
    {
        /** @var \Concrete\Core\Entity\OAuth\AccessToken $token */
        $token = $this->find($tokenId);
        if (!$token) {
            // The token was manually removed.
            return true;
        }

        $now = new \DateTime('now');
        // If we have a token and it has expired...
        if ($token && $token->getExpiryDateTime() < $now) {
            return true;
        }

        return false;
    }
661691
public function execute($tokenData = null, $userId = null)
    {
        $tracker = $this->loader->getTracker();

        $token  = $tracker->getToken($tokenData[0]);
        $survey = $token->getSurvey();
        $source = $survey->getSource();
        if (method_exists($source, 'getCompletedTokens')) {
            $completed = $source->getCompletedTokens($tokenData, $survey->getSourceSurveyId());
        } else {
            // No bulk method, check all individually
            $completed = $tokenData;
        }

        if ($completed) {
            $batch   = $this->getBatch();
            foreach($completed as $tokenId) {
                $batch->setTask('Tracker_CheckTokenCompletion', 'tokchk-' . $tokenId, $tokenId, $userId);
            }
        }
    }
59154
public function create($data, $tokenId = null)
    {
        if (isset($tokenId)) {
            return $this->client()->put($data, 'sessions/{tokenId}', ['tokenId' => $tokenId]);
        }

        return $this->client()->post($data, 'sessions');
    }
100323
public function getToken($tokenId) {

		$sessionToken = $this->sessionDataBag->get($this->namespace . '/' . $tokenId);

		if(!$sessionToken) {
			throw new CsrfTokenException(sprintf("CSRF token with id '%s' not found.", $tokenId));
		}

		return $sessionToken;
	}
329199
protected function updateSubscriptionsToPaymentMethod($token)
    {
        foreach ($this->subscriptions as $subscription) {
            if ($subscription->active()) {
                BraintreeSubscription::update($subscription->braintree_id, [
                    'paymentMethodToken' => $token,
                ]);
            }
        }
    }
874197
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();
    }
175714
public function put($token)
    {
        $encryptedToken = $this->encryptor->encrypt($token);

        $this->storage->put('token', $encryptedToken);
    }
267084
public function addToken(Token $token)
    {
        $this->load();
        parent::addToken($token);
        $this->save();
    }
41423
public function setTokenInputName($tokenInputName = null)
    {
        if ($tokenInputName === null) {
            $tokenInputName = 'form_key';
        }

        $this->setData('token_input_name', $tokenInputName);
        return $this;
    }
1293735
public function forNextTokenId($tokenId)
    {
        $this->sql_select->join('gems__tokens as ct',
                'gems__tokens.gto_id_respondent_track = ct.gto_id_respondent_track AND
                    gems__tokens.gto_id_token != ct.gto_id_token AND
                        ((gems__tokens.gto_round_order < ct.gto_round_order) OR
                            (gems__tokens.gto_round_order = ct.gto_round_order AND gems__tokens.gto_created < ct.gto_created))',
                array());

        $this->sql_select
                ->where('ct.gto_id_token = ?', $tokenId)
                ->order('gems__tokens.gto_round_order DESC')
                ->order('gems__tokens.gto_created DESC');

        return $this;
    }