Saves the current time for a user as an option if the current request is for something
in the reporting UI, the current user is not anonymous and the time hasn't been saved
in the last 5 minutes.
335414
public function logCurrentUserLastSeenTime()
    {
        $module = Common::getRequestVar('module', false);
        $currentUserLogin = Piwik::getCurrentUserLogin();

        // only log time for non-anonymous visits to the reporting UI
        if ($module == 'API'
            || $module == 'Proxy'
            || Piwik::isUserIsAnonymous()
        ) {
            return;
        }

        // get the last known time
        $optionName = self::OPTION_PREFIX . $currentUserLogin;
        $lastSeen = Option::get($optionName);

        // do not log if last known time is less than N minutes from now (so we don't make too many
        // queries)
        if (time() - $lastSeen <= self::LAST_TIME_SAVE_DELTA) {
            return;
        }

        // log last seen time (Note: autoload is important so the Option::get above does not result in
        // a separate query)
        Option::set($optionName, time(), $autoload = 1);
    }
931131
def save(self):
        
        if not self.vads_trans_date:
            self.vads_trans_date = datetime.datetime.utcnow().replace(
                tzinfo=utc).strftime("%Y%m%d%H%M%S")
        if not self.vads_trans_id:
            self.vads_trans_id = tools.get_vads_trans_id(
                self.vads_site_id, self.vads_trans_date)
        if self.theme and not self.vads_theme_config:
            self.vads_theme_config = str(self.theme)
        if not self.pk:
            super(PaymentRequest, self).save()
        self.set_vads_payment_config()
        self.set_signature()
        super(PaymentRequest, self).save()
564933
function reportTime(params, callback) {
  var validated_params,
      req_params;

  try {
    validated_params = internals.validateReportTimeParams(params);
  }
  catch (e) {
    setImmediate(callback, e);
    return;
  }

  req_params = internals.createReportTimeRequestParams(validated_params);
  api_service.makeRequest(req_params, callback);
}
838927
def process_request(self, request):
        
        
        if django.VERSION < (1, 10):
            is_authenticated = request.user.is_authenticated()
        else:
            is_authenticated = request.user.is_authenticated

        if not is_authenticated:
            return

        now = datetime.now()
        if '_session_security' not in request.session:
            set_last_activity(request.session, now)
            return

        delta = now - get_last_activity(request.session)
        expire_seconds = self.get_expire_seconds(request)
        if delta >= timedelta(seconds=expire_seconds):
            logout(request)
        elif (request.path == reverse('session_security_ping') and
                'idleFor' in request.GET):
            self.update_last_activity(request, now)
        elif not self.is_passive_request(request):
            set_last_activity(request.session, now)
1241427
def save(self, *args, **kwargs):
        
        self._pre_save(*args, **kwargs)
        response = self._save(*args, **kwargs)
        response = self._post_save(response, *args, **kwargs)
        return response
1028292
def save(self, *args, **kwargs):
        """"""
        if self.timestamp is None:
            self.timestamp = timezone.now()

        super().save(*args, **kwargs)
1312414
private void saveRegisterWatermarkTimer() {
		long currentWatermark = timerService.currentWatermark();
		// protect against overflow
		if (currentWatermark + 1 > currentWatermark) {
			timerService.registerEventTimeTimer(VoidNamespace.INSTANCE, currentWatermark + 1);
		}
	}
1069412
function saveUser(user, req, cb) {
  user.markModified('attributes');
  user.markModified('password');
  if (user.extensionattributes && user.extensionattributes.login && user.extensionattributes.login.flagged) {
    user.extensionattributes.login.flagged = false;
    user.extensionattributes.login.attempts = 0;
    user.extensionattributes.login.timestamp = moment().subtract(loginExtSettings.timeout.attempt_interval.time, loginExtSettings.timeout.attempt_interval.unit);
    user.markModified('extensionattributes');
  }
  user.save(function (err, usr) {
    if (err) {
      cb(err, null);
    }
    cb(null, usr, req);
  });
}
143265
def set_client_user_consent(self):
        
        date_given = timezone.now()
        expires_at = date_given + timedelta(
            days=settings.get('OIDC_SKIP_CONSENT_EXPIRE'))

        uc, created = UserConsent.objects.get_or_create(
            user=self.request.user,
            client=self.client,
            defaults={
                'expires_at': expires_at,
                'date_given': date_given,
            }
        )
        uc.scope = self.params['scope']

        # Rewrite expires_at and date_given if object already exists.
        if not created:
            uc.expires_at = expires_at
            uc.date_given = date_given

        uc.save()
891835
def get_time_now(self):
        """"""
        import datetime
        import getpass
        username = getpass.getuser()
        # this is not working on some systems: os.environ["USERNAME"]
        timenow = str(datetime.datetime.now())
        timenow = timenow.split('.')[0]
        msg = '<div class="date">Created on ' + timenow
        msg += " by " + username +'</div>'
        return msg
128360
function (time) {
    var data = this.data;
    var prevCheckTime = this.prevCheckTime;

    if (!data.enabled) { return; }

    // Only check for intersection if interval time has passed.
    if (prevCheckTime && (time - prevCheckTime < data.interval)) { return; }

    // Update check time.
    this.prevCheckTime = time;
    this.checkIntersections();
  }
