ILIAS
release_9 Revision v9.13-25-g2c18ec4c24f
◀ ilDoc Overview
BlogAccess.php
Go to the documentation of this file.
1
<?php
2
19
declare(strict_types=1);
20
21
namespace
ILIAS\Blog\Access
;
22
23
class
BlogAccess
24
{
25
protected
int
$owner
;
26
protected
int
$id_type
;
27
protected
$access
;
28
protected
?
int
$node_id
;
29
protected
int
$user_id
;
30
31
public
function
__construct
(
32
$access_handler,
33
?
int
$node_id,
34
int
$id_type,
35
int
$user_id,
36
int
$owner
37
) {
38
$this->
access
= $access_handler;
39
$this->node_id =
$node_id
;
40
$this->id_type =
$id_type
;
41
$this->user_id =
$user_id
;
42
$this->owner =
$owner
;
43
}
44
45
public
function
canWrite
(): bool
46
{
47
return
$this->
access
->checkAccess(
'write'
,
''
, $this->node_id);
48
}
49
50
public
function
mayContribute
(): bool
51
{
52
if
($this->id_type === \
ilObject2GUI::WORKSPACE_NODE_ID
) {
53
return
$this->
checkPermissionBool
(
"write"
);
54
}
55
56
return
($this->
checkPermissionBool
(
"redact"
) ||
57
$this->
checkPermissionBool
(
"contribute"
));
58
}
59
60
public
function
mayEditPosting
(
61
int
$a_posting_id,
62
int
$a_author_id = null
63
): bool {
64
// single author blog (owner) in personal workspace
65
if
($this->id_type === \
ilObject2GUI::WORKSPACE_NODE_ID
) {
66
return
$this->
checkPermissionBool
(
"write"
);
67
}
68
69
// repository blogs
70
71
// redact allows to edit all postings
72
if
($this->
checkPermissionBool
(
"redact"
)) {
73
return
true
;
74
}
75
76
// contribute gives access to own postings
77
if
($this->
checkPermissionBool
(
"contribute"
)) {
78
// check owner of posting
79
if
(!$a_author_id) {
80
$post
= new \ilBlogPosting($a_posting_id);
81
$a_author_id =
$post
->getAuthor();
82
}
83
return
$this->user_id === $a_author_id;
84
}
85
return
false
;
86
}
87
88
protected
function
checkPermissionBool
(
string
$perm): bool
89
{
90
if
(!is_null($this->node_id)) {
91
return
$this->
access
->checkAccess($perm,
""
, $this->node_id);
92
}
93
if
($this->owner === $this->user_id) {
94
return
true
;
95
}
96
return
false
;
97
}
98
99
}
ILIAS\Repository\access
access()
Definition:
trait.GlobalDICDomainServices.php:48
ILIAS\Blog\Access\BlogAccess\mayEditPosting
mayEditPosting(int $a_posting_id, int $a_author_id=null)
Definition:
BlogAccess.php:60
ILIAS\Blog\Access\BlogAccess\checkPermissionBool
checkPermissionBool(string $perm)
Definition:
BlogAccess.php:88
ILIAS\Blog\Access\BlogAccess
Definition:
BlogAccess.php:23
ILIAS\Blog\Access\BlogAccess\__construct
__construct( $access_handler, ?int $node_id, int $id_type, int $user_id, int $owner)
Definition:
BlogAccess.php:31
ILIAS\Blog\Access\BlogAccess\$owner
int $owner
Definition:
BlogAccess.php:25
ILIAS\Blog\Access
Definition:
BlogAccess.php:21
ILIAS\Blog\Access\BlogAccess\$user_id
int $user_id
Definition:
BlogAccess.php:29
ILIAS\Blog\Access\BlogAccess\mayContribute
mayContribute()
Definition:
BlogAccess.php:50
ILIAS\Blog\Access\BlogAccess\canWrite
canWrite()
Definition:
BlogAccess.php:45
ilObject2GUI\WORKSPACE_NODE_ID
const WORKSPACE_NODE_ID
Definition:
class.ilObject2GUI.php:47
ILIAS\Blog\Access\BlogAccess\$id_type
int $id_type
Definition:
BlogAccess.php:26
$post
$post
Definition:
ltitoken.php:49
ILIAS\Blog\Access\BlogAccess\$node_id
int $node_id
Definition:
BlogAccess.php:28
ILIAS\Blog\Access\BlogAccess\$access
$access
Definition:
BlogAccess.php:27
Modules
Blog
Access
BlogAccess.php
Generated on Wed Sep 10 2025 14:10:29 for ILIAS by
1.8.13 (using
Doxyfile
)