ILIAS  release_8 Revision v8.24
ilObjChatroomAccess Class Reference

Access class for chatroom objects. More...

+ Inheritance diagram for ilObjChatroomAccess:
+ Collaboration diagram for ilObjChatroomAccess:

Public Member Functions

 _checkAccess (string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id=null)
 Checks whether a user may invoke a command or not (this method is called by ilAccessHandler::checkAccess) More...
 
 canBeDelivered (ilWACPath $ilWACPath)
 
 _checkAccess (string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id=null)
 Checks whether a user may invoke a command or not (this method is called by ilAccessHandler::checkAccess) More...
 
 canBeDelivered (ilWACPath $ilWACPath)
 
 canBeDelivered (ilWACPath $ilWACPath)
 

Static Public Member Functions

static _getCommands ()
 get commands More...
 
static _checkGoto (string $target)
 check whether goto script will succeed More...
 
static isActivated (int $refId, int $objId, bool &$a_visible_flag=null)
 
static lookupOnline (int $a_obj_id)
 
- Static Public Member Functions inherited from ilObjectAccess
static _getCommands ()
 get commands More...
 
static _checkGoto (string $target)
 check whether goto script will succeed More...
 
static _isOffline (int $obj_id)
 Type-specific implementation of general status, has to be overwritten if object type does not support centralized offline handling. More...
 
static _preloadData (array $obj_ids, array $ref_ids)
 Preload data. More...
 

Static Private Member Functions

static checkRoomAccess (string $a_permission, int $a_ref_id, int $a_obj_id, int $a_user_id)
 

Static Private Attributes

static bool $chat_enabled = null
 

Detailed Description

Access class for chatroom objects.

Author
Jan Posselt <jposselt at databay.de>
Version
$Id$

Definition at line 27 of file class.ilObjChatroomAccess.php.

Member Function Documentation

◆ _checkAccess()

ilObjChatroomAccess::_checkAccess ( string  $cmd,
string  $permission,
int  $ref_id,
int  $obj_id,
?int  $user_id = null 
)

Checks whether a user may invoke a command or not (this method is called by ilAccessHandler::checkAccess)

Please do not check any preconditions handled by ilConditionHandler here. Also don't do any RBAC checks.

Reimplemented from ilObjectAccess.

Definition at line 58 of file class.ilObjChatroomAccess.php.

