ILIAS  release_8 Revision v8.24
ilObjWikiAccess Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilObjWikiAccess:
+ Collaboration diagram for ilObjWikiAccess:

Public Member Functions

 __construct ()
 
 _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...
 
- Public Member Functions inherited from ilObjectAccess
 _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 _lookupOnline (int $a_id)
 
static _lookupOnlineStatus (array $a_ids)
 see legacyOnlineFilter in ilContainer More...
 
static _lookupPublicFiles (int $a_id)
 Check wether files should be public. More...
 
- 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...
 

Protected Attributes

ilObjUser $user
 
ilLanguage $lng
 
ilRbacSystem $rbacsystem
 
ilAccessHandler $access
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 22 of file class.ilObjWikiAccess.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjWikiAccess::__construct ( )

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

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 }
global $DIC
Definition: feed.php:28

References $DIC, ILIAS\Repository\access(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ _checkAccess()

ilObjWikiAccess::_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 51 of file class.ilObjWikiAccess.php.

51 : bool
52 {
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)
66 && !$rbacsystem->checkAccessOfUser($user_id, 'write', $ref_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 }
82 switch ($permission) {
83 case "read":
84 case "visible":
85 if (!self::_lookupOnline($obj_id) &&
86 (!$rbacsystem->checkAccessOfUser($user_id, 'write', $ref_id))) {
87 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
88 return false;
89 }
90
91 $info = ilExcRepoObjAssignment::getInstance()->getAccessInfo($ref_id, $user_id);
92 if (!$info->isGranted()) {
93 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, implode(" / ", $info->getNotGrantedReasons()));
94 return false;
95 }
96 break;
97 }
98
99 return true;
100 }
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...
ilAccessHandler $access
checkAccessOfUser(int $a_user_id, string $a_operations, int $a_ref_id, string $a_type="")
$ilUser
Definition: imgupload.php:34
$ref_id
Definition: ltiauth.php:67

References $access, $ilUser, $lng, $rbacsystem, $ref_id, $user, ilRbacSystem\checkAccessOfUser(), ilExcRepoObjAssignment\getInstance(), ilAccessInfo\IL_NO_OBJECT_ACCESS, ilAccessInfo\IL_STATUS_MESSAGE, and ilLanguage\txt().

+ Here is the call graph for this function:

◆ _checkGoto()

static ilObjWikiAccess::_checkGoto ( string  $target)
static

check whether goto script will succeed

Reimplemented from ilObjectAccess.

Definition at line 102 of file class.ilObjWikiAccess.php.

102 : bool
103 {
104 global $DIC;
105
106 $ilAccess = $DIC->access();
107 // echo "-".$target."-"; exit;
108 $t_arr = explode("_", $target);
109
110 if ($t_arr[0] !== "wiki" || (((int) $t_arr[1]) <= 0) && $t_arr[1] !== "wpage") {
111 return false;
112 }
113
114 if ($t_arr[1] === "wpage") {
115 $wpg_id = (int) $t_arr[2];
116 $w_id = ilWikiPage::lookupWikiId($wpg_id);
117 if ((int) ($t_arr[3] ?? 0) > 0) {
118 $refs = array((int) $t_arr[3]);
119 } else {
120 $refs = ilObject::_getAllReferences($w_id);
121 }
122 foreach ($refs as $r) {
123 if ($ilAccess->checkAccess("read", "", (int) $r) ||
124 $ilAccess->checkAccess("visible", "", (int) $r)) {
125 return true;
126 }
127 }
128 } elseif ($ilAccess->checkAccess("read", "", (int) $t_arr[1]) ||
129 $ilAccess->checkAccess("visible", "", (int) $t_arr[1])) {
130 return true;
131 }
132 return false;
133 }
static _getAllReferences(int $id)
get all reference ids for object ID
static lookupWikiId(int $a_page_id)

References $DIC, ilObject\_getAllReferences(), ILIAS\Repository\int(), and ilWikiPage\lookupWikiId().

+ Here is the call graph for this function:

◆ _getCommands()

static ilObjWikiAccess::_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 40 of file class.ilObjWikiAccess.php.

40 : 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 }

Referenced by ilObjWikiListGUI\init().

+ Here is the caller graph for this function:

◆ _lookupOnline()

static ilObjWikiAccess::_lookupOnline ( int  $a_id)
static

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

135 : bool
136 {
137 global $DIC;
138
139 $ilDB = $DIC->database();
140
141 $q = "SELECT * FROM il_wiki_data WHERE id = " .
142 $ilDB->quote($a_id, "integer");
143 $wk_set = $ilDB->query($q);
144 $wk_rec = $ilDB->fetchAssoc($wk_set);
145
146 return (bool) $wk_rec["is_online"];
147 }

References $DIC, and $ilDB.

Referenced by ilObjWikiListGUI\getProperties().

+ Here is the caller graph for this function:

◆ _lookupOnlineStatus()

static ilObjWikiAccess::_lookupOnlineStatus ( array  $a_ids)
static

see legacyOnlineFilter in ilContainer

Deprecated:

Definition at line 153 of file class.ilObjWikiAccess.php.

153 : array
154 {
155 global $DIC;
156
157 $ilDB = $DIC->database();
158
159 $q = "SELECT id, is_online FROM il_wiki_data WHERE " .
160 $ilDB->in("id", $a_ids, false, "integer");
161 $lm_set = $ilDB->query($q);
162 $status = [];
163 while ($r = $ilDB->fetchAssoc($lm_set)) {
164 $status[$r["id"]] = (bool) $r["is_online"];
165 }
166 return $status;
167 }
$lm_set

References $DIC, $ilDB, and $lm_set.

Referenced by ilContainer\legacyOnlineFilter().

+ Here is the caller graph for this function:

◆ _lookupPublicFiles()

static ilObjWikiAccess::_lookupPublicFiles ( int  $a_id)
static

Check wether files should be public.

Definition at line 173 of file class.ilObjWikiAccess.php.

173 : bool
174 {
175 global $DIC;
176
177 $ilDB = $DIC->database();
178
179 $q = "SELECT * FROM il_wiki_data WHERE id = " .
180 $ilDB->quote($a_id, "integer");
181 $wk_set = $ilDB->query($q);
182 $wk_rec = $ilDB->fetchAssoc($wk_set);
183
184 return (bool) $wk_rec["public_files"];
185 }

References $DIC, and $ilDB.

Field Documentation

◆ $access

ilAccessHandler ilObjWikiAccess::$access
protected

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

Referenced by _checkAccess().

◆ $lng

ilLanguage ilObjWikiAccess::$lng
protected

Definition at line 25 of file class.ilObjWikiAccess.php.

Referenced by _checkAccess().

◆ $rbacsystem

ilRbacSystem ilObjWikiAccess::$rbacsystem
protected

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

Referenced by _checkAccess().

◆ $user

ilObjUser ilObjWikiAccess::$user
protected

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

Referenced by _checkAccess().


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