Set notification settings for given user.
326311
public static function setSendUserSettings($destination, $account, $values) {
    if (is_object($account) && !empty($values)) {
      foreach ($values as $message_template => $frequency) {
        $query = \Drupal::database()->merge('user_activity_send');
        $query->fields([
          'uid' => $account->id(),
          'destination' => $destination,
          'message_template' => $message_template,
          'frequency' => $frequency,
        ]);
        $query->keys([
          'uid' => $account->id(),
          'destination' => $destination,
          'message_template' => $message_template,
        ]);
        $query->execute();
      }
    }
  }
466639
def notify(self, state, notifications):
        '''
        
        '''

        def do_append(desc, notifications):
            for notification in notifications:
                if not isinstance(notification, PendingNotification):
                    raise ValueError("Expected notify() params to be a list "
                                     "of PendingNotification instance, got %r."
                                     % notification)
                key = str(notification.recipient.key)
                if key not in desc.pending_notifications:
                    desc.pending_notifications[key] = list()
                desc.pending_notifications[key].append(notification)

        return state.agent.update_descriptor(do_append, notifications)
267761
function updateUserSettings(userId, settings, overwrite, callback) {
        return _updateUserObjectField(userId, ['settings'], settings, overwrite)
            .then(function (userData) {
                return userData.settings;
            })
            .nodeify(callback);
    }
618013
def send_reminder(self, user, sender=None, **kwargs):
        """"""
        if user.is_active:
            return False
        token = RegistrationTokenGenerator().make_token(user)
        kwargs.update({"token": token})
        self.email_message(
            user, self.reminder_subject, self.reminder_body, sender, **kwargs
        ).send()
1153704
public MaterialSection setNotifications(int notifications) {
        String textNotification;

        textNotification = String.valueOf(notifications);

        if(notifications < 1) {
            textNotification = "";
        }
        if(notifications > 99) {
            textNotification = "99+";
        }

        this.notifications.setText(textNotification);
        numberNotifications = notifications;

        return this;
    }
661503
private function set_notification_language($user) {
        global $CFG;

        // Copied from current_language().
        if (!empty($user->lang)) {
            $lang = $user->lang;
        } else if (isset($CFG->lang)) {
            $lang = $CFG->lang;
        } else {
            $lang = 'en';
        }
        force_current_language($lang);
    }
513513
def get_notifications(user):
    ''''''
    notifications = []

    for name, func in _providers.items():
        notifications.extend([{
            'type': name,
            'created_on': dt,
            'details': details
        } for dt, details in func(user)])

    return notifications
1223255
def _update_notification(self, message=None):
        """"""
        if message is None:
            message = ''
        message_label = self._parts['notification label']
        message_label.config(text=message)
        self._base.update()
36658
def notify(cls, user_or_email, instance):
        """"""
        return super(InstanceEvent, cls).notify(user_or_email,
                                                object_id=instance.pk)
525000
private void setNotificationOptions(Context context,MFPPushNotificationOptions options) {

    if (this.appContext == null) {
      this.appContext = context.getApplicationContext();
    }
    this.options = options;
    Gson gson = new Gson();
    String json = gson.toJson(options);
    SharedPreferences sharedPreferences = appContext.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
    MFPPushUtils.storeContentInSharedPreferences(sharedPreferences, MFPPush.PREFS_MESSAGES_OPTIONS, json);
  }
1279795
public function notifyUser()
    {
        switch ($this->type) {
            case self::TYPE_PASSWORD_RESET:
                $event = new PasswordReset;
                break;
            case self::TYPE_ACTIVATION:
                $event = new UserActivation;
                break;
            case self::TYPE_INVITATION:
                $event = new UserInvitation;
                break;
        }

        $this->user->notify($event);
    }
626075
def set_user(user, sender, instance, **kwargs):
        
        try:
            app_label, model_name = settings.AUTH_USER_MODEL.split('.')
            auth_user_model = apps.get_model(app_label, model_name)
        except ValueError:
            auth_user_model = apps.get_model('auth', 'user')
        if sender == LogAction and isinstance(user, auth_user_model) and instance.user is None:
            instance.user = user
        if hasattr(threadlocal, 'actionslog'):
            instance.remote_ip = threadlocal.actionslog['remote_ip']
595773
def save(self, *args, **kwargs):
        
        created = self.pk is None

        # save notification to database only if user settings allow it
        if self.check_user_settings(medium='web'):
            super(Notification, self).save(*args, **kwargs)

        if created:
            # send notifications through other mediums according to user settings
            self.send_notifications()
542100
def _add_notification(self, message):
        
        sess = cherrypy.session
        username = sess.get(SESSION_KEY, None)
        if username not in self.notifications:
            self.notifications[username] = []
        self.notifications[username].append(message)
931787
def set_notification_callback(self, notification_cb):
    """"""
    self._notification_cb = notification_cb
    if not notification_cb and self.dimensions:
      self.measured_value.notify_value_set = None
    return self
634158
protected function overrideNotificationMiddleware(): void
    {
        $this->app->singleton('Cortex\Foundation\Http\Middleware\NotificationMiddleware', function ($app) {
            return new NotificationMiddleware(
                $app['session.store'],
                $app['notification'],
                $app['config']->get('notification.session_key')
            );
        });
    }
244128
def _Notify(username, notification_type, message, object_reference):
  """"""

  # Do not try to notify system users (e.g. Cron).
  if username in aff4_users.GRRUser.SYSTEM_USERS:
    return

  if object_reference:
    uc = object_reference.UnionCast()
    if hasattr(uc, "client_id"):
      message = _HostPrefix(uc.client_id) + message

  n = rdf_objects.UserNotification(
      username=username,
      notification_type=notification_type,
      state=rdf_objects.UserNotification.State.STATE_PENDING,
      message=message,
      reference=object_reference)
  data_store.REL_DB.WriteUserNotification(n)