ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilObjGlossaryAccess.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5
6include_once("./Services/Object/classes/class.ilObjectAccess.php");
7
18{
32 function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
33 {
34 global $ilUser, $lng, $rbacsystem, $ilAccess;
35
36 if ($a_user_id == "")
37 {
38 $a_user_id = $ilUser->getId();
39 }
40
41 switch ($a_permission)
42 {
43 case "read":
45 && !$rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id))
46 {
47 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
48 return false;
49 }
50 break;
51
52 case "visible":
53 if (!ilObjGlossaryAccess::_lookupOnline($a_obj_id) &&
54 (!$rbacsystem->checkAccessOfUser($a_user_id,'write', $a_ref_id)))
55 {
56 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
57 return false;
58 }
59 break;
60 }
61
62
63 return true;
64 }
65
78 function _getCommands()
79 {
80 $commands = array
81 (
82 array("permission" => "read", "cmd" => "view", "lang_var" => "show",
83 "default" => true),
84 array("permission" => "write", "cmd" => "edit", "lang_var" => "edit_content"),
85 array("permission" => "edit_content", "cmd" => "edit", "lang_var" => "edit_content"), // #11099
86 array("permission" => "write", "cmd" => "properties", "lang_var" => "settings")
87 );
88
89 return $commands;
90 }
91
92 //
93 // access relevant methods
94 //
95
99 function _lookupOnline($a_id)
100 {
101 global $ilDB;
102
103 $q = "SELECT * FROM glossary WHERE id = ".
104 $ilDB->quote($a_id, "integer");
105 $lm_set = $ilDB->query($q);
106 $lm_rec = $ilDB->fetchAssoc($lm_set);
107
108 return ilUtil::yn2tf($lm_rec["is_online"]);
109 }
110
114 function _checkGoto($a_target)
115 {
116 global $ilAccess;
117
118 $t_arr = explode("_", $a_target);
119
120 if (($t_arr[0] != "glo" && $t_arr[0] != "git") || ((int) $t_arr[1]) <= 0)
121 {
122 return false;
123 }
124
125 if ($t_arr[0] == "glo")
126 {
127 if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
128 $ilAccess->checkAccess("visible", "", $t_arr[1]))
129 {
130 return true;
131 }
132 }
133
134 if ($t_arr[0] == "git")
135 {
136 if ($t_arr[2] > 0)
137 {
138 $ref_ids = array($t_arr[2]);
139 }
140 else
141 {
142 // determine learning object
143 require_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
144 $glo_id = ilGlossaryTerm::_lookGlossaryID($t_arr[1]);
145 $ref_ids = ilObject::_getAllReferences($glo_id);
146 }
147 // check read permissions
148 foreach ($ref_ids as $ref_id)
149 {
150 // Permission check
151 if ($ilAccess->checkAccess("read", "", $ref_id))
152 {
153 return true;
154 }
155 }
156 }
157
158 return false;
159 }
160
161
162}
163
164?>
const IL_NO_OBJECT_ACCESS
static _lookGlossaryID($term_id)
get glossary id form term id
Class ilObjGlossaryAccess.
_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...
_checkGoto($a_target)
check whether goto script will succeed
_lookupOnline($a_id)
check wether learning module is online
Class ilObjectAccess.
static _getAllReferences($a_id)
get all reference ids of object
static yn2tf($a_yn)
convert "y"/"n" to true/false
global $lng
Definition: privfeed.php:40
$ref_id
Definition: sahs_server.php:39
global $ilDB
$lm_set
global $ilUser
Definition: imgupload.php:15