ILIAS  release_8 Revision v8.24
class.ilObjCourseListGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=0);
4
28{
30
34 public function init(): void
35 {
36 $this->static_link_enabled = true;
37 $this->delete_enabled = true;
38 $this->cut_enabled = true;
39 $this->copy_enabled = true;
40 $this->subscribe_enabled = true;
41 $this->link_enabled = false;
42 $this->info_screen_enabled = true;
43 $this->type = "crs";
44 $this->gui_class_name = "ilobjcoursegui";
45
46 $this->substitutions = ilAdvancedMDSubstitution::_getInstanceByObjectType($this->type);
47 if ($this->substitutions->isActive()) {
48 $this->substitutions_enabled = true;
49 }
50
51 // general commands array
52 $this->commands = ilObjCourseAccess::_getCommands();
53 }
54
58 public function initItem(
59 int $ref_id,
60 int $obj_id,
61 string $type,
62 string $title = "",
63 string $description = ""
64 ): void {
66 }
67
69 {
70 if (null === $this->certificatePreloader) {
71 $repository = new ilUserCertificateRepository();
72 $this->certificatePreloader = new ilCertificateObjectsForUserPreloader($repository);
73 }
74 return $this->certificatePreloader;
75 }
76
80 public function getProperties(): array
81 {
82 global $DIC;
83
84 $props = parent::getProperties();
85
86 // check activation
87 if (
88 !ilObjCourseAccess::_isActivated($this->obj_id) &&
89 !ilObject::lookupOfflineStatus($this->obj_id)
90 ) {
91 $showRegistrationInfo = false;
92 $props[] = array(
93 "alert" => true,
94 "property" => $this->lng->txt("status"),
95 "value" => $this->lng->txt("offline")
96 );
97 }
98
99 // blocked
100 $members = ilCourseParticipant::_getInstanceByObjId($this->obj_id, $this->user->getId());
101 if ($members->isBlocked() && $members->isAssigned()) {
102 $props[] = array("alert" => true,
103 "property" => $this->lng->txt("member_status"),
104 "value" => $this->lng->txt("crs_status_blocked")
105 );
106 }
107
108 // pending subscription
109 if (ilCourseParticipants::_isSubscriber($this->obj_id, $this->user->getId())) {
110 $props[] = array("alert" => true,
111 "property" => $this->lng->txt("member_status"),
112 "value" => $this->lng->txt("crs_status_pending")
113 );
114 }
115
116 $info = ilObjCourseAccess::lookupRegistrationInfo($this->obj_id);
117 if (isset($info['reg_info_list_prop'])) {
118 $props[] = array(
119 'alert' => false,
120 'newline' => true,
121 'property' => $info['reg_info_list_prop']['property'],
122 'value' => $info['reg_info_list_prop']['value']
123 );
124 }
125 if (isset($info['reg_info_list_prop_limit'])) {
126 $props[] = array(
127 'alert' => false,
128 'newline' => false,
129 'property' => $info['reg_info_list_prop_limit']['property'],
130 'propertyNameVisible' => (bool) strlen($info['reg_info_list_prop_limit']['property']),
131 'value' => $info['reg_info_list_prop_limit']['value']
132 );
133 }
134
135 // waiting list
136 if (ilCourseWaitingList::_isOnList($this->user->getId(), $this->obj_id)) {
137 $props[] = array(
138 "alert" => true,
139 "property" => $this->lng->txt('member_status'),
140 "value" => $this->lng->txt('on_waiting_list')
141 );
142 }
143
144 // course period
145 $info = ilObjCourseAccess::lookupPeriodInfo($this->obj_id);
146 if (is_array($info)) {
147 $props[] = array(
148 'alert' => false,
149 'newline' => true,
150 'property' => $info['property'] ?? "",
151 'value' => $info['value'] ?? ""
152 );
153 }
154
155 // check for certificates
156 $hasCertificate = $this->getCertificatePreloader()->isPreloaded($this->user->getId(), $this->obj_id);
157 if ($hasCertificate) {
158 $this->lng->loadLanguageModule('certificate');
159 $cmd_link = "ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $this->ref_id . "&cmd=deliverCertificate";
160 $props[] = [
161 'alert' => false,
162 'property' => $this->lng->txt('certificate'),
163 'value' => $DIC->ui()->renderer()->render(
164 $DIC->ui()->factory()->link()->standard($this->lng->txt('download_certificate'), $cmd_link)
165 )
166 ];
167 }
168
169 // booking information
171 if (!$repo instanceof ilBookingReservationDBRepository) {
172 $repo = (new ilBookingReservationDBRepositoryFactory())->getRepoWithContextObjCache([$this->obj_id]);
173 }
174 $book_info = new ilBookingInfoListItemPropertiesAdapter($repo);
175 return $book_info->appendProperties($this->obj_id, $props);
176 }
177
181 public function checkCommandAccess(
182 string $permission,
183 string $cmd,
184 int $ref_id,
185 string $type,
186 ?int $obj_id = null
187 ): bool {
188 // Only check cmd access for cmd 'register' and 'unregister'
189 if ($cmd != 'view' && $cmd != 'leave' && $cmd != 'join' && $cmd !== 'leaveWaitList') {
190 $cmd = '';
191 }
192
193 if ($permission == 'crs_linked') {
194 return
195 parent::checkCommandAccess('read', $cmd, $ref_id, $type, $obj_id) ||
196 parent::checkCommandAccess('join', $cmd, $ref_id, $type, $obj_id);
197 }
198 return parent::checkCommandAccess($permission, $cmd, $ref_id, $type, $obj_id);
199 }
200} // END class.ilObjCategoryGUI
static _getInstanceByObjectType(string $a_type)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getInstanceByObjId(int $a_obj_id, int $a_usr_id)
static lookupRegistrationInfo(int $a_obj_id)
static lookupPeriodInfo(int $a_obj_id)
static _getCommands()
@inheritDoc
static _isActivated(int $a_obj_id, ?bool &$a_visible_flag=null, bool $a_mind_member_view=true)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkCommandAccess(string $permission, string $cmd, int $ref_id, string $type, ?int $obj_id=null)
@inheritDoc
initItem(int $ref_id, int $obj_id, string $type, string $title="", string $description="")
initialize new item (is called by getItemHTML())
ilCertificateObjectsForUserPreloader $certificatePreloader
static lookupOfflineStatus(int $obj_id)
Lookup offline status using objectDataCache.
static _isSubscriber(int $a_obj_id, int $a_usr_id)
static _isOnList(int $a_usr_id, int $a_obj_id)
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
$type