ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjCourseListGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=0);
20
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 // blocked
87 $members = ilCourseParticipant::_getInstanceByObjId($this->obj_id, $this->user->getId());
88 if ($members->isBlocked() && $members->isAssigned()) {
89 $props[] = array("alert" => true,
90 "property" => $this->lng->txt("member_status"),
91 "value" => $this->lng->txt("crs_status_blocked")
92 );
93 }
94
95 // pending subscription
96 if (ilCourseParticipants::_isSubscriber($this->obj_id, $this->user->getId())) {
97 $props[] = array("alert" => true,
98 "property" => $this->lng->txt("member_status"),
99 "value" => $this->lng->txt("crs_status_pending")
100 );
101 }
102
104 if (isset($info['reg_info_list_prop'])) {
105 $props[] = array(
106 'alert' => false,
107 'newline' => true,
108 'property' => $info['reg_info_list_prop']['property'],
109 'value' => $info['reg_info_list_prop']['value']
110 );
111 }
112 if (isset($info['reg_info_list_prop_limit'])) {
113 $props[] = array(
114 'alert' => false,
115 'newline' => false,
116 'property' => $info['reg_info_list_prop_limit']['property'],
117 'propertyNameVisible' => (bool) strlen($info['reg_info_list_prop_limit']['property']),
118 'value' => $info['reg_info_list_prop_limit']['value']
119 );
120 }
121
122 // waiting list
123 if (ilCourseWaitingList::_isOnList($this->user->getId(), $this->obj_id)) {
124 $props[] = array(
125 "alert" => true,
126 "property" => $this->lng->txt('member_status'),
127 "value" => $this->lng->txt('on_waiting_list')
128 );
129 }
130
131 // course period
133 if (is_array($info)) {
134 $props[] = array(
135 'alert' => false,
136 'newline' => true,
137 'property' => $info['property'] ?? "",
138 'value' => $info['value'] ?? ""
139 );
140 }
141
142 // check for certificates
143 $hasCertificate = $this->getCertificatePreloader()->isPreloaded($this->user->getId(), $this->obj_id);
144 if ($hasCertificate) {
145 $this->lng->loadLanguageModule('certificate');
146 $cmd_link = "ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $this->ref_id . "&cmd=deliverCertificate";
147 $props[] = [
148 'alert' => false,
149 'property' => $this->lng->txt('certificate'),
150 'value' => $DIC->ui()->renderer()->render(
151 $DIC->ui()->factory()->link()->standard($this->lng->txt('download_certificate'), $cmd_link)
152 )
153 ];
154 }
155
156 // booking information
158 if (!$repo instanceof \ILIAS\BookingManager\Reservations\ReservationDBRepository) {
159 $repo = $DIC->bookingManager()->internal()->repo()->reservationWithContextObjCache([$this->obj_id]);
160 }
161 $book_info = new ilBookingInfoListItemPropertiesAdapter($repo);
162 return $book_info->appendProperties($this->obj_id, $props);
163 }
164
168 public function checkCommandAccess(
169 string $permission,
170 string $cmd,
171 int $ref_id,
172 string $type,
173 ?int $obj_id = null
174 ): bool {
175 // Only check cmd access for cmd 'register' and 'unregister'
176 if ($cmd != 'view' && $cmd != 'leave' && $cmd != 'join' && $cmd !== 'leaveWaitList') {
177 $cmd = '';
178 }
179
180 if ($permission == 'crs_linked') {
181 return
182 parent::checkCommandAccess('read', $cmd, $ref_id, $type, $obj_id) ||
183 parent::checkCommandAccess('join', $cmd, $ref_id, $type, $obj_id);
184 }
185 return parent::checkCommandAccess($permission, $cmd, $ref_id, $type, $obj_id);
186 }
187} // 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...
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
Class ilObjCourseListGUI.
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 _isSubscriber(int $a_obj_id, int $a_usr_id)
static _isOnList(int $a_usr_id, int $a_obj_id)
$info
Definition: entry_point.php:21
$ref_id
Definition: ltiauth.php:66
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26