ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilObjBlogAccess.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
26 {
27  protected ilObjUser $user;
29 
30  public function __construct()
31  {
32  global $DIC;
33 
34  $this->user = $DIC->user();
35  $this->access = $DIC->access();
36  }
37 
38  public static function _getCommands(): array
39  {
40  return array(
41  array("permission" => "read", "cmd" => "preview", "lang_var" => "show", "default" => true),
42  array("permission" => "write", "cmd" => "render", "lang_var" => "edit"),
43  array("permission" => "contribute", "cmd" => "render", "lang_var" => "edit"),
44  array("permission" => "write", "cmd" => "edit", "lang_var" => "settings"),
45  array("permission" => "write", "cmd" => "export", "lang_var" => "export_html")
46  );
47  }
48 
49  public static function _checkGoto(string $target): bool
50  {
51  global $DIC;
52 
53  $ilAccess = $DIC->access();
54 
55  $t_arr = explode("_", $target);
56 
57  if (substr($target, -3) === "wsp") {
58  return ilSharedResourceGUI::hasAccess((int) $t_arr[1]);
59  }
60 
61  if ($t_arr[0] !== "blog" || ((int) $t_arr[1]) <= 0) {
62  return false;
63  }
64 
65  // #12648
66  if ($ilAccess->checkAccess("read", "", (int) $t_arr[1]) ||
67  $ilAccess->checkAccess("visible", "", (int) $t_arr[1])) {
68  return true;
69  }
70  return false;
71  }
72 
73  public function canBeDelivered(ilWACPath $ilWACPath): bool
74  {
75  $ilUser = $this->user;
76  $ilAccess = $this->access;
77  if (preg_match("/\\/blog_([\\d]*)\\//uim", $ilWACPath->getPath(), $results)) {
78  $obj_id = $results[1];
79  if ($obj_id == "") {
80  return false;
81  }
82 
83  // personal workspace
84  $tree = new ilWorkspaceTree(0);
85  $node_id = $tree->lookupNodeId((int) $obj_id);
86  if ($node_id) {
87  $access_handler = new ilWorkspaceAccessHandler($tree);
88  if ($access_handler->checkAccessOfUser($tree, $ilUser->getId(), "read", "view", $node_id, "blog")) {
89  return true;
90  }
91  }
92  // repository (RBAC)
93  else {
94  $ref_ids = ilObject::_getAllReferences((int) $obj_id);
95  foreach ($ref_ids as $ref_id) {
96  if ($ilAccess->checkAccessOfUser($ilUser->getId(), "read", "view", $ref_id, "blog", (int) $obj_id)) {
97  return true;
98  }
99  }
100  }
101  }
102 
103  return false;
104  }
105 
106  public static function isCommentsExportPossible(int $blog_id): bool
107  {
108  global $DIC;
109 
110  $setting = $DIC->settings();
111  $notes = $DIC->notes();
112  $privacy = ilPrivacySettings::getInstance();
113  if ($setting->get("disable_comments")) {
114  return false;
115  }
116  if (!$privacy->enabledCommentsExport()) {
117  return false;
118  }
119  if (!$notes->domain()->commentsActive($blog_id)) {
120  return false;
121  }
122  return true;
123  }
124 }
static _checkGoto(string $target)
ilAccessHandler $access
Class ilObjBlogAccess.
static _getAllReferences(int $id)
get all reference ids for object ID
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
canBeDelivered(ilWACPath $ilWACPath)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
static isCommentsExportPossible(int $blog_id)
static hasAccess(int $a_node_id, bool $a_is_portfolio=false)
$results