ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjWikiAccess.php
Go to the documentation of this file.
1<?php
2
23{
24 protected ilObjUser $user;
25 protected ilLanguage $lng;
28
29 public function __construct()
30 {
31 global $DIC;
32
33 $this->user = $DIC->user();
34 $this->lng = $DIC->language();
35 $this->rbacsystem = $DIC->rbac()->system();
36 $this->access = $DIC->access();
37 }
38
39
40 public static function _getCommands(): array
41 {
42 $commands = array(
43 array("permission" => "read", "cmd" => "view", "lang_var" => "show",
44 "default" => true),
45 array("permission" => "write", "cmd" => "editSettings", "lang_var" => "settings")
46 );
47
48 return $commands;
49 }
50
51 public function _checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id = null): bool
52 {
53 $ilUser = $this->user;
56 $ilAccess = $this->access;
57
58 if (is_null($user_id)) {
59 $user_id = $ilUser->getId();
60 }
61
62 switch ($cmd) {
63 case "view":
64
65 if (!self::_lookupOnline($obj_id)
67 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
68 return false;
69 }
70 break;
71
72 // for permission query feature
73 case "infoScreen":
74 if (!self::_lookupOnline($obj_id)) {
75 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
76 } else {
77 $ilAccess->addInfoItem(ilAccessInfo::IL_STATUS_MESSAGE, $lng->txt("online"));
78 }
79 break;
80 }
81 switch ($permission) {
82 case "read":
83 case "visible":
84 if (self::_isOffline($obj_id) &&
86 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
87 return false;
88 }
89
91 if (!$info->isGranted()) {
92 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, implode(" / ", $info->getNotGrantedReasons()));
93 return false;
94 }
95 break;
96 }
97
98 return true;
99 }
100
101 public static function _checkGoto(string $target): bool
102 {
103 global $DIC;
104
105 $ilAccess = $DIC->access();
106 // echo "-".$target."-"; exit;
107 $t_arr = explode("_", $target);
108
109 if ($t_arr[0] !== "wiki" || (((int) $t_arr[1]) <= 0) && $t_arr[1] !== "wpage") {
110 return false;
111 }
112
113 if ($t_arr[1] === "wpage") {
114 $wpg_id = (int) $t_arr[2];
115 $w_id = ilWikiPage::lookupWikiId($wpg_id);
116 if ((int) ($t_arr[3] ?? 0) > 0) {
117 $refs = array((int) $t_arr[3]);
118 } else {
119 $refs = ilObject::_getAllReferences($w_id);
120 }
121 foreach ($refs as $r) {
122 if ($ilAccess->checkAccess("read", "", (int) $r) ||
123 $ilAccess->checkAccess("visible", "", (int) $r)) {
124 return true;
125 }
126 }
127 } elseif ($ilAccess->checkAccess("read", "", (int) $t_arr[1]) ||
128 $ilAccess->checkAccess("visible", "", (int) $t_arr[1])) {
129 return true;
130 }
131 return false;
132 }
133
134 public static function _lookupOnline(int $a_id): bool
135 {
136 return !self::_isOffline($a_id);
137 }
138
143 public static function _lookupOnlineStatus(array $a_ids): array
144 {
145 $status = [];
146 foreach ($a_ids as $id) {
147 $status[$id] = !self::_isOffline($id);
148 }
149 return $status;
150 }
151
152
156 public static function _lookupPublicFiles(int $a_id): bool
157 {
158 global $DIC;
159
160 $ilDB = $DIC->database();
161
162 $q = "SELECT * FROM il_wiki_data WHERE id = " .
163 $ilDB->quote($a_id, "integer");
164 $wk_set = $ilDB->query($q);
165 $wk_rec = $ilDB->fetchAssoc($wk_set);
166
167 return (bool) $wk_rec["public_files"];
168 }
169}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
language handling
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
User class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupOnlineStatus(array $a_ids)
see legacyOnlineFilter in ilContainer
ilAccessHandler $access
_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::checkAcc...
static _lookupPublicFiles(int $a_id)
Check wether files should be public.
static _lookupOnline(int $a_id)
static _getCommands()
get commands
static _checkGoto(string $target)
check whether goto script will succeed
Class ilObjectAccess.
static _isOffline(int $obj_id)
Type-specific implementation of general status, has to be overwritten if object type does not support...
static _getAllReferences(int $id)
get all reference ids for object ID
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
checkAccessOfUser(int $a_user_id, string $a_operations, int $a_ref_id, string $a_type="")
static lookupWikiId(int $a_page_id)
$info
Definition: entry_point.php:21
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
$ref_id
Definition: ltiauth.php:66
global $DIC
Definition: shib_login.php:26
$q
Definition: shib_logout.php:23