1026646
def set_current_time(self, t):
        

        method = "set_current_time"

        A = None
        metadata = {method: t}

        send_array(self.socket, A, metadata)
        A, metadata = recv_array(
            self.socket, poll=self.poll, poll_timeout=self.poll_timeout,
            flags=self.zmq_flags)
273462
def pre_save(sender, instance, raw, using, update_fields, **kwargs):
    """"""
    if raw:
        # Return if loading Fixtures
        return

    try:
        with transaction.atomic():
            if not should_audit(instance):
                return False
            try:
                object_json_repr = serializers.serialize("json", [instance])
            except Exception:
                # We need a better way for this to work. ManyToMany will fail on pre_save on create
                return None

            if instance.pk is None:
                created = True
            else:
                created = False

            # created or updated?
            if not created:
                old_model = sender.objects.get(pk=instance.pk)
                delta = model_delta(old_model, instance)
                changed_fields = json.dumps(delta)
                event_type = CRUDEvent.UPDATE

            # user
            try:
                user = get_current_user()
                # validate that the user still exists
                user = get_user_model().objects.get(pk=user.pk)
            except:
                user = None

            if isinstance(user, AnonymousUser):
                user = None

            # callbacks
            kwargs['request'] = get_current_request()  # make request available for callbacks
            create_crud_event = all(
                callback(instance, object_json_repr, created, raw, using, update_fields, **kwargs)
                for callback in CRUD_DIFFERENCE_CALLBACKS if callable(callback))
            # create crud event only if all callbacks returned True
            if create_crud_event and not created:
                c_t = ContentType.objects.get_for_model(instance)
                sid = transaction.savepoint()
                try:
                    with transaction.atomic():
                        crud_event = CRUDEvent.objects.create(
                            event_type=event_type,
                            object_repr=str(instance),
                            object_json_repr=object_json_repr,
                            changed_fields=changed_fields,
                            content_type_id=c_t.id,
                            object_id=instance.pk,
                            user_id=getattr(user, 'id', None),
                            datetime=timezone.now(),
                            user_pk_as_string=str(user.pk) if user else user
                        )
                except Exception as e:
                    logger.exception(
                        "easy audit had a pre-save exception on CRUDEvent creation. instance: {}, instance pk: {}".format(
                            instance, instance.pk))
                    transaction.savepoint_rollback(sid)
    except Exception:
        logger.exception('easy audit had a pre-save exception.')
544013
def reject_user_timesheet(request, user_id):
    
    form = YearMonthForm(request.GET or request.POST)
    user = User.objects.get(pk=user_id)
    if form.is_valid():
        from_date, to_date = form.save()
        entries = Entry.no_join.filter(
            status=Entry.VERIFIED, user=user, start_time__gte=from_date,
            end_time__lte=to_date)
        if request.POST.get('yes'):
            if entries.exists():
                count = entries.count()
                Entry.no_join.filter(pk__in=entries).update(status=Entry.UNVERIFIED)
                msg = 'You have rejected %d previously verified entries.' \
                    % count
            else:
                msg = 'There are no verified entries to reject.'
            messages.info(request, msg)
        else:
            return render(request, 'timepiece/user/timesheet/reject.html', {
                'date': from_date,
                'timesheet_user': user
            })
    else:
        msg = 'You must provide a month and year for entries to be rejected.'
        messages.error(request, msg)

    url = reverse('view_user_timesheet', args=(user_id,))
    return HttpResponseRedirect(url)
506860
function(user) {
      if (Parse.User._currentUser !== user) {
        Parse.User.logOut();
      }
      user._isCurrentUser = true;
      Parse.User._currentUser = user;
      Parse.User._currentUserMatchesDisk = true;

      var json = user.toJSON();
      json._id = user.id;
      json._sessionToken = user._sessionToken;
      Parse.localStorage.setItem(
          Parse._getParsePath(Parse.User._CURRENT_USER_KEY),
          JSON.stringify(json));
    }
27256
protected function saveData()
    {
        if ($this->trackEngine) {
            // concatenate user input (gtf_field fields)
            // before the data is saved (the fields them
            $this->formData['gr2t_track_info'] = $this->trackEngine->calculateFieldsInfo($this->formData);
        }

        // Perform the save
        $model          = $this->getModel();
        $this->formData = $model->save($this->formData);
        $changed        = $model->getChanged();
        $refresh        = false;

        // Retrieve the key if just created
        if ($this->createData) {
            $this->respondentTrackId = $this->formData['gr2t_id_respondent_track'];
            $this->respondentTrack   = $this->loader->getTracker()->getRespondentTrack($this->formData);
            
            // Explicitly save the fields as the transformer in the model only handles
            // before save event (like default values) for existing respondenttracks
            $this->respondentTrack->setFieldData($this->formData);

            // Create the actual tokens!!!!
            $this->trackEngine->checkRoundsFor($this->respondentTrack, $this->userId);
            $refresh = true;

        } else {
            // Check if the input has changed, i.e. one of the dates may have changed
            $refresh = (boolean) $changed;
        }

        if ($refresh) {
            // Perform a refresh from the database, to avoid date trouble
            $this->respondentTrack->refresh();
            $this->respondentTrack->checkTrackTokens($this->userId);
        }


        // Communicate with the user
        $this->afterSave($changed);
    }
859731
def _is_logged_in(self):
        
        # if the user has not logged in in 24 hours, relogin
        if not self._http._has_session() or datetime.utcnow() >= self._lastlogin + timedelta(hours=24):
            return self._login()
        else:
            return {}