ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 static function _getCommands()
34 {
35 $commands = array
36 (
37 array("permission" => "read", "cmd" => "", "lang_var" => "show",
38 "default" => true),
39 array("permission" => "read", "cmd" => "exportHTML", "lang_var" => "export_html"),
40 array("permission" => "write", "cmd" => "editLinks", "lang_var" => "edit_content"),
41 array("permission" => "write", "cmd" => "settings", "lang_var" => "settings")
42 );
43
44 return $commands;
45 }
46
50 static function _checkGoto($a_target)
51 {
52 global $ilAccess;
53
54 $t_arr = explode("_", $a_target);
55
56 if ($t_arr[0] != "webr" || ((int) $t_arr[1]) <= 0)
57 {
58 return false;
59 }
60
61 if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
62 $ilAccess->checkAccess("visible", "", $t_arr[1]))
63 {
64 return true;
65 }
66 return false;
67 }
68
81 public function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
82 {
83 global $rbacsystem;
84
85 // Set offline if no valid link exists
86 if($a_permission == 'read')
87 {
88 if(!self::_getFirstLink($a_obj_id) && !$rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id))
89 {
90 return false;
91 }
92 }
93
94 if ($a_cmd == "settings")
95 {
96 if (self::_checkDirectLink($a_obj_id))
97 {
98 return false;
99 }
100 }
101 return parent::_checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id);
102 }
103
112 public static function _getFirstLink($a_webr_id)
113 {
114 global $ilDB;
115
116 if (isset(self::$item[$a_webr_id]))
117 {
118 return self::$item[$a_webr_id];
119 }
120 $query = "SELECT * FROM webr_items ".
121 "WHERE webr_id = ". $ilDB->quote($a_webr_id ,'integer').' '.
122 "AND active = ".$ilDB->quote(1,'integer').' ';
123 $res = $ilDB->query($query);
124
125 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
126 {
127 $item['title'] = $row->title;
128 $item['description'] = $row->description;
129 $item['target'] = $row->target;
130 $item['active'] = (bool) $row->active;
131 $item['disable_check'] = $row->disable_check;
132 $item['create_date'] = $row->create_date;
133 $item['last_update'] = $row->last_update;
134 $item['last_check'] = $row->last_check;
135 $item['valid'] = $row->valid;
136 $item['link_id'] = $row->link_id;
137 self::$item[$row->webr_id] = $item;
138 }
139 return $item ? $item : array();
140 }
141
147 static function _preloadData($a_obj_ids, $a_ref_ids)
148 {
149 global $ilDB, $ilUser;
150
151 $res = $ilDB->query(
152 "SELECT * FROM webr_items WHERE ".
153 $ilDB->in("webr_id", $a_obj_ids, false, "integer").
154 " AND active = ". $ilDB->quote(1,'integer'));
155 foreach ($a_obj_ids as $id)
156 {
157 self::$item[$id] = array();
158 }
159 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
160 {
161 $item['title'] = $row->title;
162 $item['description'] = $row->description;
163 $item['target'] = $row->target;
164 $item['active'] = (bool) $row->active;
165 $item['disable_check'] = $row->disable_check;
166 $item['create_date'] = $row->create_date;
167 $item['last_update'] = $row->last_update;
168 $item['last_check'] = $row->last_check;
169 $item['valid'] = $row->valid;
170 $item['link_id'] = $row->link_id;
171 self::$item[$row->webr_id] = $item;
172 }
173 }
174
180 static function _checkDirectLink($a_obj_id)
181 {
182 if(isset(self::$single_link[$a_obj_id]))
183 {
184 return self::$single_link[$a_obj_id];
185 }
186 include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
187 return self::$single_link[$a_obj_id] = ilLinkResourceItems::_isSingular($a_obj_id);
188 }
189
190}
191
192?>
An exception for terminatinating execution or to throw for unit testing.
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.
static _preloadData($a_obj_ids, $a_ref_ids)
Preload data.
_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
Class ilObjectAccess.
global $ilDB
$ilUser
Definition: imgupload.php:18