ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Notes\AccessManager Class Reference
+ Collaboration diagram for ILIAS\Notes\AccessManager:

Public Member Functions

 __construct (InternalDataService $data, InternalRepoService $repo, InternalDomainService $domain)
 
 canEdit (Note $note, int $user_id=0)
 
 canDelete (Note $note, int $user_id=0, $public_deletion_enabled=false)
 

Protected Attributes

ilAccessHandler $access
 
ilSetting $settings
 
int $user_id
 
InternalDomainService $domain
 
InternalRepoService $repo
 
InternalDataService $data
 

Detailed Description

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 26 of file class.AccessManager.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Notes\AccessManager::__construct ( InternalDataService  $data,
InternalRepoService  $repo,
InternalDomainService  $domain 
)

Definition at line 35 of file class.AccessManager.php.

39 {
40 $this->data = $data;
41 $this->repo = $repo;
42 $this->domain = $domain;
43 $this->user_id = $domain->user()->getId();
44 $this->settings = $domain->settings();
45 $this->access = $domain->access();
46 }
InternalDomainService $domain

References ILIAS\Notes\AccessManager\$data, ILIAS\Notes\AccessManager\$domain, ILIAS\Notes\AccessManager\$repo, ILIAS\Repository\access(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

Member Function Documentation

◆ canDelete()

ILIAS\Notes\AccessManager::canDelete ( Note  $note,
int  $user_id = 0,
  $public_deletion_enabled = false 
)

Definition at line 58 of file class.AccessManager.php.

62 : bool {
63 if ($user_id === 0) {
65 }
68 $user_can_delete_their_comments = (bool) $settings->get("comments_del_user", '0');
69 $tutor_can_delete_comments = (bool) $settings->get("comments_del_tutor", '1');
70
72 return false;
73 }
74
75 $is_author = ($note->getAuthor() === $user_id);
76
77 if ($is_author && $note->getType() === Note::PRIVATE) {
78 return true;
79 }
80
81 if ($public_deletion_enabled && $note->getType() === Note::PUBLIC) {
82 return true;
83 }
84
85 if ($is_author && $user_can_delete_their_comments && $note->getType() === Note::PUBLIC) {
86 return true;
87 }
88
89 // this logic has been set from pdnotes
90 if ($tutor_can_delete_comments) {
91 foreach (\ilObject::_getAllReferences($note->getContext()->getObjId()) as $ref_id) {
92 if ($access->checkAccess("write", "", $ref_id)) {
93 return true;
94 }
95 }
96 }
97 return false;
98 }
static _getAllReferences(int $id)
get all reference ids for object ID
get(string $a_keyword, ?string $a_default_value=null)
get setting
const ANONYMOUS_USER_ID
Definition: constants.php:27
checkAccess(string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance)
$ref_id
Definition: ltiauth.php:66

References $user_id.

◆ canEdit()

ILIAS\Notes\AccessManager::canEdit ( Note  $note,
int  $user_id = 0 
)

Definition at line 48 of file class.AccessManager.php.

51 : bool {
52 if ($user_id === 0) {
54 }
55 return $user_id !== ANONYMOUS_USER_ID && $note->getAuthor() === $user_id;
56 }

References ILIAS\Notes\AccessManager\$user_id.

Field Documentation

◆ $access

ilAccessHandler ILIAS\Notes\AccessManager::$access
protected

Definition at line 28 of file class.AccessManager.php.

◆ $data

InternalDataService ILIAS\Notes\AccessManager::$data
protected

Definition at line 33 of file class.AccessManager.php.

Referenced by ILIAS\Notes\AccessManager\__construct().

◆ $domain

InternalDomainService ILIAS\Notes\AccessManager::$domain
protected

Definition at line 31 of file class.AccessManager.php.

Referenced by ILIAS\Notes\AccessManager\__construct().

◆ $repo

InternalRepoService ILIAS\Notes\AccessManager::$repo
protected

Definition at line 32 of file class.AccessManager.php.

Referenced by ILIAS\Notes\AccessManager\__construct().

◆ $settings

ilSetting ILIAS\Notes\AccessManager::$settings
protected

Definition at line 29 of file class.AccessManager.php.

◆ $user_id

int ILIAS\Notes\AccessManager::$user_id
protected

Definition at line 30 of file class.AccessManager.php.

Referenced by ILIAS\Notes\AccessManager\canEdit().


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