Update the track, both in the database and in memory.

@param array $values The values that this token should be set to
@param int $userId The current user
@return int 1 if data changed, 0 otherwise
336394
private function _update(array $values, $userId)
    {
        if ($this->tracker->filterChangesOnly($this->_trackData, $values)) {

            if (\Gems_Tracker::$verbose) {
                $echo = '';
                foreach ($values as $key => $val) {
                    $echo .= $key . ': ' . $this->_trackData[$key] . ' => ' . $val . "\n";
                }
                \MUtil_Echo::r($echo, 'Updated values for ' . $this->_trackId);
            }

            if (! isset($values['gto_changed'])) {
                $values['gtr_changed'] = new \MUtil_Db_Expr_CurrentTimestamp();
            }
            if (! isset($values['gtr_changed_by'])) {
                $values['gtr_changed_by'] = $userId;
            }

            // Update values in this object
            $this->_trackData = $values + $this->_trackData;

            // return 1;
            return $this->db->update('gems__tracks', $values, array('gtr_id_track = ?' => $this->_trackId));

        } else {
            return 0;
        }
    }
683942
public function update(array $values)
    {
        $sql = $this->grammar->compileUpdate($this, $values);

        return $this->connection->update($sql, $this->cleanBindings(
            $this->grammar->prepareBindingsForUpdate($this->bindings, $values)
        ));
    }
853908
public function execute($respTrackData = null, $userId = null)
    {
        $batch     = $this->getBatch();
        $tracker   = $this->loader->getTracker();
        $respTrack = $tracker->getRespondentTrack($respTrackData);
        $engine    = $respTrack->getTrackEngine();

        $engine->checkRoundsFor($respTrack, $userId, $batch);
    }
1310770
public function update(array $values): int {
    $this->coerceDataTypesToDatabase($values);
    return $this->builder->update($values);
  }
1297056
private function _updateSurvey(array $values, $userId)
    {
        if ($this->tracker->filterChangesOnly($this->_gemsSurvey, $values)) {

            if (\Gems_Tracker::$verbose) {
                $echo = '';
                foreach ($values as $key => $val) {
                    $old = isset($this->_gemsSurvey[$key]) ? $this->_gemsSurvey[$key] : null;
                    $echo .= $key . ': ' . $old . ' => ' . $val . "\n";
                }
                \MUtil_Echo::r($echo, 'Updated values for ' . $this->_surveyId);
            }

            if (! isset($values['gsu_changed'])) {
                $values['gsu_changed'] = new \MUtil_Db_Expr_CurrentTimestamp();
            }
            if (! isset($values['gsu_changed_by'])) {
                $values['gsu_changed_by'] = $userId;
            }

            if ($this->exists) {
                // Update values in this object
                $this->_gemsSurvey = $values + $this->_gemsSurvey;

                // return 1;
                return $this->db->update('gems__surveys', $values, array('gsu_id_survey = ?' => $this->_surveyId));

            } else {
                if (! isset($values['gsu_created'])) {
                    $values['gsu_created'] = new \MUtil_Db_Expr_CurrentTimestamp();
                }
                if (! isset($values['gsu_created_by'])) {
                    $values['gsu_created_by'] = $userId;
                }

                // Update values in this object
                $this->_gemsSurvey = $values + $this->_gemsSurvey;

                // Remove the Gems survey id
                unset($this->_gemsSurvey['gsu_id_survey']);

                $this->_surveyId = $this->db->insert('gems__surveys', $this->_gemsSurvey);
                $this->_gemsSurvey['gsu_id_survey'] = $this->_surveyId;
                $this->exists = true;

                return 1;
            }

        } else {
            return 0;
        }
    }
223928
public function markAsRead($userId)
    {
        try {
            $participant = $this->getParticipantFromUser($userId);
            $participant->last_read = new Carbon;
            $participant->save();
        } catch (ModelNotFoundException $e) {
            // do nothing
        }
    }
718100
public function set( $key, $value, $user_id = null ) {
		if ( ! isset( $user_id ) ) {
			$user_id = $this->user_id;
		}
		if ( $user_id <= 0 ) {
			return false;
		}

		return update_user_meta( $user_id, $this->get_meta_key( $key ), $value );
	}
626689
public function updateUserRecordWithLastlogin($userId) {

        $now = Carbon::now();
        $ip  = $this->request->getClientIp();

        DB::table('users')
            ->where('id', $userId)
            ->update(['last_login' => $now, 'last_login_ip' => $ip] )
        ;
    }
270733
protected function saveUserMultipleValue($value, int $user_id)
    {
        $previous = get_user_meta($user_id, $this->getName(), false);

        if (is_null($value) || empty($value)) {
            delete_user_meta($user_id, $this->getName());
        } elseif (empty($previous) && is_array($value)) {
            array_walk($value, function ($val) use ($user_id) {
                add_user_meta($user_id, $this->getName(), $val, false);
            });
        } else {
            delete_user_meta($user_id, $this->getName());

            array_walk($value, function ($val) use ($user_id) {
                add_user_meta($user_id, $this->getName(), $val, false);
            });
        }
    }
