ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjBlogAccess.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26{
27 protected ilLanguage $lng;
28 protected ilObjUser $user;
30
31 public function __construct()
32 {
33 global $DIC;
34
35 $this->user = $DIC->user();
36 $this->access = $DIC->access();
37 $this->lng = $DIC->language();
38 }
39
40 public static function _getCommands(): array
41 {
42 return array(
43 array("permission" => "read", "cmd" => "preview", "lang_var" => "show", "default" => true),
44 array("permission" => "write", "cmd" => "render", "lang_var" => "edit"),
45 array("permission" => "contribute", "cmd" => "render", "lang_var" => "edit"),
46 array("permission" => "write", "cmd" => "edit", "lang_var" => "settings"),
47 array("permission" => "write", "cmd" => "export", "lang_var" => "export_html")
48 );
49 }
50
51 public static function _checkGoto(string $target): bool
52 {
53 global $DIC;
54
55 $ilAccess = $DIC->access();
56
57 $t_arr = explode("_", $target);
58
59 if (substr($target, -3) === "wsp") {
60 return ilSharedResourceGUI::hasAccess((int) $t_arr[1]);
61 }
62
63 if ($t_arr[0] !== "blog" || ((int) $t_arr[1]) <= 0) {
64 return false;
65 }
66
67 // #12648
68 if ($ilAccess->checkAccess("read", "", (int) $t_arr[1]) ||
69 $ilAccess->checkAccess("visible", "", (int) $t_arr[1])) {
70 return true;
71 }
72 return false;
73 }
74
75 public function canBeDelivered(ilWACPath $ilWACPath): bool
76 {
77 $ilUser = $this->user;
78 $ilAccess = $this->access;
79 if (preg_match("/\\/blog_([\\d]*)\\//uim", $ilWACPath->getPath(), $results)) {
80 $obj_id = $results[1];
81 if ($obj_id == "") {
82 return false;
83 }
84
85 // personal workspace
86 $tree = new ilWorkspaceTree(0);
87 $node_id = $tree->lookupNodeId((int) $obj_id);
88 if ($node_id) {
89 $access_handler = new ilWorkspaceAccessHandler($tree);
90 if ($access_handler->checkAccessOfUser($tree, $ilUser->getId(), "read", "view", $node_id, "blog")) {
91 return true;
92 }
93 } // repository (RBAC)
94 else {
95 $ref_ids = ilObject::_getAllReferences((int) $obj_id);
96 foreach ($ref_ids as $ref_id) {
97 if ($ilAccess->checkAccessOfUser(
98 $ilUser->getId(),
99 "read",
100 "view",
101 $ref_id,
102 "blog",
103 (int) $obj_id
104 )) {
105 return true;
106 }
107 }
108 }
109 }
110
111 return false;
112 }
113
114 public static function isCommentsExportPossible(int $blog_id): bool
115 {
116 global $DIC;
117
118 $setting = $DIC->settings();
119 $notes = $DIC->notes();
121 if ($setting->get("disable_comments")) {
122 return false;
123 }
124 if (!$privacy->enabledCommentsExport()) {
125 return false;
126 }
127 if (!$notes->domain()->commentsActive($blog_id)) {
128 return false;
129 }
130 return true;
131 }
132
133 public function _checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id = null): bool
134 {
135 switch ($permission) {
136 case "visible":
137 case "read":
138 if (self::_isOffline($obj_id) && !$this->access->checkAccessOfUser($user_id, "write", "", $ref_id)) {
139 $this->access->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $this->lng->txt("offline"));
140 return false;
141 }
142 break;
143 }
144 return true;
145 }
146
147}
language handling
Class ilObjBlogAccess.
static _getCommands()
get commands
static isCommentsExportPossible(int $blog_id)
ilAccessHandler $access
canBeDelivered(ilWACPath $ilWACPath)
_checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id=null)
Checks whether a user may invoke a command or not (this method is called by ilAccessHandler::checkAcc...
static _checkGoto(string $target)
check whether goto script will succeed
User class.
Class ilObjectAccess.
static _getAllReferences(int $id)
get all reference ids for object ID
static hasAccess(int $a_node_id, bool $a_is_portfolio=false)
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
$ref_id
Definition: ltiauth.php:66
$results
global $DIC
Definition: shib_login.php:26