ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Notifications\UserSettings\PushNotification Class Reference
+ Inheritance diagram for ILIAS\Notifications\UserSettings\PushNotification:
+ Collaboration diagram for ILIAS\Notifications\UserSettings\PushNotification:

Public Member Functions

 getIdentifier ()
 
 isAvailable ()
 If this function returns false the setting will not be shown, even if it's PropertyAttributes would allow it to be. More...
 
 getLabel (Language $lng)
 
 getSettingsPage ()
 
 getSection ()
 
 getInput (FieldFactory $field_factory, Language $lng, Refinery $refinery, ilSetting $settings, ?ilObjUser $user=null)
 
 getLegacyInput (Language $lng, ilSetting $settings, ?ilObjUser $user=null)
 
 getDefaultValueForDisplay (Language $lng, ilSetting $settings)
 
 hasUserPersonalizedSetting (ilSetting $settings, ilObjUser $user)
 
 persistUserInput (ilObjUser $user, mixed $input)
 
 retrieveValueFromUser (ilObjUser $user)
 
- Public Member Functions inherited from ILIAS\User\Settings\SettingDefinition
 isAvailable ()
 If this function returns false the setting will not be shown, even if it's PropertyAttributes would allow it to be. More...
 
 getSettingsPage ()
 
 getDefaultValueForDisplay (Language $lng, \ilSetting $settings)
 
 hasUserPersonalizedSetting (\ilSetting $settings, \ilObjUser $user)
 
 getInput (FieldFactory $field_factory, Language $lng, Refinery $refinery, \ilSetting $settings, ?\ilObjUser $user=null)
 
 getLegacyInput (Language $lng, \ilSetting $settings, ?\ilObjUser $user=null)
 You don't need to add a post_var to the input as the User will handle this for you, thus you can also not rely on the post_var anywhere else, as it will be changed. More...
 
 persistUserInput (\ilObjUser $user, mixed $input)
 
- Public Member Functions inherited from ILIAS\User\Property
 getIdentifier ()
 
 getLabel (Language $lng)
 
 getSection ()
 
 retrieveValueFromUser (\ilObjUser $user)
 

Detailed Description

Definition at line 39 of file PushNotification.php.

Member Function Documentation

◆ getDefaultValueForDisplay()

ILIAS\Notifications\UserSettings\PushNotification::getDefaultValueForDisplay ( Language  $lng,
ilSetting  $settings 
)

Definition at line 98 of file PushNotification.php.

98 : string
99 {
100 return $lng->txt('none');
101 }
global $lng
Definition: privfeed.php:31

References $lng.

◆ getIdentifier()

ILIAS\Notifications\UserSettings\PushNotification::getIdentifier ( )

Implements ILIAS\User\Property.

Definition at line 41 of file PushNotification.php.

41 : string
42 {
43 return 'push_notification';
44 }

Referenced by ILIAS\Notifications\UserSettings\PushNotification\getLabel().

+ Here is the caller graph for this function:

◆ getInput()

ILIAS\Notifications\UserSettings\PushNotification::getInput ( FieldFactory  $field_factory,
Language  $lng,
Refinery  $refinery,
ilSetting  $settings,
?ilObjUser  $user = null 
)

Definition at line 67 of file PushNotification.php.

73 : Input {
74 $lng->loadLanguageModule('notifications_adm');
75
76 $pref = $user ? $this->retrieveValueFromUser($user) : [];
77 $provider = [];
78
79 foreach (require PushNotificationObjective::PATH() as $class) {
80 $obj = new $class();
81 $provider[$obj->getIdentifier()] = $field_factory->checkbox(
82 $obj->getName($lng),
83 $obj->getDescription($lng),
84 )->withValue(in_array($obj->getIdentifier(), $pref));
85 }
86
87 return $field_factory->section(
89 $lng->txt('push_settings')
90 );
91 }
$provider
Definition: ltitoken.php:80

References $lng, and $provider.

◆ getLabel()

ILIAS\Notifications\UserSettings\PushNotification::getLabel ( Language  $lng)

Definition at line 51 of file PushNotification.php.

51 : string
52 {
53 $lng->loadLanguageModule('notifications');
54 return $lng->txt($this->getIdentifier());
55 }

References $lng, and ILIAS\Notifications\UserSettings\PushNotification\getIdentifier().

+ Here is the call graph for this function:

◆ getLegacyInput()

ILIAS\Notifications\UserSettings\PushNotification::getLegacyInput ( Language  $lng,
ilSetting  $settings,
?ilObjUser  $user = null 
)

Definition at line 93 of file PushNotification.php.

94 {
95 throw new Exception('This Setting does not provide an legacy Input.');
96 }
This class represents a property in a property form.

◆ getSection()

ILIAS\Notifications\UserSettings\PushNotification::getSection ( )

Implements ILIAS\User\Property.

Definition at line 62 of file PushNotification.php.

63 {
64 return AvailableSections::Communication;
65 }

◆ getSettingsPage()

ILIAS\Notifications\UserSettings\PushNotification::getSettingsPage ( )

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 57 of file PushNotification.php.

58 {
59 return AvailablePages::MainSettings;
60 }

◆ hasUserPersonalizedSetting()

ILIAS\Notifications\UserSettings\PushNotification::hasUserPersonalizedSetting ( ilSetting  $settings,
ilObjUser  $user 
)

Definition at line 103 of file PushNotification.php.

103 : bool
104 {
105 return $user->getPref('push_notification_provider') !== null;
106 }
getPref(string $a_keyword)

References ilObjUser\getPref().

+ Here is the call graph for this function:

◆ isAvailable()

ILIAS\Notifications\UserSettings\PushNotification::isAvailable ( )

If this function returns false the setting will not be shown, even if it's PropertyAttributes would allow it to be.

This is meant e.g. to check if the chat server is configured or the badges enabled. Settings that are not available will also not be available on the table to define their PropertyAttributes

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 46 of file PushNotification.php.

46 : bool
47 {
48 return (new ilSetting('notifications'))->get('enable_push') === '1' && count(require PushNotificationObjective::PATH()) > 0;
49 }
ILIAS Setting Class.

References ILIAS\Setup\Artifact\BuildArtifactObjective\PATH().

+ Here is the call graph for this function:

◆ persistUserInput()

ILIAS\Notifications\UserSettings\PushNotification::persistUserInput ( ilObjUser  $user,
mixed  $input 
)

Definition at line 108 of file PushNotification.php.

108 : ilObjUser
109 {
110 $active = [];
111 foreach ($input ?? [] as $key => $value) {
112 if ($value === true) {
113 $active[] = $key;
114 }
115 }
116 $user->setPref('push_notification_provider', json_encode($active));
117 $user->update();
118 return $user;
119 }
User class.
setPref(string $a_keyword, ?string $a_value)

References ilObjUser\setPref(), and ilObjUser\update().

+ Here is the call graph for this function:

◆ retrieveValueFromUser()

ILIAS\Notifications\UserSettings\PushNotification::retrieveValueFromUser ( ilObjUser  $user)

Definition at line 121 of file PushNotification.php.

121 : ?array
122 {
123 return json_decode($user->getPref('push_notification_provider') ?? '[]');
124 }

References ilObjUser\getPref().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: