ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 
11 {
15  protected $is_granted;
16 
21 
25  protected $lng;
26 
30  protected $access;
31 
37  protected function __construct($a_is_granted, array $a_not_granted_reasons)
38  {
39  global $DIC;
40 
41  $this->access = $DIC->access();
42  $this->is_granted = $a_is_granted;
43  $this->not_granted_reasons = $a_not_granted_reasons;
44 
45  $this->lng = $DIC->language();
46  }
47 
48 
54  public function isGranted()
55  {
56  return $this->is_granted;
57  }
58 
64  public function getNotGrantedReasons()
65  {
67  }
68 
76  public static function getInfo($a_ref_id, $a_user_id)
77  {
78  global $DIC;
79 
80  $repo_obj_ass = ilExcRepoObjAssignment::getInstance();
81  $lng = $DIC->language();
82  $access = $DIC->access();
83 
84  // if this object is not assigned to any assignment, we do not deny the access
85  $assignment_info = $repo_obj_ass->getAssignmentInfoOfObj($a_ref_id, $a_user_id);
86  if (count($assignment_info) == 0) {
87  return new self(true, []);
88  }
89 
90  $granted = true;
91  $reasons = [];
92  foreach ($assignment_info as $i) {
93  if (!$i->isUserSubmission()) {
94  $has_write_permission = false;
95  foreach ($i->getReadableRefIds() as $exc_ref_id) {
96  if ($access->checkAccessOfUser($a_user_id, "write", "", $exc_ref_id)) {
97  $has_write_permission = true;
98  }
99  }
100  if (!$has_write_permission) {
101  $granted = false;
102  $reasons[0] = $lng->txt("exc_obj_not_submitted_by_user");
103  }
104  }
105  }
106 
107  return new self($granted, $reasons);
108  }
109 }
getNotGrantedReasons()
Get reasons why access is not granted.
static getInstance()
Get instance.
__construct($a_is_granted, array $a_not_granted_reasons)
Constructor.
isGranted()
Is access granted due to exercise assignment conditions?
$DIC
Definition: xapitoken.php:46
$i
Definition: metadata.php:24
Repository object assignment information.