ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilLPListOfProgressGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
17{
18 public $tracked_user = null;
19 public $details_id = 0;
20 public $details_type = '';
21 public $details_mode = 0;
22
23 public function __construct($a_mode, $a_ref_id, $a_user_id = 0)
24 {
25 parent::__construct($a_mode, $a_ref_id, $a_user_id);
26 $this->__initUser($a_user_id);
27
28 // Set item id for details
29 $this->__initDetails((int) $_GET['details_id']);
30 $this->ctrl->saveParameter($this, 'details_id', $_REQUEST['details_id']);
31 }
32
33
37 public function executeCommand()
38 {
39 global $DIC;
40
41 $ilUser = $DIC['ilUser'];
42
43 $this->ctrl->setReturn($this, "show");
44 $this->ctrl->saveParameter($this, 'user_id', $this->getUserId());
45 switch ($this->ctrl->getNextClass()) {
46 case 'illpprogresstablegui':
47 include_once './Services/Tracking/classes/repository_statistics/class.ilLPProgressTableGUI.php';
48 $table_gui = new ilLPProgressTableGUI($this, "", $this->tracked_user);
49 $this->ctrl->setReturn($this, 'show');
50 $this->ctrl->forwardCommand($table_gui);
51 break;
52
53 default:
54 $cmd = $this->__getDefaultCommand();
55 $this->$cmd();
56
57 }
58 return true;
59 }
60
61 public function show()
62 {
63 global $DIC;
64
65 $ilObjDataCache = $DIC['ilObjDataCache'];
66
67 switch ($this->getMode()) {
68 // Show only detail of current repository item if called from repository
70 $this->__initDetails($this->getRefId());
71 return $this->details();
72
75 // if called from user folder obj_id is id of current user
76 $this->__initUser($this->getUserId());
77 break;
78 }
79
80 // not called from repository
81 $this->__showProgressList();
82 }
83
87 protected function saveProgress()
88 {
89 $info = new ilInfoScreenGUI($this);
90 $info->setContextRefId((int) $this->ref_id);
91 $info->setContextObjId((int) $this->details_obj_id);
92 $info->setContentObjType((string) $this->obj_type);
93 $info->saveProgress(false);
94 $this->ctrl->redirect($this);
95 }
96
97 public function details()
98 {
99 global $DIC;
100
101 $ilToolbar = $DIC['ilToolbar'];
102 $ilCtrl = $DIC['ilCtrl'];
103 $rbacsystem = $DIC['rbacsystem'];
104 $ilAccess = $DIC['ilAccess'];
105
110 // Show back button to crs if called from crs. Otherwise if called from personal desktop or administration
111 // show back to list
112 if ((int) $_GET['crs_id']) {
113 $this->ctrl->setParameter($this, 'details_id', (int) $_GET['crs_id']);
114
115 $ilToolbar->addButton(
116 $this->lng->txt('trac_view_crs'),
117 $this->ctrl->getLinkTarget($this, 'details')
118 );
119 } elseif ($this->getMode() == self::LP_CONTEXT_PERSONAL_DESKTOP or
120 $this->getMode() == self::LP_CONTEXT_ADMINISTRATION or
121 $this->getMode() == self::LP_CONTEXT_USER_FOLDER) {
122 $ilToolbar->addButton(
123 $this->lng->txt('trac_view_list'),
124 $this->ctrl->getLinkTarget($this, 'show')
125 );
126 }
127
128 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.lp_progress_container.html', 'Services/Tracking');
129
130 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
131 $info = new ilInfoScreenGUI($this);
132 $info->setContextRefId((int) $this->details_id);
133 $info->setContextObjId((int) $this->details_obj_id);
134 $info->setContentObjType((string) $this->obj_type);
135 $info->enableLearningProgress(true);
136 $info->setFormAction($ilCtrl->getFormAction($this));
137 $this->__appendUserInfo($info, $this->tracked_user);
138 $this->__appendLPDetails($info, $this->details_obj_id, $this->tracked_user->getId());
139 $this->__showObjectDetails($info, $this->details_obj_id, false);
140
141 // Finally set template variable
142 $this->tpl->setVariable("LM_INFO", $info->getHTML());
143
144 include_once './Services/Object/classes/class.ilObjectLP.php';
145 $olp = ilObjectLP::getInstance($this->details_obj_id);
146 $collection = $olp->getCollectionInstance();
147 $obj_ids = array();
148 if ($collection) {
149 foreach ($collection->getItems() as $item_id) {
150 if ($collection instanceof ilLPCollectionOfRepositoryObjects) {
151 $obj_id = ilObject::_lookupObjectId($item_id);
152 if ($ilAccess->checkAccessOfUser($this->tracked_user->getId(), 'visible', '', $item_id)) {
153 $obj_ids[$obj_id] = array( $item_id );
154 }
155 } else {
156 $obj_ids[] = $item_id;
157 }
158 }
159 }
160
161 // #15247
162 if (count($obj_ids) > 0) {
163 // seems obsolete
164 include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
165 $personal_only = !ilLearningProgressAccess::checkPermission('read_learning_progress', $this->getRefId());
166
167 include_once("./Services/Tracking/classes/repository_statistics/class.ilLPProgressTableGUI.php");
168 $lp_table = new ilLPProgressTableGUI($this, "details", $this->tracked_user, $obj_ids, true, $this->details_mode, $personal_only, $this->details_obj_id, $this->details_id);
169 $this->tpl->setVariable("LP_OBJECTS", $lp_table->getHTML());
170 }
171
172 $this->tpl->setVariable("LEGEND", $this->__getLegendHTML());
173 }
174
175 public function __showProgressList()
176 {
177 global $DIC;
178
179 $ilUser = $DIC['ilUser'];
180 $ilObjDataCache = $DIC['ilObjDataCache'];
181 $ilCtrl = $DIC['ilCtrl'];
182
183 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.lp_list_progress.html', 'Services/Tracking');
184
185 // User info
186 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
187 $info = new ilInfoScreenGUI($this);
188 $info->setFormAction($ilCtrl->getFormAction($this));
189
190 if ($this->__appendUserInfo($info, $this->tracked_user)) {
191 $this->tpl->setCurrentBlock("info_user");
192 $this->tpl->setVariable("USER_INFO", $info->getHTML());
193 $this->tpl->parseCurrentBlock();
194 }
195
196 include_once("./Services/Tracking/classes/repository_statistics/class.ilLPProgressTableGUI.php");
197 $lp_table = new ilLPProgressTableGUI($this, "", $this->tracked_user, null, false, null, false, null, null, $this->getMode());
198 $this->tpl->setVariable("LP_OBJECTS", $lp_table->getHTML());
199
200 $this->tpl->setVariable("LEGEND", $this->__getLegendHTML());
201 }
202
203 public function __initUser($a_usr_id = 0)
204 {
205 global $DIC;
206
207 $ilUser = $DIC['ilUser'];
208 $rbacreview = $DIC['rbacreview'];
209 $rbacsystem = $DIC['rbacsystem'];
210
211 if ($_POST['user_id']) {
212 $a_usr_id = $_POST['user_id'];
213 $this->ctrl->setParameter($this, 'user_id', $_POST['user_id']);
214 }
215
216 if ($a_usr_id) {
217 $this->tracked_user = ilObjectFactory::getInstanceByObjId($a_usr_id);
218 } else {
219 $this->tracked_user = $ilUser;
220 }
221
222 // #8762: see ilObjUserGUI->getTabs()
223 if ($this->mode == self::LP_CONTEXT_USER_FOLDER && $rbacsystem->checkAccess('read', $this->ref_id)) {
224 return true;
225 }
226
227 if ($this->mode == self::LP_CONTEXT_ORG_UNIT && ilObjOrgUnitAccess::_checkAccessToUserLearningProgress($this->ref_id, $a_usr_id)) {
228 return true;
229 }
230
231 // Check access
232 if (!$rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID)) {
233 $this->tracked_user = $ilUser;
234 }
235
236 return true;
237 }
238
239 public function __initDetails($a_details_id)
240 {
241 global $DIC;
242
243 $ilObjDataCache = $DIC['ilObjDataCache'];
244
245 if (!$a_details_id) {
246 $a_details_id = $this->getRefId();
247 }
248 if ($a_details_id) {
249 $ref_ids = ilObject::_getAllReferences($a_details_id);
250
251 $this->details_id = $a_details_id;
252 $this->details_obj_id = $ilObjDataCache->lookupObjId($this->details_id);
253 $this->details_type = $ilObjDataCache->lookupType($this->details_obj_id);
254
255 include_once 'Services/Object/classes/class.ilObjectLP.php';
256 $olp = ilObjectLP::getInstance($this->details_obj_id);
257 $this->details_mode = $olp->getCurrentMode();
258 }
259 }
260}
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
Class ilInfoScreenGUI.
__construct($a_mode, $a_ref_id, $a_user_id=0)
TableGUI class for learning progress.
static checkPermission($a_permission, $a_ref_id, $a_user_id=null)
wrapper for rbac access checks
__getLegendHTML(int $variant=ilLPStatusIcons::ICON_VARIANT_LONG)
__showObjectDetails(&$info, $item_id=0, $add_section=true)
show details about current object.
__appendLPDetails(&$info, $item_id, $user_id)
static _checkAccessToUserLearningProgress($ref_id, $usr_id)
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static getInstance($a_obj_id)
static _lookupObjectId($a_ref_id)
lookup object id
static _getAllReferences($a_id)
get all reference ids of object
const SYSTEM_ROLE_ID
Definition: constants.php:27
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc