ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
24 include_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 
54  parent::__construct();
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  {
94  $app_info = $this->getAppointmentInfo();
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  return $props;
233  }
234 
235 
236 
243  protected function getAppointmentInfo()
244  {
245  if (isset($this->app_info[$this->obj_id])) {
246  return $this->app_info[$this->obj_id];
247  }
248  include_once('./Modules/Session/classes/class.ilSessionAppointment.php');
249  return $this->app_info[$this->obj_id] = ilSessionAppointment::_lookupAppointment($this->obj_id);
250  }
251 
257  protected static function lookupAssignedMaterials($a_sess_id)
258  {
259  global $DIC;
260 
261  $ilDB = $DIC['ilDB'];
262 
263  $query = 'SELECT * FROM event_items ei ' .
264  'JOIN tree ON item_id = child ' .
265  'WHERE event_id = ' . $ilDB->quote($a_sess_id, 'integer') . ' ' .
266  'AND tree > 0';
267  $res = $ilDB->query($query);
268  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
269  $items[] = $row->item_id;
270  }
271  return $items ? $items : array();
272  }
273 }
getAppointmentInfo()
get appointment info
global $DIC
Definition: saml.php:7
$_GET["client_id"]
getCommandLink($a_cmd)
Get command link url.
enableSubstitutions($a_status)
Enable substitutions.
static _getInstanceByObjectType($a_type)
Singleton: use this method to get an instance.
checkCommandAccess($a_permission, $a_cmd, $a_ref_id, $a_type, $a_obj_id="")
Only check cmd access for cmd &#39;register&#39; and &#39;unregister&#39;.
static lookupSession($a_obj_id)
Get session data.
global $ilCtrl
Definition: ilias.php:18
$a_type
Definition: workflow.php:92
foreach($_POST as $key=> $value) $res
getTitle()
get title Overwritten since sessions prepend the date of the session to the title ...
Class ilObjectListGUI.
static _appointmentToString($start, $end, $fulltime)
getDetailsLevel()
Get current details level.
static _getCommands()
get list of command/permission combinations
$query
static getInstance($a_ref_id)
Get instance.
$row
static lookupAssignedMaterials($a_sess_id)
Get assigned items of event.
static _lookupAppointment($a_obj_id)
lookup appointment
global $ilDB