ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjWikiAccess.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/Object/classes/class.ilObjectAccess.php");
5
16{
20 protected $user;
21
25 protected $lng;
26
30 protected $rbacsystem;
31
35 protected $access;
36
37
41 public function __construct()
42 {
43 global $DIC;
44
45 $this->user = $DIC->user();
46 $this->lng = $DIC->language();
47 $this->rbacsystem = $DIC->rbac()->system();
48 $this->access = $DIC->access();
49 }
50
51
64 public static function _getCommands()
65 {
66 $commands = array(
67 array("permission" => "read", "cmd" => "view", "lang_var" => "show",
68 "default" => true),
69 array("permission" => "write", "cmd" => "editSettings", "lang_var" => "settings")
70 );
71
72 return $commands;
73 }
74
87 public function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
88 {
92 $ilAccess = $this->access;
93
94 if ($a_user_id == "") {
95 $a_user_id = $ilUser->getId();
96 }
97
98 switch ($a_cmd) {
99 case "view":
100
101 if (!ilObjWikiAccess::_lookupOnline($a_obj_id)
102 && !$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id)) {
103 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
104 return false;
105 }
106 break;
107
108 // for permission query feature
109 case "infoScreen":
110 if (!ilObjWikiAccess::_lookupOnline($a_obj_id)) {
111 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
112 } else {
113 $ilAccess->addInfoItem(IL_STATUS_MESSAGE, $lng->txt("online"));
114 }
115 break;
116
117 }
118 switch ($a_permission) {
119 case "read":
120 case "visible":
121 if (!ilObjWikiAccess::_lookupOnline($a_obj_id) &&
122 (!$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id))) {
123 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
124 return false;
125 }
126
127 include_once("./Modules/Exercise/RepoObjectAssignment/classes/class.ilExcRepoObjAssignment.php");
128 $info = ilExcRepoObjAssignment::getInstance()->getAccessInfo($a_ref_id, $a_user_id);
129 if (!$info->isGranted()) {
130 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, implode(" / ", $info->getNotGrantedReasons()));
131 return false;
132 }
133 break;
134 }
135
136 return true;
137 }
138
142 public static function _checkGoto($a_target)
143 {
144 global $DIC;
145
146 $ilAccess = $DIC->access();
147 // echo "-".$a_target."-"; exit;
148 $t_arr = explode("_", $a_target);
149
150 if ($t_arr[0] != "wiki" || (((int) $t_arr[1]) <= 0) && $t_arr[1] != "wpage") {
151 return false;
152 }
153
154 if ($t_arr[1] == "wpage") {
155 $wpg_id = (int) $t_arr[2];
156 include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
157 $w_id = ilWikiPage::lookupWikiId($wpg_id);
158 if ((int) $t_arr[3] > 0) {
159 $refs = array((int) $t_arr[3]);
160 } else {
161 $refs = ilObject::_getAllReferences($w_id);
162 }
163 foreach ($refs as $r) {
164 if ($ilAccess->checkAccess("read", "", $r)) {
165 return true;
166 }
167 }
168 } elseif ($ilAccess->checkAccess("read", "", $t_arr[1])) {
169 return true;
170 }
171 return false;
172 }
173
179 public static function _lookupOnline($a_id)
180 {
181 global $DIC;
182
183 $ilDB = $DIC->database();
184
185 $q = "SELECT * FROM il_wiki_data WHERE id = " .
186 $ilDB->quote($a_id, "integer");
187 $wk_set = $ilDB->query($q);
188 $wk_rec = $ilDB->fetchAssoc($wk_set);
189
190 return $wk_rec["is_online"];
191 }
192
198 public static function _lookupPublicFiles($a_id)
199 {
200 global $DIC;
201
202 $ilDB = $DIC->database();
203
204 $q = "SELECT * FROM il_wiki_data WHERE id = " .
205 $ilDB->quote($a_id, "integer");
206 $wk_set = $ilDB->query($q);
207 $wk_rec = $ilDB->fetchAssoc($wk_set);
208
209 return $wk_rec["public_files"];
210 }
211}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
const IL_STATUS_MESSAGE
const IL_NO_OBJECT_ACCESS
Class ilObjWikiAccess.
_checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id="")
checks wether a user may invoke a command or not (this method is called by ilAccessHandler::checkAcce...
static _checkGoto($a_target)
check whether goto script will succeed
static _lookupOnline($a_id)
Check wether wiki cast is online.
static _lookupPublicFiles($a_id)
Check wether files should be public.
__construct()
Constructor.
static _getCommands()
get commands
Class ilObjectAccess.
static _getAllReferences($a_id)
get all reference ids of object
static lookupWikiId($a_page_id)
Lookup wiki id.
$r
Definition: example_031.php:79
$info
Definition: index.php:5
global $DIC
Definition: saml.php:7
global $ilDB
$ilUser
Definition: imgupload.php:18