ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ILIAS\Notifications\Provider\AwarenessToastProvider Class Reference
+ Inheritance diagram for ILIAS\Notifications\Provider\AwarenessToastProvider:
+ Collaboration diagram for ILIAS\Notifications\Provider\AwarenessToastProvider:

Public Member Functions

 getToasts ()
 
- Public Member Functions inherited from ILIAS\GlobalScreen\Scope\Toast\Provider\AbstractToastProvider
 __construct (Container $dic)
 
- Public Member Functions inherited from ILIAS\GlobalScreen\Provider\AbstractProvider
 __construct (Container $dic)
 
 getFullyQualifiedClassName ()
 
 getProviderNameForPresentation ()
 

Data Fields

const MAX_ONLINE_USER_COUNT = 20
 

Private Attributes

const PROVIDER_KEY = 'awareness'
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS\GlobalScreen\Provider\AbstractProvider
 globalScreen ()
 
- Protected Attributes inherited from ILIAS\GlobalScreen\Scope\Toast\Provider\AbstractToastProvider
Container $dic
 
ILIAS UI Factory $ui_factory
 
IdentificationProviderInterface $if
 
ToastFactory $toast_factory
 
- Protected Attributes inherited from ILIAS\GlobalScreen\Provider\AbstractProvider
Container $dic
 

Detailed Description

Author
Ingmar Szmais iszma.nosp@m.is@d.nosp@m.ataba.nosp@m.y.de

Definition at line 34 of file AwarenessToastProvider.php.

Member Function Documentation

◆ getToasts()

ILIAS\Notifications\Provider\AwarenessToastProvider::getToasts ( )

Implements ILIAS\GlobalScreen\Scope\Toast\Provider\ToastProvider.

Definition at line 43 of file AwarenessToastProvider.php.

References $id, ILIAS\$setting, ILIAS\LTI\ToolProvider\$settings, ANONYMOUS_USER_ID, ILIAS\UI\Implementation\Component\Toast\Toast\DEFAULT_DELAY_TIME, ILIAS\UI\Implementation\Component\Toast\Toast\DEFAULT_VANISH_TIME, ilSetting\get(), ilUserUtil\getNamePresentation(), ILIAS\Awareness\User\Collector\getOnlineUsers(), if, and IL_CAL_DATETIME.

43  : array
44  {
45  $this->dic->language()->loadLanguageModule('awrn');
46  $settings = new ilSetting('awrn');
47 
48  $toasts = [];
49  if (
50  $settings->get('awrn_enabled', '0') !== '1' ||
51  $settings->get('use_osd', '0') !== '1' ||
52  0 === $this->dic->user()->getId() ||
53  $this->dic->user()->isAnonymous()
54  ) {
55  return $toasts;
56  }
57 
58  $users = Collector::getOnlineUsers();
59  unset($users[$this->dic->user()->getId()], $users[ANONYMOUS_USER_ID]);
60  $users = array_slice($users, 0, self::MAX_ONLINE_USER_COUNT, true);
61 
62  $new_user_ids = [];
63  foreach ($users as $id => $user) {
64  $time = (new ilDateTime($user['last_login'], IL_CAL_DATETIME, $this->dic->user()->getTimeZone()))->getUnixTime();
65  if ($time >= (time() - ($this->dic->http()->request()->getQueryParams()['max_age'] ?? 0))) {
66  $new_user_ids[] = $id;
67  }
68  }
69 
71  $new_user_ids,
72  true,
73  false,
74  "",
75  false,
76  false,
77  true,
78  true
79  );
80 
81  if ($new_users !== []) {
82  $setting = new ilSetting('notifications');
83  $toast = $this->toast_factory
84  ->standard(
85  $this->if->identifier(self::PROVIDER_KEY . '_' . $this->dic->user()->getId()),
86  $this->dic->language()->txt('awareness_now_online')
87  )
88  ->withIcon($this->dic->ui()->factory()->symbol()->icon()->standard(Standard::USR, ''))
89  ->withVanishTime((int) $setting->get('osd_vanish', (string) Toast::DEFAULT_VANISH_TIME))
90  ->withDelayTime((int) $setting->get('osd_delay', (string) Toast::DEFAULT_DELAY_TIME));
91  $links = [];
92  foreach ($new_users as $user) {
93  $uname = "[" . $user['login'] . "]";
94  if ($user['public_profile']) {
95  $uname = $user['lastname'] . ", " . $user['firstname'] . " " . $uname;
96  }
97 
98  $toast = $toast->withAdditionToastAction(
99  $this->toast_factory->action(
100  self::PROVIDER_KEY . '_' . $user['id'],
101  $uname,
102  function () use ($user): void {
103  $this->dic->ctrl()->redirectToURL('/goto.php?target=usr_' . $user['id']);
104  }
105  )
106  );
107  }
108 
109  $toasts = [$toast];
110  }
111 
112  return $toasts;
113  }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
get(string $a_keyword, ?string $a_default_value=null)
get setting
const IL_CAL_DATETIME
const ANONYMOUS_USER_ID
Definition: constants.php:27
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link="", bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
ilSetting $setting
Definition: class.ilias.php:54
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

Field Documentation

◆ MAX_ONLINE_USER_COUNT

const ILIAS\Notifications\Provider\AwarenessToastProvider::MAX_ONLINE_USER_COUNT = 20

Definition at line 38 of file AwarenessToastProvider.php.

◆ PROVIDER_KEY

const ILIAS\Notifications\Provider\AwarenessToastProvider::PROVIDER_KEY = 'awareness'
private

Definition at line 36 of file AwarenessToastProvider.php.


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