ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 ()
 

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

Constructor & Destructor Documentation

◆ __construct()

ilChatUserActionProvider::__construct ( )

Constructor.

Reimplemented from ilUserActionProvider.

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

46 {
47 parent::__construct();
48
49 include_once 'Modules/Chatroom/classes/class.ilObjChatroom.php';
50 $this->pub_ref_id = ilObjChatroom::_getPublicRefId();
51
52 $chatSettings = new ilSetting('chatroom');
53 $this->chat_enabled = $chatSettings->get('chat_enabled');
54 $this->osc_enabled = $chatSettings->get('enable_osc');
55
56 $this->lng->loadLanguageModule('chatroom');
57 }
ILIAS Setting Class.

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

100 {
101 if(!array_key_exists($a_user_id, self::$accepts_messages_cache))
102 {
103 self::$accepts_messages_cache[$a_user_id] = ilUtil::yn2tf(ilObjUser::_lookupPref($a_user_id, 'chat_osc_accept_msg'));
104 }
105
106 return self::$accepts_messages_cache[$a_user_id];
107 }
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 85 of file class.ilChatUserActionProvider.php.

86 {
87 if(!array_key_exists($a_user_id, self::$user_access))
88 {
89 self::$user_access[$a_user_id] = $GLOBALS['DIC']->rbac()->system()->checkAccessOfUser($a_user_id, 'read', $this->pub_ref_id);
90 }
91
92 return self::$user_access[$a_user_id];
93 }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.

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

116 {
118 include_once("./Services/User/Actions/classes/class.ilUserAction.php");
119
120 require_once 'Services/User/classes/class.ilObjUser.php';
121
122 if(!$this->chat_enabled)
123 {
124 return $coll;
125 }
126
127 if($this->checkUserChatAccess($this->getUserId()))
128 {
129 // no chat with user him/herself
130 if ($a_target_user != $this->getUserId())
131 {
132 if($this->checkUserChatAccess($a_target_user))
133 {
134 $f = new ilUserAction();
135 $f->setType("invite");
136 $f->setText($this->lng->txt('chat_invite_public_room'));
137 $f->setHref('./ilias.php?baseClass=ilRepositoryGUI&ref_id=' . $this->pub_ref_id . '&usr_id=' . $a_target_user . '&cmd=view-invitePD');
138 $coll->addAction($f);
139 }
140 }
141 }
142
143 if($this->osc_enabled)
144 {
145 $f = new ilUserAction();
146 $f->setHref('#');
147 $f->setType("invite_osd");
148 if($this->acceptsMessages($a_target_user))
149 {
150 $f->setText($this->lng->txt('chat_osc_start_conversation'));
151 $f->setData(array(
152 'onscreenchat-userid' => $a_target_user,
153 'onscreenchat-username' => ilObjUser::_lookupLogin($a_target_user)
154 ));
155 }
156 else
157 {
158 $f->setText($this->lng->txt('chat_osc_doesnt_accept_msg'));
159 $f->setData(array(
160 'onscreenchat-inact-userid' => $a_target_user
161 ));
162 }
163 $coll->addAction($f);
164 }
165
166 return $coll;
167 }
checkUserChatAccess($a_user_id)
Check user chat access.
static _lookupLogin($a_user_id)
lookup login
Action that can be performed on a user.

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

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

◆ getComponentId()

ilChatUserActionProvider::getComponentId ( )

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

Reimplemented from ilUserActionProvider.

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

63 {
64 return "chtr";
65 }

Field Documentation

◆ $accepts_messages_cache

ilChatUserActionProvider::$accepts_messages_cache = array()
staticprotected

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

◆ $chat_enabled

ilChatUserActionProvider::$chat_enabled = false
protected

Boolean to indicate if the chat is enabled.

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

◆ $osc_enabled

ilChatUserActionProvider::$osc_enabled = false
protected

Boolean to indicate if on screen chat is enabled.

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

◆ $pub_ref_id

ilChatUserActionProvider::$pub_ref_id = 0
protected

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

◆ $user_access

ilChatUserActionProvider::$user_access = array()
staticprotected

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


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