37661
public function setCurrent($userid)
	{
		$this->debug->groupCollapsed(__METHOD__, $userid);
		Session::start();
		$user = $this->get($userid);
		// initialize session array
		ArrayUtil::path($_SESSION, $this->cfg['sessionPath'], array());
		// create link to session array
		// $this->user = &ArrayUtil::path($_SESSION, $this->cfg['sessionPath']);
        $path = $this->cfg['sessionPath'];
        if (!\is_array($path)) {
            $path = \array_filter(\preg_split('#[\./]#', $path), 'strlen');
        }
        $this->user =& $_SESSION;
        foreach ($path as $k) {
        	if (!isset($this->user[$k])) {
        		$this->user[$k] = array();
        	}
        	$this->user =& $this->user[$k];
        }
		// load session array
		$this->user = $user;
		$this->user['_ts_cur'] = time();
		$this->userid = $this->user['userid'];
		$this->update(array('lastactivity'=>'NOW()'));
		$this->debug->groupEnd();
		return;
	}
755175
public function update(array $values)
    {
        $result = $this->getBuilder()->update($values);

        // Reset query builder
        $this->resetBuilder();

        return (int) $result;
    }
1237570
public function update(array $values)
    {
        if (!$this->hasId()) {
            throw new UpdateException('ID not set - did you call find($id) before update($values)?');
        }

        if (!$this->isUpdatable()) {
            throw new UpdateException('Permission denied: Entity can not be updated');
        }

        $this->transactional(function () use ($values) {
            $this->forceUpdate($values);
        });

        return $this;
    }
33625
public function createOrUpdateAuthRecord($userId) {
        $token = $this->_getToken($userId);
        $authPwlessModel = new Model_AuthPasswordless();
        $select = $authPwlessModel->select()->where('user_id = ?', $userId);
        if ($authRecord = $authPwlessModel->fetchRow($select)) {
            $authPwlessModel->update(
                array(
                    'token' => $token,
                    'token_expiration_date' => $this->_getExpirationDate(),
                    'claimed' => 0
                ), 'id = ' . $authRecord->id
            );
            return $token;
        }
        $authPwlessModel->insert(
            array(
                'user_id' => $userId,
                'token' => $token,
                'token_expiration_date' => $this->_getExpirationDate()
            )
        );
        return $token;
    }
404152
public function userGet(int $user_id)
    {
        $value = get_user_meta($user_id, $this->getName(), true);

        if (! empty($value)) {
            $this->setValue($value);
        }
    }
212113
public function delete($userid)
	{
		$event = new Event('onPlatformUserDelete');
		$event->addArgument('userid', $userid);
		$event->addArgument('activePlugin', $this->activePlugin);

		Factory::getDispatcher()->triggerEvent($event);

		$debug = $event->getArgument('debug', null);
		if ($debug) {
			$this->debug[] = $debug;
		}

		$error = $event->getArgument('error', null);
		if ($error) {
			$this->error[] = $error;
		}
	}
357644
public function saveSubscription(int $userId = null) : void
    {
        $json = \file_get_contents('php://input');

        if (!$json)
        {
            return;
        }

        $data = \json_decode($json, true);

        if (!$data || empty($data['endpoint']) || empty($data['publicKey']) || empty($data['authToken']))
        {
            return;
        }

        $row = $this->subscriptionTable->findActive()->where('endpoint', $data['endpoint'])->fetch();

        switch ($this->request->getMethod()) {
            case 'POST':
            case 'PUT':
            {
                if ($row)
                {
                    $row->update([
                        'user_id' => $userId ?: $row->user_id ?: null,
                        'key' => $data['publicKey'],
                        'token' => $data['authToken'],
                        'encoding' => $data['contentEncoding']
                    ]);
                    
                    return;
                }

                $row = $this->subscriptionTable->insert([
                    'user_id' => $userId,
                    'endpoint' => $data['endpoint'],
                    'key' => $data['publicKey'],
                    'token' => $data['authToken'],
                    'encoding' => $data['contentEncoding']
                ]);

                $this->sendNotification($row, 'Notifications enabled!', true);

                return;
            }
            case 'DELETE':
            {
                if ($row)
                {
                    $row->update([
                        'active' => 0
                    ]);
                }

                return;
            }
            default:
                throw new \Nette\Application\BadRequestException();
        }
    }
1063137
public function setHasRespondents($userId)
    {
        if (! $this->_get('gor_has_respondents')) {
            $values['gor_has_respondents'] = 1;
            $values['gor_changed']         = new \MUtil_Db_Expr_CurrentTimestamp();
            $values['gor_changed_by']      = $userId;

            $where = $this->db->quoteInto('gor_id_organization = ?', $this->_id);

            $this->db->update('gems__organizations', $values, $where);

            // Invalidate cache / change value
            $this->_set('gor_has_respondents', 1);
        }

        return $this;
    }