ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 public static $item = array();
19 public static $single_link = array();
20
33 public static function _getCommands()
34 {
35 $commands = array(
36 array("permission" => "read", "cmd" => "", "lang_var" => "show",
37 "default" => true),
38 array("permission" => "read", "cmd" => "exportHTML", "lang_var" => "export_html"),
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 public static 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 return false;
57 }
58
59 if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
60 $ilAccess->checkAccess("visible", "", $t_arr[1])) {
61 return true;
62 }
63 return false;
64 }
65
78 public function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
79 {
80 global $rbacsystem;
81
82 // Set offline if no valid link exists
83 if ($a_permission == 'read') {
84 if (!self::_getFirstLink($a_obj_id) && !$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id)) {
85 return false;
86 }
87 }
88
89 if ($a_cmd == "settings") {
90 if (self::_checkDirectLink($a_obj_id)) {
91 return false;
92 }
93 }
94 return parent::_checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id);
95 }
96
105 public static function _getFirstLink($a_webr_id)
106 {
107 global $ilDB;
108
109 if (isset(self::$item[$a_webr_id])) {
110 return self::$item[$a_webr_id];
111 }
112 $query = "SELECT * FROM webr_items " .
113 "WHERE webr_id = " . $ilDB->quote($a_webr_id, 'integer') . ' ' .
114 "AND active = " . $ilDB->quote(1, 'integer') . ' ';
115 $res = $ilDB->query($query);
116
117 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
118 $item['title'] = $row->title;
119 $item['description'] = $row->description;
120 $item['target'] = $row->target;
121 $item['active'] = (bool) $row->active;
122 $item['disable_check'] = $row->disable_check;
123 $item['create_date'] = $row->create_date;
124 $item['last_update'] = $row->last_update;
125 $item['last_check'] = $row->last_check;
126 $item['valid'] = $row->valid;
127 $item['link_id'] = $row->link_id;
128 self::$item[$row->webr_id] = $item;
129 }
130 return $item ? $item : array();
131 }
132
138 public static function _preloadData($a_obj_ids, $a_ref_ids)
139 {
140 global $ilDB, $ilUser;
141
142 $res = $ilDB->query(
143 "SELECT * FROM webr_items WHERE " .
144 $ilDB->in("webr_id", $a_obj_ids, false, "integer") .
145 " AND active = " . $ilDB->quote(1, 'integer')
146 );
147 foreach ($a_obj_ids as $id) {
148 self::$item[$id] = array();
149 }
150 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
151 $item['title'] = $row->title;
152 $item['description'] = $row->description;
153 $item['target'] = $row->target;
154 $item['active'] = (bool) $row->active;
155 $item['disable_check'] = $row->disable_check;
156 $item['create_date'] = $row->create_date;
157 $item['last_update'] = $row->last_update;
158 $item['last_check'] = $row->last_check;
159 $item['valid'] = $row->valid;
160 $item['link_id'] = $row->link_id;
161 self::$item[$row->webr_id] = $item;
162 }
163 }
164
170 public static function _checkDirectLink($a_obj_id)
171 {
172 if (isset(self::$single_link[$a_obj_id])) {
173 return self::$single_link[$a_obj_id];
174 }
175 include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
176 return self::$single_link[$a_obj_id] = ilLinkResourceItems::_isSingular($a_obj_id);
177 }
178}
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.
if(!array_key_exists('StateId', $_REQUEST)) $id
$query
foreach($_POST as $key=> $value) $res
global $ilDB
$ilUser
Definition: imgupload.php:18