58 : bool
59 {
60 if (!$user_id) {
61 $user_id = $GLOBALS['DIC']->user()->getId();
62 }
63
64 return self::checkRoomAccess($permission, $ref_id, $obj_id, (int) $user_id);
65 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
static checkRoomAccess(string $a_permission, int $a_ref_id, int $a_obj_id, int $a_user_id)
$ref_id
Definition: ltiauth.php:67

References $GLOBALS, $ref_id, and checkRoomAccess().

+ Here is the call graph for this function:

◆ _checkGoto()

static ilObjChatroomAccess::_checkGoto ( string  $target)
static

check whether goto script will succeed

Reimplemented from ilObjectAccess.

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

40 : bool
41 {
42 $t_arr = explode('_', $target);
43
44 if (count($t_arr) < 2 || $t_arr[0] !== 'chtr' || ((int) $t_arr[1]) <= 0) {
45 return false;
46 }
47
48 if (
49 ilChatroom::checkUserPermissions('visible', (int) $t_arr[1], false) ||
50 ilChatroom::checkUserPermissions('read', (int) $t_arr[1], false)
51 ) {
52 return true;
53 }
54
55 return false;
56 }
static checkUserPermissions($permissions, int $ref_id, bool $send_info=true)
Checks user permissions by given array and ref_id.

References ilChatroom\checkUserPermissions().

+ Here is the call graph for this function:

◆ _getCommands()

static ilObjChatroomAccess::_getCommands ( )
static

get commands

this method returns an array of all possible commands/permission combinations

example: $commands = array ( array("permission" => "read", "cmd" => "view", "lang_var" => "show"), array("permission" => "write", "cmd" => "edit", "lang_var" => "edit"), );

Returns
array{permission?:string, cmd?:string, lang_var?:string, default?:bool}[]

Reimplemented from ilObjectAccess.

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

31 : array
32 {
33 $commands = [];
34 $commands[] = ['permission' => 'read', 'cmd' => 'view', 'lang_var' => 'enter', 'default' => true];
35 $commands[] = ['permission' => 'write', 'cmd' => 'settings-general', 'lang_var' => 'settings'];
36
37 return $commands;
38 }

Referenced by ilObjChatroomListGUI\init().

+ Here is the caller graph for this function:

◆ canBeDelivered()

ilObjChatroomAccess::canBeDelivered ( ilWACPath  $ilWACPath)

Reimplemented from ilObjectAccess.

Definition at line 148 of file class.ilObjChatroomAccess.php.

148 : bool
149 {
150 if (preg_match("/chatroom\\/smilies\\//ui", $ilWACPath->getPath())) {
151 return true;
152 }
153
154 return false;
155 }

References ilWACPath\getPath().

+ Here is the call graph for this function:

◆ checkRoomAccess()

static ilObjChatroomAccess::checkRoomAccess ( string  $a_permission,
int  $a_ref_id,
int  $a_obj_id,
int  $a_user_id 
)
staticprivate

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

67 : bool
68 {
69 global $DIC;
70
71 if (self::$chat_enabled === null) {
72 $chatSetting = new ilSetting('chatroom');
73 self::$chat_enabled = (bool) $chatSetting->get('chat_enabled', '0');
74 }
75
76 $hasWriteAccess = $DIC->rbac()->system()->checkAccessOfUser($a_user_id, 'write', $a_ref_id);
77 if ($hasWriteAccess) {
78 return true;
79 }
80
81 switch ($a_permission) {
82 case 'visible':
83 $visible = null;
84
85 $active = self::isActivated($a_ref_id, $a_obj_id, $visible);
86
87 if (!$active) {
88 $DIC->access()->addInfoItem(
90 $DIC->language()->txt('offline')
91 );
92 }
93
94 if ($active === false && $visible === false) {
95 return false;
96 }
97 break;
98
99 case 'read':
100 $active = self::isActivated($a_ref_id, $a_obj_id);
101 if (!$active) {
102 $DIC->access()->addInfoItem(
104 $DIC->language()->txt('offline')
105 );
106 return false;
107 }
108 break;
109 }
110
111 return self::$chat_enabled;
112 }
static isActivated(int $refId, int $objId, bool &$a_visible_flag=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28

References $chat_enabled, $DIC, ilAccessInfo\IL_NO_OBJECT_ACCESS, and isActivated().

Referenced by _checkAccess().

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

◆ isActivated()

static ilObjChatroomAccess::isActivated ( int  $refId,
int  $objId,
bool &  $a_visible_flag = null 
)
static

Definition at line 114 of file class.ilObjChatroomAccess.php.

114 : bool
115 {
116 if (!self::lookupOnline($objId)) {
117 $a_visible_flag = false;
118 return false;
119 }
120
121 $a_visible_flag = true;
122
124 switch ($item['timing_type']) {
126 if (time() < $item['timing_start'] || time() > $item['timing_end']) {
127 $a_visible_flag = (bool) $item['visible'];
128 return false;
129 }
130 }
131
132 return true;
133 }
static getItem(int $ref_id)
$objId
Definition: xapitoken.php:57
$refId
Definition: xapitoken.php:58

References $objId, $refId, ilObjectActivation\getItem(), and ilObjectActivation\TIMINGS_ACTIVATION.

Referenced by ilChatroom\checkPermissions(), and checkRoomAccess().

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

◆ lookupOnline()

static ilObjChatroomAccess::lookupOnline ( int  $a_obj_id)
static

Definition at line 135 of file class.ilObjChatroomAccess.php.

135 : bool
136 {
137 global $DIC;
138
139 $res = $DIC->database()->query(
140 'SELECT online_status FROM chatroom_settings WHERE object_id = ' .
141 $DIC->database()->quote($a_obj_id, 'integer')
142 );
143 $row = $DIC->database()->fetchAssoc($res);
144
145 return (bool) ($row['online_status'] ?? false);
146 }
$res
Definition: ltiservices.php:69

References $DIC, and $res.

Field Documentation

◆ $chat_enabled

bool ilObjChatroomAccess::$chat_enabled = null
staticprivate

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

Referenced by checkRoomAccess().


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