ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilObjLinkResourceAccess.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
5include_once("./Services/Object/classes/class.ilObjectAccess.php");
6
17{
18 static $item = array();
19 static $single_link = array();
20
33 function _getCommands()
34 {
35 $commands = array
36 (
37 array("permission" => "read", "cmd" => "", "lang_var" => "show",
38 "default" => true),
39 array("permission" => "write", "cmd" => "editLinks", "lang_var" => "edit_content"),
40 array("permission" => "write", "cmd" => "settings", "lang_var" => "settings")
41 );
42
43 return $commands;
44 }
45
49 function _checkGoto($a_target)
50 {
51 global $ilAccess;
52
53 $t_arr = explode("_", $a_target);
54
55 if ($t_arr[0] != "webr" || ((int) $t_arr[1]) <= 0)
56 {
57 return false;
58 }
59
60 if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
61 $ilAccess->checkAccess("visible", "", $t_arr[1]))
62 {
63 return true;
64 }
65 return false;
66 }
67
80 public function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
81 {
82 global $rbacsystem;
83
84 // Set offline if no valid link exists
85 if($a_permission == 'read')
86 {
87 if(!self::_getFirstLink($a_obj_id) && !$rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id))
88 {
89 return false;
90 }
91 }
92
93 if ($a_cmd == "settings")
94 {
95 if (self::_checkDirectLink($a_obj_id))
96 {
97 return false;
98 }
99 }
100 return parent::_checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id);
101 }
102
111 public static function _getFirstLink($a_webr_id)
112 {
113 global $ilDB;
114
115 if (isset(self::$item[$a_webr_id]))
116 {
117 return self::$item[$a_webr_id];
118 }
119 $query = "SELECT * FROM webr_items ".
120 "WHERE webr_id = ". $ilDB->quote($a_webr_id ,'integer').' '.
121 "AND active = ".$ilDB->quote(1,'integer').' ';
122 $res = $ilDB->query($query);
123
124 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
125 {
126 $item['title'] = $row->title;
127 $item['description'] = $row->description;
128 $item['target'] = $row->target;
129 $item['active'] = (bool) $row->active;
130 $item['disable_check'] = $row->disable_check;
131 $item['create_date'] = $row->create_date;
132 $item['last_update'] = $row->last_update;
133 $item['last_check'] = $row->last_check;
134 $item['valid'] = $row->valid;
135 $item['link_id'] = $row->link_id;
136 self::$item[$row->webr_id] = $item;
137 }
138 return $item ? $item : array();
139 }
140
146 function _preloadData($a_obj_ids, $a_ref_ids)
147 {
148 global $ilDB, $ilUser;
149
150 $res = $ilDB->query(
151 "SELECT * FROM webr_items WHERE ".
152 $ilDB->in("webr_id", $a_obj_ids, false, "integer").
153 " AND active = ". $ilDB->quote(1,'integer'));
154 foreach ($a_obj_ids as $id)
155 {
156 self::$item[$id] = array();
157 }
158 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
159 {
160 $item['title'] = $row->title;
161 $item['description'] = $row->description;
162 $item['target'] = $row->target;
163 $item['active'] = (bool) $row->active;
164 $item['disable_check'] = $row->disable_check;
165 $item['create_date'] = $row->create_date;
166 $item['last_update'] = $row->last_update;
167 $item['last_check'] = $row->last_check;
168 $item['valid'] = $row->valid;
169 $item['link_id'] = $row->link_id;
170 self::$item[$row->webr_id] = $item;
171 }
172 }
173
179 static function _checkDirectLink($a_obj_id)
180 {
181 if(isset(self::$single_link[$a_obj_id]))
182 {
183 return self::$single_link[$a_obj_id];
184 }
185 include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
186 return self::$single_link[$a_obj_id] = ilLinkResourceItems::_isSingular($a_obj_id);
187 }
188
189}
190
191?>
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
static _isSingular($a_webr_id)
Check whether there is only one active link in the web resource.
Class ilObjLinkResourceAccess.
static _getFirstLink($a_webr_id)
Get first link item Check before with _isSingular() if there is more or less than one.
static _checkDirectLink($a_obj_id)
Check whether there is only one active link in the web resource.
_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...
_preloadData($a_obj_ids, $a_ref_ids)
Preload data.
_checkGoto($a_target)
check whether goto script will succeed
Class ilObjectAccess.
global $ilDB
global $ilUser
Definition: imgupload.php:15