ILIAS  release_7 Revision v7.30-3-g800a261c036
ilChatUserActionProvider Class Reference

Adds link to chat. More...

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

Public Member Functions

 __construct ()
 Constructor. More...
 
 getComponentId ()
 
Returns
string component id as defined in services.xml/module.xml
More...
 
 getActionTypes ()
 
Returns
array[string] keys must be unique action ids (strings), values should be the names of the actions (from ilLanguage)
More...
 
 collectActionsForTargetUser ($a_target_user)
 Collect all actions. More...
 
- Public Member Functions inherited from ilUserActionProvider
 __construct ()
 Constructor. More...
 
 setUserId ($a_val)
 Set user id. More...
 
 getUserId ()
 Get user id. More...
 
 collectActionsForTargetUser ($a_target_user)
 Collect actions for a target user. More...
 
 getComponentId ()
 
 getActionTypes ()
 
 getJsScripts ($a_action_type)
 Get js scripts. More...
 

Protected Member Functions

 checkUserChatAccess ($a_user_id)
 Check user chat access. More...
 
 acceptsMessages ($a_user_id)
 

Protected Attributes

 $pub_ref_id = 0
 
 $chat_enabled = false
 Boolean to indicate if the chat is enabled. More...
 
 $osc_enabled = false
 Boolean to indicate if on screen chat is enabled. More...
 
- Protected Attributes inherited from ilUserActionProvider
 $user_id
 
 $lng
 
 $db
 

Static Protected Attributes

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

Detailed Description

Adds link to chat.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilChatUserActionProvider::__construct ( )

Constructor.

Reimplemented from ilUserActionProvider.

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

43 {
45
46 include_once 'Modules/Chatroom/classes/class.ilObjChatroom.php';
47 $this->pub_ref_id = ilObjChatroom::_getPublicRefId();
48
49 $chatSettings = new ilSetting('chatroom');
50 $this->chat_enabled = $chatSettings->get('chat_enabled');
51 $this->osc_enabled = $chatSettings->get('enable_osc');
52
53 $this->lng->loadLanguageModule('chatroom');
54 }
ILIAS Setting Class.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

+ Here is the call graph for this function:

Member Function Documentation

◆ acceptsMessages()

ilChatUserActionProvider::acceptsMessages (   $a_user_id)
protected
Parameters
int$a_user_id
Returns
bool

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

96 {
97 if (!array_key_exists($a_user_id, self::$accepts_messages_cache)) {
98 self::$accepts_messages_cache[$a_user_id] = ilUtil::yn2tf(ilObjUser::_lookupPref($a_user_id, 'chat_osc_accept_msg'));
99 }
100
101 return self::$accepts_messages_cache[$a_user_id];
102 }
static _lookupPref($a_usr_id, $a_keyword)
static yn2tf($a_yn)
convert "y"/"n" to true/false

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 (   $a_user_id)
protected

Check user chat access.

Parameters
int$a_user_id
Returns
bool

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

83 {
84 if (!array_key_exists($a_user_id, self::$user_access)) {
85 self::$user_access[$a_user_id] = $GLOBALS['DIC']->rbac()->system()->checkAccessOfUser($a_user_id, 'read', $this->pub_ref_id);
86 }
87
88 return self::$user_access[$a_user_id];
89 }
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 (   $a_target_user)

Collect all actions.

Parameters
int$a_target_usertarget user
Returns
ilUserActionCollection collection

Reimplemented from ilUserActionProvider.

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

111 {
113
114 if (!$this->chat_enabled) {
115 return $coll;
116 }
117
118 if ($this->checkUserChatAccess($this->getUserId()) && $a_target_user != $this->getUserId()) {
119 if ($this->checkUserChatAccess($a_target_user)) {
120 $f = new ilUserAction();
121 $f->setType("invite");
122 $f->setText($this->lng->txt('chat_invite_public_room'));
123 $f->setHref('./ilias.php?baseClass=ilRepositoryGUI&ref_id=' . $this->pub_ref_id . '&usr_id=' . $a_target_user . '&cmd=view-invitePD');
124 $coll->addAction($f);
125 }
126 }
127
128 if ($this->osc_enabled && $a_target_user != $this->getUserId()) {
129 $f = new ilUserAction();
130 $f->setHref('#');
131 $f->setType("invite_osd");
132 if ($this->acceptsMessages($a_target_user)) {
133 $f->setText($this->lng->txt('chat_osc_start_conversation'));
134 $f->setData(array(
135 'onscreenchat-userid' => $a_target_user,
136 'onscreenchat-username' => ilObjUser::_lookupLogin($a_target_user)
137 ));
138 } else {
139 $f->setText($this->lng->txt('chat_osc_doesnt_accept_msg'));
140 $f->setData(array(
141 'onscreenchat-inact-userid' => $a_target_user
142 ));
143 }
144 $coll->addAction($f);
145 }
146
147 return $coll;
148 }
checkUserChatAccess($a_user_id)
Check user chat access.
static _lookupLogin($a_user_id)
lookup login
Action that can be performed on a user.

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

+ Here is the call graph for this function:

◆ getActionTypes()

ilChatUserActionProvider::getActionTypes ( )

Returns
array[string] keys must be unique action ids (strings), values should be the names of the actions (from ilLanguage)

Reimplemented from ilUserActionProvider.

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

68 {
69 return array(
70 "invite" => $this->lng->txt('chat_user_action_invite_public_room'),
71 "invite_osd" => $this->lng->txt('chat_user_action_invite_osd')
72 );
73 }

◆ getComponentId()

ilChatUserActionProvider::getComponentId ( )

Returns
string component id as defined in services.xml/module.xml

Reimplemented from ilUserActionProvider.

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

60 {
61 return "chtr";
62 }

Field Documentation

◆ $accepts_messages_cache

ilChatUserActionProvider::$accepts_messages_cache = array()
staticprotected

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

◆ $chat_enabled

ilChatUserActionProvider::$chat_enabled = false
protected

Boolean to indicate if the chat is enabled.

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

◆ $osc_enabled

ilChatUserActionProvider::$osc_enabled = false
protected

Boolean to indicate if on screen chat is enabled.

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

◆ $pub_ref_id

ilChatUserActionProvider::$pub_ref_id = 0
protected

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

◆ $user_access

ilChatUserActionProvider::$user_access = array()
staticprotected

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


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