ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilObjCourseListGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once "Services/Object/classes/class.ilObjectListGUI.php";
6
16{
21
25 public function init()
26 {
27 $this->static_link_enabled = true;
28 $this->delete_enabled = true;
29 $this->cut_enabled = true;
30 $this->copy_enabled = true;
31 $this->subscribe_enabled = true;
32 $this->link_enabled = false;
33 $this->info_screen_enabled = true;
34 $this->type = "crs";
35 $this->gui_class_name = "ilobjcoursegui";
36
37 $this->substitutions = ilAdvancedMDSubstitution::_getInstanceByObjectType($this->type);
38 if ($this->substitutions->isActive()) {
39 $this->substitutions_enabled = true;
40 }
41
42 // general commands array
43 $this->commands = ilObjCourseAccess::_getCommands();
44 }
45
49 public function initItem($a_ref_id, $a_obj_id, $type, $a_title = "", $a_description = "")
50 {
51 parent::initItem($a_ref_id, $a_obj_id, $type, $a_title, $a_description);
52
53 $this->conditions_ok = ilConditionHandler::_checkAllConditionsOfTarget($a_ref_id, $this->obj_id);
54 }
55
60 {
61 if (null === $this->certificatePreloader) {
62 $repository = new ilUserCertificateRepository();
63 $this->certificatePreloader = new ilCertificateObjectsForUserPreloader($repository);
64 }
65
67 }
68
77 public function getProperties()
78 {
79 global $DIC;
80
81 $lng = $DIC['lng'];
82 $ilUser = $DIC['ilUser'];
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" => $lng->txt("status"),
95 "value" => $lng->txt("offline")
96 );
97 }
98
99 // blocked
100 include_once 'Modules/Course/classes/class.ilCourseParticipant.php';
101 $members = ilCourseParticipant::_getInstanceByObjId($this->obj_id, $ilUser->getId());
102 if ($members->isBlocked($ilUser->getId()) and $members->isAssigned($ilUser->getId())) {
103 $props[] = array("alert" => true, "property" => $lng->txt("member_status"),
104 "value" => $lng->txt("crs_status_blocked"));
105 }
106
107 // pending subscription
108 include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
109 if (ilCourseParticipants::_isSubscriber($this->obj_id, $ilUser->getId())) {
110 $props[] = array("alert" => true, "property" => $lng->txt("member_status"),
111 "value" => $lng->txt("crs_status_pending"));
112 }
113
114 include_once './Modules/Course/classes/class.ilObjCourseAccess.php';
115 $info = ilObjCourseAccess::lookupRegistrationInfo($this->obj_id);
116 if ($info['reg_info_list_prop']) {
117 $props[] = array(
118 'alert' => false,
119 'newline' => true,
120 'property' => $info['reg_info_list_prop']['property'],
121 'value' => $info['reg_info_list_prop']['value']
122 );
123 }
124 if ($info['reg_info_list_prop_limit']) {
125 $props[] = array(
126 'alert' => false,
127 'newline' => false,
128 'property' => $info['reg_info_list_prop_limit']['property'],
129 'propertyNameVisible' => strlen($info['reg_info_list_prop_limit']['property']) ? true : false,
130 'value' => $info['reg_info_list_prop_limit']['value']
131 );
132 }
133
134 // waiting list
135 include_once './Modules/Course/classes/class.ilCourseWaitingList.php';
136 if (ilCourseWaitingList::_isOnList($ilUser->getId(), $this->obj_id)) {
137 $props[] = array(
138 "alert" => true,
139 "property" => $lng->txt('member_status'),
140 "value" => $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($ilUser->getId(), $this->obj_id);
157 if (true === $hasCertificate) {
158 $lng->loadLanguageModule('certificate');
159 $cmd_link = "ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $this->ref_id . "&cmd=deliverCertificate";
160 $props[] = [
161 'alert' => false,
162 'property' => $lng->txt('certificate'),
163 'value' => $DIC->ui()->renderer()->render(
164 $DIC->ui()->factory()->link()->standard($lng->txt('download_certificate'), $cmd_link)
165 )
166 ];
167 }
168
169 // booking information
171 $book_info = new ilBookingInfoListItemPropertiesAdapter($repo);
172 $props = $book_info->appendProperties($this->obj_id, $props);
173
174 return $props;
175 }
176
177
187 public function checkCommandAccess($a_permission, $a_cmd, $a_ref_id, $a_type, $a_obj_id = "")
188 {
189 // Only check cmd access for cmd 'register' and 'unregister'
190 if ($a_cmd != 'view' and $a_cmd != 'leave' and $a_cmd != 'join') {
191 $a_cmd = '';
192 }
193
194 if ($a_permission == 'crs_linked') {
195 return
196 parent::checkCommandAccess('read', $a_cmd, $a_ref_id, $a_type, $a_obj_id) ||
197 parent::checkCommandAccess('join', $a_cmd, $a_ref_id, $a_type, $a_obj_id);
198 }
199 return parent::checkCommandAccess($a_permission, $a_cmd, $a_ref_id, $a_type, $a_obj_id);
200 }
201} // END class.ilObjCategoryGUI
An exception for terminatinating execution or to throw for unit testing.
static _getInstanceByObjectType($a_type)
Singleton: use this method to get an instance.
static _checkAllConditionsOfTarget($a_target_ref_id, $a_target_id, $a_target_type="", $a_usr_id=0)
checks wether all conditions of a target object are fulfilled
static _getInstanceByObjId($a_obj_id, $a_usr_id)
Get singleton instance.
static lookupPeriodInfo($a_obj_id)
Lookup course period info.
static _isActivated($a_obj_id, &$a_visible_flag=null, $a_mind_member_view=true)
Is activated?
static _getCommands()
get commands
static lookupRegistrationInfo($a_obj_id)
Lookup registration info @global ilDB $ilDB @global ilObjUser $ilUser @global ilLanguage $lng.
static getBookingInfoRepo()
Get booking info repo.
Class ilObjCourseListGUI.
getProperties()
Get item properties.
checkCommandAccess($a_permission, $a_cmd, $a_ref_id, $a_type, $a_obj_id="")
Workaround for course titles (linked if join or read permission is granted)
initItem($a_ref_id, $a_obj_id, $type, $a_title="", $a_description="")
inititialize new item (is called by getItemHTML())
Class ilObjectListGUI.
static lookupOfflineStatus($a_obj_id)
Lookup offline status using objectDataCache.
static _isSubscriber($a_obj_id, $a_usr_id)
check if user is subscriber
static _isOnList($a_usr_id, $a_obj_id)
Check if a user on the waiting list.
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:92
$DIC
Definition: xapitoken.php:46