ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjSessionListGUI.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24include_once('Services/Object/classes/class.ilObjectListGUI.php');
25
26
35{
36 protected $app_info = array();
37
38
45 public function __construct()
46 {
47 global $DIC;
48
49 $lng = $DIC['lng'];
50
51 $lng->loadLanguageModule('crs');
52 $lng->loadLanguageModule('sess');
53
55 }
56
63 public function init()
64 {
65 $this->delete_enabled = true;
66 $this->cut_enabled = true;
67 $this->copy_enabled = true;
68 $this->subscribe_enabled = true;
69 $this->link_enabled = true;
70 $this->info_screen_enabled = true;
71 $this->subitems_enabled = true;
72 $this->type = "sess";
73 $this->gui_class_name = "ilobjsessiongui";
74
75 $this->substitutions = ilAdvancedMDSubstitution::_getInstanceByObjectType($this->type);
76 $this->enableSubstitutions($this->substitutions->isActive());
77
78 // general commands array
79 include_once('./Modules/Session/classes/class.ilObjSessionAccess.php');
80 $this->commands = ilObjSessionAccess::_getCommands();
81 }
82
92 public function getTitle()
93 {
95 $title = strlen($this->title) ? (': ' . $this->title) : '';
96 return ilSessionAppointment::_appointmentToString($app_info['start'], $app_info['end'], $app_info['fullday']) . $title;
97 }
98
99
100
108 public function getCommandLink($a_cmd)
109 {
110 global $DIC;
111
112 $ilCtrl = $DIC['ilCtrl'];
113
114 // separate method for this line
115 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->ref_id);
116 $cmd_link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", $a_cmd);
117 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
118 return $cmd_link;
119 }
120
130 public function checkCommandAccess($a_permission, $a_cmd, $a_ref_id, $a_type, $a_obj_id = "")
131 {
132 if ($a_cmd != 'register' and $a_cmd != 'unregister') {
133 $a_cmd = '';
134 }
135 return parent::checkCommandAccess($a_permission, $a_cmd, $a_ref_id, $a_type, $a_obj_id);
136 }
137
138
146 public function getProperties()
147 {
148 $app_info = $this->getAppointmentInfo();
149
150 /*
151 $props[] = array(
152 'alert' => false,
153 'property' => $this->lng->txt('event_date'),
154 'value' => ilSessionAppointment::_appointmentToString($app_info['start'],$app_info['end'],$app_info['fullday']));
155 */
156 include_once './Modules/Session/classes/class.ilObjSession.php';
157 $session_data = new ilObjSession($this->obj_id, false);
158 include_once './Modules/Session/classes/class.ilSessionParticipants.php';
159 $part = ilSessionParticipants::getInstance($this->ref_id);
160
161 if ($session_data->isRegistrationUserLimitEnabled()) {
162 if ($part->getCountMembers() <= $session_data->getRegistrationMaxUsers()) {
163 $props[] = array(
164 'alert' => false,
165 'property' => $this->lng->txt('sess_list_reg_limit_places'),
166 'value' => max(
167 0,
168 $session_data->getRegistrationMaxUsers() - $part->getCountMembers()
169 )
170 );
171 }
172 }
173
175 if ($items = self::lookupAssignedMaterials($this->obj_id)) {
176 $props[] = array(
177 'alert' => false,
178 'property' => $this->lng->txt('event_ass_materials_prop'),
179 'value' => count($items)
180 );
181 }
182 }
184 include_once './Modules/Session/classes/class.ilObjSession.php';
185 $session_data = ilObjSession::lookupSession($this->obj_id);
186
187 if (strlen($session_data['location'])) {
188 $props[] = array(
189 'alert' => false,
190 'property' => $this->lng->txt('event_location'),
191 'value' => $session_data['location']
192 );
193 }
194 if (strlen($session_data['details'])) {
195 $props[] = array(
196 'alert' => false,
197 'property' => $this->lng->txt('event_details_workflow'),
198 'value' => nl2br($session_data['details']),
199 'newline' => true
200 );
201 }
202 $has_new_line = false;
203 if (strlen($session_data['name'])) {
204 $props[] = array(
205 'alert' => false,
206 'property' => $this->lng->txt('event_lecturer'),
207 'value' => $session_data['name'],
208 'newline' => true
209 );
210 $has_new_line = true;
211 }
212 if (strlen($session_data['email'])) {
213 $props[] = array(
214 'alert' => false,
215 'property' => $this->lng->txt('tutor_email'),
216 'value' => $session_data['email'],
217 'newline' => $has_new_line ? false : true
218 );
219 $has_new_line = true;
220 }
221 if (strlen($session_data['phone'])) {
222 $props[] = array(
223 'alert' => false,
224 'property' => $this->lng->txt('tutor_phone'),
225 'value' => $session_data['phone'],
226 'newline' => $has_new_line ? false : true
227 );
228 $has_new_line = true;
229 }
230 }
231
232 // booking information
234 $book_info = new ilBookingInfoListItemPropertiesAdapter($repo);
235 $props = $book_info->appendProperties($this->obj_id, $props);
236
237 return $props;
238 }
239
240
241
248 protected function getAppointmentInfo()
249 {
250 if (isset($this->app_info[$this->obj_id])) {
251 return $this->app_info[$this->obj_id];
252 }
253 include_once('./Modules/Session/classes/class.ilSessionAppointment.php');
254 return $this->app_info[$this->obj_id] = ilSessionAppointment::_lookupAppointment($this->obj_id);
255 }
256
262 protected static function lookupAssignedMaterials($a_sess_id)
263 {
264 global $DIC;
265
266 $ilDB = $DIC['ilDB'];
267
268 $query = 'SELECT * FROM event_items ei ' .
269 'JOIN tree ON item_id = child ' .
270 'WHERE event_id = ' . $ilDB->quote($a_sess_id, 'integer') . ' ' .
271 'AND tree > 0';
272 $res = $ilDB->query($query);
273 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
274 $items[] = $row->item_id;
275 }
276 return $items ? $items : array();
277 }
278}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
static _getInstanceByObjectType($a_type)
Singleton: use this method to get an instance.
static _getCommands()
get list of command/permission combinations
static getBookingInfoRepo()
Get booking info repo.
getTitle()
get title Overwritten since sessions prepend the date of the session to the title
static lookupAssignedMaterials($a_sess_id)
Get assigned items of event.
getCommandLink($a_cmd)
Get command link url.
getAppointmentInfo()
get appointment info
checkCommandAccess($a_permission, $a_cmd, $a_ref_id, $a_type, $a_obj_id="")
Only check cmd access for cmd 'register' and 'unregister'.
static lookupSession($a_obj_id)
Get session data.
Class ilObjectListGUI.
enableSubstitutions($a_status)
Enable substitutions.
getDetailsLevel()
Get current details level.
static _lookupAppointment($a_obj_id)
lookup appointment
static _appointmentToString($start, $end, $fulltime)
static getInstance($a_ref_id)
Get instance.
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$query
foreach($_POST as $key=> $value) $res
global $ilDB