ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
5 include_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 $DIC;
52 
53  $ilAccess = $DIC['ilAccess'];
54 
55  $t_arr = explode("_", $a_target);
56 
57  if ($t_arr[0] != "webr" || ((int) $t_arr[1]) <= 0) {
58  return false;
59  }
60 
61  if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
62  $ilAccess->checkAccess("visible", "", $t_arr[1])) {
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 $DIC;
83 
84  $rbacsystem = $DIC['rbacsystem'];
85 
86  // Set offline if no valid link exists
87  if ($a_permission == 'read') {
88  if (!self::_getFirstLink($a_obj_id) && !$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id)) {
89  return false;
90  }
91  }
92 
93  if ($a_cmd == "settings") {
94  if (self::_checkDirectLink($a_obj_id)) {
95  return false;
96  }
97  }
98  return parent::_checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id);
99  }
100 
109  public static function _getFirstLink($a_webr_id)
110  {
111  global $DIC;
112 
113  $ilDB = $DIC['ilDB'];
114 
115  if (isset(self::$item[$a_webr_id])) {
116  return self::$item[$a_webr_id];
117  }
118  $query = "SELECT * FROM webr_items " .
119  "WHERE webr_id = " . $ilDB->quote($a_webr_id, 'integer') . ' ' .
120  "AND active = " . $ilDB->quote(1, 'integer') . ' ';
121  $res = $ilDB->query($query);
122 
123  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
124  $item['title'] = $row->title;
125  $item['description'] = $row->description;
126  $item['target'] = $row->target;
127  $item['active'] = (bool) $row->active;
128  $item['disable_check'] = $row->disable_check;
129  $item['create_date'] = $row->create_date;
130  $item['last_update'] = $row->last_update;
131  $item['last_check'] = $row->last_check;
132  $item['valid'] = $row->valid;
133  $item['link_id'] = $row->link_id;
134  self::$item[$row->webr_id] = $item;
135  }
136  return $item ? $item : array();
137  }
138 
144  public static function _preloadData($a_obj_ids, $a_ref_ids)
145  {
146  global $DIC;
147 
148  $ilDB = $DIC['ilDB'];
149  $ilUser = $DIC['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  );
156  foreach ($a_obj_ids as $id) {
157  self::$item[$id] = array();
158  }
159  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
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  public static function _checkDirectLink($a_obj_id)
180  {
181  if (isset(self::$single_link[$a_obj_id])) {
182  return self::$single_link[$a_obj_id];
183  }
184  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
185  return self::$single_link[$a_obj_id] = ilLinkResourceItems::_isSingular($a_obj_id);
186  }
187 }
static _isSingular($a_webr_id)
Check whether there is only one active link in the web resource.
static _checkGoto($a_target)
check whether goto script will succeed
global $DIC
Definition: saml.php:7
if(!array_key_exists('StateId', $_REQUEST)) $id
static _checkDirectLink($a_obj_id)
Check whether there is only one active link in the web resource.
foreach($_POST as $key=> $value) $res
$ilUser
Definition: imgupload.php:18
$query
_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 _preloadData($a_obj_ids, $a_ref_ids)
Preload data.
$row
static _getFirstLink($a_webr_id)
Get first link item Check before with _isSingular() if there is more or less than one...
Class ilObjectAccess.
global $ilDB
Class ilObjLinkResourceAccess.