ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilPDStudyProgrammeSimpleListGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2015 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
5require_once("Services/Block/classes/class.ilBlockGUI.php");
6require_once('./Modules/StudyProgramme/classes/class.ilObjStudyProgrammeAdmin.php');
7
16{
17 const BLOCK_TYPE = "prgsimplelist";
18
22 protected $il_lng;
23
27 protected $il_user;
28
32 protected $il_access;
33
37 protected $il_setting;
38
43
48
53
54 public function __construct()
55 {
56 global $DIC;
57
59
60 $lng = $DIC['lng'];
61 $ilUser = $DIC['ilUser'];
62 $ilAccess = $DIC['ilAccess'];
63 $ilSetting = $DIC['ilSetting'];
64 $this->il_lng = $lng;
65 $this->il_user = $ilUser;
66 $this->il_access = $ilAccess;
67 $this->il_setting = $ilSetting;
68 $this->il_logger = ilLoggerFactory::getLogger('prg');
69
70 $this->sp_user_assignment_db = ilStudyProgrammeDIC::dic()['ilStudyProgrammeUserAssignmentDB'];
71
72 // No need to load data, as we won't display this.
73 if (!$this->shouldShowThisList()) {
74 return;
75 }
76
77 $this->getUsersAssignments();
78 //check which kind of option is selected in settings
79 $this->getVisibleOnPDMode();
80 //check to display info message if option "read" is selected
81 $this->getToShowInfoMessage();
82
83 // As this won't be visible we don't have to initialize this.
84 if (!$this->userHasReadableStudyProgrammes()) {
85 return;
86 }
87
88 $this->setTitle($this->il_lng->txt("objs_prg"));
89 }
90
91 public function getHTML()
92 {
93 // TODO: This should be determined from somewhere up in the hierarchy, as
94 // this will lead to problems, when e.g. a command changes. But i don't see
95 // how atm...
96 if (!$this->shouldShowThisList()) {
97 return "";
98 }
99
100 if (!$this->userHasReadableStudyProgrammes()) {
101 return "";
102 }
103 return parent::getHTML();
104 }
105
106 public function getDataSectionContent()
107 {
108 $content = "";
109 foreach ($this->users_assignments as $assignment) {
110 if (!$this->isReadable($assignment)) {
111 continue;
112 }
113
114 try {
115 $list_item = $this->new_ilStudyProgrammeAssignmentListGUI($assignment);
116 $list_item->setShowInfoMessage($this->show_info_message);
117 $list_item->setVisibleOnPDMode($this->visible_on_pd_mode);
118 $content .= $list_item->getHTML();
120 $this->il_logger->alert("$e");
122 $this->il_logger->alert("$e");
123 }
124 }
125 return $content;
126 }
127
131 public function getBlockType() : string
132 {
133 return self::BLOCK_TYPE;
134 }
135
139 protected function isRepositoryObject() : bool
140 {
141 return false;
142 }
143
144 public function fillDataSection()
145 {
146 assert($this->userHasReadableStudyProgrammes()); // We should not get here.
147 $this->tpl->setVariable("BLOCK_ROW", $this->getDataSectionContent());
148 }
149
150
151 protected function userHasVisibleStudyProgrammes()
152 {
153 if (count($this->users_assignments) == 0) {
154 return false;
155 }
156 foreach ($this->users_assignments as $assignment) {
157 if ($this->isVisible($assignment)) {
158 return true;
159 }
160 }
161 return false;
162 }
163
165 {
166 if (count($this->users_assignments) == 0) {
167 return false;
168 }
169 foreach ($this->users_assignments as $assignment) {
170 if ($this->isReadable($assignment)) {
171 return true;
172 }
173 }
174 return false;
175 }
176
177 protected function getVisibleOnPDMode()
178 {
179 $this->visible_on_pd_mode = $this->il_setting->get(ilObjStudyProgrammeAdmin::SETTING_VISIBLE_ON_PD);
180 }
181
182 protected function hasPermission(ilStudyProgrammeAssignment $assignment, $permission)
183 {
185 return $this->il_access->checkAccess($permission, "", $prg->getRefId(), "prg", $prg->getId());
186 }
187
188 protected function getToShowInfoMessage()
189 {
190 $viewSettings = new ilPDSelectedItemsBlockViewSettings($GLOBALS['DIC']->user(), (int) $_GET['view']);
191 $this->show_info_message = $viewSettings->isStudyProgrammeViewActive();
192 }
193
194 protected function isVisible(ilStudyProgrammeAssignment $assignment)
195 {
196 return $this->hasPermission($assignment, "visible");
197 }
198
199 protected function isReadable(ilStudyProgrammeAssignment $assignment)
200 {
201 if ($this->visible_on_pd_mode == ilObjStudyProgrammeAdmin::SETTING_VISIBLE_ON_PD_ALLWAYS) {
202 return true;
203 }
204
205 return $this->hasPermission($assignment, "read");
206 }
207
208 protected function shouldShowThisList()
209 {
210 global $DIC;
211 $ctrl = $DIC->ctrl();
212 return ($_GET["cmd"] == "jumpToSelectedItems" ||
213 ($ctrl->getCmdClass() == "ildashboardgui" && $ctrl->getCmd() == "show")
214 ) && !$_GET["expand"];
215 }
216
217 protected function getUsersAssignments()
218 {
219 $this->users_assignments = $this->sp_user_assignment_db->getInstancesOfUser($this->il_user->getId());
220 }
221
223 {
224 $prg = ilObjStudyProgramme::getInstanceByObjId($assignment->getRootId());
225 $progress = $prg->getProgressForAssignment($a_assignment->getId());
226 $progress_gui = new ilStudyProgrammeProgressListGUI($progress);
227 $progress_gui->setOnlyRelevant(true);
228 return $progress_gui;
229 }
230}
user()
Definition: user.php:4
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
This class represents a block method of a block.
setTitle($a_title)
Set Title.
static getLogger($a_component_id)
Get component logger.
Personal Desktop-Presentation for the Study Programme.
fillDataSection()
Standard implementation for row based data.
isRepositoryObject()
Returns whether block has a corresponding repository object.bool
new_ilStudyProgrammeAssignmentListGUI(ilStudyProgrammeAssignment $a_assignment)
isVisible(ilStudyProgrammeAssignment $assignment)
isReadable(ilStudyProgrammeAssignment $assignment)
hasPermission(ilStudyProgrammeAssignment $assignment, $permission)
Represents one assignment of the user to a program tree.
Exception is thrown when a progress for some programme node and assignment is missing.
Class ilStudyProgrammeProgressListGUI.
Exception is thrown when invariants on the program tree would be violated by manipulation of tree.
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilSetting
Definition: privfeed.php:17