ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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{
17
30 function _getCommands()
31 {
32 $commands = array
33 (
34 array("permission" => "read", "cmd" => "view", "lang_var" => "show",
35 "default" => true),
36 array("permission" => "write", "cmd" => "editSettings", "lang_var" => "settings")
37 );
38
39 return $commands;
40 }
41
54 function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
55 {
56 global $ilUser, $lng, $rbacsystem, $ilAccess;
57
58 if ($a_user_id == "")
59 {
60 $a_user_id = $ilUser->getId();
61 }
62
63 switch ($a_cmd)
64 {
65 case "view":
66
68 && !$rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id))
69 {
70 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
71 return false;
72 }
73 break;
74
75 // for permission query feature
76 case "infoScreen":
77 if(!ilObjWikiAccess::_lookupOnline($a_obj_id))
78 {
79 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
80 }
81 else
82 {
83 $ilAccess->addInfoItem(IL_STATUS_MESSAGE, $lng->txt("online"));
84 }
85 break;
86
87 }
88 switch ($a_permission)
89 {
90 case "read":
91 case "visible":
92 if (!ilObjWikiAccess::_lookupOnline($a_obj_id) &&
93 (!$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id)))
94 {
95 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
96 return false;
97 }
98 break;
99 }
100
101 return true;
102 }
103
107 function _checkGoto($a_target)
108 {
109 global $ilAccess;
110// echo "-".$a_target."-"; exit;
111 $t_arr = explode("_", $a_target);
112
113 if ($t_arr[0] != "wiki" || (((int) $t_arr[1]) <= 0) && $t_arr[1] != "wpage")
114 {
115 return false;
116 }
117
118 if ($t_arr[1] == "wpage")
119 {
120 $wpg_id = (int) $t_arr[2];
121 include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
122 $w_id = ilWikiPage::lookupWikiId($wpg_id);
123 if ((int) $t_arr[3] > 0)
124 {
125 $refs = array((int) $t_arr[3]);
126 }
127 else
128 {
129 $refs = ilObject::_getAllReferences($w_id);
130 }
131 foreach ($refs as $r)
132 {
133 if ($ilAccess->checkAccess("read", "", $r))
134 {
135 return true;
136 }
137 }
138 }
139 else if ($ilAccess->checkAccess("read", "", $t_arr[1]))
140 {
141 return true;
142 }
143 return false;
144 }
145
151 function _lookupOnline($a_id)
152 {
153 global $ilDB;
154
155 $q = "SELECT * FROM il_wiki_data WHERE id = ".
156 $ilDB->quote($a_id, "integer");
157 $wk_set = $ilDB->query($q);
158 $wk_rec = $ilDB->fetchAssoc($wk_set);
159
160 return $wk_rec["is_online"];
161 }
162
168 function _lookupPublicFiles($a_id)
169 {
170 global $ilDB;
171
172 $q = "SELECT * FROM il_wiki_data WHERE id = ".
173 $ilDB->quote($a_id, "integer");
174 $wk_set = $ilDB->query($q);
175 $wk_rec = $ilDB->fetchAssoc($wk_set);
176
177 return $wk_rec["public_files"];
178 }
179
180}
181
182?>
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...
_getCommands()
get commands
_checkGoto($a_target)
check whether goto script will succeed
_lookupOnline($a_id)
Check wether wiki cast is online.
_lookupPublicFiles($a_id)
Check wether files should be public.
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
global $lng
Definition: privfeed.php:40
global $ilDB
global $ilUser
Definition: imgupload.php:15