ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
ilChatUserActionProvider Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilChatUserActionProvider:
+ Collaboration diagram for ilChatUserActionProvider:

Public Member Functions

 __construct ()
 
 getComponentId ()
 
 getActionTypes ()
 
 collectActionsForTargetUser (int $a_target_user)
 Collect all actions. More...
 
- Public Member Functions inherited from ilUserActionProvider
 __construct ()
 
 setUserId (int $a_val)
 
 getUserId ()
 
 collectActionsForTargetUser (int $a_target_user)
 Collect actions for a target user. More...
 
 getComponentId ()
 
 getActionTypes ()
 
 getJsScripts (string $a_action_type)
 

Protected Member Functions

 checkUserChatAccess (int $a_user_id)
 
 acceptsMessages (int $a_user_id)
 

Protected Attributes

int $pub_ref_id = 0
 
bool $chat_enabled = false
 
bool $osc_enabled = false
 
- Protected Attributes inherited from ilUserActionProvider
int $user_id
 
ilLanguage $lng
 
ilDBInterface $db
 

Static Protected Attributes

static array $user_access = array()
 
static array $accepts_messages_cache = array()
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Adds link to chat

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 23 of file class.ilChatUserActionProvider.php.

Constructor & Destructor Documentation

◆ __construct()

ilChatUserActionProvider::__construct ( )

Reimplemented from ilUserActionProvider.

Definition at line 33 of file class.ilChatUserActionProvider.php.

34 {
36
37 $this->pub_ref_id = ilObjChatroom::_getPublicRefId();
38
39 $chatSettings = new ilSetting('chatroom');
40 $this->chat_enabled = (bool) $chatSettings->get('chat_enabled');
41 $this->osc_enabled = (bool) $chatSettings->get('enable_osc');
42
43 $this->lng->loadLanguageModule('chatroom');
44 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct(), ilObjChatroom\_getPublicRefId(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Member Function Documentation

◆ acceptsMessages()

ilChatUserActionProvider::acceptsMessages ( int  $a_user_id)
protected

Definition at line 71 of file class.ilChatUserActionProvider.php.

71 : bool
72 {
73 if (!array_key_exists($a_user_id, self::$accepts_messages_cache)) {
74 self::$accepts_messages_cache[$a_user_id] = ilUtil::yn2tf(
75 ilObjUser::_lookupPref($a_user_id, 'chat_osc_accept_msg') ?? 'n'
76 );
77 }
78
79 return (bool) self::$accepts_messages_cache[$a_user_id];
80 }
static _lookupPref(int $a_usr_id, string $a_keyword)
static yn2tf(string $a_yn)

References ilObjUser\_lookupPref(), and ilUtil\yn2tf().

Referenced by collectActionsForTargetUser().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkUserChatAccess()

ilChatUserActionProvider::checkUserChatAccess ( int  $a_user_id)
protected

Definition at line 62 of file class.ilChatUserActionProvider.php.

62 : bool
63 {
64 if (!array_key_exists($a_user_id, self::$user_access)) {
65 self::$user_access[$a_user_id] = $GLOBALS['DIC']->rbac()->system()->checkAccessOfUser($a_user_id, 'read', $this->pub_ref_id);
66 }
67
68 return self::$user_access[$a_user_id];
69 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64

References $GLOBALS.

Referenced by collectActionsForTargetUser().

+ Here is the caller graph for this function:

◆ collectActionsForTargetUser()

ilChatUserActionProvider::collectActionsForTargetUser ( int  $a_target_user)

Collect all actions.

Reimplemented from ilUserActionProvider.

Definition at line 85 of file class.ilChatUserActionProvider.php.

86 {
88
89 if (!$this->chat_enabled) {
90 return $coll;
91 }
92
93 if ($this->checkUserChatAccess($this->getUserId()) && $a_target_user != $this->getUserId()) {
94 if ($this->checkUserChatAccess($a_target_user)) {
95 $f = new ilUserAction();
96 $f->setType("invite");
97 $f->setText($this->lng->txt('chat_invite_public_room'));
98 $f->setHref('./ilias.php?baseClass=ilRepositoryGUI&ref_id=' . $this->pub_ref_id . '&usr_id=' . $a_target_user . '&cmd=view-invitePD');
99 $coll->addAction($f);
100 }
101 }
102
103 if ($this->osc_enabled && $a_target_user != $this->getUserId()) {
104 $f = new ilUserAction();
105 $f->setHref('#');
106 $f->setType("invite_osd");
107 if ($this->acceptsMessages($a_target_user)) {
108 $f->setText($this->lng->txt('chat_osc_start_conversation'));
109 $f->setData(array(
110 'onscreenchat-userid' => $a_target_user,
111 'onscreenchat-username' => ilObjUser::_lookupLogin($a_target_user)
112 ));
113 } else {
114 $f->setText($this->lng->txt('chat_osc_doesnt_accept_msg'));
115 $f->setData(array(
116 'onscreenchat-inact-userid' => $a_target_user
117 ));
118 }
119 $coll->addAction($f);
120 }
121
122 return $coll;
123 }
static _lookupLogin(int $a_user_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References Vendor\Package\$f, ilObjUser\_lookupLogin(), acceptsMessages(), checkUserChatAccess(), ilUserActionCollection\getInstance(), ilUserActionProvider\getUserId(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getActionTypes()

ilChatUserActionProvider::getActionTypes ( )
Returns
array<string,string>

Reimplemented from ilUserActionProvider.

Definition at line 54 of file class.ilChatUserActionProvider.php.

54 : array
55 {
56 return array(
57 "invite" => $this->lng->txt('chat_user_action_invite_public_room'),
58 "invite_osd" => $this->lng->txt('chat_user_action_invite_osd')
59 );
60 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getComponentId()

ilChatUserActionProvider::getComponentId ( )
Returns
string component id as defined in services.xml/module.xml

Reimplemented from ilUserActionProvider.

Definition at line 46 of file class.ilChatUserActionProvider.php.

46 : string
47 {
48 return "chtr";
49 }

Field Documentation

◆ $accepts_messages_cache

array ilChatUserActionProvider::$accepts_messages_cache = array()
staticprotected

Definition at line 28 of file class.ilChatUserActionProvider.php.

◆ $chat_enabled

bool ilChatUserActionProvider::$chat_enabled = false
protected

Definition at line 30 of file class.ilChatUserActionProvider.php.

◆ $osc_enabled

bool ilChatUserActionProvider::$osc_enabled = false
protected

Definition at line 31 of file class.ilChatUserActionProvider.php.

◆ $pub_ref_id

int ilChatUserActionProvider::$pub_ref_id = 0
protected

Definition at line 29 of file class.ilChatUserActionProvider.php.

◆ $user_access

array ilChatUserActionProvider::$user_access = array()
staticprotected

Definition at line 26 of file class.ilChatUserActionProvider.php.


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