ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\Blog\Access\BlogAccess Class Reference
+ Collaboration diagram for ILIAS\Blog\Access\BlogAccess:

Public Member Functions

 __construct ( $access_handler, ?int $node_id, int $id_type, int $user_id, int $owner)
 
 canWrite ()
 
 mayContribute ()
 
 mayEditPosting (int $a_posting_id, ?int $a_author_id=null)
 

Protected Member Functions

 checkPermissionBool (string $perm)
 

Protected Attributes

int $owner
 
int $id_type
 
 $access
 
int $node_id
 
int $user_id
 

Detailed Description

Definition at line 23 of file BlogAccess.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Blog\Access\BlogAccess::__construct (   $access_handler,
?int  $node_id,
int  $id_type,
int  $user_id,
int  $owner 
)

Definition at line 31 of file BlogAccess.php.

References ILIAS\Blog\Access\BlogAccess\$id_type, ILIAS\Blog\Access\BlogAccess\$node_id, ILIAS\Blog\Access\BlogAccess\$owner, ILIAS\Blog\Access\BlogAccess\$user_id, and ILIAS\Repository\access().

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  }
+ Here is the call graph for this function:

Member Function Documentation

◆ canWrite()

ILIAS\Blog\Access\BlogAccess::canWrite ( )

Definition at line 45 of file BlogAccess.php.

References ILIAS\Repository\access().

45  : bool
46  {
47  return $this->access->checkAccess('write', '', $this->node_id);
48  }
+ Here is the call graph for this function:

◆ checkPermissionBool()

ILIAS\Blog\Access\BlogAccess::checkPermissionBool ( string  $perm)
protected

Definition at line 88 of file BlogAccess.php.

References ILIAS\Repository\access().

Referenced by ILIAS\Blog\Access\BlogAccess\mayContribute(), and ILIAS\Blog\Access\BlogAccess\mayEditPosting().

88  : 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  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mayContribute()

ILIAS\Blog\Access\BlogAccess::mayContribute ( )

Definition at line 50 of file BlogAccess.php.

References ILIAS\Blog\Access\BlogAccess\checkPermissionBool(), and ilObject2GUI\WORKSPACE_NODE_ID.

50  : 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  }
checkPermissionBool(string $perm)
Definition: BlogAccess.php:88
+ Here is the call graph for this function:

◆ mayEditPosting()

ILIAS\Blog\Access\BlogAccess::mayEditPosting ( int  $a_posting_id,
?int  $a_author_id = null 
)

Definition at line 60 of file BlogAccess.php.

References $post, ILIAS\Blog\Access\BlogAccess\checkPermissionBool(), and ilObject2GUI\WORKSPACE_NODE_ID.

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  }
checkPermissionBool(string $perm)
Definition: BlogAccess.php:88
$post
Definition: ltitoken.php:46
+ Here is the call graph for this function:

Field Documentation

◆ $access

ILIAS\Blog\Access\BlogAccess::$access
protected

Definition at line 27 of file BlogAccess.php.

◆ $id_type

int ILIAS\Blog\Access\BlogAccess::$id_type
protected

Definition at line 26 of file BlogAccess.php.

Referenced by ILIAS\Blog\Access\BlogAccess\__construct().

◆ $node_id

int ILIAS\Blog\Access\BlogAccess::$node_id
protected

Definition at line 28 of file BlogAccess.php.

Referenced by ILIAS\Blog\Access\BlogAccess\__construct().

◆ $owner

int ILIAS\Blog\Access\BlogAccess::$owner
protected

Definition at line 25 of file BlogAccess.php.

Referenced by ILIAS\Blog\Access\BlogAccess\__construct().

◆ $user_id

int ILIAS\Blog\Access\BlogAccess::$user_id
protected

Definition at line 29 of file BlogAccess.php.

Referenced by ILIAS\Blog\Access\BlogAccess\__construct().


The documentation for this class was generated from the following file: