ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilExcRepoObjAssignmentAccessInfo.php
Go to the documentation of this file.
1<?php
2
25{
26 protected bool $is_granted;
27
31 protected array $not_granted_reasons;
32
33 protected ilLanguage $lng;
35
40 protected function __construct(bool $a_is_granted, array $a_not_granted_reasons)
41 {
42 global $DIC;
43
44 $this->access = $DIC->access();
45 $this->is_granted = $a_is_granted;
46 $this->not_granted_reasons = $a_not_granted_reasons;
47
48 $this->lng = $DIC->language();
49 }
50
51
55 public function isGranted(): bool
56 {
57 return $this->is_granted;
58 }
59
65 public function getNotGrantedReasons(): array
66 {
68 }
69
74 public static function getInfo(int $a_ref_id, int $a_user_id): self
75 {
76 global $DIC;
77
79 $lng = $DIC->language();
80 $access = $DIC->access();
81
82 // if this object is not assigned to any assignment, we do not deny the access
83 $assignment_info = $repo_obj_ass->getAssignmentInfoOfObj($a_ref_id, $a_user_id);
84 if (count($assignment_info) == 0) {
85 return new self(true, []);
86 }
87
88 $granted = true;
89 $reasons = [];
90 foreach ($assignment_info as $i) {
91 if (!$i->isUserSubmission()) {
92 $has_write_permission = false;
93 foreach ($i->getReadableRefIds() as $exc_ref_id) {
94 if ($access->checkAccessOfUser($a_user_id, "write", "", $exc_ref_id)) {
95 $has_write_permission = true;
96 }
97 }
98 if (!$has_write_permission) {
99 $granted = false;
100 $reasons[0] = $lng->txt("exc_obj_not_submitted_by_user");
101 }
102 }
103 }
104
105 return new self($granted, $reasons);
106 }
107}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
isGranted()
Is access granted due to exercise assignment conditions?
__construct(bool $a_is_granted, array $a_not_granted_reasons)
Constructor.
static getInfo(int $a_ref_id, int $a_user_id)
getNotGrantedReasons()
Get reasons why access is not granted.
language handling
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkAccessOfUser(int $a_user_id, 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)
global $DIC
Definition: shib_login.php:26