ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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
 
ilCtrlInterface $ctrl
 
- Protected Attributes inherited from ilUserActionProvider
int $user_id
 
Language $lng
 
ilDBInterface $db
 

Static Protected Attributes

static array $user_access = []
 
static array $accepts_messages_cache = []
 

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 34 of file class.ilChatUserActionProvider.php.

35 {
37
38 global $DIC;
39
40 $this->pub_ref_id = ilObjChatroom::_getPublicRefId();
41
42 $chatSettings = new ilSetting('chatroom');
43 $this->chat_enabled = (bool) $chatSettings->get('chat_enabled');
44 $this->osc_enabled = (bool) $chatSettings->get('enable_osc');
45
46 $this->lng->loadLanguageModule('chatroom');
47 $this->ctrl = $DIC->ctrl();
48 }
ILIAS Setting Class.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), ilObjChatroom\_getPublicRefId(), ILIAS\Repository\ctrl(), 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 75 of file class.ilChatUserActionProvider.php.

75 : bool
76 {
77 if (!array_key_exists($a_user_id, self::$accepts_messages_cache)) {
78 self::$accepts_messages_cache[$a_user_id] = ilUtil::yn2tf(
79 ilObjUser::_lookupPref($a_user_id, 'chat_osc_accept_msg') ?? 'n'
80 );
81 }
82
83 return (bool) self::$accepts_messages_cache[$a_user_id];
84 }
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 66 of file class.ilChatUserActionProvider.php.

66 : bool
67 {
68 if (!array_key_exists($a_user_id, self::$user_access)) {
69 self::$user_access[$a_user_id] = $GLOBALS['DIC']->rbac()->system()->checkAccessOfUser($a_user_id, 'read', $this->pub_ref_id);
70 }
71
72 return self::$user_access[$a_user_id];
73 }
$GLOBALS["DIC"]
Definition: wac.php:54

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 89 of file class.ilChatUserActionProvider.php.

90 {
91 $coll = new ilUserActionCollection();
92
93 if (!$this->chat_enabled) {
94 return $coll;
95 }
96
97 if ($this->checkUserChatAccess($this->getUserId()) && $a_target_user != $this->getUserId()) {
98 if ($this->checkUserChatAccess($a_target_user)) {
99 $f = new ilUserAction();
100 $f->setType("invite");
101 $f->setText($this->lng->txt('chat_user_action_invite_public_room'));
102 $this->ctrl->setParameterByClass(ilObjChatroomGUI::class, 'ref_id', $this->pub_ref_id);
103 $this->ctrl->setParameterByClass(ilObjChatroomGUI::class, 'user', $a_target_user);
104 $f->setHref($this->ctrl->getLinkTargetByClass([ilRepositoryGUI::class, ilObjChatroomGUI::class], 'inviteUsersToPrivateRoom-byId'));
105 $coll->addAction($f);
106 }
107 }
108
109 if ($this->osc_enabled && $a_target_user != $this->getUserId()) {
110 $f = new ilUserAction();
111 $f->setHref('#');
112 $f->setType("invite_osd");
113 if ($this->acceptsMessages($a_target_user)) {
114 $f->setText($this->lng->txt('chat_osc_start_conversation'));
115 $f->setData([
116 'onscreenchat-userid' => $a_target_user,
117 'onscreenchat-username' => ilObjUser::_lookupLogin($a_target_user)
118 ]);
119 } else {
120 $f->setText($this->lng->txt('chat_osc_doesnt_accept_msg'));
121 $f->setData([
122 'onscreenchat-inact-userid' => $a_target_user
123 ]);
124 }
125 $coll->addAction($f);
126 }
127
128 return $coll;
129 }
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(), ILIAS\Repository\ctrl(), 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 58 of file class.ilChatUserActionProvider.php.

58 : array
59 {
60 return [
61 "invite" => $this->lng->txt('chat_user_action_invite_public_room'),
62 "invite_osd" => $this->lng->txt('chat_user_action_invite_osd')
63 ];
64 }

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 50 of file class.ilChatUserActionProvider.php.

50 : string
51 {
52 return "chtr";
53 }

Field Documentation

◆ $accepts_messages_cache

array ilChatUserActionProvider::$accepts_messages_cache = []
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.

◆ $ctrl

ilCtrlInterface ilChatUserActionProvider::$ctrl
protected

Definition at line 32 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 = []
staticprotected

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


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