19 declare(strict_types=1);
34 $commands[] = [
'permission' =>
'read',
'cmd' =>
'view',
'lang_var' =>
'enter',
'default' =>
true];
35 $commands[] = [
'permission' =>
'write',
'cmd' =>
'settings-general',
'lang_var' =>
'settings'];
42 $t_arr = explode(
'_', $target);
44 if (count($t_arr) < 2 || $t_arr[0] !==
'chtr' || ((
int) $t_arr[1]) <= 0) {
58 public function _checkAccess(
string $cmd,
string $permission,
int $ref_id,
int $obj_id, ?
int $user_id = null): bool
61 $user_id =
$GLOBALS[
'DIC']->user()->getId();
64 return self::checkRoomAccess($permission, $ref_id, $obj_id, (
int) $user_id);
67 private static function checkRoomAccess(
string $a_permission,
int $a_ref_id,
int $a_obj_id,
int $a_user_id): bool
71 if (self::$chat_enabled === null) {
73 self::$chat_enabled = (bool) $chatSetting->get(
'chat_enabled',
'0');
76 $hasWriteAccess = $DIC->rbac()->system()->checkAccessOfUser($a_user_id,
'write', $a_ref_id);
77 if ($hasWriteAccess) {
81 switch ($a_permission) {
85 $active = self::isActivated($a_ref_id, $a_obj_id, $visible);
88 $DIC->access()->addInfoItem(
90 $DIC->language()->txt(
'offline')
94 if ($active ===
false && $visible ===
false) {
100 $active = self::isActivated($a_ref_id, $a_obj_id);
102 $DIC->access()->addInfoItem(
104 $DIC->language()->txt(
'offline')
111 return self::$chat_enabled;
116 if (!self::lookupOnline($objId)) {
117 $a_visible_flag =
false;
121 $a_visible_flag =
true;
124 switch ($item[
'timing_type']) {
126 if (time() < $item[
'timing_start'] || time() > $item[
'timing_end']) {
127 $a_visible_flag = (bool) $item[
'visible'];
139 $res = $DIC->database()->query(
140 'SELECT online_status FROM chatroom_settings WHERE object_id = ' .
141 $DIC->database()->quote($a_obj_id,
'integer')
143 $row = $DIC->database()->fetchAssoc(
$res);
145 return (
bool) ($row[
'online_status'] ??
false);
150 if (preg_match(
"/chatroom\\/smilies\\//ui", $ilWACPath->
getPath())) {
static checkUserPermissions($permissions, int $ref_id, bool $send_info=true)
Checks user permissions by given array and ref_id.
static lookupOnline(int $a_obj_id)
const IL_NO_OBJECT_ACCESS
static checkRoomAccess(string $a_permission, int $a_ref_id, int $a_obj_id, int $a_user_id)
static _checkGoto(string $target)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
_checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id=null)
Access class for chatroom objects.
static isActivated(int $refId, int $objId, bool &$a_visible_flag=null)
canBeDelivered(ilWACPath $ilWACPath)
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getItem(int $ref_id)
static bool $chat_enabled