ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilExcRepoObjAssignmentAccessInfo.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once("./Modules/Exercise/RepoObjectAssignment/interfaces/interface.ilExcRepoObjAssignmentAccessInfoInterface.php");
6
13{
17 protected $is_granted;
18
23
27 protected $lng;
28
32 protected $access;
33
39 protected function __construct($a_is_granted, array $a_not_granted_reasons)
40 {
41 global $DIC;
42
43 $this->access = $DIC->access();
44 $this->is_granted = $a_is_granted;
45 $this->not_granted_reasons = $a_not_granted_reasons;
46
47 $this->lng = $DIC->language();
48 }
49
50
56 public function isGranted()
57 {
58 return $this->is_granted;
59 }
60
66 public function getNotGrantedReasons()
67 {
69 }
70
78 public static function getInfo($a_ref_id, $a_user_id)
79 {
80 global $DIC;
81
82 include_once("./Modules/Exercise/RepoObjectAssignment/classes/class.ilExcRepoObjAssignment.php");
84 $lng = $DIC->language();
85 $access = $DIC->access();
86
87 // if this object is not assigned to any assignment, we do not deny the access
88 $assignment_info = $repo_obj_ass->getAssignmentInfoOfObj($a_ref_id, $a_user_id);
89 if (count($assignment_info) == 0) {
90 return new self(true, []);
91 }
92
93 $granted = true;
94 $reasons = [];
95 foreach ($assignment_info as $i) {
96 if (!$i->isUserSubmission()) {
97 $has_write_permission = false;
98 foreach ($i->getReadableRefIds() as $exc_ref_id) {
99 if ($access->checkAccessOfUser($a_user_id, "write", "", $exc_ref_id)) {
100 $has_write_permission = true;
101 }
102 }
103 if (!$has_write_permission) {
104 $granted = false;
105 $reasons[0] = $lng->txt("exc_obj_not_submitted_by_user");
106 }
107 }
108 }
109
110 return new self($granted, $reasons);
111 }
112}
An exception for terminatinating execution or to throw for unit testing.
Repository object assignment information.
isGranted()
Is access granted due to exercise assignment conditions?
__construct($a_is_granted, array $a_not_granted_reasons)
Constructor.
getNotGrantedReasons()
Get reasons why access is not granted.
$i
Definition: disco.tpl.php:19
global $DIC
Definition: saml.php:7